aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32l4/src/bin/button_exti.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-07-15 00:30:31 +0200
committerDario Nieuwenhuis <[email protected]>2021-07-15 00:37:00 +0200
commit71c8d7aa7d84175810b6495c72d3767179d6b341 (patch)
tree4540627162f510fed391a82f691a05d932e91756 /examples/stm32l4/src/bin/button_exti.rs
parentf916fe54760b51a12876b8d060531aa773a75e6d (diff)
stm32l4/examples: remove old-pac uses.
Diffstat (limited to 'examples/stm32l4/src/bin/button_exti.rs')
-rw-r--r--examples/stm32l4/src/bin/button_exti.rs47
1 files changed, 22 insertions, 25 deletions
diff --git a/examples/stm32l4/src/bin/button_exti.rs b/examples/stm32l4/src/bin/button_exti.rs
index c6b7c83ec..6a06e4370 100644
--- a/examples/stm32l4/src/bin/button_exti.rs
+++ b/examples/stm32l4/src/bin/button_exti.rs
@@ -8,17 +8,16 @@
8 8
9#[path = "../example_common.rs"] 9#[path = "../example_common.rs"]
10mod example_common; 10mod example_common;
11use cortex_m_rt::entry;
11use embassy::executor::Executor; 12use embassy::executor::Executor;
12use embassy::time::Clock; 13use embassy::time::Clock;
13use embassy::util::Forever; 14use embassy::util::Forever;
14use embassy_stm32::exti::ExtiInput; 15use embassy_stm32::exti::ExtiInput;
15use embassy_stm32::gpio::{Input, Pull}; 16use embassy_stm32::gpio::{Input, Pull};
17use embassy_stm32::pac;
16use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; 18use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
17use example_common::*; 19use example_common::*;
18 20
19use cortex_m_rt::entry;
20use stm32l4::stm32l4x5 as pac;
21
22#[embassy::task] 21#[embassy::task]
23async fn main_task() { 22async fn main_task() {
24 let p = embassy_stm32::init(Default::default()); 23 let p = embassy_stm32::init(Default::default());
@@ -50,28 +49,26 @@ static EXECUTOR: Forever<Executor> = Forever::new();
50fn main() -> ! { 49fn main() -> ! {
51 info!("Hello World!"); 50 info!("Hello World!");
52 51
53 let pp = pac::Peripherals::take().unwrap(); 52 unsafe {
54 53 pac::DBGMCU.cr().modify(|w| {
55 pp.DBGMCU.cr.modify(|_, w| { 54 w.set_dbg_sleep(true);
56 w.dbg_sleep().set_bit(); 55 w.set_dbg_standby(true);
57 w.dbg_standby().set_bit(); 56 w.set_dbg_stop(true);
58 w.dbg_stop().set_bit() 57 });
59 }); 58
60 59 pac::RCC.apb2enr().modify(|w| {
61 pp.RCC.ahb2enr.modify(|_, w| { 60 w.set_syscfgen(true);
62 w.gpioaen().set_bit(); 61 });
63 w.gpioben().set_bit(); 62
64 w.gpiocen().set_bit(); 63 pac::RCC.ahb2enr().modify(|w| {
65 w.gpioden().set_bit(); 64 w.set_gpioaen(true);
66 w.gpioeen().set_bit(); 65 w.set_gpioben(true);
67 w.gpiofen().set_bit(); 66 w.set_gpiocen(true);
68 w 67 w.set_gpioden(true);
69 }); 68 w.set_gpioeen(true);
70 69 w.set_gpiofen(true);
71 pp.RCC.apb2enr.modify(|_, w| { 70 });
72 w.syscfgen().set_bit(); 71 }
73 w
74 });
75 72
76 unsafe { embassy::time::set_clock(&ZeroClock) }; 73 unsafe { embassy::time::set_clock(&ZeroClock) };
77 74