diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-01-04 23:58:13 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-01-05 00:00:44 +0100 |
| commit | 2eb0cc5df78b2abd38228ee1f07b7c446e17d362 (patch) | |
| tree | a9df2ed2c0acc481e19275473f981da098b541f1 /examples/stm32l0/src/bin | |
| parent | c3fd9a0f44ae898c5cf1272dab6b8f46e119fab3 (diff) | |
stm32/rcc: remove Rcc struct, RccExt trait.
All the RCC configuration is executed in init().
Diffstat (limited to 'examples/stm32l0/src/bin')
| -rw-r--r-- | examples/stm32l0/src/bin/button_exti.rs | 14 | ||||
| -rw-r--r-- | examples/stm32l0/src/bin/lorawan.rs | 12 |
2 files changed, 10 insertions, 16 deletions
diff --git a/examples/stm32l0/src/bin/button_exti.rs b/examples/stm32l0/src/bin/button_exti.rs index 20d6f5555..88c75ce6d 100644 --- a/examples/stm32l0/src/bin/button_exti.rs +++ b/examples/stm32l0/src/bin/button_exti.rs | |||
| @@ -8,16 +8,18 @@ mod example_common; | |||
| 8 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| 9 | use embassy_stm32::exti::ExtiInput; | 9 | use embassy_stm32::exti::ExtiInput; |
| 10 | use embassy_stm32::gpio::{Input, Pull}; | 10 | use embassy_stm32::gpio::{Input, Pull}; |
| 11 | use embassy_stm32::{rcc, Peripherals}; | 11 | use embassy_stm32::Peripherals; |
| 12 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | 12 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; |
| 13 | use example_common::*; | 13 | use example_common::*; |
| 14 | 14 | ||
| 15 | #[embassy::main] | 15 | fn config() -> embassy_stm32::Config { |
| 16 | async fn main(_spawner: Spawner, mut p: Peripherals) { | 16 | let mut config = embassy_stm32::Config::default(); |
| 17 | let mut rcc = rcc::Rcc::new(p.RCC); | 17 | config.rcc.enable_hsi48 = true; |
| 18 | // Enables SYSCFG | 18 | config |
| 19 | let _ = rcc.enable_hsi48(&mut p.SYSCFG, p.CRS); | 19 | } |
| 20 | 20 | ||
| 21 | #[embassy::main(config = "config()")] | ||
| 22 | async fn main(_spawner: Spawner, p: Peripherals) { | ||
| 21 | let button = Input::new(p.PB2, Pull::Up); | 23 | let button = Input::new(p.PB2, Pull::Up); |
| 22 | let mut button = ExtiInput::new(button, p.EXTI2); | 24 | let mut button = ExtiInput::new(button, p.EXTI2); |
| 23 | 25 | ||
diff --git a/examples/stm32l0/src/bin/lorawan.rs b/examples/stm32l0/src/bin/lorawan.rs index 7ce859a8d..df08ba18c 100644 --- a/examples/stm32l0/src/bin/lorawan.rs +++ b/examples/stm32l0/src/bin/lorawan.rs | |||
| @@ -11,10 +11,8 @@ mod example_common; | |||
| 11 | 11 | ||
| 12 | use embassy_lora::{sx127x::*, LoraTimer}; | 12 | use embassy_lora::{sx127x::*, LoraTimer}; |
| 13 | use embassy_stm32::{ | 13 | use embassy_stm32::{ |
| 14 | dbgmcu::Dbgmcu, | ||
| 15 | exti::ExtiInput, | 14 | exti::ExtiInput, |
| 16 | gpio::{Input, Level, Output, Pull, Speed}, | 15 | gpio::{Input, Level, Output, Pull, Speed}, |
| 17 | rcc, | ||
| 18 | rng::Rng, | 16 | rng::Rng, |
| 19 | spi, | 17 | spi, |
| 20 | time::U32Ext, | 18 | time::U32Ext, |
| @@ -26,18 +24,12 @@ use lorawan_encoding::default_crypto::DefaultFactory as Crypto; | |||
| 26 | fn config() -> embassy_stm32::Config { | 24 | fn config() -> embassy_stm32::Config { |
| 27 | let mut config = embassy_stm32::Config::default(); | 25 | let mut config = embassy_stm32::Config::default(); |
| 28 | config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; | 26 | config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; |
| 27 | config.rcc.enable_hsi48 = true; | ||
| 29 | config | 28 | config |
| 30 | } | 29 | } |
| 31 | 30 | ||
| 32 | #[embassy::main(config = "config()")] | 31 | #[embassy::main(config = "config()")] |
| 33 | async fn main(_spawner: embassy::executor::Spawner, mut p: Peripherals) { | 32 | async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { |
| 34 | unsafe { | ||
| 35 | Dbgmcu::enable_all(); | ||
| 36 | } | ||
| 37 | |||
| 38 | let mut rcc = rcc::Rcc::new(p.RCC); | ||
| 39 | let _ = rcc.enable_hsi48(&mut p.SYSCFG, p.CRS); | ||
| 40 | |||
| 41 | // SPI for sx127x | 33 | // SPI for sx127x |
| 42 | let spi = spi::Spi::new( | 34 | let spi = spi::Spi::new( |
| 43 | p.SPI1, | 35 | p.SPI1, |
