From fc6e1e06b305d302d1b7ad17e8ef3a9be986c358 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 17 Aug 2022 18:49:55 +0200 Subject: [PATCH] Remove HAL initialization from #[embassy::main] macro. --- README.md | 4 +- docs/modules/ROOT/examples/basic/src/main.rs | 5 +- .../layer-by-layer/blinky-async/src/main.rs | 4 +- embassy-cortex-m/src/interrupt.rs | 3 +- embassy-macros/Cargo.toml | 3 - embassy-macros/src/macros/main.rs | 62 ++++--------------- embassy-nrf/Cargo.toml | 1 - embassy-nrf/src/chips/nrf52805.rs | 2 +- embassy-nrf/src/chips/nrf52810.rs | 2 +- embassy-nrf/src/chips/nrf52811.rs | 2 +- embassy-nrf/src/chips/nrf52820.rs | 2 +- embassy-nrf/src/chips/nrf52832.rs | 2 +- embassy-nrf/src/chips/nrf52833.rs | 2 +- embassy-nrf/src/chips/nrf52840.rs | 2 +- embassy-nrf/src/chips/nrf5340_app.rs | 2 +- embassy-nrf/src/chips/nrf5340_net.rs | 2 +- embassy-nrf/src/chips/nrf9160.rs | 2 +- embassy-nrf/src/lib.rs | 2 +- embassy-rp/Cargo.toml | 1 - embassy-rp/src/interrupt.rs | 2 +- embassy-rp/src/lib.rs | 2 +- embassy-stm32/Cargo.toml | 1 - embassy-stm32/build.rs | 2 +- embassy-stm32/src/lib.rs | 2 +- examples/boot/application/nrf/src/bin/a.rs | 5 +- examples/boot/application/nrf/src/bin/b.rs | 5 +- .../boot/application/stm32f3/src/bin/a.rs | 5 +- .../boot/application/stm32f3/src/bin/b.rs | 4 +- .../boot/application/stm32f7/src/bin/a.rs | 5 +- .../boot/application/stm32f7/src/bin/b.rs | 4 +- .../boot/application/stm32h7/src/bin/a.rs | 5 +- .../boot/application/stm32h7/src/bin/b.rs | 4 +- .../boot/application/stm32l0/src/bin/a.rs | 5 +- .../boot/application/stm32l0/src/bin/b.rs | 4 +- .../boot/application/stm32l1/src/bin/a.rs | 5 +- .../boot/application/stm32l1/src/bin/b.rs | 4 +- .../boot/application/stm32l4/src/bin/a.rs | 5 +- .../boot/application/stm32l4/src/bin/b.rs | 4 +- .../boot/application/stm32wl/src/bin/a.rs | 5 +- .../boot/application/stm32wl/src/bin/b.rs | 4 +- examples/nrf/src/bin/awaitable_timer.rs | 5 +- examples/nrf/src/bin/blinky.rs | 4 +- examples/nrf/src/bin/buffered_uart.rs | 5 +- examples/nrf/src/bin/channel.rs | 4 +- .../nrf/src/bin/channel_sender_receiver.rs | 4 +- .../nrf/src/bin/executor_fairness_test.rs | 4 +- examples/nrf/src/bin/gpiote_channel.rs | 4 +- examples/nrf/src/bin/gpiote_port.rs | 4 +- examples/nrf/src/bin/mutex.rs | 4 +- examples/nrf/src/bin/nvmc.rs | 4 +- examples/nrf/src/bin/ppi.rs | 4 +- examples/nrf/src/bin/pubsub.rs | 3 +- examples/nrf/src/bin/pwm.rs | 4 +- examples/nrf/src/bin/pwm_double_sequence.rs | 4 +- examples/nrf/src/bin/pwm_sequence.rs | 4 +- examples/nrf/src/bin/pwm_sequence_ppi.rs | 4 +- examples/nrf/src/bin/pwm_sequence_ws2812b.rs | 4 +- examples/nrf/src/bin/pwm_servo.rs | 4 +- examples/nrf/src/bin/qdec.rs | 5 +- examples/nrf/src/bin/qspi.rs | 5 +- examples/nrf/src/bin/qspi_lowpower.rs | 5 +- examples/nrf/src/bin/rng.rs | 5 +- examples/nrf/src/bin/saadc.rs | 5 +- examples/nrf/src/bin/saadc_continuous.rs | 5 +- examples/nrf/src/bin/self_spawn.rs | 4 +- .../src/bin/self_spawn_current_executor.rs | 4 +- examples/nrf/src/bin/spim.rs | 5 +- examples/nrf/src/bin/temp.rs | 5 +- examples/nrf/src/bin/timer.rs | 4 +- examples/nrf/src/bin/twim.rs | 5 +- examples/nrf/src/bin/twim_lowpower.rs | 5 +- examples/nrf/src/bin/uart.rs | 5 +- examples/nrf/src/bin/uart_idle.rs | 5 +- examples/nrf/src/bin/uart_split.rs | 5 +- examples/nrf/src/bin/usb_ethernet.rs | 5 +- examples/nrf/src/bin/usb_hid_keyboard.rs | 5 +- examples/nrf/src/bin/usb_hid_mouse.rs | 5 +- examples/nrf/src/bin/usb_serial.rs | 5 +- examples/nrf/src/bin/usb_serial_multitask.rs | 5 +- examples/nrf/src/bin/wdt.rs | 4 +- examples/rp/src/bin/blinky.rs | 5 +- examples/rp/src/bin/button.rs | 4 +- examples/rp/src/bin/gpio_async.rs | 5 +- examples/rp/src/bin/spi.rs | 5 +- examples/rp/src/bin/spi_display.rs | 5 +- examples/rp/src/bin/uart.rs | 5 +- examples/stm32f0/src/bin/hello.rs | 4 +- examples/stm32f1/src/bin/adc.rs | 4 +- examples/stm32f1/src/bin/blinky.rs | 4 +- examples/stm32f1/src/bin/hello.rs | 7 ++- examples/stm32f1/src/bin/usb_serial.rs | 7 ++- examples/stm32f2/src/bin/blinky.rs | 4 +- examples/stm32f2/src/bin/pll.rs | 7 ++- examples/stm32f3/src/bin/blinky.rs | 4 +- examples/stm32f3/src/bin/button_events.rs | 4 +- examples/stm32f3/src/bin/button_exti.rs | 4 +- examples/stm32f3/src/bin/flash.rs | 4 +- examples/stm32f3/src/bin/hello.rs | 7 ++- examples/stm32f3/src/bin/spi_dma.rs | 4 +- examples/stm32f3/src/bin/usart_dma.rs | 4 +- examples/stm32f3/src/bin/usb_serial.rs | 7 ++- examples/stm32f4/src/bin/adc.rs | 4 +- examples/stm32f4/src/bin/blinky.rs | 4 +- examples/stm32f4/src/bin/button_exti.rs | 4 +- examples/stm32f4/src/bin/dac.rs | 4 +- examples/stm32f4/src/bin/flash.rs | 4 +- examples/stm32f4/src/bin/hello.rs | 7 ++- examples/stm32f4/src/bin/pwm.rs | 4 +- examples/stm32f4/src/bin/sdmmc.rs | 7 ++- examples/stm32f4/src/bin/spi_dma.rs | 4 +- examples/stm32f4/src/bin/usart_buffered.rs | 5 +- examples/stm32f4/src/bin/usart_dma.rs | 4 +- examples/stm32f4/src/bin/wdt.rs | 4 +- examples/stm32f7/src/bin/adc.rs | 4 +- examples/stm32f7/src/bin/blinky.rs | 4 +- examples/stm32f7/src/bin/button_exti.rs | 4 +- examples/stm32f7/src/bin/eth.rs | 7 ++- examples/stm32f7/src/bin/flash.rs | 4 +- examples/stm32f7/src/bin/hello.rs | 7 ++- examples/stm32f7/src/bin/sdmmc.rs | 7 ++- examples/stm32f7/src/bin/usart_dma.rs | 4 +- examples/stm32g0/src/bin/blinky.rs | 4 +- examples/stm32g0/src/bin/button_exti.rs | 4 +- examples/stm32g4/src/bin/blinky.rs | 4 +- examples/stm32g4/src/bin/button_exti.rs | 4 +- examples/stm32g4/src/bin/pwm.rs | 4 +- examples/stm32h7/src/bin/adc.rs | 7 ++- examples/stm32h7/src/bin/blinky.rs | 4 +- examples/stm32h7/src/bin/button_exti.rs | 4 +- examples/stm32h7/src/bin/camera.rs | 7 ++- examples/stm32h7/src/bin/eth.rs | 7 ++- examples/stm32h7/src/bin/eth_client.rs | 7 ++- examples/stm32h7/src/bin/flash.rs | 4 +- examples/stm32h7/src/bin/fmc.rs | 7 ++- .../stm32h7/src/bin/low_level_timer_api.rs | 7 ++- examples/stm32h7/src/bin/mco.rs | 4 +- examples/stm32h7/src/bin/pwm.rs | 7 ++- examples/stm32h7/src/bin/rng.rs | 4 +- examples/stm32h7/src/bin/sdmmc.rs | 7 ++- examples/stm32h7/src/bin/signal.rs | 4 +- examples/stm32h7/src/bin/usart_split.rs | 4 +- examples/stm32l0/src/bin/blinky.rs | 4 +- examples/stm32l0/src/bin/button.rs | 4 +- examples/stm32l0/src/bin/button_exti.rs | 6 +- examples/stm32l0/src/bin/flash.rs | 4 +- examples/stm32l0/src/bin/lorawan.rs | 8 ++- examples/stm32l0/src/bin/spi.rs | 4 +- examples/stm32l0/src/bin/usart_dma.rs | 4 +- examples/stm32l0/src/bin/usart_irq.rs | 5 +- examples/stm32l1/src/bin/blinky.rs | 4 +- examples/stm32l1/src/bin/flash.rs | 4 +- examples/stm32l1/src/bin/spi.rs | 4 +- examples/stm32l4/src/bin/blinky.rs | 4 +- examples/stm32l4/src/bin/button_exti.rs | 4 +- examples/stm32l4/src/bin/i2c.rs | 5 +- .../stm32l4/src/bin/i2c_blocking_async.rs | 5 +- examples/stm32l4/src/bin/i2c_dma.rs | 5 +- examples/stm32l4/src/bin/rng.rs | 7 ++- .../stm32l4/src/bin/spi_blocking_async.rs | 4 +- examples/stm32l4/src/bin/spi_dma.rs | 4 +- examples/stm32l4/src/bin/usart_dma.rs | 4 +- examples/stm32l5/src/bin/button_exti.rs | 4 +- examples/stm32l5/src/bin/rng.rs | 7 ++- examples/stm32l5/src/bin/usb_ethernet.rs | 7 ++- examples/stm32l5/src/bin/usb_hid_mouse.rs | 5 +- examples/stm32l5/src/bin/usb_serial.rs | 7 ++- examples/stm32u5/src/bin/blinky.rs | 4 +- examples/stm32wb/src/bin/blinky.rs | 4 +- examples/stm32wb/src/bin/button_exti.rs | 4 +- examples/stm32wl/src/bin/blinky.rs | 4 +- examples/stm32wl/src/bin/button_exti.rs | 4 +- examples/stm32wl/src/bin/flash.rs | 4 +- examples/stm32wl/src/bin/lorawan.rs | 8 ++- examples/stm32wl/src/bin/subghz.rs | 8 ++- tests/rp/src/bin/gpio.rs | 4 +- tests/rp/src/bin/gpio_async.rs | 4 +- tests/stm32/src/bin/gpio.rs | 6 +- tests/stm32/src/bin/spi.rs | 6 +- tests/stm32/src/bin/spi_dma.rs | 6 +- tests/stm32/src/bin/timer.rs | 6 +- tests/stm32/src/bin/usart.rs | 6 +- tests/stm32/src/bin/usart_dma.rs | 6 +- 182 files changed, 454 insertions(+), 423 deletions(-) diff --git a/README.md b/README.md index 42374067..eaa1e10a 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 cec39fd9..d680dd06 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 b944a799..7d62b610 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 be11c5eb..1df8671b 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 6abafa58..19a3e9de 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 b040edc5..a0cb0f0b 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 72f4b538..9d6690ac 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 8fca4da1..d078fa0a 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 538a617d..faa52d8f 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 808adf51..bbdf1cbe 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 6be5bd36..dba033b0 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 cdc644d6..18b8eda6 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 4c3c5574..39a0f93f 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 bdaeadb9..e3d8f34a 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 26dc56bd..edf800ef 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 e28cfe01..ae136e09 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 1a0bd10f..a4be8564 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 ad6c16c1..f3b3ca0c 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 eeb4ec43..bf4919d5 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 d652a8c7..f21a5433 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 44150be0..8c053a4f 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 7260f06d..dea68e44 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 3b4aa5df..c892007a 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 78025f3d..30ff02d5 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 3044645a..6343f570 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 2f76d20c..ad44804a 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 fd18e937..d06e6aea 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 934f862d..98d6dbdf 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 10d709cf..154d62d2 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 c89e8a31..11883626 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 cc363bb3..8407adac 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 3fa63bdc..cc694e84 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 fcf3f2ef..7ec6bb96 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 46e394c4..f1e1eaca 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 fcf3f2ef..7ec6bb96 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 46e394c4..f1e1eaca 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 f092f023..91d16ea1 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 934f862d..98d6dbdf 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 14408a90..613694ec 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 e565fd7c..97619814 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 f2c1d9fa..a9422480 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 98db6546..5283d7ea 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 f02b7d84..d2a15397 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 e97c6c5e..a7ea08d0 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 bca7bb24..ef85e871 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 b9845493..7aaeda54 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 65c7b4df..f2654cb4 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 7746a7f9..46c260a4 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 5fe7eadb..378a5926 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 1d4387de..a0b55580 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 9a60cc0a..fb2a97f1 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 5f33f3e0..d1441d5c 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 c8a08329..dca40fd5 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 cfd8db86..08436c8f 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 b7a04c03..c549b55c 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 f5c587c3..4131e084 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 d6b3f005..de457822 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 d28a5a17..08a7a1fd 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 6bda82f7..f9565e89 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 57e0fdbe..976673a2 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 080b27a1..a83fe3fe 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 a4314e8b..70ab5c73 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 65c78d84..e90fc3df 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 d0305736..80ecaae7 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 e0152802..56539eef 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 1d8309d7..11fe6fb4 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 fd741b21..437a1a80 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 654098e0..a898488f 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 61ff1d6d..de790233 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 bb7ee9db..a0a6d359 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 ebf3d710..916ac07e 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 5f363b69..011ad2a5 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 0f455dff..cf3d9938 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 2de5f90c..12c21c09 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 93cb0590..4f8e59cc 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 863f3e5d..16d1a9a2 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 88bf87bd..0008e0e6 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 7d233d24..ce11c6cb 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 95631532..d2f1a972 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 560cb356..47e40b88 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 e53fca1a..dade3bf3 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 02cbc941..22793735 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 ba905b01..c61b87a3 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 a3160c10..7d337002 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 2760b23f..8b46bd07 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 0d295489..06721146 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 c9081ea1..a0775bad 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 e54593fe..dae001a8 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 5171043e..74e31cbb 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 549d1bfb..721b21c3 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 cf7facb7..7f27e625 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 48ae2e71..2afdeeb3 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 01e63b15..bc0c160b 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 7146eaa5..84d7c50a 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 ef511031..404946f2 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 dee06e5d..b770b338 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 be2f6f67..c7982884 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 bd9953a0..7846912c 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 f554c509..7f874bb6 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 62d16502..2b27a8da 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 87b1138f..36d38d87 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 27ed4fcc..1dc01edd 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 f71fe098..249bbd88 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 60dfb362..25d3bb9c 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 392f5bf4..9098a971 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 4f780656..0d96efb6 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 f957656e..6facb9bb 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 0b352c2b..1d4f426b 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 6eef1996..996694f2 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 023ca097..f871c1d3 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 2555998c..9c269ae2 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 7859ba2a..febdec6b 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 48394f4f..a5128525 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 2a813c05..a0b9bc57 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 f71fe098..249bbd88 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 60dfb362..25d3bb9c 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 33504af7..f8904fa0 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 15864cab..f4d8a1c5 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 f957656e..6facb9bb 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 1f321df1..975c5b91 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 9884d163..27da10ef 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 f71fe098..249bbd88 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 0832386e..8909a1fe 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 ea3c563b..e905a311 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 60dfb362..25d3bb9c 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 7c16d0a3..f10da3d6 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 f50976a3..96457e76 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 98ce15cc..be2fa64c 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 60dfb362..25d3bb9c 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 a3bb2d5e..8e93a54c 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 4282fced..7ad2f52c 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 a66c6f19..736a2992 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 0c477deb..2d6f3a16 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 5140a6e2..838427b0 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 f2477c7a..e759c47a 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 83ba3742..31aa3f33 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 36ed2e4a..4797de0a 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 81fb3d16..2c52f4a0 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 19ae5ade..ec98bf14 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 2fc75c7a..c4ec2b60 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 12bb0ce9..7447319e 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 8cf21eff..06aad4d9 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 a5e05c3a..14200334 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 22a096af..ab23fd5b 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 7ad5ae3a..f33bd9bb 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 29e54c1b..4e5b6936 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 74694295..e61c642b 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 1c5ce94d..b686c410 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 b77d97f8..f6d99836 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 58306be9..8ecdb7bb 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 78938fe3..399b09f9 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 05e869e7..42441615 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 3d689b5e..8e360149 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 0832386e..8909a1fe 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 5bfa560d..177f6baf 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 c924bc9c..8cc069d0 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 2b338427..9323fd53 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 ed47fc6c..d0e1306a 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 e06b29b8..a893cef6 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 e44754be..5b19433c 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 fdd5a85e..4b3a9b23 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 99462e59..ac394252 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 45094374..b7919424 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 9e1df15d..cc757899 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 6aac0088..b8eef6d0 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 508bce8a..f8894231 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 4f3eabc5..40054295 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 3d8e8391..47f126e8 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 41afaf4d..d2816950 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 e764b4cc..4b8588bb 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 9f143597..ebc25562 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 46183b8a..3c4da1e9 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 2db022ea..35dae71a 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 775dfbbf..0e2d4103 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 6f6baf77..2d1a2ee5 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 1098682a..d8878687 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 8eab731b..dc7223c6 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 6d38b0bb..2c0b7fc4 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 8147c5f0..af1118b5 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 76b07ca1..34903084 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 7b60e4b2..f454c1f7 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 323c41ca..fbaccd17 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")]