diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-07-15 00:30:31 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-07-15 00:37:00 +0200 |
| commit | 71c8d7aa7d84175810b6495c72d3767179d6b341 (patch) | |
| tree | 4540627162f510fed391a82f691a05d932e91756 /examples/stm32l4/src/bin/button_exti.rs | |
| parent | f916fe54760b51a12876b8d060531aa773a75e6d (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.rs | 47 |
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"] |
| 10 | mod example_common; | 10 | mod example_common; |
| 11 | use cortex_m_rt::entry; | ||
| 11 | use embassy::executor::Executor; | 12 | use embassy::executor::Executor; |
| 12 | use embassy::time::Clock; | 13 | use embassy::time::Clock; |
| 13 | use embassy::util::Forever; | 14 | use embassy::util::Forever; |
| 14 | use embassy_stm32::exti::ExtiInput; | 15 | use embassy_stm32::exti::ExtiInput; |
| 15 | use embassy_stm32::gpio::{Input, Pull}; | 16 | use embassy_stm32::gpio::{Input, Pull}; |
| 17 | use embassy_stm32::pac; | ||
| 16 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | 18 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; |
| 17 | use example_common::*; | 19 | use example_common::*; |
| 18 | 20 | ||
| 19 | use cortex_m_rt::entry; | ||
| 20 | use stm32l4::stm32l4x5 as pac; | ||
| 21 | |||
| 22 | #[embassy::task] | 21 | #[embassy::task] |
| 23 | async fn main_task() { | 22 | async 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(); | |||
| 50 | fn main() -> ! { | 49 | fn 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 | ||
