aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-01-04 23:58:13 +0100
committerDario Nieuwenhuis <[email protected]>2022-01-05 00:00:44 +0100
commit2eb0cc5df78b2abd38228ee1f07b7c446e17d362 (patch)
treea9df2ed2c0acc481e19275473f981da098b541f1 /examples
parentc3fd9a0f44ae898c5cf1272dab6b8f46e119fab3 (diff)
stm32/rcc: remove Rcc struct, RccExt trait.
All the RCC configuration is executed in init().
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32l0/src/bin/button_exti.rs14
-rw-r--r--examples/stm32l0/src/bin/lorawan.rs12
-rw-r--r--examples/stm32wl55/src/bin/lorawan.rs13
-rw-r--r--examples/stm32wl55/src/bin/subghz.rs5
4 files changed, 13 insertions, 31 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;
8use embassy::executor::Spawner; 8use embassy::executor::Spawner;
9use embassy_stm32::exti::ExtiInput; 9use embassy_stm32::exti::ExtiInput;
10use embassy_stm32::gpio::{Input, Pull}; 10use embassy_stm32::gpio::{Input, Pull};
11use embassy_stm32::{rcc, Peripherals}; 11use embassy_stm32::Peripherals;
12use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; 12use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
13use example_common::*; 13use example_common::*;
14 14
15#[embassy::main] 15fn config() -> embassy_stm32::Config {
16async 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()")]
22async 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
12use embassy_lora::{sx127x::*, LoraTimer}; 12use embassy_lora::{sx127x::*, LoraTimer};
13use embassy_stm32::{ 13use 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;
26fn config() -> embassy_stm32::Config { 24fn 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()")]
33async fn main(_spawner: embassy::executor::Spawner, mut p: Peripherals) { 32async 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,
diff --git a/examples/stm32wl55/src/bin/lorawan.rs b/examples/stm32wl55/src/bin/lorawan.rs
index 7048a5814..5d26dead2 100644
--- a/examples/stm32wl55/src/bin/lorawan.rs
+++ b/examples/stm32wl55/src/bin/lorawan.rs
@@ -10,10 +10,9 @@ mod example_common;
10 10
11use embassy_lora::{stm32wl::*, LoraTimer}; 11use embassy_lora::{stm32wl::*, LoraTimer};
12use embassy_stm32::{ 12use embassy_stm32::{
13 dbgmcu::Dbgmcu,
14 dma::NoDma, 13 dma::NoDma,
15 gpio::{Level, Output, Pin, Speed}, 14 gpio::{Level, Output, Pin, Speed},
16 interrupt, pac, rcc, 15 interrupt, pac,
17 rng::Rng, 16 rng::Rng,
18 subghz::*, 17 subghz::*,
19 Peripherals, 18 Peripherals,
@@ -24,19 +23,13 @@ use lorawan_encoding::default_crypto::DefaultFactory as Crypto;
24fn config() -> embassy_stm32::Config { 23fn config() -> embassy_stm32::Config {
25 let mut config = embassy_stm32::Config::default(); 24 let mut config = embassy_stm32::Config::default();
26 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; 25 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16;
26 config.rcc.enable_lsi = true;
27 config 27 config
28} 28}
29 29
30#[embassy::main(config = "config()")] 30#[embassy::main(config = "config()")]
31async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { 31async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) {
32 unsafe { 32 unsafe { pac::RCC.ccipr().modify(|w| w.set_rngsel(0b01)) }
33 Dbgmcu::enable_all();
34 let mut rcc = rcc::Rcc::new(p.RCC);
35 rcc.enable_lsi();
36 pac::RCC.ccipr().modify(|w| {
37 w.set_rngsel(0b01);
38 });
39 }
40 33
41 let ctrl1 = Output::new(p.PC3.degrade(), Level::High, Speed::High); 34 let ctrl1 = Output::new(p.PC3.degrade(), Level::High, Speed::High);
42 let ctrl2 = Output::new(p.PC4.degrade(), Level::High, Speed::High); 35 let ctrl2 = Output::new(p.PC4.degrade(), Level::High, Speed::High);
diff --git a/examples/stm32wl55/src/bin/subghz.rs b/examples/stm32wl55/src/bin/subghz.rs
index a73c361c2..52fe6e9fa 100644
--- a/examples/stm32wl55/src/bin/subghz.rs
+++ b/examples/stm32wl55/src/bin/subghz.rs
@@ -11,7 +11,6 @@ mod example_common;
11use embassy::channel::signal::Signal; 11use embassy::channel::signal::Signal;
12use embassy::interrupt::{Interrupt, InterruptExt}; 12use embassy::interrupt::{Interrupt, InterruptExt};
13use embassy::traits::gpio::WaitForRisingEdge; 13use embassy::traits::gpio::WaitForRisingEdge;
14use embassy_stm32::dbgmcu::Dbgmcu;
15use embassy_stm32::dma::NoDma; 14use embassy_stm32::dma::NoDma;
16use embassy_stm32::exti::ExtiInput; 15use embassy_stm32::exti::ExtiInput;
17use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 16use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
@@ -72,10 +71,6 @@ fn config() -> embassy_stm32::Config {
72 71
73#[embassy::main(config = "config()")] 72#[embassy::main(config = "config()")]
74async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { 73async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) {
75 unsafe {
76 Dbgmcu::enable_all();
77 }
78
79 let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); 74 let mut led1 = Output::new(p.PB15, Level::High, Speed::Low);
80 let mut led2 = Output::new(p.PB9, Level::Low, Speed::Low); 75 let mut led2 = Output::new(p.PB9, Level::Low, Speed::Low);
81 let mut led3 = Output::new(p.PB11, Level::Low, Speed::Low); 76 let mut led3 = Output::new(p.PB11, Level::Low, Speed::Low);