diff --git a/README.md b/README.md index 423740674..eaa1e10ab 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,9 @@ async fn blink(pin: AnyPin) { // Main is itself an async task as well. #[embassy_executor::main] -async fn main(spawner: Spawner, p: Peripherals) { +async fn main(spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); + // Spawned tasks run in the background, concurrently. spawner.spawn(blink(p.P0_13.degrade())).unwrap(); diff --git a/docs/modules/ROOT/examples/basic/src/main.rs b/docs/modules/ROOT/examples/basic/src/main.rs index cec39fd91..d680dd064 100644 --- a/docs/modules/ROOT/examples/basic/src/main.rs +++ b/docs/modules/ROOT/examples/basic/src/main.rs @@ -7,7 +7,6 @@ use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::peripherals::P0_13; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; // global logger #[embassy_executor::task] @@ -21,7 +20,9 @@ async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) { } #[embassy_executor::main] -async fn main(spawner: Spawner, p: Peripherals) { +async fn main(spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); + let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300)))); } diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs index b944a7994..7d62b6107 100644 --- a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs +++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs @@ -5,11 +5,11 @@ use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_s: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh); let mut button = ExtiInput::new(Input::new(p.PC13, Pull::Up), p.EXTI13); diff --git a/embassy-cortex-m/src/interrupt.rs b/embassy-cortex-m/src/interrupt.rs index be11c5eba..1df8671b9 100644 --- a/embassy-cortex-m/src/interrupt.rs +++ b/embassy-cortex-m/src/interrupt.rs @@ -6,10 +6,11 @@ use cortex_m::peripheral::NVIC; use embassy_hal_common::Peripheral; pub use embassy_macros::cortex_m_interrupt_take as take; -/// Do not use. Used for macros only. Not covered by semver guarantees. +/// Do not use. Used for macros and HALs only. Not covered by semver guarantees. #[doc(hidden)] pub mod _export { pub use atomic_polyfill as atomic; + pub use embassy_macros::{cortex_m_interrupt as interrupt, cortex_m_interrupt_declare as declare}; } /// Implementation detail, do not use outside embassy crates. diff --git a/embassy-macros/Cargo.toml b/embassy-macros/Cargo.toml index 6abafa581..19a3e9de2 100644 --- a/embassy-macros/Cargo.toml +++ b/embassy-macros/Cargo.toml @@ -13,8 +13,5 @@ proc-macro2 = "1.0.29" proc-macro = true [features] -nrf = [] -stm32 = [] -rp = [] std = [] wasm = [] diff --git a/embassy-macros/src/macros/main.rs b/embassy-macros/src/macros/main.rs index b040edc5a..a0cb0f0b3 100644 --- a/embassy-macros/src/macros/main.rs +++ b/embassy-macros/src/macros/main.rs @@ -5,11 +5,7 @@ use quote::quote; use crate::util::ctxt::Ctxt; #[derive(Debug, FromMeta)] -struct Args { - #[allow(unused)] - #[darling(default)] - config: Option, -} +struct Args {} pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result { #[allow(unused_variables)] @@ -20,26 +16,14 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result = None; - - if hal.is_some() && fargs.len() != 2 { - ctxt.error_spanned_by(&f.sig, "main function must have 2 arguments"); - } - if hal.is_none() && fargs.len() != 1 { - ctxt.error_spanned_by(&f.sig, "main function must have 1 argument"); + if fargs.len() != 1 { + ctxt.error_spanned_by(&f.sig, "main function must have 1 argument: the spawner."); } ctxt.check()?; @@ -74,35 +58,15 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result().unwrap()).unwrap_or_else(|| { - syn::Expr::Verbatim(quote! { - Default::default() + let main = quote! { + #[cortex_m_rt::entry] + fn main() -> ! { + let mut executor = ::embassy_executor::executor::Executor::new(); + let executor = unsafe { __make_static(&mut executor) }; + + executor.run(|spawner| { + spawner.must_spawn(__embassy_main(spawner)); }) - }); - - let (hal_setup, peris_arg) = match hal { - Some(hal) => ( - quote!( - let p = #hal::init(#config); - ), - quote!(p), - ), - None => (quote!(), quote!()), - }; - - quote! { - #[cortex_m_rt::entry] - fn main() -> ! { - #hal_setup - - let mut executor = ::embassy_executor::executor::Executor::new(); - let executor = unsafe { __make_static(&mut executor) }; - - executor.run(|spawner| { - spawner.must_spawn(__embassy_main(spawner, #peris_arg)); - }) - } } }; diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 72f4b538f..9d6690acb 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -67,7 +67,6 @@ _gpio-p1 = [] embassy-executor = { version = "0.1.0", path = "../embassy-executor", optional = true } embassy-util = { version = "0.1.0", path = "../embassy-util" } embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]} -embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["nrf"]} embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } embassy-usb = {version = "0.1.0", path = "../embassy-usb", optional=true } diff --git a/embassy-nrf/src/chips/nrf52805.rs b/embassy-nrf/src/chips/nrf52805.rs index 8fca4da1a..d078fa0ad 100644 --- a/embassy-nrf/src/chips/nrf52805.rs +++ b/embassy-nrf/src/chips/nrf52805.rs @@ -197,7 +197,7 @@ impl_saadc_input!(P0_04, ANALOGINPUT2); impl_saadc_input!(P0_05, ANALOGINPUT3); pub mod irqs { - use embassy_macros::cortex_m_interrupt_declare as declare; + use embassy_cortex_m::interrupt::_export::declare; use crate::pac::Interrupt as InterruptEnum; diff --git a/embassy-nrf/src/chips/nrf52810.rs b/embassy-nrf/src/chips/nrf52810.rs index 538a617d2..faa52d8fb 100644 --- a/embassy-nrf/src/chips/nrf52810.rs +++ b/embassy-nrf/src/chips/nrf52810.rs @@ -218,7 +218,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6); impl_saadc_input!(P0_31, ANALOGINPUT7); pub mod irqs { - use embassy_macros::cortex_m_interrupt_declare as declare; + use embassy_cortex_m::interrupt::_export::declare; use crate::pac::Interrupt as InterruptEnum; diff --git a/embassy-nrf/src/chips/nrf52811.rs b/embassy-nrf/src/chips/nrf52811.rs index 808adf517..bbdf1cbe5 100644 --- a/embassy-nrf/src/chips/nrf52811.rs +++ b/embassy-nrf/src/chips/nrf52811.rs @@ -219,7 +219,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6); impl_saadc_input!(P0_31, ANALOGINPUT7); pub mod irqs { - use embassy_macros::cortex_m_interrupt_declare as declare; + use embassy_cortex_m::interrupt::_export::declare; use crate::pac::Interrupt as InterruptEnum; diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs index 6be5bd361..dba033b0f 100644 --- a/embassy-nrf/src/chips/nrf52820.rs +++ b/embassy-nrf/src/chips/nrf52820.rs @@ -211,7 +211,7 @@ impl_ppi_channel!(PPI_CH30, 30 => static); impl_ppi_channel!(PPI_CH31, 31 => static); pub mod irqs { - use embassy_macros::cortex_m_interrupt_declare as declare; + use embassy_cortex_m::interrupt::_export::declare; use crate::pac::Interrupt as InterruptEnum; diff --git a/embassy-nrf/src/chips/nrf52832.rs b/embassy-nrf/src/chips/nrf52832.rs index cdc644d6e..18b8eda67 100644 --- a/embassy-nrf/src/chips/nrf52832.rs +++ b/embassy-nrf/src/chips/nrf52832.rs @@ -235,7 +235,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6); impl_saadc_input!(P0_31, ANALOGINPUT7); pub mod irqs { - use embassy_macros::cortex_m_interrupt_declare as declare; + use embassy_cortex_m::interrupt::_export::declare; use crate::pac::Interrupt as InterruptEnum; diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs index 4c3c5574d..39a0f93f9 100644 --- a/embassy-nrf/src/chips/nrf52833.rs +++ b/embassy-nrf/src/chips/nrf52833.rs @@ -278,7 +278,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6); impl_saadc_input!(P0_31, ANALOGINPUT7); pub mod irqs { - use embassy_macros::cortex_m_interrupt_declare as declare; + use embassy_cortex_m::interrupt::_export::declare; use crate::pac::Interrupt as InterruptEnum; diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs index bdaeadb9b..e3d8f34a1 100644 --- a/embassy-nrf/src/chips/nrf52840.rs +++ b/embassy-nrf/src/chips/nrf52840.rs @@ -283,7 +283,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6); impl_saadc_input!(P0_31, ANALOGINPUT7); pub mod irqs { - use embassy_macros::cortex_m_interrupt_declare as declare; + use embassy_cortex_m::interrupt::_export::declare; use crate::pac::Interrupt as InterruptEnum; diff --git a/embassy-nrf/src/chips/nrf5340_app.rs b/embassy-nrf/src/chips/nrf5340_app.rs index 26dc56bdb..edf800ef3 100644 --- a/embassy-nrf/src/chips/nrf5340_app.rs +++ b/embassy-nrf/src/chips/nrf5340_app.rs @@ -468,7 +468,7 @@ impl_saadc_input!(P0_19, ANALOGINPUT6); impl_saadc_input!(P0_20, ANALOGINPUT7); pub mod irqs { - use embassy_macros::cortex_m_interrupt_declare as declare; + use embassy_cortex_m::interrupt::_export::declare; use crate::pac::Interrupt as InterruptEnum; diff --git a/embassy-nrf/src/chips/nrf5340_net.rs b/embassy-nrf/src/chips/nrf5340_net.rs index e28cfe013..ae136e09d 100644 --- a/embassy-nrf/src/chips/nrf5340_net.rs +++ b/embassy-nrf/src/chips/nrf5340_net.rs @@ -328,7 +328,7 @@ impl_ppi_channel!(PPI_CH30, 30 => configurable); impl_ppi_channel!(PPI_CH31, 31 => configurable); pub mod irqs { - use embassy_macros::cortex_m_interrupt_declare as declare; + use embassy_cortex_m::interrupt::_export::declare; use crate::pac::Interrupt as InterruptEnum; diff --git a/embassy-nrf/src/chips/nrf9160.rs b/embassy-nrf/src/chips/nrf9160.rs index 1a0bd10fe..a4be8564e 100644 --- a/embassy-nrf/src/chips/nrf9160.rs +++ b/embassy-nrf/src/chips/nrf9160.rs @@ -346,7 +346,7 @@ impl_saadc_input!(P0_19, ANALOGINPUT6); impl_saadc_input!(P0_20, ANALOGINPUT7); pub mod irqs { - use embassy_macros::cortex_m_interrupt_declare as declare; + use embassy_cortex_m::interrupt::_export::declare; use crate::pac::Interrupt as InterruptEnum; diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index ad6c16c1f..f3b3ca0ca 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs @@ -135,8 +135,8 @@ pub use chip::pac; pub(crate) use chip::pac; pub use chip::{peripherals, Peripherals}; pub use embassy_cortex_m::executor; +pub use embassy_cortex_m::interrupt::_export::interrupt; pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; -pub use embassy_macros::cortex_m_interrupt as interrupt; pub mod config { //! Configuration options used when initializing the HAL. diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index eeb4ec43d..bf4919d5f 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -32,7 +32,6 @@ embassy-executor = { version = "0.1.0", path = "../embassy-executor", features = embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]} embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } -embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["rp"]} atomic-polyfill = "1.0.1" defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } diff --git a/embassy-rp/src/interrupt.rs b/embassy-rp/src/interrupt.rs index d652a8c71..f21a5433b 100644 --- a/embassy-rp/src/interrupt.rs +++ b/embassy-rp/src/interrupt.rs @@ -4,8 +4,8 @@ //! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. // Re-exports +use embassy_cortex_m::interrupt::_export::declare; pub use embassy_cortex_m::interrupt::*; -use embassy_macros::cortex_m_interrupt_declare as declare; use crate::pac::Interrupt as InterruptEnum; declare!(TIMER_IRQ_0); diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs index 44150be0d..8c053a4f7 100644 --- a/embassy-rp/src/lib.rs +++ b/embassy-rp/src/lib.rs @@ -17,8 +17,8 @@ mod reset; // Reexports pub use embassy_cortex_m::executor; +pub use embassy_cortex_m::interrupt::_export::interrupt; pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; -pub use embassy_macros::cortex_m_interrupt as interrupt; #[cfg(feature = "unstable-pac")] pub use rp2040_pac2 as pac; #[cfg(not(feature = "unstable-pac"))] diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 7260f06d2..dea68e440 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -34,7 +34,6 @@ flavors = [ embassy-util = { version = "0.1.0", path = "../embassy-util" } embassy-executor = { version = "0.1.0", path = "../embassy-executor" } embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-4"]} -embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["stm32"] } embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } embassy-net = { version = "0.1.0", path = "../embassy-net", optional = true } diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 3b4aa5dfd..c892007a3 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -96,7 +96,7 @@ fn main() { g.extend(quote! { pub mod interrupt { use crate::pac::Interrupt as InterruptEnum; - use embassy_macros::cortex_m_interrupt_declare as declare; + use embassy_cortex_m::interrupt::_export::declare; #( declare!(#irqs); )* diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 78025f3db..30ff02d56 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -75,8 +75,8 @@ pub(crate) mod _generated { // Reexports pub use _generated::{peripherals, Peripherals}; pub use embassy_cortex_m::executor; +pub use embassy_cortex_m::interrupt::_export::interrupt; pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; -pub use embassy_macros::cortex_m_interrupt as interrupt; #[cfg(feature = "unstable-pac")] pub use stm32_metapac as pac; #[cfg(not(feature = "unstable-pac"))] diff --git a/examples/boot/application/nrf/src/bin/a.rs b/examples/boot/application/nrf/src/bin/a.rs index 3044645a8..6343f5705 100644 --- a/examples/boot/application/nrf/src/bin/a.rs +++ b/examples/boot/application/nrf/src/bin/a.rs @@ -6,15 +6,16 @@ use embassy_boot_nrf::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; use embassy_nrf::nvmc::Nvmc; -use embassy_nrf::Peripherals; use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy_executor::main] -async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let mut button = Input::new(p.P0_11, Pull::Up); let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); diff --git a/examples/boot/application/nrf/src/bin/b.rs b/examples/boot/application/nrf/src/bin/b.rs index 2f76d20c6..ad44804af 100644 --- a/examples/boot/application/nrf/src/bin/b.rs +++ b/examples/boot/application/nrf/src/bin/b.rs @@ -4,13 +4,14 @@ #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] +use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_nrf::gpio::{Level, Output, OutputDrive}; -use embassy_nrf::Peripherals; use panic_reset as _; #[embassy_executor::main] -async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); diff --git a/examples/boot/application/stm32f3/src/bin/a.rs b/examples/boot/application/stm32f3/src/bin/a.rs index fd18e9373..d06e6aea2 100644 --- a/examples/boot/application/stm32f3/src/bin/a.rs +++ b/examples/boot/application/stm32f3/src/bin/a.rs @@ -6,16 +6,17 @@ use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use embassy_stm32::Peripherals; use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy_executor::main] -async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); diff --git a/examples/boot/application/stm32f3/src/bin/b.rs b/examples/boot/application/stm32f3/src/bin/b.rs index 934f862d9..98d6dbdf6 100644 --- a/examples/boot/application/stm32f3/src/bin/b.rs +++ b/examples/boot/application/stm32f3/src/bin/b.rs @@ -7,11 +7,11 @@ use defmt_rtt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use panic_reset as _; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let mut led = Output::new(p.PA5, Level::High, Speed::Low); loop { diff --git a/examples/boot/application/stm32f7/src/bin/a.rs b/examples/boot/application/stm32f7/src/bin/a.rs index 10d709cfd..154d62d2b 100644 --- a/examples/boot/application/stm32f7/src/bin/a.rs +++ b/examples/boot/application/stm32f7/src/bin/a.rs @@ -6,16 +6,17 @@ use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use embassy_stm32::Peripherals; use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy_executor::main] -async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); diff --git a/examples/boot/application/stm32f7/src/bin/b.rs b/examples/boot/application/stm32f7/src/bin/b.rs index c89e8a310..118836267 100644 --- a/examples/boot/application/stm32f7/src/bin/b.rs +++ b/examples/boot/application/stm32f7/src/bin/b.rs @@ -7,11 +7,11 @@ use defmt_rtt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use panic_reset as _; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); Timer::after(Duration::from_millis(300)).await; let mut led = Output::new(p.PB7, Level::High, Speed::Low); led.set_high(); diff --git a/examples/boot/application/stm32h7/src/bin/a.rs b/examples/boot/application/stm32h7/src/bin/a.rs index cc363bb32..8407adac3 100644 --- a/examples/boot/application/stm32h7/src/bin/a.rs +++ b/examples/boot/application/stm32h7/src/bin/a.rs @@ -6,16 +6,17 @@ use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use embassy_stm32::Peripherals; use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy_executor::main] -async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); diff --git a/examples/boot/application/stm32h7/src/bin/b.rs b/examples/boot/application/stm32h7/src/bin/b.rs index 3fa63bdcf..cc694e843 100644 --- a/examples/boot/application/stm32h7/src/bin/b.rs +++ b/examples/boot/application/stm32h7/src/bin/b.rs @@ -7,11 +7,11 @@ use defmt_rtt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use panic_reset as _; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); Timer::after(Duration::from_millis(300)).await; let mut led = Output::new(p.PB14, Level::High, Speed::Low); led.set_high(); diff --git a/examples/boot/application/stm32l0/src/bin/a.rs b/examples/boot/application/stm32l0/src/bin/a.rs index fcf3f2ef1..7ec6bb96d 100644 --- a/examples/boot/application/stm32l0/src/bin/a.rs +++ b/examples/boot/application/stm32l0/src/bin/a.rs @@ -6,17 +6,18 @@ use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; +use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use embassy_stm32::Peripherals; use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy_executor::main] -async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); diff --git a/examples/boot/application/stm32l0/src/bin/b.rs b/examples/boot/application/stm32l0/src/bin/b.rs index 46e394c4c..f1e1eaca3 100644 --- a/examples/boot/application/stm32l0/src/bin/b.rs +++ b/examples/boot/application/stm32l0/src/bin/b.rs @@ -7,11 +7,11 @@ use defmt_rtt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use panic_reset as _; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let mut led = Output::new(p.PB6, Level::High, Speed::Low); loop { diff --git a/examples/boot/application/stm32l1/src/bin/a.rs b/examples/boot/application/stm32l1/src/bin/a.rs index fcf3f2ef1..7ec6bb96d 100644 --- a/examples/boot/application/stm32l1/src/bin/a.rs +++ b/examples/boot/application/stm32l1/src/bin/a.rs @@ -6,17 +6,18 @@ use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; +use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use embassy_stm32::Peripherals; use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy_executor::main] -async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); diff --git a/examples/boot/application/stm32l1/src/bin/b.rs b/examples/boot/application/stm32l1/src/bin/b.rs index 46e394c4c..f1e1eaca3 100644 --- a/examples/boot/application/stm32l1/src/bin/b.rs +++ b/examples/boot/application/stm32l1/src/bin/b.rs @@ -7,11 +7,11 @@ use defmt_rtt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use panic_reset as _; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let mut led = Output::new(p.PB6, Level::High, Speed::Low); loop { diff --git a/examples/boot/application/stm32l4/src/bin/a.rs b/examples/boot/application/stm32l4/src/bin/a.rs index f092f0239..91d16ea11 100644 --- a/examples/boot/application/stm32l4/src/bin/a.rs +++ b/examples/boot/application/stm32l4/src/bin/a.rs @@ -6,16 +6,17 @@ use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use embassy_stm32::Peripherals; use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy_executor::main] -async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); diff --git a/examples/boot/application/stm32l4/src/bin/b.rs b/examples/boot/application/stm32l4/src/bin/b.rs index 934f862d9..98d6dbdf6 100644 --- a/examples/boot/application/stm32l4/src/bin/b.rs +++ b/examples/boot/application/stm32l4/src/bin/b.rs @@ -7,11 +7,11 @@ use defmt_rtt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use panic_reset as _; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let mut led = Output::new(p.PA5, Level::High, Speed::Low); loop { diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs index 14408a90a..613694ec2 100644 --- a/examples/boot/application/stm32wl/src/bin/a.rs +++ b/examples/boot/application/stm32wl/src/bin/a.rs @@ -6,16 +6,17 @@ use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; +use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use embassy_stm32::Peripherals; use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy_executor::main] -async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); diff --git a/examples/boot/application/stm32wl/src/bin/b.rs b/examples/boot/application/stm32wl/src/bin/b.rs index e565fd7c6..976198148 100644 --- a/examples/boot/application/stm32wl/src/bin/b.rs +++ b/examples/boot/application/stm32wl/src/bin/b.rs @@ -7,11 +7,11 @@ use defmt_rtt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use panic_reset as _; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let mut led = Output::new(p.PB15, Level::High, Speed::Low); loop { diff --git a/examples/nrf/src/bin/awaitable_timer.rs b/examples/nrf/src/bin/awaitable_timer.rs index f2c1d9fa4..a94224800 100644 --- a/examples/nrf/src/bin/awaitable_timer.rs +++ b/examples/nrf/src/bin/awaitable_timer.rs @@ -4,12 +4,13 @@ use defmt::info; use embassy_executor::executor::Spawner; +use embassy_nrf::interrupt; use embassy_nrf::timer::Timer; -use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let mut t = Timer::new_awaitable(p.TIMER0, interrupt::take!(TIMER0)); // default frequency is 1MHz, so this triggers every second t.cc(0).write(1_000_000); diff --git a/examples/nrf/src/bin/blinky.rs b/examples/nrf/src/bin/blinky.rs index 98db6546c..5283d7ead 100644 --- a/examples/nrf/src/bin/blinky.rs +++ b/examples/nrf/src/bin/blinky.rs @@ -5,11 +5,11 @@ use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_nrf::gpio::{Level, Output, OutputDrive}; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); loop { diff --git a/examples/nrf/src/bin/buffered_uart.rs b/examples/nrf/src/bin/buffered_uart.rs index f02b7d845..d2a153972 100644 --- a/examples/nrf/src/bin/buffered_uart.rs +++ b/examples/nrf/src/bin/buffered_uart.rs @@ -5,13 +5,14 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_nrf::buffered_uarte::{BufferedUarte, State}; -use embassy_nrf::{interrupt, uarte, Peripherals}; +use embassy_nrf::{interrupt, uarte}; use embedded_io::asynch::{BufRead, Write}; use futures::pin_mut; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let mut config = uarte::Config::default(); config.parity = uarte::Parity::EXCLUDED; config.baudrate = uarte::Baudrate::BAUD115200; diff --git a/examples/nrf/src/bin/channel.rs b/examples/nrf/src/bin/channel.rs index e97c6c5ee..a7ea08d09 100644 --- a/examples/nrf/src/bin/channel.rs +++ b/examples/nrf/src/bin/channel.rs @@ -6,7 +6,6 @@ use defmt::unwrap; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_nrf::gpio::{Level, Output, OutputDrive}; -use embassy_nrf::Peripherals; use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; use embassy_util::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; @@ -29,7 +28,8 @@ async fn my_task() { } #[embassy_executor::main] -async fn main(spawner: Spawner, p: Peripherals) { +async fn main(spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); unwrap!(spawner.spawn(my_task())); diff --git a/examples/nrf/src/bin/channel_sender_receiver.rs b/examples/nrf/src/bin/channel_sender_receiver.rs index bca7bb248..ef85e8717 100644 --- a/examples/nrf/src/bin/channel_sender_receiver.rs +++ b/examples/nrf/src/bin/channel_sender_receiver.rs @@ -6,7 +6,6 @@ use defmt::unwrap; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; -use embassy_nrf::Peripherals; use embassy_util::blocking_mutex::raw::NoopRawMutex; use embassy_util::channel::mpmc::{Channel, Receiver, Sender}; use embassy_util::Forever; @@ -42,7 +41,8 @@ async fn recv_task(led: AnyPin, receiver: Receiver<'static, NoopRawMutex, LedSta } #[embassy_executor::main] -async fn main(spawner: Spawner, p: Peripherals) { +async fn main(spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let channel = CHANNEL.put(Channel::new()); unwrap!(spawner.spawn(send_task(channel.sender()))); diff --git a/examples/nrf/src/bin/executor_fairness_test.rs b/examples/nrf/src/bin/executor_fairness_test.rs index b98454936..7aaeda543 100644 --- a/examples/nrf/src/bin/executor_fairness_test.rs +++ b/examples/nrf/src/bin/executor_fairness_test.rs @@ -7,7 +7,6 @@ use core::task::Poll; use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Instant, Timer}; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task] @@ -35,7 +34,8 @@ async fn run3() { } #[embassy_executor::main] -async fn main(spawner: Spawner, _p: Peripherals) { +async fn main(spawner: Spawner) { + let _p = embassy_nrf::init(Default::default()); unwrap!(spawner.spawn(run1())); unwrap!(spawner.spawn(run2())); unwrap!(spawner.spawn(run3())); diff --git a/examples/nrf/src/bin/gpiote_channel.rs b/examples/nrf/src/bin/gpiote_channel.rs index 65c7b4df7..f2654cb4e 100644 --- a/examples/nrf/src/bin/gpiote_channel.rs +++ b/examples/nrf/src/bin/gpiote_channel.rs @@ -6,11 +6,11 @@ use defmt::info; use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); info!("Starting!"); let ch1 = InputChannel::new( diff --git a/examples/nrf/src/bin/gpiote_port.rs b/examples/nrf/src/bin/gpiote_port.rs index 7746a7f96..46c260a4f 100644 --- a/examples/nrf/src/bin/gpiote_port.rs +++ b/examples/nrf/src/bin/gpiote_port.rs @@ -5,7 +5,6 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task(pool_size = 4)] @@ -19,7 +18,8 @@ async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) { } #[embassy_executor::main] -async fn main(spawner: Spawner, p: Peripherals) { +async fn main(spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); info!("Starting!"); let btn1 = Input::new(p.P0_11.degrade(), Pull::Up); diff --git a/examples/nrf/src/bin/mutex.rs b/examples/nrf/src/bin/mutex.rs index 5fe7eadb9..378a5926b 100644 --- a/examples/nrf/src/bin/mutex.rs +++ b/examples/nrf/src/bin/mutex.rs @@ -5,7 +5,6 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; -use embassy_nrf::Peripherals; use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; use embassy_util::mutex::Mutex; use {defmt_rtt as _, panic_probe as _}; @@ -30,7 +29,8 @@ async fn my_task() { } #[embassy_executor::main] -async fn main(spawner: Spawner, _p: Peripherals) { +async fn main(spawner: Spawner) { + let _p = embassy_nrf::init(Default::default()); unwrap!(spawner.spawn(my_task())); loop { diff --git a/examples/nrf/src/bin/nvmc.rs b/examples/nrf/src/bin/nvmc.rs index 1d4387de7..a0b555802 100644 --- a/examples/nrf/src/bin/nvmc.rs +++ b/examples/nrf/src/bin/nvmc.rs @@ -6,12 +6,12 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_nrf::nvmc::Nvmc; -use embassy_nrf::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); info!("Hello NVMC!"); // probe-run breaks without this, I'm not sure why. diff --git a/examples/nrf/src/bin/ppi.rs b/examples/nrf/src/bin/ppi.rs index 9a60cc0a0..fb2a97f1c 100644 --- a/examples/nrf/src/bin/ppi.rs +++ b/examples/nrf/src/bin/ppi.rs @@ -9,12 +9,12 @@ use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity}; use embassy_nrf::ppi::Ppi; -use embassy_nrf::Peripherals; use gpiote::{OutputChannel, OutputChannelPolarity}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); info!("Starting!"); let button1 = InputChannel::new( diff --git a/examples/nrf/src/bin/pubsub.rs b/examples/nrf/src/bin/pubsub.rs index 5f33f3e0b..d1441d5c1 100644 --- a/examples/nrf/src/bin/pubsub.rs +++ b/examples/nrf/src/bin/pubsub.rs @@ -20,7 +20,8 @@ enum Message { } #[embassy_executor::main] -async fn main(spawner: Spawner, _p: embassy_nrf::Peripherals) { +async fn main(spawner: Spawner) { + let _p = embassy_nrf::init(Default::default()); defmt::info!("Hello World!"); // It's good to set up the subscribers before publishing anything. diff --git a/examples/nrf/src/bin/pwm.rs b/examples/nrf/src/bin/pwm.rs index c8a083294..dca40fd58 100644 --- a/examples/nrf/src/bin/pwm.rs +++ b/examples/nrf/src/bin/pwm.rs @@ -6,7 +6,6 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{Prescaler, SimplePwm}; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; // for i in range(1024): print(int((math.sin(i/512*math.pi)*0.4+0.5)**2*32767), ', ', end='') @@ -71,7 +70,8 @@ static DUTY: [u16; 1024] = [ ]; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let mut pwm = SimplePwm::new_4ch(p.PWM0, p.P0_13, p.P0_14, p.P0_16, p.P0_15); pwm.set_prescaler(Prescaler::Div1); pwm.set_max_duty(32767); diff --git a/examples/nrf/src/bin/pwm_double_sequence.rs b/examples/nrf/src/bin/pwm_double_sequence.rs index cfd8db86b..08436c8f5 100644 --- a/examples/nrf/src/bin/pwm_double_sequence.rs +++ b/examples/nrf/src/bin/pwm_double_sequence.rs @@ -8,11 +8,11 @@ use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{ Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, StartSequence, }; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let seq_words_0: [u16; 5] = [1000, 250, 100, 50, 0]; let seq_words_1: [u16; 4] = [50, 100, 250, 1000]; diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index b7a04c036..c549b55c6 100644 --- a/examples/nrf/src/bin/pwm_sequence.rs +++ b/examples/nrf/src/bin/pwm_sequence.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let seq_words: [u16; 5] = [1000, 250, 100, 50, 0]; let mut config = Config::default(); diff --git a/examples/nrf/src/bin/pwm_sequence_ppi.rs b/examples/nrf/src/bin/pwm_sequence_ppi.rs index f5c587c35..4131e0841 100644 --- a/examples/nrf/src/bin/pwm_sequence_ppi.rs +++ b/examples/nrf/src/bin/pwm_sequence_ppi.rs @@ -10,11 +10,11 @@ use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; use embassy_nrf::ppi::Ppi; use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let seq_words: [u16; 5] = [1000, 250, 100, 50, 0]; let mut config = Config::default(); diff --git a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs index d6b3f005c..de4578229 100644 --- a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs +++ b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs @@ -8,7 +8,6 @@ use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{ Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, SingleSequencer, }; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; // WS2812B LED light demonstration. Drives just one light. @@ -27,7 +26,8 @@ const RES: u16 = 0x8000; // Provides data to a WS2812b (Neopixel) LED and makes it go blue. The data // line is assumed to be P1_05. #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let mut config = Config::default(); config.sequence_load = SequenceLoad::Common; config.prescaler = Prescaler::Div1; diff --git a/examples/nrf/src/bin/pwm_servo.rs b/examples/nrf/src/bin/pwm_servo.rs index d28a5a17e..08a7a1fdc 100644 --- a/examples/nrf/src/bin/pwm_servo.rs +++ b/examples/nrf/src/bin/pwm_servo.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{Prescaler, SimplePwm}; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let mut pwm = SimplePwm::new_1ch(p.PWM0, p.P0_05); // sg90 microervo requires 50hz or 20ms period // set_period can only set down to 125khz so we cant use it directly diff --git a/examples/nrf/src/bin/qdec.rs b/examples/nrf/src/bin/qdec.rs index 6bda82f78..f9565e89c 100644 --- a/examples/nrf/src/bin/qdec.rs +++ b/examples/nrf/src/bin/qdec.rs @@ -4,12 +4,13 @@ use defmt::info; use embassy_executor::executor::Spawner; +use embassy_nrf::interrupt; use embassy_nrf::qdec::{self, Qdec}; -use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let irq = interrupt::take!(QDEC); let config = qdec::Config::default(); let mut rotary_enc = Qdec::new(p.QDEC, irq, p.P0_31, p.P0_30, config); diff --git a/examples/nrf/src/bin/qspi.rs b/examples/nrf/src/bin/qspi.rs index 57e0fdbe2..976673a2f 100644 --- a/examples/nrf/src/bin/qspi.rs +++ b/examples/nrf/src/bin/qspi.rs @@ -4,7 +4,7 @@ use defmt::{assert_eq, info, unwrap}; use embassy_executor::executor::Spawner; -use embassy_nrf::{interrupt, qspi, Peripherals}; +use embassy_nrf::{interrupt, qspi}; use {defmt_rtt as _, panic_probe as _}; const PAGE_SIZE: usize = 4096; @@ -15,7 +15,8 @@ const PAGE_SIZE: usize = 4096; struct AlignedBuf([u8; 4096]); #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); // Config for the MX25R64 present in the nRF52840 DK let mut config = qspi::Config::default(); config.read_opcode = qspi::ReadOpcode::READ4IO; diff --git a/examples/nrf/src/bin/qspi_lowpower.rs b/examples/nrf/src/bin/qspi_lowpower.rs index 080b27a16..a83fe3fe9 100644 --- a/examples/nrf/src/bin/qspi_lowpower.rs +++ b/examples/nrf/src/bin/qspi_lowpower.rs @@ -7,7 +7,7 @@ use core::mem; use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; -use embassy_nrf::{interrupt, qspi, Peripherals}; +use embassy_nrf::{interrupt, qspi}; use {defmt_rtt as _, panic_probe as _}; // Workaround for alignment requirements. @@ -16,7 +16,8 @@ use {defmt_rtt as _, panic_probe as _}; struct AlignedBuf([u8; 64]); #[embassy_executor::main] -async fn main(_spawner: Spawner, mut p: Peripherals) { +async fn main(_p: Spawner) { + let mut p = embassy_nrf::init(Default::default()); let mut irq = interrupt::take!(QSPI); loop { diff --git a/examples/nrf/src/bin/rng.rs b/examples/nrf/src/bin/rng.rs index a4314e8b9..70ab5c731 100644 --- a/examples/nrf/src/bin/rng.rs +++ b/examples/nrf/src/bin/rng.rs @@ -3,13 +3,14 @@ #![feature(type_alias_impl_trait)] use embassy_executor::executor::Spawner; +use embassy_nrf::interrupt; use embassy_nrf::rng::Rng; -use embassy_nrf::{interrupt, Peripherals}; use rand::Rng as _; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let mut rng = Rng::new(p.RNG, interrupt::take!(RNG)); // Async API diff --git a/examples/nrf/src/bin/saadc.rs b/examples/nrf/src/bin/saadc.rs index 65c78d842..e90fc3df0 100644 --- a/examples/nrf/src/bin/saadc.rs +++ b/examples/nrf/src/bin/saadc.rs @@ -5,12 +5,13 @@ use defmt::info; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; +use embassy_nrf::interrupt; use embassy_nrf::saadc::{ChannelConfig, Config, Saadc}; -use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, mut p: Peripherals) { +async fn main(_p: Spawner) { + let mut p = embassy_nrf::init(Default::default()); let config = Config::default(); let channel_config = ChannelConfig::single_ended(&mut p.P0_02); let mut saadc = Saadc::new(p.SAADC, interrupt::take!(SAADC), config, [channel_config]); diff --git a/examples/nrf/src/bin/saadc_continuous.rs b/examples/nrf/src/bin/saadc_continuous.rs index d0305736f..80ecaae7b 100644 --- a/examples/nrf/src/bin/saadc_continuous.rs +++ b/examples/nrf/src/bin/saadc_continuous.rs @@ -5,15 +5,16 @@ use defmt::info; use embassy_executor::executor::Spawner; use embassy_executor::time::Duration; +use embassy_nrf::interrupt; use embassy_nrf::saadc::{ChannelConfig, Config, Saadc, SamplerState}; use embassy_nrf::timer::Frequency; -use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; // Demonstrates both continuous sampling and scanning multiple channels driven by a PPI linked timer #[embassy_executor::main] -async fn main(_spawner: Spawner, mut p: Peripherals) { +async fn main(_p: Spawner) { + let mut p = embassy_nrf::init(Default::default()); let config = Config::default(); let channel_1_config = ChannelConfig::single_ended(&mut p.P0_02); let channel_2_config = ChannelConfig::single_ended(&mut p.P0_03); diff --git a/examples/nrf/src/bin/self_spawn.rs b/examples/nrf/src/bin/self_spawn.rs index e0152802e..56539eef6 100644 --- a/examples/nrf/src/bin/self_spawn.rs +++ b/examples/nrf/src/bin/self_spawn.rs @@ -5,7 +5,6 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task(pool_size = 2)] @@ -16,7 +15,8 @@ async fn my_task(spawner: Spawner, n: u32) { } #[embassy_executor::main] -async fn main(spawner: Spawner, _p: Peripherals) { +async fn main(spawner: Spawner) { + let _p = embassy_nrf::init(Default::default()); info!("Hello World!"); unwrap!(spawner.spawn(my_task(spawner, 0))); } diff --git a/examples/nrf/src/bin/self_spawn_current_executor.rs b/examples/nrf/src/bin/self_spawn_current_executor.rs index 1d8309d77..11fe6fb40 100644 --- a/examples/nrf/src/bin/self_spawn_current_executor.rs +++ b/examples/nrf/src/bin/self_spawn_current_executor.rs @@ -5,7 +5,6 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task(pool_size = 2)] @@ -16,7 +15,8 @@ async fn my_task(n: u32) { } #[embassy_executor::main] -async fn main(spawner: Spawner, _p: Peripherals) { +async fn main(spawner: Spawner) { + let _p = embassy_nrf::init(Default::default()); info!("Hello World!"); unwrap!(spawner.spawn(my_task(0))); } diff --git a/examples/nrf/src/bin/spim.rs b/examples/nrf/src/bin/spim.rs index fd741b21c..437a1a805 100644 --- a/examples/nrf/src/bin/spim.rs +++ b/examples/nrf/src/bin/spim.rs @@ -5,11 +5,12 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; -use embassy_nrf::{interrupt, spim, Peripherals}; +use embassy_nrf::{interrupt, spim}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); info!("running!"); let mut config = spim::Config::default(); diff --git a/examples/nrf/src/bin/temp.rs b/examples/nrf/src/bin/temp.rs index 654098e0b..a898488f9 100644 --- a/examples/nrf/src/bin/temp.rs +++ b/examples/nrf/src/bin/temp.rs @@ -5,12 +5,13 @@ use defmt::info; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; +use embassy_nrf::interrupt; use embassy_nrf::temp::Temp; -use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let irq = interrupt::take!(TEMP); let mut temp = Temp::new(p.TEMP, irq); diff --git a/examples/nrf/src/bin/timer.rs b/examples/nrf/src/bin/timer.rs index 61ff1d6db..de7902336 100644 --- a/examples/nrf/src/bin/timer.rs +++ b/examples/nrf/src/bin/timer.rs @@ -5,7 +5,6 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task] @@ -25,7 +24,8 @@ async fn run2() { } #[embassy_executor::main] -async fn main(spawner: Spawner, _p: Peripherals) { +async fn main(spawner: Spawner) { + let _p = embassy_nrf::init(Default::default()); unwrap!(spawner.spawn(run1())); unwrap!(spawner.spawn(run2())); } diff --git a/examples/nrf/src/bin/twim.rs b/examples/nrf/src/bin/twim.rs index bb7ee9db4..a0a6d359b 100644 --- a/examples/nrf/src/bin/twim.rs +++ b/examples/nrf/src/bin/twim.rs @@ -8,14 +8,15 @@ use defmt::*; use embassy_executor::executor::Spawner; +use embassy_nrf::interrupt; use embassy_nrf::twim::{self, Twim}; -use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x50; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); info!("Initializing TWI..."); let config = twim::Config::default(); let irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); diff --git a/examples/nrf/src/bin/twim_lowpower.rs b/examples/nrf/src/bin/twim_lowpower.rs index ebf3d7109..916ac07e3 100644 --- a/examples/nrf/src/bin/twim_lowpower.rs +++ b/examples/nrf/src/bin/twim_lowpower.rs @@ -13,14 +13,15 @@ use core::mem; use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; +use embassy_nrf::interrupt; use embassy_nrf::twim::{self, Twim}; -use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x50; #[embassy_executor::main] -async fn main(_spawner: Spawner, mut p: Peripherals) { +async fn main(_p: Spawner) { + let mut p = embassy_nrf::init(Default::default()); info!("Started!"); let mut irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); diff --git a/examples/nrf/src/bin/uart.rs b/examples/nrf/src/bin/uart.rs index 5f363b69e..011ad2a5d 100644 --- a/examples/nrf/src/bin/uart.rs +++ b/examples/nrf/src/bin/uart.rs @@ -4,11 +4,12 @@ use defmt::*; use embassy_executor::executor::Spawner; -use embassy_nrf::{interrupt, uarte, Peripherals}; +use embassy_nrf::{interrupt, uarte}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let mut config = uarte::Config::default(); config.parity = uarte::Parity::EXCLUDED; config.baudrate = uarte::Baudrate::BAUD115200; diff --git a/examples/nrf/src/bin/uart_idle.rs b/examples/nrf/src/bin/uart_idle.rs index 0f455dffd..cf3d99389 100644 --- a/examples/nrf/src/bin/uart_idle.rs +++ b/examples/nrf/src/bin/uart_idle.rs @@ -4,11 +4,12 @@ use defmt::*; use embassy_executor::executor::Spawner; -use embassy_nrf::{interrupt, uarte, Peripherals}; +use embassy_nrf::{interrupt, uarte}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let mut config = uarte::Config::default(); config.parity = uarte::Parity::EXCLUDED; config.baudrate = uarte::Baudrate::BAUD115200; diff --git a/examples/nrf/src/bin/uart_split.rs b/examples/nrf/src/bin/uart_split.rs index 2de5f90c1..12c21c09f 100644 --- a/examples/nrf/src/bin/uart_split.rs +++ b/examples/nrf/src/bin/uart_split.rs @@ -6,7 +6,7 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_nrf::peripherals::UARTE0; use embassy_nrf::uarte::UarteRx; -use embassy_nrf::{interrupt, uarte, Peripherals}; +use embassy_nrf::{interrupt, uarte}; use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; use embassy_util::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; @@ -14,7 +14,8 @@ use {defmt_rtt as _, panic_probe as _}; static CHANNEL: Channel = Channel::new(); #[embassy_executor::main] -async fn main(spawner: Spawner, p: Peripherals) { +async fn main(spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let mut config = uarte::Config::default(); config.parity = uarte::Parity::EXCLUDED; config.baudrate = uarte::Baudrate::BAUD115200; diff --git a/examples/nrf/src/bin/usb_ethernet.rs b/examples/nrf/src/bin/usb_ethernet.rs index 93cb05907..4f8e59cc3 100644 --- a/examples/nrf/src/bin/usb_ethernet.rs +++ b/examples/nrf/src/bin/usb_ethernet.rs @@ -13,7 +13,7 @@ use embassy_net::tcp::TcpSocket; use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources}; use embassy_nrf::rng::Rng; use embassy_nrf::usb::{Driver, PowerUsb}; -use embassy_nrf::{interrupt, pac, peripherals, Peripherals}; +use embassy_nrf::{interrupt, pac, peripherals}; use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; @@ -82,7 +82,8 @@ async fn net_task(stack: &'static Stack) -> ! { } #[embassy_executor::main] -async fn main(spawner: Spawner, p: Peripherals) { +async fn main(spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let clock: pac::CLOCK = unsafe { mem::transmute(()) }; info!("Enabling ext hfosc..."); diff --git a/examples/nrf/src/bin/usb_hid_keyboard.rs b/examples/nrf/src/bin/usb_hid_keyboard.rs index 863f3e5dd..16d1a9a27 100644 --- a/examples/nrf/src/bin/usb_hid_keyboard.rs +++ b/examples/nrf/src/bin/usb_hid_keyboard.rs @@ -10,7 +10,7 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Pin, Pull}; use embassy_nrf::usb::{Driver, PowerUsb}; -use embassy_nrf::{interrupt, pac, Peripherals}; +use embassy_nrf::{interrupt, pac}; use embassy_usb::control::OutResponse; use embassy_usb::{Builder, Config, DeviceStateHandler}; use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State}; @@ -23,7 +23,8 @@ use {defmt_rtt as _, panic_probe as _}; static SUSPENDED: AtomicBool = AtomicBool::new(false); #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let clock: pac::CLOCK = unsafe { mem::transmute(()) }; info!("Enabling ext hfosc..."); diff --git a/examples/nrf/src/bin/usb_hid_mouse.rs b/examples/nrf/src/bin/usb_hid_mouse.rs index 88bf87bd6..0008e0e64 100644 --- a/examples/nrf/src/bin/usb_hid_mouse.rs +++ b/examples/nrf/src/bin/usb_hid_mouse.rs @@ -9,7 +9,7 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_nrf::usb::{Driver, PowerUsb}; -use embassy_nrf::{interrupt, pac, Peripherals}; +use embassy_nrf::{interrupt, pac}; use embassy_usb::control::OutResponse; use embassy_usb::{Builder, Config}; use embassy_usb_hid::{HidWriter, ReportId, RequestHandler, State}; @@ -18,7 +18,8 @@ use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let clock: pac::CLOCK = unsafe { mem::transmute(()) }; info!("Enabling ext hfosc..."); diff --git a/examples/nrf/src/bin/usb_serial.rs b/examples/nrf/src/bin/usb_serial.rs index 7d233d24d..ce11c6cbb 100644 --- a/examples/nrf/src/bin/usb_serial.rs +++ b/examples/nrf/src/bin/usb_serial.rs @@ -8,7 +8,7 @@ use core::mem; use defmt::{info, panic}; use embassy_executor::executor::Spawner; use embassy_nrf::usb::{Driver, Instance, PowerUsb, UsbSupply}; -use embassy_nrf::{interrupt, pac, Peripherals}; +use embassy_nrf::{interrupt, pac}; use embassy_usb::driver::EndpointError; use embassy_usb::{Builder, Config}; use embassy_usb_serial::{CdcAcmClass, State}; @@ -16,7 +16,8 @@ use futures::future::join; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let clock: pac::CLOCK = unsafe { mem::transmute(()) }; info!("Enabling ext hfosc..."); diff --git a/examples/nrf/src/bin/usb_serial_multitask.rs b/examples/nrf/src/bin/usb_serial_multitask.rs index 956315322..d2f1a9723 100644 --- a/examples/nrf/src/bin/usb_serial_multitask.rs +++ b/examples/nrf/src/bin/usb_serial_multitask.rs @@ -8,7 +8,7 @@ use core::mem; use defmt::{info, panic, unwrap}; use embassy_executor::executor::Spawner; use embassy_nrf::usb::{Driver, PowerUsb}; -use embassy_nrf::{interrupt, pac, peripherals, Peripherals}; +use embassy_nrf::{interrupt, pac, peripherals}; use embassy_usb::driver::EndpointError; use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb_serial::{CdcAcmClass, State}; @@ -33,7 +33,8 @@ async fn echo_task(mut class: CdcAcmClass<'static, MyDriver>) { } #[embassy_executor::main] -async fn main(spawner: Spawner, p: Peripherals) { +async fn main(spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); let clock: pac::CLOCK = unsafe { mem::transmute(()) }; info!("Enabling ext hfosc..."); diff --git a/examples/nrf/src/bin/wdt.rs b/examples/nrf/src/bin/wdt.rs index 560cb3567..47e40b886 100644 --- a/examples/nrf/src/bin/wdt.rs +++ b/examples/nrf/src/bin/wdt.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::wdt::{Config, Watchdog}; -use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_nrf::init(Default::default()); info!("Hello World!"); let mut config = Config::default(); diff --git a/examples/rp/src/bin/blinky.rs b/examples/rp/src/bin/blinky.rs index e53fca1af..dade3bf32 100644 --- a/examples/rp/src/bin/blinky.rs +++ b/examples/rp/src/bin/blinky.rs @@ -5,12 +5,13 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; -use embassy_rp::{gpio, Peripherals}; +use embassy_rp::gpio; use gpio::{Level, Output}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_rp::init(Default::default()); let mut led = Output::new(p.PIN_25, Level::Low); loop { diff --git a/examples/rp/src/bin/button.rs b/examples/rp/src/bin/button.rs index 02cbc9416..22793735b 100644 --- a/examples/rp/src/bin/button.rs +++ b/examples/rp/src/bin/button.rs @@ -4,11 +4,11 @@ use embassy_executor::executor::Spawner; use embassy_rp::gpio::{Input, Level, Output, Pull}; -use embassy_rp::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_rp::init(Default::default()); let button = Input::new(p.PIN_28, Pull::Up); let mut led = Output::new(p.PIN_25, Level::Low); diff --git a/examples/rp/src/bin/gpio_async.rs b/examples/rp/src/bin/gpio_async.rs index ba905b015..c61b87a38 100644 --- a/examples/rp/src/bin/gpio_async.rs +++ b/examples/rp/src/bin/gpio_async.rs @@ -5,7 +5,7 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; -use embassy_rp::{gpio, Peripherals}; +use embassy_rp::gpio; use gpio::{Input, Level, Output, Pull}; use {defmt_rtt as _, panic_probe as _}; @@ -20,7 +20,8 @@ use {defmt_rtt as _, panic_probe as _}; /// continue and turn off the LED, and then wait for 2 seconds before completing /// the loop and starting over again. #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_rp::init(Default::default()); let mut led = Output::new(p.PIN_25, Level::Low); let mut async_input = Input::new(p.PIN_16, Pull::None); diff --git a/examples/rp/src/bin/spi.rs b/examples/rp/src/bin/spi.rs index a3160c106..7d3370027 100644 --- a/examples/rp/src/bin/spi.rs +++ b/examples/rp/src/bin/spi.rs @@ -5,12 +5,13 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_rp::spi::Spi; -use embassy_rp::{gpio, spi, Peripherals}; +use embassy_rp::{gpio, spi}; use gpio::{Level, Output}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_rp::init(Default::default()); info!("Hello World!"); // Example for resistive touch sensor in Waveshare Pico-ResTouch diff --git a/examples/rp/src/bin/spi_display.rs b/examples/rp/src/bin/spi_display.rs index 2760b23fa..8b46bd070 100644 --- a/examples/rp/src/bin/spi_display.rs +++ b/examples/rp/src/bin/spi_display.rs @@ -8,8 +8,8 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::Delay; use embassy_rp::gpio::{Level, Output}; +use embassy_rp::spi; use embassy_rp::spi::Spi; -use embassy_rp::{spi, Peripherals}; use embedded_graphics::image::{Image, ImageRawLE}; use embedded_graphics::mono_font::ascii::FONT_10X20; use embedded_graphics::mono_font::MonoTextStyle; @@ -28,7 +28,8 @@ use crate::touch::Touch; const TOUCH_FREQ: u32 = 200_000; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_rp::init(Default::default()); info!("Hello World!"); let bl = p.PIN_13; diff --git a/examples/rp/src/bin/uart.rs b/examples/rp/src/bin/uart.rs index 0d2954894..067211464 100644 --- a/examples/rp/src/bin/uart.rs +++ b/examples/rp/src/bin/uart.rs @@ -3,11 +3,12 @@ #![feature(type_alias_impl_trait)] use embassy_executor::executor::Spawner; -use embassy_rp::{uart, Peripherals}; +use embassy_rp::uart; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_rp::init(Default::default()); let config = uart::Config::default(); let mut uart = uart::Uart::new(p.UART0, p.PIN_0, p.PIN_1, p.PIN_2, p.PIN_3, config); uart.send("Hello World!\r\n".as_bytes()); diff --git a/examples/stm32f0/src/bin/hello.rs b/examples/stm32f0/src/bin/hello.rs index c9081ea12..a0775badb 100644 --- a/examples/stm32f0/src/bin/hello.rs +++ b/examples/stm32f0/src/bin/hello.rs @@ -5,11 +5,11 @@ use defmt::info; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, _p: Peripherals) -> ! { +async fn main(_spawner: Spawner) -> ! { + let _p = embassy_stm32::init(Default::default()); loop { Timer::after(Duration::from_secs(1)).await; info!("Hello"); diff --git a/examples/stm32f1/src/bin/adc.rs b/examples/stm32f1/src/bin/adc.rs index e54593fe5..dae001a8b 100644 --- a/examples/stm32f1/src/bin/adc.rs +++ b/examples/stm32f1/src/bin/adc.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Delay, Duration, Timer}; use embassy_stm32::adc::Adc; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut adc = Adc::new(p.ADC1, &mut Delay); diff --git a/examples/stm32f1/src/bin/blinky.rs b/examples/stm32f1/src/bin/blinky.rs index 5171043e8..74e31cbb3 100644 --- a/examples/stm32f1/src/bin/blinky.rs +++ b/examples/stm32f1/src/bin/blinky.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PC13, Level::High, Speed::Low); diff --git a/examples/stm32f1/src/bin/hello.rs b/examples/stm32f1/src/bin/hello.rs index 549d1bfba..721b21c36 100644 --- a/examples/stm32f1/src/bin/hello.rs +++ b/examples/stm32f1/src/bin/hello.rs @@ -6,7 +6,7 @@ use defmt::info; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::time::Hertz; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -15,8 +15,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, _p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(_spawner: Spawner) -> ! { + let _p = embassy_stm32::init(config()); loop { info!("Hello World!"); Timer::after(Duration::from_secs(1)).await; diff --git a/examples/stm32f1/src/bin/usb_serial.rs b/examples/stm32f1/src/bin/usb_serial.rs index cf7facb79..7f27e6251 100644 --- a/examples/stm32f1/src/bin/usb_serial.rs +++ b/examples/stm32f1/src/bin/usb_serial.rs @@ -8,7 +8,7 @@ use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::time::Hertz; use embassy_stm32::usb::{Driver, Instance}; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use embassy_usb::driver::EndpointError; use embassy_usb::Builder; use embassy_usb_serial::{CdcAcmClass, State}; @@ -23,8 +23,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, mut p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let mut p = embassy_stm32::init(config()); info!("Hello World!"); { diff --git a/examples/stm32f2/src/bin/blinky.rs b/examples/stm32f2/src/bin/blinky.rs index 48ae2e711..2afdeeb35 100644 --- a/examples/stm32f2/src/bin/blinky.rs +++ b/examples/stm32f2/src/bin/blinky.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PB14, Level::High, Speed::Low); diff --git a/examples/stm32f2/src/bin/pll.rs b/examples/stm32f2/src/bin/pll.rs index 01e63b15e..bc0c160ba 100644 --- a/examples/stm32f2/src/bin/pll.rs +++ b/examples/stm32f2/src/bin/pll.rs @@ -11,7 +11,7 @@ use embassy_stm32::rcc::{ APBPrescaler, ClockSrc, HSEConfig, HSESrc, PLL48Div, PLLConfig, PLLMainDiv, PLLMul, PLLPreDiv, PLLSrc, }; use embassy_stm32::time::Hertz; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; // Example config for maximum performance on a NUCLEO-F207ZG board @@ -43,8 +43,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, _p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let _p = embassy_stm32::init(config()); loop { Timer::after(Duration::from_millis(1000)).await; info!("1s elapsed"); diff --git a/examples/stm32f3/src/bin/blinky.rs b/examples/stm32f3/src/bin/blinky.rs index 7146eaa54..84d7c50a6 100644 --- a/examples/stm32f3/src/bin/blinky.rs +++ b/examples/stm32f3/src/bin/blinky.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PA5, Level::High, Speed::Low); diff --git a/examples/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs index ef5110316..404946f2a 100644 --- a/examples/stm32f3/src/bin/button_events.rs +++ b/examples/stm32f3/src/bin/button_events.rs @@ -16,7 +16,6 @@ use embassy_executor::time::{with_timeout, Duration, Timer}; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; use embassy_stm32::peripherals::PA0; -use embassy_stm32::Peripherals; use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; use embassy_util::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; @@ -100,7 +99,8 @@ enum ButtonEvent { static CHANNEL: Channel = Channel::new(); #[embassy_executor::main] -async fn main(spawner: Spawner, p: Peripherals) { +async fn main(spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let button = Input::new(p.PA0, Pull::Down); let button = ExtiInput::new(button, p.EXTI0); info!("Press the USER button..."); diff --git a/examples/stm32f3/src/bin/button_exti.rs b/examples/stm32f3/src/bin/button_exti.rs index dee06e5de..b770b338b 100644 --- a/examples/stm32f3/src/bin/button_exti.rs +++ b/examples/stm32f3/src/bin/button_exti.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let button = Input::new(p.PA0, Pull::Down); diff --git a/examples/stm32f3/src/bin/flash.rs b/examples/stm32f3/src/bin/flash.rs index be2f6f671..c7982884f 100644 --- a/examples/stm32f3/src/bin/flash.rs +++ b/examples/stm32f3/src/bin/flash.rs @@ -5,12 +5,12 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_stm32::flash::Flash; -use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello Flash!"); const ADDR: u32 = 0x26000; diff --git a/examples/stm32f3/src/bin/hello.rs b/examples/stm32f3/src/bin/hello.rs index bd9953a0e..7846912c9 100644 --- a/examples/stm32f3/src/bin/hello.rs +++ b/examples/stm32f3/src/bin/hello.rs @@ -6,7 +6,7 @@ use defmt::info; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::time::Hertz; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -16,8 +16,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, _p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(_spawner: Spawner) -> ! { + let _p = embassy_stm32::init(config()); loop { info!("Hello World!"); Timer::after(Duration::from_secs(1)).await; diff --git a/examples/stm32f3/src/bin/spi_dma.rs b/examples/stm32f3/src/bin/spi_dma.rs index f554c509a..7f874bb66 100644 --- a/examples/stm32f3/src/bin/spi_dma.rs +++ b/examples/stm32f3/src/bin/spi_dma.rs @@ -9,12 +9,12 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; -use embassy_stm32::Peripherals; use heapless::String; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut spi = Spi::new( diff --git a/examples/stm32f3/src/bin/usart_dma.rs b/examples/stm32f3/src/bin/usart_dma.rs index 62d165029..2b27a8daa 100644 --- a/examples/stm32f3/src/bin/usart_dma.rs +++ b/examples/stm32f3/src/bin/usart_dma.rs @@ -8,12 +8,12 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use embassy_stm32::Peripherals; use heapless::String; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let config = Config::default(); diff --git a/examples/stm32f3/src/bin/usb_serial.rs b/examples/stm32f3/src/bin/usb_serial.rs index 87b1138f5..36d38d87f 100644 --- a/examples/stm32f3/src/bin/usb_serial.rs +++ b/examples/stm32f3/src/bin/usb_serial.rs @@ -8,7 +8,7 @@ use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::time::mhz; use embassy_stm32::usb::{Driver, Instance}; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use embassy_usb::driver::EndpointError; use embassy_usb::Builder; use embassy_usb_serial::{CdcAcmClass, State}; @@ -27,8 +27,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); // Needed for nucleo-stm32f303ze diff --git a/examples/stm32f4/src/bin/adc.rs b/examples/stm32f4/src/bin/adc.rs index 27ed4fcc5..1dc01edd3 100644 --- a/examples/stm32f4/src/bin/adc.rs +++ b/examples/stm32f4/src/bin/adc.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Delay, Duration, Timer}; use embassy_stm32::adc::Adc; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut adc = Adc::new(p.ADC1, &mut Delay); diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs index f71fe0989..249bbd88f 100644 --- a/examples/stm32f4/src/bin/blinky.rs +++ b/examples/stm32f4/src/bin/blinky.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PB7, Level::High, Speed::Low); diff --git a/examples/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs index 60dfb362b..25d3bb9c2 100644 --- a/examples/stm32f4/src/bin/button_exti.rs +++ b/examples/stm32f4/src/bin/button_exti.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let button = Input::new(p.PC13, Pull::Down); diff --git a/examples/stm32f4/src/bin/dac.rs b/examples/stm32f4/src/bin/dac.rs index 392f5bf4d..9098a9715 100644 --- a/examples/stm32f4/src/bin/dac.rs +++ b/examples/stm32f4/src/bin/dac.rs @@ -5,11 +5,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::dac::{Channel, Dac, Value}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) -> ! { +async fn main(_spawner: Spawner) -> ! { + let p = embassy_stm32::init(Default::default()); info!("Hello World, dude!"); let mut dac = Dac::new_1ch(p.DAC, p.PA4); diff --git a/examples/stm32f4/src/bin/flash.rs b/examples/stm32f4/src/bin/flash.rs index 4f780656e..0d96efb67 100644 --- a/examples/stm32f4/src/bin/flash.rs +++ b/examples/stm32f4/src/bin/flash.rs @@ -5,12 +5,12 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_stm32::flash::Flash; -use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello Flash!"); let mut f = Flash::unlock(p.FLASH); diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs index f957656ef..6facb9bb7 100644 --- a/examples/stm32f4/src/bin/hello.rs +++ b/examples/stm32f4/src/bin/hello.rs @@ -6,7 +6,7 @@ use defmt::info; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::time::Hertz; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -15,8 +15,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, _p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(_spawner: Spawner) -> ! { + let _p = embassy_stm32::init(config()); loop { info!("Hello World!"); Timer::after(Duration::from_secs(1)).await; diff --git a/examples/stm32f4/src/bin/pwm.rs b/examples/stm32f4/src/bin/pwm.rs index 0b352c2b7..1d4f426b8 100644 --- a/examples/stm32f4/src/bin/pwm.rs +++ b/examples/stm32f4/src/bin/pwm.rs @@ -8,11 +8,11 @@ use embassy_executor::time::{Duration, Timer}; use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; use embassy_stm32::pwm::Channel; use embassy_stm32::time::khz; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let ch1 = PwmPin::new_ch1(p.PE9); diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs index 6eef19963..996694f2c 100644 --- a/examples/stm32f4/src/bin/sdmmc.rs +++ b/examples/stm32f4/src/bin/sdmmc.rs @@ -6,7 +6,7 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::mhz; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -15,8 +15,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(_spawner: Spawner) -> ! { + let p = embassy_stm32::init(config()); info!("Hello World!"); let irq = interrupt::take!(SDIO); diff --git a/examples/stm32f4/src/bin/spi_dma.rs b/examples/stm32f4/src/bin/spi_dma.rs index 023ca0971..f871c1d3e 100644 --- a/examples/stm32f4/src/bin/spi_dma.rs +++ b/examples/stm32f4/src/bin/spi_dma.rs @@ -9,12 +9,12 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; -use embassy_stm32::Peripherals; use heapless::String; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut spi = Spi::new( diff --git a/examples/stm32f4/src/bin/usart_buffered.rs b/examples/stm32f4/src/bin/usart_buffered.rs index 2555998ce..9c269ae27 100644 --- a/examples/stm32f4/src/bin/usart_buffered.rs +++ b/examples/stm32f4/src/bin/usart_buffered.rs @@ -5,13 +5,14 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; +use embassy_stm32::interrupt; use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; -use embassy_stm32::{interrupt, Peripherals}; use embedded_io::asynch::BufRead; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let config = Config::default(); diff --git a/examples/stm32f4/src/bin/usart_dma.rs b/examples/stm32f4/src/bin/usart_dma.rs index 7859ba2ae..febdec6b6 100644 --- a/examples/stm32f4/src/bin/usart_dma.rs +++ b/examples/stm32f4/src/bin/usart_dma.rs @@ -8,12 +8,12 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use embassy_stm32::Peripherals; use heapless::String; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let config = Config::default(); diff --git a/examples/stm32f4/src/bin/wdt.rs b/examples/stm32f4/src/bin/wdt.rs index 48394f4f1..a51285257 100644 --- a/examples/stm32f4/src/bin/wdt.rs +++ b/examples/stm32f4/src/bin/wdt.rs @@ -7,11 +7,11 @@ use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::wdg::IndependentWatchdog; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PB7, Level::High, Speed::Low); diff --git a/examples/stm32f7/src/bin/adc.rs b/examples/stm32f7/src/bin/adc.rs index 2a813c050..a0b9bc578 100644 --- a/examples/stm32f7/src/bin/adc.rs +++ b/examples/stm32f7/src/bin/adc.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Delay, Duration, Timer}; use embassy_stm32::adc::Adc; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut adc = Adc::new(p.ADC1, &mut Delay); diff --git a/examples/stm32f7/src/bin/blinky.rs b/examples/stm32f7/src/bin/blinky.rs index f71fe0989..249bbd88f 100644 --- a/examples/stm32f7/src/bin/blinky.rs +++ b/examples/stm32f7/src/bin/blinky.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PB7, Level::High, Speed::Low); diff --git a/examples/stm32f7/src/bin/button_exti.rs b/examples/stm32f7/src/bin/button_exti.rs index 60dfb362b..25d3bb9c2 100644 --- a/examples/stm32f7/src/bin/button_exti.rs +++ b/examples/stm32f7/src/bin/button_exti.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let button = Input::new(p.PC13, Pull::Down); diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index 33504af76..f8904fa03 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs @@ -12,7 +12,7 @@ use embassy_stm32::eth::{Ethernet, State}; use embassy_stm32::peripherals::ETH; use embassy_stm32::rng::Rng; use embassy_stm32::time::mhz; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use embassy_util::Forever; use embedded_io::asynch::Write; use rand_core::RngCore; @@ -39,8 +39,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(spawner: Spawner, p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(spawner: Spawner) -> ! { + let p = embassy_stm32::init(config()); info!("Hello World!"); // Generate random seed. diff --git a/examples/stm32f7/src/bin/flash.rs b/examples/stm32f7/src/bin/flash.rs index 15864cabb..f4d8a1c51 100644 --- a/examples/stm32f7/src/bin/flash.rs +++ b/examples/stm32f7/src/bin/flash.rs @@ -6,12 +6,12 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::flash::Flash; -use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello Flash!"); const ADDR: u32 = 0x8_0000; diff --git a/examples/stm32f7/src/bin/hello.rs b/examples/stm32f7/src/bin/hello.rs index f957656ef..6facb9bb7 100644 --- a/examples/stm32f7/src/bin/hello.rs +++ b/examples/stm32f7/src/bin/hello.rs @@ -6,7 +6,7 @@ use defmt::info; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::time::Hertz; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -15,8 +15,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, _p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(_spawner: Spawner) -> ! { + let _p = embassy_stm32::init(config()); loop { info!("Hello World!"); Timer::after(Duration::from_secs(1)).await; diff --git a/examples/stm32f7/src/bin/sdmmc.rs b/examples/stm32f7/src/bin/sdmmc.rs index 1f321df17..975c5b91f 100644 --- a/examples/stm32f7/src/bin/sdmmc.rs +++ b/examples/stm32f7/src/bin/sdmmc.rs @@ -6,7 +6,7 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::mhz; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -15,8 +15,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(_spawner: Spawner) -> ! { + let p = embassy_stm32::init(config()); info!("Hello World!"); let irq = interrupt::take!(SDMMC1); diff --git a/examples/stm32f7/src/bin/usart_dma.rs b/examples/stm32f7/src/bin/usart_dma.rs index 9884d1634..27da10efd 100644 --- a/examples/stm32f7/src/bin/usart_dma.rs +++ b/examples/stm32f7/src/bin/usart_dma.rs @@ -8,12 +8,12 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use embassy_stm32::Peripherals; use heapless::String; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let config = Config::default(); let mut usart = Uart::new(p.UART7, p.PA8, p.PA15, p.DMA1_CH1, NoDma, config); diff --git a/examples/stm32g0/src/bin/blinky.rs b/examples/stm32g0/src/bin/blinky.rs index f71fe0989..249bbd88f 100644 --- a/examples/stm32g0/src/bin/blinky.rs +++ b/examples/stm32g0/src/bin/blinky.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PB7, Level::High, Speed::Low); diff --git a/examples/stm32g0/src/bin/button_exti.rs b/examples/stm32g0/src/bin/button_exti.rs index 0832386ed..8909a1fea 100644 --- a/examples/stm32g0/src/bin/button_exti.rs +++ b/examples/stm32g0/src/bin/button_exti.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let button = Input::new(p.PC13, Pull::Up); diff --git a/examples/stm32g4/src/bin/blinky.rs b/examples/stm32g4/src/bin/blinky.rs index ea3c563b4..e905a311d 100644 --- a/examples/stm32g4/src/bin/blinky.rs +++ b/examples/stm32g4/src/bin/blinky.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PA5, Level::High, Speed::Low); diff --git a/examples/stm32g4/src/bin/button_exti.rs b/examples/stm32g4/src/bin/button_exti.rs index 60dfb362b..25d3bb9c2 100644 --- a/examples/stm32g4/src/bin/button_exti.rs +++ b/examples/stm32g4/src/bin/button_exti.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let button = Input::new(p.PC13, Pull::Down); diff --git a/examples/stm32g4/src/bin/pwm.rs b/examples/stm32g4/src/bin/pwm.rs index 7c16d0a3a..f10da3d6e 100644 --- a/examples/stm32g4/src/bin/pwm.rs +++ b/examples/stm32g4/src/bin/pwm.rs @@ -8,11 +8,11 @@ use embassy_executor::time::{Duration, Timer}; use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; use embassy_stm32::pwm::Channel; use embassy_stm32::time::khz; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let ch1 = PwmPin::new_ch1(p.PA5); diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs index f50976a30..96457e766 100644 --- a/examples/stm32h7/src/bin/adc.rs +++ b/examples/stm32h7/src/bin/adc.rs @@ -8,7 +8,7 @@ use embassy_executor::time::{Delay, Duration, Timer}; use embassy_stm32::adc::{Adc, SampleTime}; use embassy_stm32::rcc::AdcClockSource; use embassy_stm32::time::mhz; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { @@ -20,8 +20,9 @@ pub fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, mut p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let mut p = embassy_stm32::init(config()); info!("Hello World!"); let mut adc = Adc::new(p.ADC3, &mut Delay); diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs index 98ce15cc6..be2fa64cc 100644 --- a/examples/stm32h7/src/bin/blinky.rs +++ b/examples/stm32h7/src/bin/blinky.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PB14, Level::High, Speed::Low); diff --git a/examples/stm32h7/src/bin/button_exti.rs b/examples/stm32h7/src/bin/button_exti.rs index 60dfb362b..25d3bb9c2 100644 --- a/examples/stm32h7/src/bin/button_exti.rs +++ b/examples/stm32h7/src/bin/button_exti.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let button = Input::new(p.PC13, Pull::Down); diff --git a/examples/stm32h7/src/bin/camera.rs b/examples/stm32h7/src/bin/camera.rs index a3bb2d5e2..8e93a54c8 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs @@ -9,7 +9,7 @@ use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::i2c::I2c; use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; use embassy_stm32::time::{khz, mhz}; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use {defmt_rtt as _, panic_probe as _}; #[allow(unused)] @@ -32,8 +32,9 @@ const HEIGHT: usize = 100; static mut FRAME: [u32; WIDTH * HEIGHT / 2] = [0u32; WIDTH * HEIGHT / 2]; -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); defmt::info!("Hello World!"); let mco = Mco::new(p.MCO1, p.PA8, Mco1Source::Hsi, McoClock::Divided(3)); diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 4282fcedd..7ad2f52c7 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs @@ -12,7 +12,7 @@ use embassy_stm32::eth::{Ethernet, State}; use embassy_stm32::peripherals::ETH; use embassy_stm32::rng::Rng; use embassy_stm32::time::mhz; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use embassy_util::Forever; use embedded_io::asynch::Write; use rand_core::RngCore; @@ -41,8 +41,9 @@ pub fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(spawner: Spawner, p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(spawner: Spawner) -> ! { + let p = embassy_stm32::init(config()); info!("Hello World!"); // Generate random seed. diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index a66c6f196..736a2992e 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs @@ -12,7 +12,7 @@ use embassy_stm32::eth::{Ethernet, State}; use embassy_stm32::peripherals::ETH; use embassy_stm32::rng::Rng; use embassy_stm32::time::mhz; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use embassy_util::Forever; use embedded_io::asynch::Write; use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; @@ -42,8 +42,9 @@ pub fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(spawner: Spawner, p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(spawner: Spawner) -> ! { + let p = embassy_stm32::init(config()); info!("Hello World!"); // Generate random seed. diff --git a/examples/stm32h7/src/bin/flash.rs b/examples/stm32h7/src/bin/flash.rs index 0c477deba..2d6f3a163 100644 --- a/examples/stm32h7/src/bin/flash.rs +++ b/examples/stm32h7/src/bin/flash.rs @@ -6,12 +6,12 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::flash::Flash; -use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello Flash!"); const ADDR: u32 = 0x08_0000; diff --git a/examples/stm32h7/src/bin/fmc.rs b/examples/stm32h7/src/bin/fmc.rs index 5140a6e22..838427b0a 100644 --- a/examples/stm32h7/src/bin/fmc.rs +++ b/examples/stm32h7/src/bin/fmc.rs @@ -7,7 +7,7 @@ use embassy_executor::executor::Spawner; use embassy_executor::time::{Delay, Duration, Timer}; use embassy_stm32::fmc::Fmc; use embassy_stm32::time::mhz; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { @@ -18,8 +18,9 @@ pub fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); let mut core_peri = cortex_m::Peripherals::take().unwrap(); diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index f2477c7a7..e759c47a8 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs @@ -9,7 +9,7 @@ use embassy_stm32::gpio::low_level::AFType; use embassy_stm32::gpio::Speed; use embassy_stm32::pwm::*; use embassy_stm32::time::{khz, mhz, Hertz}; -use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef, Peripherals}; +use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef}; use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { @@ -24,8 +24,9 @@ pub fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); let mut pwm = SimplePwm32::new(p.TIM5, p.PA0, p.PA1, p.PA2, p.PA3, khz(10)); diff --git a/examples/stm32h7/src/bin/mco.rs b/examples/stm32h7/src/bin/mco.rs index 83ba3742b..31aa3f330 100644 --- a/examples/stm32h7/src/bin/mco.rs +++ b/examples/stm32h7/src/bin/mco.rs @@ -7,11 +7,11 @@ use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PB14, Level::High, Speed::Low); diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index 36ed2e4a4..4797de0a0 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs @@ -8,7 +8,7 @@ use embassy_executor::time::{Duration, Timer}; use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; use embassy_stm32::pwm::Channel; use embassy_stm32::time::{khz, mhz}; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { @@ -23,8 +23,9 @@ pub fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); let ch1 = PwmPin::new_ch1(p.PA6); diff --git a/examples/stm32h7/src/bin/rng.rs b/examples/stm32h7/src/bin/rng.rs index 81fb3d162..2c52f4a02 100644 --- a/examples/stm32h7/src/bin/rng.rs +++ b/examples/stm32h7/src/bin/rng.rs @@ -5,11 +5,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::rng::Rng; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut rng = Rng::new(p.RNG); diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs index 19ae5ade1..ec98bf14e 100644 --- a/examples/stm32h7/src/bin/sdmmc.rs +++ b/examples/stm32h7/src/bin/sdmmc.rs @@ -6,7 +6,7 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::mhz; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -15,8 +15,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(_spawner: Spawner) -> ! { + let p = embassy_stm32::init(config()); info!("Hello World!"); let irq = interrupt::take!(SDMMC1); diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs index 2fc75c7af..c4ec2b609 100644 --- a/examples/stm32h7/src/bin/signal.rs +++ b/examples/stm32h7/src/bin/signal.rs @@ -5,7 +5,6 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; -use embassy_stm32::Peripherals; use embassy_util::channel::signal::Signal; use {defmt_rtt as _, panic_probe as _}; @@ -25,7 +24,8 @@ async fn my_sending_task() { } #[embassy_executor::main] -async fn main(spawner: Spawner, _p: Peripherals) { +async fn main(spawner: Spawner) { + let _p = embassy_stm32::init(Default::default()); unwrap!(spawner.spawn(my_sending_task())); loop { diff --git a/examples/stm32h7/src/bin/usart_split.rs b/examples/stm32h7/src/bin/usart_split.rs index 12bb0ce9c..7447319ed 100644 --- a/examples/stm32h7/src/bin/usart_split.rs +++ b/examples/stm32h7/src/bin/usart_split.rs @@ -7,7 +7,6 @@ use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::peripherals::{DMA1_CH1, UART7}; use embassy_stm32::usart::{Config, Uart, UartRx}; -use embassy_stm32::Peripherals; use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; use embassy_util::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; @@ -27,7 +26,8 @@ async fn writer(mut usart: Uart<'static, UART7, NoDma, NoDma>) { static CHANNEL: Channel = Channel::new(); #[embassy_executor::main] -async fn main(spawner: Spawner, p: Peripherals) -> ! { +async fn main(spawner: Spawner) -> ! { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let config = Config::default(); diff --git a/examples/stm32l0/src/bin/blinky.rs b/examples/stm32l0/src/bin/blinky.rs index 8cf21effb..06aad4d90 100644 --- a/examples/stm32l0/src/bin/blinky.rs +++ b/examples/stm32l0/src/bin/blinky.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PB5, Level::High, Speed::Low); diff --git a/examples/stm32l0/src/bin/button.rs b/examples/stm32l0/src/bin/button.rs index a5e05c3a3..14200334d 100644 --- a/examples/stm32l0/src/bin/button.rs +++ b/examples/stm32l0/src/bin/button.rs @@ -5,11 +5,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let button = Input::new(p.PB2, Pull::Up); diff --git a/examples/stm32l0/src/bin/button_exti.rs b/examples/stm32l0/src/bin/button_exti.rs index 22a096af8..ab23fd5bc 100644 --- a/examples/stm32l0/src/bin/button_exti.rs +++ b/examples/stm32l0/src/bin/button_exti.rs @@ -6,7 +6,6 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; fn config() -> embassy_stm32::Config { @@ -15,8 +14,9 @@ fn config() -> embassy_stm32::Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); let button = Input::new(p.PB2, Pull::Up); let mut button = ExtiInput::new(button, p.EXTI2); diff --git a/examples/stm32l0/src/bin/flash.rs b/examples/stm32l0/src/bin/flash.rs index 7ad5ae3aa..f33bd9bbd 100644 --- a/examples/stm32l0/src/bin/flash.rs +++ b/examples/stm32l0/src/bin/flash.rs @@ -5,12 +5,12 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_stm32::flash::Flash; -use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello Flash!"); const ADDR: u32 = 0x26000; diff --git a/examples/stm32l0/src/bin/lorawan.rs b/examples/stm32l0/src/bin/lorawan.rs index 29e54c1be..4e5b69362 100644 --- a/examples/stm32l0/src/bin/lorawan.rs +++ b/examples/stm32l0/src/bin/lorawan.rs @@ -6,13 +6,14 @@ #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] +use embassy_executor::executor::Spawner; use embassy_lora::sx127x::*; use embassy_lora::LoraTimer; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::rng::Rng; +use embassy_stm32::spi; use embassy_stm32::time::khz; -use embassy_stm32::{spi, Peripherals}; use lorawan::default_crypto::DefaultFactory as Crypto; use lorawan_device::async_device::{region, Device, JoinMode}; use {defmt_rtt as _, panic_probe as _}; @@ -24,8 +25,9 @@ fn config() -> embassy_stm32::Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: embassy_executor::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); // SPI for sx127x let spi = spi::Spi::new( p.SPI1, diff --git a/examples/stm32l0/src/bin/spi.rs b/examples/stm32l0/src/bin/spi.rs index 74694295c..e61c642b8 100644 --- a/examples/stm32l0/src/bin/spi.rs +++ b/examples/stm32l0/src/bin/spi.rs @@ -8,11 +8,11 @@ use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World, folks!"); let mut spi = Spi::new( diff --git a/examples/stm32l0/src/bin/usart_dma.rs b/examples/stm32l0/src/bin/usart_dma.rs index 1c5ce94d7..b686c410e 100644 --- a/examples/stm32l0/src/bin/usart_dma.rs +++ b/examples/stm32l0/src/bin/usart_dma.rs @@ -5,11 +5,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::usart::{Config, Uart}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); let mut usart = Uart::new(p.USART1, p.PB7, p.PB6, p.DMA1_CH2, p.DMA1_CH3, Config::default()); usart.write(b"Hello Embassy World!\r\n").await.unwrap(); diff --git a/examples/stm32l0/src/bin/usart_irq.rs b/examples/stm32l0/src/bin/usart_irq.rs index b77d97f85..f6d998368 100644 --- a/examples/stm32l0/src/bin/usart_irq.rs +++ b/examples/stm32l0/src/bin/usart_irq.rs @@ -5,13 +5,14 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; +use embassy_stm32::interrupt; use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; -use embassy_stm32::{interrupt, Peripherals}; use embedded_io::asynch::{Read, Write}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hi!"); static mut TX_BUFFER: [u8; 8] = [0; 8]; diff --git a/examples/stm32l1/src/bin/blinky.rs b/examples/stm32l1/src/bin/blinky.rs index 58306be94..8ecdb7bb9 100644 --- a/examples/stm32l1/src/bin/blinky.rs +++ b/examples/stm32l1/src/bin/blinky.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PA12, Level::High, Speed::Low); diff --git a/examples/stm32l1/src/bin/flash.rs b/examples/stm32l1/src/bin/flash.rs index 78938fe3e..399b09f98 100644 --- a/examples/stm32l1/src/bin/flash.rs +++ b/examples/stm32l1/src/bin/flash.rs @@ -5,12 +5,12 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_stm32::flash::Flash; -use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello Flash!"); const ADDR: u32 = 0x26000; diff --git a/examples/stm32l1/src/bin/spi.rs b/examples/stm32l1/src/bin/spi.rs index 05e869e71..424416156 100644 --- a/examples/stm32l1/src/bin/spi.rs +++ b/examples/stm32l1/src/bin/spi.rs @@ -8,11 +8,11 @@ use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World, folks!"); let mut spi = Spi::new( diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs index 3d689b5ee..8e3601496 100644 --- a/examples/stm32l4/src/bin/blinky.rs +++ b/examples/stm32l4/src/bin/blinky.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PB14, Level::High, Speed::Low); diff --git a/examples/stm32l4/src/bin/button_exti.rs b/examples/stm32l4/src/bin/button_exti.rs index 0832386ed..8909a1fea 100644 --- a/examples/stm32l4/src/bin/button_exti.rs +++ b/examples/stm32l4/src/bin/button_exti.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let button = Input::new(p.PC13, Pull::Up); diff --git a/examples/stm32l4/src/bin/i2c.rs b/examples/stm32l4/src/bin/i2c.rs index 5bfa560dc..177f6baf7 100644 --- a/examples/stm32l4/src/bin/i2c.rs +++ b/examples/stm32l4/src/bin/i2c.rs @@ -6,15 +6,16 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::i2c::I2c; +use embassy_stm32::interrupt; use embassy_stm32::time::Hertz; -use embassy_stm32::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) -> ! { +async fn main(_spawner: Spawner) -> ! { + let p = embassy_stm32::init(Default::default()); let irq = interrupt::take!(I2C2_EV); let mut i2c = I2c::new( p.I2C2, diff --git a/examples/stm32l4/src/bin/i2c_blocking_async.rs b/examples/stm32l4/src/bin/i2c_blocking_async.rs index c924bc9c5..8cc069d0e 100644 --- a/examples/stm32l4/src/bin/i2c_blocking_async.rs +++ b/examples/stm32l4/src/bin/i2c_blocking_async.rs @@ -7,8 +7,8 @@ use embassy_embedded_hal::adapter::BlockingAsync; use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::i2c::I2c; +use embassy_stm32::interrupt; use embassy_stm32::time::Hertz; -use embassy_stm32::{interrupt, Peripherals}; use embedded_hal_async::i2c::I2c as I2cTrait; use {defmt_rtt as _, panic_probe as _}; @@ -16,7 +16,8 @@ const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) -> ! { +async fn main(_spawner: Spawner) -> ! { + let p = embassy_stm32::init(Default::default()); let irq = interrupt::take!(I2C2_EV); let i2c = I2c::new( p.I2C2, diff --git a/examples/stm32l4/src/bin/i2c_dma.rs b/examples/stm32l4/src/bin/i2c_dma.rs index 2b338427b..9323fd53f 100644 --- a/examples/stm32l4/src/bin/i2c_dma.rs +++ b/examples/stm32l4/src/bin/i2c_dma.rs @@ -5,15 +5,16 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::i2c::I2c; +use embassy_stm32::interrupt; use embassy_stm32::time::Hertz; -use embassy_stm32::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) -> ! { +async fn main(_spawner: Spawner) -> ! { + let p = embassy_stm32::init(Default::default()); let irq = interrupt::take!(I2C2_EV); let mut i2c = I2c::new( p.I2C2, diff --git a/examples/stm32l4/src/bin/rng.rs b/examples/stm32l4/src/bin/rng.rs index ed47fc6c9..d0e1306a3 100644 --- a/examples/stm32l4/src/bin/rng.rs +++ b/examples/stm32l4/src/bin/rng.rs @@ -6,7 +6,7 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; use embassy_stm32::rng::Rng; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -22,8 +22,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); let mut rng = Rng::new(p.RNG); diff --git a/examples/stm32l4/src/bin/spi_blocking_async.rs b/examples/stm32l4/src/bin/spi_blocking_async.rs index e06b29b81..a893cef6d 100644 --- a/examples/stm32l4/src/bin/spi_blocking_async.rs +++ b/examples/stm32l4/src/bin/spi_blocking_async.rs @@ -9,12 +9,12 @@ use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; -use embassy_stm32::Peripherals; use embedded_hal_async::spi::SpiBus; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let spi = Spi::new( diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index e44754bec..5b19433cc 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs @@ -7,11 +7,11 @@ use embassy_executor::executor::Spawner; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut spi = Spi::new( diff --git a/examples/stm32l4/src/bin/usart_dma.rs b/examples/stm32l4/src/bin/usart_dma.rs index fdd5a85e6..4b3a9b23c 100644 --- a/examples/stm32l4/src/bin/usart_dma.rs +++ b/examples/stm32l4/src/bin/usart_dma.rs @@ -8,12 +8,12 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use embassy_stm32::Peripherals; use heapless::String; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let config = Config::default(); diff --git a/examples/stm32l5/src/bin/button_exti.rs b/examples/stm32l5/src/bin/button_exti.rs index 99462e597..ac3942521 100644 --- a/examples/stm32l5/src/bin/button_exti.rs +++ b/examples/stm32l5/src/bin/button_exti.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let button = Input::new(p.PC13, Pull::Down); diff --git a/examples/stm32l5/src/bin/rng.rs b/examples/stm32l5/src/bin/rng.rs index 45094374b..b7919424a 100644 --- a/examples/stm32l5/src/bin/rng.rs +++ b/examples/stm32l5/src/bin/rng.rs @@ -6,7 +6,7 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; use embassy_stm32::rng::Rng; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -21,8 +21,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); let mut rng = Rng::new(p.RNG); diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index 9e1df15dd..cc7578990 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs @@ -14,7 +14,7 @@ use embassy_stm32::rcc::*; use embassy_stm32::rng::Rng; use embassy_stm32::time::Hertz; use embassy_stm32::usb::Driver; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use embassy_usb::{Builder, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; @@ -93,8 +93,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(spawner: Spawner) { + let p = embassy_stm32::init(config()); // Create the driver, from the HAL. let irq = interrupt::take!(USB_FS); let driver = Driver::new(p.USB, irq, p.PA12, p.PA11); diff --git a/examples/stm32l5/src/bin/usb_hid_mouse.rs b/examples/stm32l5/src/bin/usb_hid_mouse.rs index 6aac00881..b8eef6d0d 100644 --- a/examples/stm32l5/src/bin/usb_hid_mouse.rs +++ b/examples/stm32l5/src/bin/usb_hid_mouse.rs @@ -27,8 +27,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); // Create the driver, from the HAL. let irq = interrupt::take!(USB_FS); let driver = Driver::new(p.USB, irq, p.PA12, p.PA11); diff --git a/examples/stm32l5/src/bin/usb_serial.rs b/examples/stm32l5/src/bin/usb_serial.rs index 508bce8a8..f8894231c 100644 --- a/examples/stm32l5/src/bin/usb_serial.rs +++ b/examples/stm32l5/src/bin/usb_serial.rs @@ -7,7 +7,7 @@ use embassy_executor::executor::Spawner; use embassy_stm32::rcc::*; use embassy_stm32::time::Hertz; use embassy_stm32::usb::{Driver, Instance}; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use embassy_usb::driver::EndpointError; use embassy_usb::Builder; use embassy_usb_serial::{CdcAcmClass, State}; @@ -24,8 +24,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); // Create the driver, from the HAL. diff --git a/examples/stm32u5/src/bin/blinky.rs b/examples/stm32u5/src/bin/blinky.rs index 4f3eabc5e..400542952 100644 --- a/examples/stm32u5/src/bin/blinky.rs +++ b/examples/stm32u5/src/bin/blinky.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) -> ! { +async fn main(_spawner: Spawner) -> ! { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PH7, Level::Low, Speed::Medium); diff --git a/examples/stm32wb/src/bin/blinky.rs b/examples/stm32wb/src/bin/blinky.rs index 3d8e8391d..47f126e8d 100644 --- a/examples/stm32wb/src/bin/blinky.rs +++ b/examples/stm32wb/src/bin/blinky.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PB0, Level::High, Speed::Low); diff --git a/examples/stm32wb/src/bin/button_exti.rs b/examples/stm32wb/src/bin/button_exti.rs index 41afaf4d6..d2816950b 100644 --- a/examples/stm32wb/src/bin/button_exti.rs +++ b/examples/stm32wb/src/bin/button_exti.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let button = Input::new(p.PC4, Pull::Up); diff --git a/examples/stm32wl/src/bin/blinky.rs b/examples/stm32wl/src/bin/blinky.rs index e764b4cc3..4b8588bbc 100644 --- a/examples/stm32wl/src/bin/blinky.rs +++ b/examples/stm32wl/src/bin/blinky.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let mut led = Output::new(p.PB15, Level::High, Speed::Low); diff --git a/examples/stm32wl/src/bin/button_exti.rs b/examples/stm32wl/src/bin/button_exti.rs index 9f143597d..ebc255626 100644 --- a/examples/stm32wl/src/bin/button_exti.rs +++ b/examples/stm32wl/src/bin/button_exti.rs @@ -6,11 +6,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; -use embassy_stm32::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let button = Input::new(p.PA0, Pull::Up); diff --git a/examples/stm32wl/src/bin/flash.rs b/examples/stm32wl/src/bin/flash.rs index 46183b8a2..3c4da1e9b 100644 --- a/examples/stm32wl/src/bin/flash.rs +++ b/examples/stm32wl/src/bin/flash.rs @@ -5,12 +5,12 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_stm32::flash::Flash; -use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello Flash!"); const ADDR: u32 = 0x36000; diff --git a/examples/stm32wl/src/bin/lorawan.rs b/examples/stm32wl/src/bin/lorawan.rs index 2db022ea2..35dae71a6 100644 --- a/examples/stm32wl/src/bin/lorawan.rs +++ b/examples/stm32wl/src/bin/lorawan.rs @@ -5,13 +5,14 @@ #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] +use embassy_executor::executor::Spawner; use embassy_lora::stm32wl::*; use embassy_lora::LoraTimer; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Pin, Speed}; use embassy_stm32::rng::Rng; use embassy_stm32::subghz::*; -use embassy_stm32::{interrupt, pac, Peripherals}; +use embassy_stm32::{interrupt, pac}; use lorawan::default_crypto::DefaultFactory as Crypto; use lorawan_device::async_device::{region, Device, JoinMode}; use {defmt_rtt as _, panic_probe as _}; @@ -23,8 +24,9 @@ fn config() -> embassy_stm32::Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: embassy_executor::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); unsafe { pac::RCC.ccipr().modify(|w| w.set_rngsel(0b01)) } let ctrl1 = Output::new(p.PC3.degrade(), Level::High, Speed::High); diff --git a/examples/stm32wl/src/bin/subghz.rs b/examples/stm32wl/src/bin/subghz.rs index 775dfbbfc..0e2d4103f 100644 --- a/examples/stm32wl/src/bin/subghz.rs +++ b/examples/stm32wl/src/bin/subghz.rs @@ -6,12 +6,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_stm32::interrupt; use embassy_stm32::interrupt::{Interrupt, InterruptExt}; use embassy_stm32::subghz::*; -use embassy_stm32::{interrupt, Peripherals}; use embassy_util::channel::signal::Signal; use {defmt_rtt as _, panic_probe as _}; @@ -57,8 +58,9 @@ fn config() -> embassy_stm32::Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: embassy_executor::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); let mut led2 = Output::new(p.PB9, Level::Low, Speed::Low); let mut led3 = Output::new(p.PB11, Level::Low, Speed::Low); diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs index 6f6baf77a..2d1a2ee51 100644 --- a/tests/rp/src/bin/gpio.rs +++ b/tests/rp/src/bin/gpio.rs @@ -5,11 +5,11 @@ use defmt::{assert, *}; use embassy_executor::executor::Spawner; use embassy_rp::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull}; -use embassy_rp::Peripherals; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_rp::init(Default::default()); info!("Hello World!"); let (mut a, mut b) = (p.PIN_0, p.PIN_1); diff --git a/tests/rp/src/bin/gpio_async.rs b/tests/rp/src/bin/gpio_async.rs index 1098682af..d88786876 100644 --- a/tests/rp/src/bin/gpio_async.rs +++ b/tests/rp/src/bin/gpio_async.rs @@ -6,12 +6,12 @@ use defmt::{assert, *}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Instant, Timer}; use embassy_rp::gpio::{Input, Level, Output, Pull}; -use embassy_rp::Peripherals; use futures::future::join; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_rp::init(Default::default()); info!("embassy-rp gpio_async test"); // On the CI device the following pins are connected with each other. diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index 8eab731bf..dc7223c67 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -7,11 +7,11 @@ mod example_common; use defmt::assert; use embassy_executor::executor::Spawner; use embassy_stm32::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull, Speed}; -use embassy_stm32::Peripherals; use example_common::*; -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); // Arduino pins D0 and D1 diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index 6d38b0bbf..2c0b7fc44 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs @@ -9,11 +9,11 @@ use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::spi::{self, Spi}; use embassy_stm32::time::Hertz; -use embassy_stm32::Peripherals; use example_common::*; -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); #[cfg(feature = "stm32f103c8")] diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index 8147c5f08..af1118b59 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs @@ -8,11 +8,11 @@ use defmt::assert_eq; use embassy_executor::executor::Spawner; use embassy_stm32::spi::{self, Spi}; use embassy_stm32::time::Hertz; -use embassy_stm32::Peripherals; use example_common::*; -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); #[cfg(feature = "stm32f103c8")] diff --git a/tests/stm32/src/bin/timer.rs b/tests/stm32/src/bin/timer.rs index 76b07ca15..34903084c 100644 --- a/tests/stm32/src/bin/timer.rs +++ b/tests/stm32/src/bin/timer.rs @@ -7,11 +7,11 @@ mod example_common; use defmt::assert; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Instant, Timer}; -use embassy_stm32::Peripherals; use example_common::*; -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, _p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let _p = embassy_stm32::init(config()); info!("Hello World!"); let start = Instant::now(); diff --git a/tests/stm32/src/bin/usart.rs b/tests/stm32/src/bin/usart.rs index 7b60e4b28..f454c1f70 100644 --- a/tests/stm32/src/bin/usart.rs +++ b/tests/stm32/src/bin/usart.rs @@ -8,11 +8,11 @@ use defmt::assert_eq; use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use embassy_stm32::Peripherals; use example_common::*; -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); #[cfg(feature = "stm32wb55rg")] diff --git a/tests/stm32/src/bin/usart_dma.rs b/tests/stm32/src/bin/usart_dma.rs index 323c41cae..fbaccd174 100644 --- a/tests/stm32/src/bin/usart_dma.rs +++ b/tests/stm32/src/bin/usart_dma.rs @@ -7,11 +7,11 @@ mod example_common; use defmt::assert_eq; use embassy_executor::executor::Spawner; use embassy_stm32::usart::{Config, Uart}; -use embassy_stm32::Peripherals; use example_common::*; -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); #[cfg(feature = "stm32wb55rg")]