aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32f4/src/bin/button_exti.rs
diff options
context:
space:
mode:
authorTimo Kröger <[email protected]>2021-07-21 23:12:36 +0200
committerTimo Kröger <[email protected]>2021-07-21 23:12:36 +0200
commit5e998d1a6c2a3307faae6b3a2f55d6712a394d59 (patch)
tree4d56cffd2a40930c2c91b605b5adbaacaf970531 /examples/stm32f4/src/bin/button_exti.rs
parent40ea8298eedbe2430b647ab969d4a2e627b6ece8 (diff)
Cleanup stm32f4 examples
* Remove dependency on stm32f4 pac crate * Remove unused `ZeroClock`
Diffstat (limited to 'examples/stm32f4/src/bin/button_exti.rs')
-rw-r--r--examples/stm32f4/src/bin/button_exti.rs56
1 files changed, 22 insertions, 34 deletions
diff --git a/examples/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs
index 8fc889dad..63c273b1a 100644
--- a/examples/stm32f4/src/bin/button_exti.rs
+++ b/examples/stm32f4/src/bin/button_exti.rs
@@ -9,7 +9,6 @@
9#[path = "../example_common.rs"] 9#[path = "../example_common.rs"]
10mod example_common; 10mod example_common;
11use embassy::executor::Executor; 11use embassy::executor::Executor;
12use embassy::time::Clock;
13use embassy::util::Forever; 12use embassy::util::Forever;
14use embassy_stm32::exti::ExtiInput; 13use embassy_stm32::exti::ExtiInput;
15use embassy_stm32::gpio::{Input, Pull}; 14use embassy_stm32::gpio::{Input, Pull};
@@ -17,7 +16,7 @@ use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
17use example_common::*; 16use example_common::*;
18 17
19use cortex_m_rt::entry; 18use cortex_m_rt::entry;
20use stm32f4::stm32f429 as pac; 19use embassy_stm32::pac;
21 20
22#[embassy::task] 21#[embassy::task]
23async fn main_task() { 22async fn main_task() {
@@ -36,44 +35,33 @@ async fn main_task() {
36 } 35 }
37} 36}
38 37
39struct ZeroClock;
40
41impl Clock for ZeroClock {
42 fn now(&self) -> u64 {
43 0
44 }
45}
46
47static EXECUTOR: Forever<Executor> = Forever::new(); 38static EXECUTOR: Forever<Executor> = Forever::new();
48 39
49#[entry] 40#[entry]
50fn main() -> ! { 41fn main() -> ! {
51 info!("Hello World!"); 42 info!("Hello World!");
52 43
53 let pp = pac::Peripherals::take().unwrap(); 44 unsafe {
54 45 pac::DBGMCU.cr().modify(|w| {
55 pp.DBGMCU.cr.modify(|_, w| { 46 w.set_dbg_sleep(true);
56 w.dbg_sleep().set_bit(); 47 w.set_dbg_standby(true);
57 w.dbg_standby().set_bit(); 48 w.set_dbg_stop(true);
58 w.dbg_stop().set_bit() 49 });
59 }); 50
60 pp.RCC.ahb1enr.modify(|_, w| w.dma1en().enabled()); 51 pac::RCC.ahb1enr().modify(|w| {
61 52 w.set_gpioaen(true);
62 pp.RCC.ahb1enr.modify(|_, w| { 53 w.set_gpioben(true);
63 w.gpioaen().enabled(); 54 w.set_gpiocen(true);
64 w.gpioben().enabled(); 55 w.set_gpioden(true);
65 w.gpiocen().enabled(); 56 w.set_gpioeen(true);
66 w.gpioden().enabled(); 57 w.set_gpiofen(true);
67 w.gpioeen().enabled(); 58 });
68 w.gpiofen().enabled(); 59
69 w 60 // EXTI clock
70 }); 61 pac::RCC.apb2enr().modify(|w| {
71 pp.RCC.apb2enr.modify(|_, w| { 62 w.set_syscfgen(true);
72 w.syscfgen().enabled(); 63 });
73 w 64 }
74 });
75
76 unsafe { embassy::time::set_clock(&ZeroClock) };
77 65
78 let executor = EXECUTOR.put(Executor::new()); 66 let executor = EXECUTOR.put(Executor::new());
79 67