diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs index 0e411d78..da512dce 100644 --- a/examples/stm32f4/src/bin/blinky.rs +++ b/examples/stm32f4/src/bin/blinky.rs @@ -25,15 +25,6 @@ fn main() -> ! { w.set_dbg_standby(true); w.set_dbg_stop(true); }); - - pac::RCC.ahb1enr().modify(|w| { - w.set_gpioaen(true); - w.set_gpioben(true); - w.set_gpiocen(true); - w.set_gpioden(true); - w.set_gpioeen(true); - w.set_gpiofen(true); - }); } let p = embassy_stm32::init(Default::default()); diff --git a/examples/stm32f4/src/bin/button.rs b/examples/stm32f4/src/bin/button.rs index 901fce41..395ec484 100644 --- a/examples/stm32f4/src/bin/button.rs +++ b/examples/stm32f4/src/bin/button.rs @@ -24,15 +24,6 @@ fn main() -> ! { w.set_dbg_standby(true); w.set_dbg_stop(true); }); - - pac::RCC.ahb1enr().modify(|w| { - w.set_gpioaen(true); - w.set_gpioben(true); - w.set_gpiocen(true); - w.set_gpioden(true); - w.set_gpioeen(true); - w.set_gpiofen(true); - }); } let p = embassy_stm32::init(Default::default()); diff --git a/examples/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs index 63c273b1..bccd3870 100644 --- a/examples/stm32f4/src/bin/button_exti.rs +++ b/examples/stm32f4/src/bin/button_exti.rs @@ -48,15 +48,6 @@ fn main() -> ! { w.set_dbg_stop(true); }); - pac::RCC.ahb1enr().modify(|w| { - w.set_gpioaen(true); - w.set_gpioben(true); - w.set_gpiocen(true); - w.set_gpioden(true); - w.set_gpioeen(true); - w.set_gpiofen(true); - }); - // EXTI clock pac::RCC.apb2enr().modify(|w| { w.set_syscfgen(true); diff --git a/examples/stm32f4/src/bin/spi.rs b/examples/stm32f4/src/bin/spi.rs index f8c9997e..40b0748d 100644 --- a/examples/stm32f4/src/bin/spi.rs +++ b/examples/stm32f4/src/bin/spi.rs @@ -14,11 +14,11 @@ use embedded_hal::digital::v2::OutputPin; use example_common::*; use cortex_m_rt::entry; +use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::pac; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use embedded_hal::blocking::spi::Transfer; -use embassy_stm32::dbgmcu::Dbgmcu; #[entry] fn main() -> ! { @@ -26,15 +26,6 @@ fn main() -> ! { unsafe { Dbgmcu::enable_all(); - - pac::RCC.ahb1enr().modify(|w| { - w.set_gpioaen(true); - w.set_gpioben(true); - w.set_gpiocen(true); - w.set_gpioden(true); - w.set_gpioeen(true); - w.set_gpiofen(true); - }); } let p = embassy_stm32::init(Default::default()); diff --git a/examples/stm32f4/src/bin/usart.rs b/examples/stm32f4/src/bin/usart.rs index dbe17c91..51a2e0fd 100644 --- a/examples/stm32f4/src/bin/usart.rs +++ b/examples/stm32f4/src/bin/usart.rs @@ -47,15 +47,6 @@ fn main() -> ! { w.set_dbg_standby(true); w.set_dbg_stop(true); }); - - pac::RCC.ahb1enr().modify(|w| { - w.set_gpioaen(true); - w.set_gpioben(true); - w.set_gpiocen(true); - w.set_gpioden(true); - w.set_gpioeen(true); - w.set_gpiofen(true); - }); } let executor = EXECUTOR.put(Executor::new()); diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs index c41cc789..54e139e7 100644 --- a/examples/stm32h7/src/bin/blinky.rs +++ b/examples/stm32h7/src/bin/blinky.rs @@ -28,8 +28,7 @@ fn main() -> ! { let rcc = pp.RCC.constrain(); - rcc - .sys_ck(96.mhz()) + rcc.sys_ck(96.mhz()) .pclk1(48.mhz()) .pclk2(48.mhz()) .pclk3(48.mhz()) @@ -47,16 +46,6 @@ fn main() -> ! { w }); - pp.RCC.ahb4enr.modify(|_, w| { - w.gpioaen().set_bit(); - w.gpioben().set_bit(); - w.gpiocen().set_bit(); - w.gpioden().set_bit(); - w.gpioeen().set_bit(); - w.gpiofen().set_bit(); - w - }); - let p = embassy_stm32::init(Default::default()); let mut led = Output::new(p.PB14, Level::High, Speed::Low); diff --git a/examples/stm32h7/src/bin/dac.rs b/examples/stm32h7/src/bin/dac.rs index 12195675..330f69aa 100644 --- a/examples/stm32h7/src/bin/dac.rs +++ b/examples/stm32h7/src/bin/dac.rs @@ -13,9 +13,9 @@ use embassy_stm32::gpio::NoPin; use example_common::*; use cortex_m_rt::entry; +use embassy_stm32::dac::{Channel, Dac, Value}; use stm32h7::stm32h743 as pac; use stm32h7xx_hal::prelude::*; -use embassy_stm32::dac::{Dac, Value, Channel}; #[entry] fn main() -> ! { @@ -23,13 +23,11 @@ fn main() -> ! { let pp = pac::Peripherals::take().unwrap(); - let pwrcfg = pp.PWR.constrain() - .freeze(); + let pwrcfg = pp.PWR.constrain().freeze(); let rcc = pp.RCC.constrain(); - rcc - .sys_ck(96.mhz()) + rcc.sys_ck(96.mhz()) .pclk1(48.mhz()) .pclk2(48.mhz()) .pclk3(48.mhz()) @@ -47,21 +45,11 @@ fn main() -> ! { w }); - pp.RCC.apb1lenr.modify(|_, w|{ + pp.RCC.apb1lenr.modify(|_, w| { w.dac12en().set_bit(); w }); - pp.RCC.ahb4enr.modify(|_, w| { - w.gpioaen().set_bit(); - w.gpioben().set_bit(); - w.gpiocen().set_bit(); - w.gpioden().set_bit(); - w.gpioeen().set_bit(); - w.gpiofen().set_bit(); - w - }); - let p = embassy_stm32::init(Default::default()); let mut dac = Dac::new(p.DAC1, p.PA4, NoPin); @@ -79,11 +67,11 @@ use micromath::F32Ext; fn to_sine_wave(v: u8) -> u8 { if v >= 128 { // top half - let r = 3.14 * ( (v-128) as f32/ 128.0) ; + let r = 3.14 * ((v - 128) as f32 / 128.0); (r.sin() * 128.0 + 127.0) as u8 } else { // bottom half - let r = 3.14 + 3.14 * (v as f32/ 128.0); + let r = 3.14 + 3.14 * (v as f32 / 128.0); (r.sin() * 128.0 + 127.0) as u8 } } diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 7dc02a75..7ae80d6e 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs @@ -106,8 +106,6 @@ static NET_RESOURCES: Forever> = Forever::new(); #[entry] fn main() -> ! { - use stm32_metapac::RCC; - info!("Hello World!"); info!("Setup RCC..."); @@ -123,16 +121,6 @@ fn main() -> ! { let mut rcc = Rcc::new(&mut p.RCC, RccConfig::default()); rcc.enable_debug_wfe(&mut p.DBGMCU, true); - unsafe { - RCC.ahb4enr().modify(|w| { - w.set_gpioaen(true); - w.set_gpioben(true); - w.set_gpiocen(true); - w.set_gpioden(true); - w.set_gpioien(true); - }); - } - let rtc_int = interrupt_take!(TIM2); let rtc = TIMER_RTC.put(Clock::new(p.TIM2, rtc_int)); rtc.start(); diff --git a/examples/stm32h7/src/bin/usart.rs b/examples/stm32h7/src/bin/usart.rs index 143f9449..11e04f33 100644 --- a/examples/stm32h7/src/bin/usart.rs +++ b/examples/stm32h7/src/bin/usart.rs @@ -77,16 +77,6 @@ fn main() -> ! { w }); - pp.RCC.ahb4enr.modify(|_, w| { - w.gpioaen().set_bit(); - w.gpioben().set_bit(); - w.gpiocen().set_bit(); - w.gpioden().set_bit(); - w.gpioeen().set_bit(); - w.gpiofen().set_bit(); - w - }); - unsafe { embassy::time::set_clock(&ZeroClock) }; let executor = EXECUTOR.put(Executor::new()); diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs index 90735650..fe59a216 100644 --- a/examples/stm32h7/src/bin/usart_dma.rs +++ b/examples/stm32h7/src/bin/usart_dma.rs @@ -12,18 +12,18 @@ use core::fmt::Write; use embassy::executor::Executor; use embassy::time::Clock; use embassy::util::Forever; +use embassy_stm32::dbgmcu::Dbgmcu; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use embassy_stm32::dbgmcu::Dbgmcu; -use example_common::*; use embassy_traits::uart::Write as _Write; +use example_common::*; use hal::prelude::*; use stm32h7xx_hal as hal; use cortex_m_rt::entry; -use stm32h7::stm32h743 as pac; use heapless::String; +use stm32h7::stm32h743 as pac; #[embassy::task] async fn main_task() { @@ -40,7 +40,6 @@ async fn main_task() { info!("wrote DMA"); } - } struct ZeroClock; diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index 069c1434..41c189c6 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml @@ -21,7 +21,6 @@ embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "def embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "defmt-trace", "unstable-pac", "stm32l4s5vi"] } embassy-extras = {version = "0.1.0", path = "../../embassy-extras" } -stm32l4 = { version = "0.13", features = ["stm32l4x5" ] } stm32l4xx-hal = { version = "0.6.0", features = ["stm32l4x5"] } defmt = "0.2.0" diff --git a/examples/stm32l4/src/bin/adc.rs b/examples/stm32l4/src/bin/adc.rs index a3c44d3c..6894d664 100644 --- a/examples/stm32l4/src/bin/adc.rs +++ b/examples/stm32l4/src/bin/adc.rs @@ -11,11 +11,10 @@ mod example_common; use example_common::*; -use cortex_m_rt::entry; -//use stm32f4::stm32f429 as pac; use cortex_m::delay::Delay; +use cortex_m_rt::entry; use embassy_stm32::adc::{Adc, Resolution}; -use stm32l4::stm32l4x5 as pac; +use embassy_stm32::pac; use stm32l4xx_hal::prelude::*; use stm32l4xx_hal::rcc::PllSource; @@ -40,31 +39,16 @@ fn main() -> ! { .pll_source(PllSource::HSI16) .freeze(&mut flash.acr, &mut pwr); - let pp = unsafe { pac::Peripherals::steal() }; - - pp.RCC.ccipr.modify(|_, w| { - unsafe { - w.adcsel().bits(0b11); - } - w - }); - - pp.DBGMCU.cr.modify(|_, w| { - w.dbg_sleep().set_bit(); - w.dbg_standby().set_bit(); - w.dbg_stop().set_bit() - }); - - pp.RCC.ahb2enr.modify(|_, w| { - w.adcen().set_bit(); - w.gpioaen().set_bit(); - w.gpioben().set_bit(); - w.gpiocen().set_bit(); - w.gpioden().set_bit(); - w.gpioeen().set_bit(); - w.gpiofen().set_bit(); - w - }); + unsafe { + pac::RCC.ccipr().modify(|w| { + w.set_adcsel(0b11); + }); + pac::DBGMCU.cr().modify(|w| { + w.set_dbg_sleep(true); + w.set_dbg_standby(true); + w.set_dbg_stop(true); + }); + } let p = embassy_stm32::init(Default::default()); diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs index 0af16867..ba271b9e 100644 --- a/examples/stm32l4/src/bin/blinky.rs +++ b/examples/stm32l4/src/bin/blinky.rs @@ -24,15 +24,6 @@ fn main() -> ! { w.set_dbg_standby(true); w.set_dbg_stop(true); }); - - pac::RCC.ahb2enr().modify(|w| { - w.set_gpioaen(true); - w.set_gpioben(true); - w.set_gpiocen(true); - w.set_gpioden(true); - w.set_gpioeen(true); - w.set_gpiofen(true); - }); } let p = embassy_stm32::init(Default::default()); diff --git a/examples/stm32l4/src/bin/button.rs b/examples/stm32l4/src/bin/button.rs index c7246360..9d2fc2f2 100644 --- a/examples/stm32l4/src/bin/button.rs +++ b/examples/stm32l4/src/bin/button.rs @@ -28,15 +28,6 @@ fn main() -> ! { pac::RCC.apb2enr().modify(|w| { w.set_syscfgen(true); }); - - pac::RCC.ahb2enr().modify(|w| { - w.set_gpioaen(true); - w.set_gpioben(true); - w.set_gpiocen(true); - w.set_gpioden(true); - w.set_gpioeen(true); - w.set_gpiofen(true); - }); } let p = embassy_stm32::init(Default::default()); diff --git a/examples/stm32l4/src/bin/button_exti.rs b/examples/stm32l4/src/bin/button_exti.rs index 6a06e437..83537d92 100644 --- a/examples/stm32l4/src/bin/button_exti.rs +++ b/examples/stm32l4/src/bin/button_exti.rs @@ -59,15 +59,6 @@ fn main() -> ! { pac::RCC.apb2enr().modify(|w| { w.set_syscfgen(true); }); - - pac::RCC.ahb2enr().modify(|w| { - w.set_gpioaen(true); - w.set_gpioben(true); - w.set_gpiocen(true); - w.set_gpioden(true); - w.set_gpioeen(true); - w.set_gpiofen(true); - }); } unsafe { embassy::time::set_clock(&ZeroClock) }; diff --git a/examples/stm32l4/src/bin/dac.rs b/examples/stm32l4/src/bin/dac.rs index 5317ac35..1f7f8d46 100644 --- a/examples/stm32l4/src/bin/dac.rs +++ b/examples/stm32l4/src/bin/dac.rs @@ -13,11 +13,10 @@ use embassy_stm32::gpio::NoPin; use example_common::*; use cortex_m_rt::entry; -//use stm32f4::stm32f429 as pac; use embassy_stm32::dac::{Channel, Dac, Value}; -use stm32l4::stm32l4x5 as pac; +use embassy_stm32::pac; +use stm32l4xx_hal::prelude::*; use stm32l4xx_hal::rcc::PllSource; -use stm32l4xx_hal::{prelude::*}; #[entry] fn main() -> ! { @@ -30,36 +29,23 @@ fn main() -> ! { // TRY the other clock configuration // let clocks = rcc.cfgr.freeze(&mut flash.acr); - rcc - .cfgr + rcc.cfgr .sysclk(80.mhz()) .pclk1(80.mhz()) .pclk2(80.mhz()) .pll_source(PllSource::HSI16) .freeze(&mut flash.acr, &mut pwr); - let pp = unsafe { pac::Peripherals::steal() }; - - pp.DBGMCU.cr.modify(|_, w| { - w.dbg_sleep().set_bit(); - w.dbg_standby().set_bit(); - w.dbg_stop().set_bit() - }); - - pp.RCC.apb1enr1.modify(|_, w| { - w.dac1en().set_bit(); - w - }); - - pp.RCC.ahb2enr.modify(|_, w| { - w.gpioaen().set_bit(); - w.gpioben().set_bit(); - w.gpiocen().set_bit(); - w.gpioden().set_bit(); - w.gpioeen().set_bit(); - w.gpiofen().set_bit(); - w - }); + unsafe { + pac::DBGMCU.cr().modify(|w| { + w.set_dbg_sleep(true); + w.set_dbg_standby(true); + w.set_dbg_stop(true); + }); + pac::RCC.apb1enr1().modify(|w| { + w.set_dac1en(true); + }); + } let p = embassy_stm32::init(Default::default()); diff --git a/examples/stm32l4/src/bin/spi.rs b/examples/stm32l4/src/bin/spi.rs index 7cac01fd..8702fe0c 100644 --- a/examples/stm32l4/src/bin/spi.rs +++ b/examples/stm32l4/src/bin/spi.rs @@ -32,15 +32,6 @@ fn main() -> ! { pac::RCC.apb2enr().modify(|w| { w.set_syscfgen(true); }); - - pac::RCC.ahb2enr().modify(|w| { - w.set_gpioaen(true); - w.set_gpioben(true); - w.set_gpiocen(true); - w.set_gpioden(true); - w.set_gpioeen(true); - w.set_gpiofen(true); - }); } let p = embassy_stm32::init(Default::default()); diff --git a/examples/stm32l4/src/bin/usart.rs b/examples/stm32l4/src/bin/usart.rs index f572b1ef..1c2a861e 100644 --- a/examples/stm32l4/src/bin/usart.rs +++ b/examples/stm32l4/src/bin/usart.rs @@ -60,15 +60,6 @@ fn main() -> ! { w.set_dma1en(true); }); - pac::RCC.ahb2enr().modify(|w| { - w.set_gpioaen(true); - w.set_gpioben(true); - w.set_gpiocen(true); - w.set_gpioden(true); - w.set_gpioeen(true); - w.set_gpiofen(true); - }); - pac::RCC.apb1enr1().modify(|w| { w.set_uart4en(true); }); diff --git a/examples/stm32l4/src/bin/usart_dma.rs b/examples/stm32l4/src/bin/usart_dma.rs index e325e3da..b51699ac 100644 --- a/examples/stm32l4/src/bin/usart_dma.rs +++ b/examples/stm32l4/src/bin/usart_dma.rs @@ -67,15 +67,6 @@ fn main() -> ! { w.set_dma1en(true); w.set_dma2en(true); }); - - pac::RCC.ahb2enr().modify(|w| { - w.set_gpioaen(true); - w.set_gpioben(true); - w.set_gpiocen(true); - w.set_gpioden(true); - w.set_gpioeen(true); - w.set_gpiofen(true); - }); } unsafe { embassy::time::set_clock(&ZeroClock) }; diff --git a/examples/stm32wb55/Cargo.toml b/examples/stm32wb55/Cargo.toml index d3d128e8..92813ccd 100644 --- a/examples/stm32wb55/Cargo.toml +++ b/examples/stm32wb55/Cargo.toml @@ -21,7 +21,6 @@ embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "def embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "defmt-trace", "stm32wb55cc"] } embassy-extras = {version = "0.1.0", path = "../../embassy-extras" } -stm32wb-pac = "0.2" defmt = "0.2.0" defmt-rtt = "0.2.0" diff --git a/examples/stm32wb55/src/bin/blinky.rs b/examples/stm32wb55/src/bin/blinky.rs index d53ad611..ae11c986 100644 --- a/examples/stm32wb55/src/bin/blinky.rs +++ b/examples/stm32wb55/src/bin/blinky.rs @@ -13,19 +13,11 @@ use embedded_hal::digital::v2::OutputPin; use example_common::*; use cortex_m_rt::entry; -use stm32wb_pac as pac; #[entry] fn main() -> ! { info!("Hello World!"); - let pp = pac::Peripherals::take().unwrap(); - - pp.RCC.ahb2enr.modify(|_, w| { - w.gpioben().set_bit(); - w - }); - let p = embassy_stm32::init(Default::default()); let mut led = Output::new(p.PB0, Level::High, Speed::Low);