diff options
| author | Timo Kröger <[email protected]> | 2021-07-21 23:12:36 +0200 |
|---|---|---|
| committer | Timo Kröger <[email protected]> | 2021-07-21 23:12:36 +0200 |
| commit | 5e998d1a6c2a3307faae6b3a2f55d6712a394d59 (patch) | |
| tree | 4d56cffd2a40930c2c91b605b5adbaacaf970531 /examples/stm32f4/src/bin/button_exti.rs | |
| parent | 40ea8298eedbe2430b647ab969d4a2e627b6ece8 (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.rs | 56 |
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"] |
| 10 | mod example_common; | 10 | mod example_common; |
| 11 | use embassy::executor::Executor; | 11 | use embassy::executor::Executor; |
| 12 | use embassy::time::Clock; | ||
| 13 | use embassy::util::Forever; | 12 | use embassy::util::Forever; |
| 14 | use embassy_stm32::exti::ExtiInput; | 13 | use embassy_stm32::exti::ExtiInput; |
| 15 | use embassy_stm32::gpio::{Input, Pull}; | 14 | use embassy_stm32::gpio::{Input, Pull}; |
| @@ -17,7 +16,7 @@ use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | |||
| 17 | use example_common::*; | 16 | use example_common::*; |
| 18 | 17 | ||
| 19 | use cortex_m_rt::entry; | 18 | use cortex_m_rt::entry; |
| 20 | use stm32f4::stm32f429 as pac; | 19 | use embassy_stm32::pac; |
| 21 | 20 | ||
| 22 | #[embassy::task] | 21 | #[embassy::task] |
| 23 | async fn main_task() { | 22 | async fn main_task() { |
| @@ -36,44 +35,33 @@ async fn main_task() { | |||
| 36 | } | 35 | } |
| 37 | } | 36 | } |
| 38 | 37 | ||
| 39 | struct ZeroClock; | ||
| 40 | |||
| 41 | impl Clock for ZeroClock { | ||
| 42 | fn now(&self) -> u64 { | ||
| 43 | 0 | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | static EXECUTOR: Forever<Executor> = Forever::new(); | 38 | static EXECUTOR: Forever<Executor> = Forever::new(); |
| 48 | 39 | ||
| 49 | #[entry] | 40 | #[entry] |
| 50 | fn main() -> ! { | 41 | fn 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 | ||
