From 2c992f701049a9c0e72048b134c26fdb26f2692a Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 19 Aug 2021 23:32:22 +0200 Subject: [PATCH] stm32: move dbgmcu stuff to toplevel config setting, defaulting to true. --- embassy-stm32/src/lib.rs | 6 ++++++ embassy-stm32/src/rcc/f0/mod.rs | 8 -------- embassy-stm32/src/rcc/f4/mod.rs | 10 ---------- embassy-stm32/src/rcc/h7/mod.rs | 21 +-------------------- embassy-stm32/src/rcc/l0/mod.rs | 10 ---------- examples/stm32f0/src/bin/hello.rs | 2 +- examples/stm32f0/src/example_common.rs | 7 ------- examples/stm32f4/src/bin/blinky.rs | 5 ----- examples/stm32f4/src/bin/button.rs | 5 ----- examples/stm32f4/src/bin/button_exti.rs | 5 ----- examples/stm32f4/src/bin/can.rs | 5 ----- examples/stm32f4/src/bin/hello.rs | 1 - examples/stm32f4/src/bin/spi.rs | 5 ----- examples/stm32f4/src/bin/spi_dma.rs | 5 ----- examples/stm32f4/src/bin/usart.rs | 5 ----- examples/stm32f4/src/bin/usart_dma.rs | 5 ----- examples/stm32h7/src/bin/blinky.rs | 3 --- examples/stm32h7/src/bin/button_exti.rs | 5 ----- examples/stm32h7/src/bin/dac.rs | 5 ----- examples/stm32h7/src/bin/eth.rs | 5 ----- examples/stm32h7/src/bin/spi.rs | 5 ----- examples/stm32h7/src/bin/spi_dma.rs | 5 ----- examples/stm32h7/src/bin/usart.rs | 5 ----- examples/stm32h7/src/bin/usart_dma.rs | 5 ----- examples/stm32l0/Cargo.toml | 2 +- examples/stm32l0/src/bin/blinky.rs | 5 +---- examples/stm32l0/src/bin/button.rs | 16 +++++----------- examples/stm32l0/src/bin/button_exti.rs | 1 - examples/stm32l0/src/bin/spi.rs | 14 +++++--------- examples/stm32l0/src/bin/usart_dma.rs | 7 ++----- examples/stm32l0/src/bin/usart_irq.rs | 7 ++----- examples/stm32l4/Cargo.toml | 2 +- examples/stm32l4/src/bin/adc.rs | 3 --- examples/stm32l4/src/bin/blinky.rs | 5 ----- examples/stm32l4/src/bin/button.rs | 5 ----- examples/stm32l4/src/bin/button_exti.rs | 5 ----- examples/stm32l4/src/bin/dac.rs | 3 --- examples/stm32l4/src/bin/spi.rs | 5 ----- examples/stm32l4/src/bin/spi_dma.rs | 5 ----- examples/stm32l4/src/bin/usart.rs | 5 ----- examples/stm32l4/src/bin/usart_dma.rs | 5 ----- examples/stm32wb55/src/bin/blinky.rs | 3 --- examples/stm32wb55/src/bin/button_exti.rs | 5 ----- examples/stm32wl55/src/bin/blinky.rs | 3 --- examples/stm32wl55/src/bin/button.rs | 7 +------ examples/stm32wl55/src/bin/button_exti.rs | 3 --- 46 files changed, 26 insertions(+), 233 deletions(-) diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index af4ab95f..503d10f5 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -68,12 +68,14 @@ pub use generated::{peripherals, Peripherals}; #[non_exhaustive] pub struct Config { pub rcc: rcc::Config, + pub enable_debug_during_sleep: bool, } impl Default for Config { fn default() -> Self { Self { rcc: Default::default(), + enable_debug_during_sleep: true, } } } @@ -83,6 +85,10 @@ pub fn init(config: Config) -> Peripherals { let p = Peripherals::take(); unsafe { + if config.enable_debug_during_sleep { + dbgmcu::Dbgmcu::enable_all(); + } + gpio::init(); dma::init(); #[cfg(exti)] diff --git a/embassy-stm32/src/rcc/f0/mod.rs b/embassy-stm32/src/rcc/f0/mod.rs index 6600a1e2..ec6474e8 100644 --- a/embassy-stm32/src/rcc/f0/mod.rs +++ b/embassy-stm32/src/rcc/f0/mod.rs @@ -2,7 +2,6 @@ use core::marker::PhantomData; use embassy::util::Unborrow; -use crate::dbgmcu::Dbgmcu; use crate::pac::{FLASH, RCC}; use crate::peripherals; use crate::time::Hertz; @@ -27,7 +26,6 @@ pub struct Config { pub sys_ck: Option, pub hclk: Option, pub pclk: Option, - pub enable_debug_wfe: bool, } pub struct Rcc<'d> { @@ -190,12 +188,6 @@ impl<'d> Rcc<'d> { } }) } - - if self.config.enable_debug_wfe { - RCC.ahbenr().modify(|w| w.set_dmaen(true)); - - critical_section::with(|_| Dbgmcu::enable_all()); - } } Clocks { diff --git a/embassy-stm32/src/rcc/f4/mod.rs b/embassy-stm32/src/rcc/f4/mod.rs index eab98daf..04083dfa 100644 --- a/embassy-stm32/src/rcc/f4/mod.rs +++ b/embassy-stm32/src/rcc/f4/mod.rs @@ -21,7 +21,6 @@ pub struct Config { pub hclk: Option, pub pclk1: Option, pub pclk2: Option, - pub enable_debug_wfe: bool, } /// RCC peripheral @@ -176,15 +175,6 @@ impl<'d> Rcc<'d> { }); } - if self.config.enable_debug_wfe { - unsafe { - RCC.ahb1enr().modify(|w| w.set_dma1en(true)); - critical_section::with(|_| { - crate::dbgmcu::Dbgmcu::enable_all(); - }); - } - } - Clocks { sys: Hertz(sysclk), apb1: Hertz(pclk1), diff --git a/embassy-stm32/src/rcc/h7/mod.rs b/embassy-stm32/src/rcc/h7/mod.rs index d6a55c3b..5567a478 100644 --- a/embassy-stm32/src/rcc/h7/mod.rs +++ b/embassy-stm32/src/rcc/h7/mod.rs @@ -3,7 +3,7 @@ use core::marker::PhantomData; use embassy::util::Unborrow; use crate::pac::rcc::vals::Timpre; -use crate::pac::{DBGMCU, RCC, SYSCFG}; +use crate::pac::{RCC, SYSCFG}; use crate::peripherals; use crate::pwr::{Power, VoltageScale}; use crate::rcc::{set_freqs, Clocks}; @@ -363,25 +363,6 @@ impl<'d> Rcc<'d> { } } - /// Enables debugging during WFI/WFE - /// - /// Set `enable_dma1` to true if you do not have at least one bus master (other than the CPU) - /// enable during WFI/WFE - pub fn enable_debug_wfe(&mut self, _dbg: &mut peripherals::DBGMCU, enable_dma1: bool) { - // NOTE(unsafe) We have exclusive access to the RCC and DBGMCU - unsafe { - if enable_dma1 { - RCC.ahb1enr().modify(|w| w.set_dma1en(true)); - } - - DBGMCU.cr().modify(|w| { - w.set_dbgsleep_d1(true); - w.set_dbgstby_d1(true); - w.set_dbgstop_d1(true); - }); - } - } - /// Setup traceclk /// Returns a pll1_r_ck fn traceclk_setup(&mut self, sys_use_pll1_p: bool) { diff --git a/embassy-stm32/src/rcc/l0/mod.rs b/embassy-stm32/src/rcc/l0/mod.rs index 290449e1..1c3b314b 100644 --- a/embassy-stm32/src/rcc/l0/mod.rs +++ b/embassy-stm32/src/rcc/l0/mod.rs @@ -1,5 +1,4 @@ pub use super::types::*; -use crate::dbgmcu::Dbgmcu; use crate::pac; use crate::peripherals::{self, CRS, RCC, SYSCFG}; use crate::rcc::{get_freqs, set_freqs, Clocks}; @@ -168,15 +167,6 @@ impl<'d> Rcc<'d> { unsafe { get_freqs() } } - pub fn enable_debug_wfe(&mut self, _dbg: &mut peripherals::DBGMCU, enable_dma: bool) { - // NOTE(unsafe) We have exclusive access to the RCC and DBGMCU - unsafe { - pac::RCC.ahbenr().modify(|w| w.set_dma1en(enable_dma)); - - Dbgmcu::enable_all(); - } - } - pub fn enable_hsi48(&mut self, _syscfg: &mut SYSCFG, _crs: CRS) -> HSI48 { let rcc = pac::RCC; unsafe { diff --git a/examples/stm32f0/src/bin/hello.rs b/examples/stm32f0/src/bin/hello.rs index 8429cc60..418f2794 100644 --- a/examples/stm32f0/src/bin/hello.rs +++ b/examples/stm32f0/src/bin/hello.rs @@ -12,7 +12,7 @@ use embassy_stm32::Peripherals; #[path = "../example_common.rs"] mod example_common; -#[embassy::main(config = "example_common::config()")] +#[embassy::main] async fn main(_spawner: Spawner, _p: Peripherals) -> ! { loop { Timer::after(Duration::from_secs(1)).await; diff --git a/examples/stm32f0/src/example_common.rs b/examples/stm32f0/src/example_common.rs index f5011965..54d63383 100644 --- a/examples/stm32f0/src/example_common.rs +++ b/examples/stm32f0/src/example_common.rs @@ -6,13 +6,6 @@ use panic_probe as _; pub use defmt::*; use core::sync::atomic::{AtomicUsize, Ordering}; -use embassy_stm32::Config; - -pub fn config() -> Config { - let mut config = Config::default(); - config.rcc.enable_debug_wfe = true; - config -} defmt::timestamp! {"{=u64}", { static COUNT: AtomicUsize = AtomicUsize::new(0); diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs index b3a0ffb8..a30887f7 100644 --- a/examples/stm32f4/src/bin/blinky.rs +++ b/examples/stm32f4/src/bin/blinky.rs @@ -8,7 +8,6 @@ mod example_common; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use embedded_hal::digital::v2::OutputPin; @@ -18,10 +17,6 @@ use example_common::*; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let mut led = Output::new(p.PB7, Level::High, Speed::Low); loop { diff --git a/examples/stm32f4/src/bin/button.rs b/examples/stm32f4/src/bin/button.rs index 90998cf4..04fcfcc2 100644 --- a/examples/stm32f4/src/bin/button.rs +++ b/examples/stm32f4/src/bin/button.rs @@ -7,7 +7,6 @@ #[path = "../example_common.rs"] mod example_common; use cortex_m_rt::entry; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embedded_hal::digital::v2::{InputPin, OutputPin}; use example_common::*; @@ -16,10 +15,6 @@ use example_common::*; fn main() -> ! { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let p = embassy_stm32::init(Default::default()); let button = Input::new(p.PC13, Pull::Down); diff --git a/examples/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs index ee43fa7d..49c23ca3 100644 --- a/examples/stm32f4/src/bin/button_exti.rs +++ b/examples/stm32f4/src/bin/button_exti.rs @@ -7,7 +7,6 @@ #[path = "../example_common.rs"] mod example_common; use embassy::executor::Spawner; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; @@ -18,10 +17,6 @@ use example_common::*; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let button = Input::new(p.PC13, Pull::Down); let mut button = ExtiInput::new(button, p.EXTI13); diff --git a/examples/stm32f4/src/bin/can.rs b/examples/stm32f4/src/bin/can.rs index 2bb24f04..29dff551 100644 --- a/examples/stm32f4/src/bin/can.rs +++ b/examples/stm32f4/src/bin/can.rs @@ -10,7 +10,6 @@ mod example_common; use cortex_m_rt::entry; use embassy_stm32::can::filter::Mask32; use embassy_stm32::can::{Can, Frame, StandardId}; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::gpio::{Input, Pull}; use example_common::*; @@ -18,10 +17,6 @@ use example_common::*; fn main() -> ! { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let mut p = embassy_stm32::init(Default::default()); // The next two lines are a workaround for testing without transceiver. diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs index 1b8730ae..8059f4b5 100644 --- a/examples/stm32f4/src/bin/hello.rs +++ b/examples/stm32f4/src/bin/hello.rs @@ -17,7 +17,6 @@ mod example_common; fn config() -> Config { let mut config = Config::default(); config.rcc.sys_ck = Some(Hertz(84_000_000)); - config.rcc.enable_debug_wfe = true; config } diff --git a/examples/stm32f4/src/bin/spi.rs b/examples/stm32f4/src/bin/spi.rs index bb130a2e..19b6c62a 100644 --- a/examples/stm32f4/src/bin/spi.rs +++ b/examples/stm32f4/src/bin/spi.rs @@ -8,7 +8,6 @@ mod example_common; use cortex_m_rt::entry; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; @@ -21,10 +20,6 @@ use example_common::*; fn main() -> ! { info!("Hello World, dude!"); - unsafe { - Dbgmcu::enable_all(); - } - let p = embassy_stm32::init(Default::default()); let mut spi = Spi::new( diff --git a/examples/stm32f4/src/bin/spi_dma.rs b/examples/stm32f4/src/bin/spi_dma.rs index a965bef7..ef88fbb9 100644 --- a/examples/stm32f4/src/bin/spi_dma.rs +++ b/examples/stm32f4/src/bin/spi_dma.rs @@ -9,7 +9,6 @@ mod example_common; use core::fmt::Write; use core::str::from_utf8; use embassy::executor::Spawner; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; @@ -21,10 +20,6 @@ use heapless::String; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let mut spi = Spi::new( p.SPI1, p.PB3, diff --git a/examples/stm32f4/src/bin/usart.rs b/examples/stm32f4/src/bin/usart.rs index 781c6a95..8bb2ada9 100644 --- a/examples/stm32f4/src/bin/usart.rs +++ b/examples/stm32f4/src/bin/usart.rs @@ -7,7 +7,6 @@ #[path = "../example_common.rs"] mod example_common; use cortex_m_rt::entry; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embedded_hal::blocking::serial::Write; @@ -17,10 +16,6 @@ use example_common::*; fn main() -> ! { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let p = embassy_stm32::init(Default::default()); let config = Config::default(); diff --git a/examples/stm32f4/src/bin/usart_dma.rs b/examples/stm32f4/src/bin/usart_dma.rs index bf50b8ad..3cfa6219 100644 --- a/examples/stm32f4/src/bin/usart_dma.rs +++ b/examples/stm32f4/src/bin/usart_dma.rs @@ -8,7 +8,6 @@ mod example_common; use core::fmt::Write; use embassy::executor::Spawner; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; @@ -20,10 +19,6 @@ use heapless::String; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let config = Config::default(); let mut usart = Uart::new(p.USART3, p.PD9, p.PD8, p.DMA1_CH3, NoDma, config); diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs index 09b34eac..3784fba8 100644 --- a/examples/stm32h7/src/bin/blinky.rs +++ b/examples/stm32h7/src/bin/blinky.rs @@ -8,7 +8,6 @@ mod example_common; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use embedded_hal::digital::v2::OutputPin; @@ -18,8 +17,6 @@ use example_common::*; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - unsafe { Dbgmcu::enable_all() }; - let mut led = Output::new(p.PB14, Level::High, Speed::Low); loop { diff --git a/examples/stm32h7/src/bin/button_exti.rs b/examples/stm32h7/src/bin/button_exti.rs index ee43fa7d..49c23ca3 100644 --- a/examples/stm32h7/src/bin/button_exti.rs +++ b/examples/stm32h7/src/bin/button_exti.rs @@ -7,7 +7,6 @@ #[path = "../example_common.rs"] mod example_common; use embassy::executor::Spawner; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; @@ -18,10 +17,6 @@ use example_common::*; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let button = Input::new(p.PC13, Pull::Down); let mut button = ExtiInput::new(button, p.EXTI13); diff --git a/examples/stm32h7/src/bin/dac.rs b/examples/stm32h7/src/bin/dac.rs index 8816f63c..e4c3a731 100644 --- a/examples/stm32h7/src/bin/dac.rs +++ b/examples/stm32h7/src/bin/dac.rs @@ -19,10 +19,6 @@ fn main() -> ! { let p = embassy_stm32::init(config()); - unsafe { - Dbgmcu::enable_all(); - } - let mut dac = Dac::new(p.DAC1, p.PA4, NoPin); loop { @@ -33,7 +29,6 @@ fn main() -> ! { } } -use embassy_stm32::dbgmcu::Dbgmcu; use micromath::F32Ext; fn to_sine_wave(v: u8) -> u8 { diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index e8d13876..4a9f261c 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs @@ -19,7 +19,6 @@ use embassy_macros::interrupt_take; use embassy_net::{ Config as NetConfig, Ipv4Address, Ipv4Cidr, StackResources, StaticConfigurator, TcpSocket, }; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::eth::lan8742a::LAN8742A; use embassy_stm32::eth::{Ethernet, State}; use embassy_stm32::rng::Random; @@ -96,10 +95,6 @@ fn main() -> ! { info!("Setup RCC..."); - unsafe { - Dbgmcu::enable_all(); - } - let p = embassy_stm32::init(config()); let rng = Random::new(p.RNG); diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index 047b6584..5514b0d3 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs @@ -17,7 +17,6 @@ use example_common::*; use core::str::from_utf8; use cortex_m_rt::entry; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::peripherals::SPI3; use embassy_stm32::time::U32Ext; use heapless::String; @@ -43,10 +42,6 @@ static EXECUTOR: Forever = Forever::new(); fn main() -> ! { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let p = embassy_stm32::init(config()); let spi = spi::Spi::new( diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index f11b7eb4..ea160590 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs @@ -16,7 +16,6 @@ use example_common::*; use core::str::from_utf8; use cortex_m_rt::entry; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; use embassy_stm32::spi; use heapless::String; @@ -39,10 +38,6 @@ static EXECUTOR: Forever = Forever::new(); fn main() -> ! { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let p = embassy_stm32::init(config()); let spi = spi::Spi::new( diff --git a/examples/stm32h7/src/bin/usart.rs b/examples/stm32h7/src/bin/usart.rs index a3fcc6d3..10bf7813 100644 --- a/examples/stm32h7/src/bin/usart.rs +++ b/examples/stm32h7/src/bin/usart.rs @@ -14,7 +14,6 @@ use embassy_stm32::usart::{Config, Uart}; use example_common::*; use cortex_m_rt::entry; -use embassy_stm32::dbgmcu::Dbgmcu; #[embassy::task] async fn main_task() { @@ -39,10 +38,6 @@ static EXECUTOR: Forever = Forever::new(); fn main() -> ! { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let executor = EXECUTOR.put(Executor::new()); executor.run(|spawner| { diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs index 3f70a82b..eb71a72c 100644 --- a/examples/stm32h7/src/bin/usart_dma.rs +++ b/examples/stm32h7/src/bin/usart_dma.rs @@ -9,7 +9,6 @@ mod example_common; use core::fmt::Write; use embassy::executor::Executor; use embassy::util::Forever; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_traits::uart::Write as _Write; @@ -41,10 +40,6 @@ static EXECUTOR: Forever = Forever::new(); fn main() -> ! { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let executor = EXECUTOR.put(Executor::new()); executor.run(|spawner| { diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 9b316615..07b033c1 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -27,7 +27,7 @@ defmt = "0.2.0" defmt-rtt = "0.2.0" cortex-m = "0.7.1" -cortex-m-rt = "0.6.14" +cortex-m-rt = "0.7.0" embedded-hal = { version = "0.2.4" } panic-probe = { version = "0.2.0", features= ["print-defmt"] } futures = { version = "0.3.8", default-features = false, features = ["async-await"] } diff --git a/examples/stm32l0/src/bin/blinky.rs b/examples/stm32l0/src/bin/blinky.rs index 29f5d7c7..d8513bc7 100644 --- a/examples/stm32l0/src/bin/blinky.rs +++ b/examples/stm32l0/src/bin/blinky.rs @@ -10,17 +10,14 @@ mod example_common; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::rcc::Rcc; use embassy_stm32::Peripherals; use embedded_hal::digital::v2::OutputPin; use example_common::*; #[embassy::main] -async fn main(_spawner: Spawner, mut p: Peripherals) { +async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - Rcc::new(p.RCC).enable_debug_wfe(&mut p.DBGMCU, true); - let mut led = Output::new(p.PB5, Level::High, Speed::Low); loop { diff --git a/examples/stm32l0/src/bin/button.rs b/examples/stm32l0/src/bin/button.rs index e37d3f26..a7e82e37 100644 --- a/examples/stm32l0/src/bin/button.rs +++ b/examples/stm32l0/src/bin/button.rs @@ -6,22 +6,16 @@ #[path = "../example_common.rs"] mod example_common; -use embassy_stm32::{ - gpio::{Input, Level, Output, Pull, Speed}, - rcc::*, -}; +use embassy::executor::Spawner; +use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_stm32::Peripherals; use embedded_hal::digital::v2::{InputPin, OutputPin}; use example_common::*; -use cortex_m_rt::entry; - -#[entry] -fn main() -> ! { +#[embassy::main] +async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - let mut p = embassy_stm32::init(Default::default()); - Rcc::new(p.RCC).enable_debug_wfe(&mut p.DBGMCU, true); - let button = Input::new(p.PB2, Pull::Up); let mut led1 = Output::new(p.PA5, Level::High, Speed::Low); let mut led2 = Output::new(p.PB5, Level::High, Speed::Low); diff --git a/examples/stm32l0/src/bin/button_exti.rs b/examples/stm32l0/src/bin/button_exti.rs index 40e25b08..13ce9990 100644 --- a/examples/stm32l0/src/bin/button_exti.rs +++ b/examples/stm32l0/src/bin/button_exti.rs @@ -17,7 +17,6 @@ use example_common::*; #[embassy::main] async fn main(_spawner: Spawner, mut p: Peripherals) { let mut rcc = rcc::Rcc::new(p.RCC); - rcc.enable_debug_wfe(&mut p.DBGMCU, true); // Enables SYSCFG let _ = rcc.enable_hsi48(&mut p.SYSCFG, p.CRS); diff --git a/examples/stm32l0/src/bin/spi.rs b/examples/stm32l0/src/bin/spi.rs index 43ffb553..83c4fe32 100644 --- a/examples/stm32l0/src/bin/spi.rs +++ b/examples/stm32l0/src/bin/spi.rs @@ -7,25 +7,21 @@ #[path = "../example_common.rs"] mod example_common; +use embassy::executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; use embedded_hal::digital::v2::OutputPin; use example_common::*; -use cortex_m_rt::entry; use embassy_stm32::dma::NoDma; -use embassy_stm32::rcc; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; +use embassy_stm32::Peripherals; use embedded_hal::blocking::spi::Transfer; -#[entry] -fn main() -> ! { +#[embassy::main] +async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World, folks!"); - let mut p = embassy_stm32::init(Default::default()); - let mut rcc = rcc::Rcc::new(p.RCC); - rcc.enable_debug_wfe(&mut p.DBGMCU, true); - let mut spi = Spi::new( p.SPI1, p.PB3, @@ -40,7 +36,7 @@ fn main() -> ! { let mut cs = Output::new(p.PA15, Level::High, Speed::VeryHigh); loop { - let mut buf = [0x0A; 4]; + let mut buf = [0x0Au8; 4]; unwrap!(cs.set_low()); unwrap!(spi.transfer(&mut buf)); unwrap!(cs.set_high()); diff --git a/examples/stm32l0/src/bin/usart_dma.rs b/examples/stm32l0/src/bin/usart_dma.rs index 39a60517..2b2424e9 100644 --- a/examples/stm32l0/src/bin/usart_dma.rs +++ b/examples/stm32l0/src/bin/usart_dma.rs @@ -11,14 +11,11 @@ use example_common::*; use embassy::executor::Spawner; use embassy_stm32::usart::{Config, Uart}; -use embassy_stm32::{rcc, Peripherals}; +use embassy_stm32::Peripherals; use embassy_traits::uart::{Read, Write}; #[embassy::main] -async fn main(_spawner: Spawner, mut p: Peripherals) { - let mut rcc = rcc::Rcc::new(p.RCC); - rcc.enable_debug_wfe(&mut p.DBGMCU, true); - +async fn main(_spawner: Spawner, p: Peripherals) { let mut usart = Uart::new( p.USART1, p.PB7, diff --git a/examples/stm32l0/src/bin/usart_irq.rs b/examples/stm32l0/src/bin/usart_irq.rs index 5c79d067..66a00f41 100644 --- a/examples/stm32l0/src/bin/usart_irq.rs +++ b/examples/stm32l0/src/bin/usart_irq.rs @@ -15,13 +15,10 @@ use embassy::io::{AsyncBufReadExt, AsyncWriteExt}; use embassy_stm32::dma::NoDma; use embassy_stm32::interrupt; use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; -use embassy_stm32::{rcc, Peripherals}; +use embassy_stm32::Peripherals; #[embassy::main] -async fn main(_spawner: Spawner, mut p: Peripherals) { - let mut rcc = rcc::Rcc::new(p.RCC); - rcc.enable_debug_wfe(&mut p.DBGMCU, true); - +async fn main(_spawner: Spawner, p: Peripherals) { static mut TX_BUFFER: [u8; 8] = [0; 8]; static mut RX_BUFFER: [u8; 256] = [0; 256]; diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index 3f6b3467..3fa6fa46 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml @@ -26,7 +26,7 @@ defmt = "0.2.0" defmt-rtt = "0.2.0" cortex-m = "0.7.1" -cortex-m-rt = "0.6.14" +cortex-m-rt = "0.7.0" embedded-hal = { version = "0.2.4" } panic-probe = { version = "0.2.0", features= ["print-defmt"] } futures = { version = "0.3.8", default-features = false, features = ["async-await"] } diff --git a/examples/stm32l4/src/bin/adc.rs b/examples/stm32l4/src/bin/adc.rs index c778d9c3..14b4e5ec 100644 --- a/examples/stm32l4/src/bin/adc.rs +++ b/examples/stm32l4/src/bin/adc.rs @@ -9,7 +9,6 @@ mod example_common; use embassy::time::Delay; use embassy_stm32::adc::{Adc, Resolution}; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::pac; use example_common::*; @@ -18,8 +17,6 @@ fn main() -> ! { info!("Hello World!"); unsafe { - Dbgmcu::enable_all(); - pac::RCC.ccipr().modify(|w| { w.set_adcsel(0b11); }); diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs index c9ba587e..9c983bc6 100644 --- a/examples/stm32l4/src/bin/blinky.rs +++ b/examples/stm32l4/src/bin/blinky.rs @@ -8,7 +8,6 @@ mod example_common; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use embedded_hal::digital::v2::OutputPin; @@ -18,10 +17,6 @@ use example_common::*; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let mut led = Output::new(p.PB14, Level::High, Speed::Low); loop { diff --git a/examples/stm32l4/src/bin/button.rs b/examples/stm32l4/src/bin/button.rs index 883a0d6c..be6e2d2f 100644 --- a/examples/stm32l4/src/bin/button.rs +++ b/examples/stm32l4/src/bin/button.rs @@ -6,7 +6,6 @@ #[path = "../example_common.rs"] mod example_common; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::gpio::{Input, Pull}; use embedded_hal::digital::v2::InputPin; use example_common::*; @@ -15,10 +14,6 @@ use example_common::*; fn main() -> ! { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let p = embassy_stm32::init(Default::default()); let button = Input::new(p.PC13, Pull::Up); diff --git a/examples/stm32l4/src/bin/button_exti.rs b/examples/stm32l4/src/bin/button_exti.rs index 8a78b258..c55d6408 100644 --- a/examples/stm32l4/src/bin/button_exti.rs +++ b/examples/stm32l4/src/bin/button_exti.rs @@ -7,7 +7,6 @@ #[path = "../example_common.rs"] mod example_common; use embassy::executor::Spawner; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; @@ -18,10 +17,6 @@ use example_common::*; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let button = Input::new(p.PC13, Pull::Up); let mut button = ExtiInput::new(button, p.EXTI13); diff --git a/examples/stm32l4/src/bin/dac.rs b/examples/stm32l4/src/bin/dac.rs index c479f86c..e03fbc95 100644 --- a/examples/stm32l4/src/bin/dac.rs +++ b/examples/stm32l4/src/bin/dac.rs @@ -8,7 +8,6 @@ mod example_common; use embassy_stm32::dac::{Channel, Dac, Value}; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::gpio::NoPin; use embassy_stm32::pac; use example_common::*; @@ -18,8 +17,6 @@ fn main() -> ! { info!("Hello World!"); unsafe { - Dbgmcu::enable_all(); - pac::RCC.apb1enr1().modify(|w| { w.set_dac1en(true); }); diff --git a/examples/stm32l4/src/bin/spi.rs b/examples/stm32l4/src/bin/spi.rs index ef6e2fca..376537e9 100644 --- a/examples/stm32l4/src/bin/spi.rs +++ b/examples/stm32l4/src/bin/spi.rs @@ -7,7 +7,6 @@ #[path = "../example_common.rs"] mod example_common; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; @@ -20,10 +19,6 @@ use example_common::*; fn main() -> ! { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let p = embassy_stm32::init(Default::default()); let mut spi = Spi::new( diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index d626a129..75c19a3b 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs @@ -8,7 +8,6 @@ mod example_common; use embassy::executor::Spawner; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; @@ -21,10 +20,6 @@ use example_common::*; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let mut spi = Spi::new( p.SPI3, p.PC10, diff --git a/examples/stm32l4/src/bin/usart.rs b/examples/stm32l4/src/bin/usart.rs index 95ac84b2..09b62f68 100644 --- a/examples/stm32l4/src/bin/usart.rs +++ b/examples/stm32l4/src/bin/usart.rs @@ -7,7 +7,6 @@ #[path = "../example_common.rs"] mod example_common; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embedded_hal::blocking::serial::Write; @@ -17,10 +16,6 @@ use example_common::*; fn main() -> ! { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let p = embassy_stm32::init(Default::default()); let config = Config::default(); diff --git a/examples/stm32l4/src/bin/usart_dma.rs b/examples/stm32l4/src/bin/usart_dma.rs index f74a0e06..d307dc13 100644 --- a/examples/stm32l4/src/bin/usart_dma.rs +++ b/examples/stm32l4/src/bin/usart_dma.rs @@ -8,7 +8,6 @@ mod example_common; use core::fmt::Write; use embassy::executor::Spawner; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; @@ -20,10 +19,6 @@ use heapless::String; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let config = Config::default(); let mut usart = Uart::new(p.UART4, p.PA1, p.PA0, p.DMA1_CH3, NoDma, config); diff --git a/examples/stm32wb55/src/bin/blinky.rs b/examples/stm32wb55/src/bin/blinky.rs index 2deaf5f5..ea5f872d 100644 --- a/examples/stm32wb55/src/bin/blinky.rs +++ b/examples/stm32wb55/src/bin/blinky.rs @@ -8,7 +8,6 @@ mod example_common; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use embedded_hal::digital::v2::OutputPin; @@ -18,8 +17,6 @@ use example_common::*; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - unsafe { Dbgmcu::enable_all() }; - let mut led = Output::new(p.PB0, Level::High, Speed::Low); loop { diff --git a/examples/stm32wb55/src/bin/button_exti.rs b/examples/stm32wb55/src/bin/button_exti.rs index 92a310c7..1c070833 100644 --- a/examples/stm32wb55/src/bin/button_exti.rs +++ b/examples/stm32wb55/src/bin/button_exti.rs @@ -7,7 +7,6 @@ #[path = "../example_common.rs"] mod example_common; use embassy::executor::Spawner; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; @@ -18,10 +17,6 @@ use example_common::*; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - unsafe { - Dbgmcu::enable_all(); - } - let button = Input::new(p.PC4, Pull::Up); let mut button = ExtiInput::new(button, p.EXTI4); diff --git a/examples/stm32wl55/src/bin/blinky.rs b/examples/stm32wl55/src/bin/blinky.rs index b5e5ffcf..b13b66e0 100644 --- a/examples/stm32wl55/src/bin/blinky.rs +++ b/examples/stm32wl55/src/bin/blinky.rs @@ -8,7 +8,6 @@ mod example_common; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use embedded_hal::digital::v2::OutputPin; @@ -18,8 +17,6 @@ use example_common::*; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - unsafe { Dbgmcu::enable_all() }; - let mut led = Output::new(p.PB15, Level::High, Speed::Low); loop { diff --git a/examples/stm32wl55/src/bin/button.rs b/examples/stm32wl55/src/bin/button.rs index 84e1f599..ca1625a6 100644 --- a/examples/stm32wl55/src/bin/button.rs +++ b/examples/stm32wl55/src/bin/button.rs @@ -6,10 +6,7 @@ #[path = "../example_common.rs"] mod example_common; -use embassy_stm32::{ - dbgmcu::Dbgmcu, - gpio::{Input, Level, Output, Pull, Speed}, -}; +use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embedded_hal::digital::v2::{InputPin, OutputPin}; use example_common::*; @@ -21,8 +18,6 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - unsafe { Dbgmcu::enable_all() }; - let button = Input::new(p.PA0, Pull::Up); let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); let mut led2 = Output::new(p.PB9, Level::High, Speed::Low); diff --git a/examples/stm32wl55/src/bin/button_exti.rs b/examples/stm32wl55/src/bin/button_exti.rs index 2f6e5511..b34e5457 100644 --- a/examples/stm32wl55/src/bin/button_exti.rs +++ b/examples/stm32wl55/src/bin/button_exti.rs @@ -7,7 +7,6 @@ #[path = "../example_common.rs"] mod example_common; use embassy::executor::Spawner; -use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; @@ -18,8 +17,6 @@ use example_common::*; async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); - unsafe { Dbgmcu::enable_all() }; - let button = Input::new(p.PA0, Pull::Up); let mut button = ExtiInput::new(button, p.EXTI0);