diff options
| author | Quentin Smith <[email protected]> | 2022-08-19 00:53:06 -0400 |
|---|---|---|
| committer | Quentin Smith <[email protected]> | 2022-08-19 00:53:41 -0400 |
| commit | 71e468681b1c074e06276d34ff00e36169c632f5 (patch) | |
| tree | ce86220caabbdc044720df8efb23de7bc4c36ea0 /examples | |
| parent | 2edf532f8d8ce048137990bf74b07759428ed7c1 (diff) | |
| parent | aefa5275a2ab2cac6caef599e7adb76ce1beeddd (diff) | |
Merge branch 'master' of https://github.com/embassy-rs/embassy into rtos-trace
Diffstat (limited to 'examples')
198 files changed, 1024 insertions, 776 deletions
diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml index dd9bcc093..ef9346639 100644 --- a/examples/boot/application/nrf/Cargo.toml +++ b/examples/boot/application/nrf/Cargo.toml | |||
| @@ -5,7 +5,8 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util" } | 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util" } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly"] } | ||
| 9 | embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly", "nrf52840"] } | 10 | embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly", "nrf52840"] } |
| 10 | embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf" } | 11 | embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf" } |
| 11 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 12 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -15,5 +16,5 @@ defmt-rtt = { version = "0.3", optional = true } | |||
| 15 | panic-reset = { version = "0.1.1" } | 16 | panic-reset = { version = "0.1.1" } |
| 16 | embedded-hal = { version = "0.2.6" } | 17 | embedded-hal = { version = "0.2.6" } |
| 17 | 18 | ||
| 18 | cortex-m = "0.7.3" | 19 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 19 | cortex-m-rt = "0.7.0" | 20 | cortex-m-rt = "0.7.0" |
diff --git a/examples/boot/application/nrf/src/bin/a.rs b/examples/boot/application/nrf/src/bin/a.rs index 3044645a8..bd8fa3246 100644 --- a/examples/boot/application/nrf/src/bin/a.rs +++ b/examples/boot/application/nrf/src/bin/a.rs | |||
| @@ -6,15 +6,16 @@ | |||
| 6 | 6 | ||
| 7 | use embassy_boot_nrf::FirmwareUpdater; | 7 | use embassy_boot_nrf::FirmwareUpdater; |
| 8 | use embassy_embedded_hal::adapter::BlockingAsync; | 8 | use embassy_embedded_hal::adapter::BlockingAsync; |
| 9 | use embassy_executor::Spawner; | ||
| 9 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; | 10 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; |
| 10 | use embassy_nrf::nvmc::Nvmc; | 11 | use embassy_nrf::nvmc::Nvmc; |
| 11 | use embassy_nrf::Peripherals; | ||
| 12 | use panic_reset as _; | 12 | use panic_reset as _; |
| 13 | 13 | ||
| 14 | static APP_B: &[u8] = include_bytes!("../../b.bin"); | 14 | static APP_B: &[u8] = include_bytes!("../../b.bin"); |
| 15 | 15 | ||
| 16 | #[embassy_executor::main] | 16 | #[embassy_executor::main] |
| 17 | async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { | 17 | async fn main(_spawner: Spawner) { |
| 18 | let p = embassy_nrf::init(Default::default()); | ||
| 18 | let mut button = Input::new(p.P0_11, Pull::Up); | 19 | let mut button = Input::new(p.P0_11, Pull::Up); |
| 19 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | 20 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); |
| 20 | //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); | 21 | //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); |
diff --git a/examples/boot/application/nrf/src/bin/b.rs b/examples/boot/application/nrf/src/bin/b.rs index 2f76d20c6..5394bf0c7 100644 --- a/examples/boot/application/nrf/src/bin/b.rs +++ b/examples/boot/application/nrf/src/bin/b.rs | |||
| @@ -4,13 +4,14 @@ | |||
| 4 | #![feature(generic_associated_types)] | 4 | #![feature(generic_associated_types)] |
| 5 | #![feature(type_alias_impl_trait)] | 5 | #![feature(type_alias_impl_trait)] |
| 6 | 6 | ||
| 7 | use embassy_executor::time::{Duration, Timer}; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 8 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 9 | use embassy_nrf::Peripherals; | 9 | use embassy_time::{Duration, Timer}; |
| 10 | use panic_reset as _; | 10 | use panic_reset as _; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 13 | async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_nrf::init(Default::default()); | ||
| 14 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | 15 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); |
| 15 | //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); | 16 | //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); |
| 16 | 17 | ||
diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml index 313808a0d..27eafa653 100644 --- a/examples/boot/application/stm32f3/Cargo.toml +++ b/examples/boot/application/stm32f3/Cargo.toml | |||
| @@ -5,7 +5,8 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] } |
| 10 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } | 11 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } |
| 11 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 12 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -15,7 +16,7 @@ defmt-rtt = { version = "0.3", optional = true } | |||
| 15 | panic-reset = { version = "0.1.1" } | 16 | panic-reset = { version = "0.1.1" } |
| 16 | embedded-hal = { version = "0.2.6" } | 17 | embedded-hal = { version = "0.2.6" } |
| 17 | 18 | ||
| 18 | cortex-m = "0.7.3" | 19 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 19 | cortex-m-rt = "0.7.0" | 20 | cortex-m-rt = "0.7.0" |
| 20 | 21 | ||
| 21 | [features] | 22 | [features] |
diff --git a/examples/boot/application/stm32f3/src/bin/a.rs b/examples/boot/application/stm32f3/src/bin/a.rs index fd18e9373..11eecc5e2 100644 --- a/examples/boot/application/stm32f3/src/bin/a.rs +++ b/examples/boot/application/stm32f3/src/bin/a.rs | |||
| @@ -6,16 +6,17 @@ | |||
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_boot_stm32::FirmwareUpdater; | 7 | use embassy_boot_stm32::FirmwareUpdater; |
| 8 | use embassy_embedded_hal::adapter::BlockingAsync; | 8 | use embassy_embedded_hal::adapter::BlockingAsync; |
| 9 | use embassy_executor::Spawner; | ||
| 9 | use embassy_stm32::exti::ExtiInput; | 10 | use embassy_stm32::exti::ExtiInput; |
| 10 | use embassy_stm32::flash::Flash; | 11 | use embassy_stm32::flash::Flash; |
| 11 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 12 | use embassy_stm32::Peripherals; | ||
| 13 | use panic_reset as _; | 13 | use panic_reset as _; |
| 14 | 14 | ||
| 15 | static APP_B: &[u8] = include_bytes!("../../b.bin"); | 15 | static APP_B: &[u8] = include_bytes!("../../b.bin"); |
| 16 | 16 | ||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 18 | async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { | 18 | async fn main(_spawner: Spawner) { |
| 19 | let p = embassy_stm32::init(Default::default()); | ||
| 19 | let flash = Flash::unlock(p.FLASH); | 20 | let flash = Flash::unlock(p.FLASH); |
| 20 | let mut flash = BlockingAsync::new(flash); | 21 | let mut flash = BlockingAsync::new(flash); |
| 21 | 22 | ||
diff --git a/examples/boot/application/stm32f3/src/bin/b.rs b/examples/boot/application/stm32f3/src/bin/b.rs index 934f862d9..a5862b1b0 100644 --- a/examples/boot/application/stm32f3/src/bin/b.rs +++ b/examples/boot/application/stm32f3/src/bin/b.rs | |||
| @@ -4,14 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | #[cfg(feature = "defmt-rtt")] | 5 | #[cfg(feature = "defmt-rtt")] |
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_executor::executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_executor::time::{Duration, Timer}; | ||
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 9 | use embassy_time::{Duration, Timer}; |
| 11 | use panic_reset as _; | 10 | use panic_reset as _; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | let mut led = Output::new(p.PA5, Level::High, Speed::Low); | 15 | let mut led = Output::new(p.PA5, Level::High, Speed::Low); |
| 16 | 16 | ||
| 17 | loop { | 17 | loop { |
diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml index 2a4741dc7..7de0b82d7 100644 --- a/examples/boot/application/stm32f7/Cargo.toml +++ b/examples/boot/application/stm32f7/Cargo.toml | |||
| @@ -5,7 +5,8 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] } |
| 10 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } | 11 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } |
| 11 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 12 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -15,7 +16,7 @@ defmt-rtt = { version = "0.3", optional = true } | |||
| 15 | panic-reset = { version = "0.1.1" } | 16 | panic-reset = { version = "0.1.1" } |
| 16 | embedded-hal = { version = "0.2.6" } | 17 | embedded-hal = { version = "0.2.6" } |
| 17 | 18 | ||
| 18 | cortex-m = "0.7.3" | 19 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 19 | cortex-m-rt = "0.7.0" | 20 | cortex-m-rt = "0.7.0" |
| 20 | 21 | ||
| 21 | [features] | 22 | [features] |
diff --git a/examples/boot/application/stm32f7/src/bin/a.rs b/examples/boot/application/stm32f7/src/bin/a.rs index 10d709cfd..a3b66e7c9 100644 --- a/examples/boot/application/stm32f7/src/bin/a.rs +++ b/examples/boot/application/stm32f7/src/bin/a.rs | |||
| @@ -6,16 +6,17 @@ | |||
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_boot_stm32::FirmwareUpdater; | 7 | use embassy_boot_stm32::FirmwareUpdater; |
| 8 | use embassy_embedded_hal::adapter::BlockingAsync; | 8 | use embassy_embedded_hal::adapter::BlockingAsync; |
| 9 | use embassy_executor::Spawner; | ||
| 9 | use embassy_stm32::exti::ExtiInput; | 10 | use embassy_stm32::exti::ExtiInput; |
| 10 | use embassy_stm32::flash::Flash; | 11 | use embassy_stm32::flash::Flash; |
| 11 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 12 | use embassy_stm32::Peripherals; | ||
| 13 | use panic_reset as _; | 13 | use panic_reset as _; |
| 14 | 14 | ||
| 15 | static APP_B: &[u8] = include_bytes!("../../b.bin"); | 15 | static APP_B: &[u8] = include_bytes!("../../b.bin"); |
| 16 | 16 | ||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 18 | async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { | 18 | async fn main(_spawner: Spawner) { |
| 19 | let p = embassy_stm32::init(Default::default()); | ||
| 19 | let flash = Flash::unlock(p.FLASH); | 20 | let flash = Flash::unlock(p.FLASH); |
| 20 | let mut flash = BlockingAsync::new(flash); | 21 | let mut flash = BlockingAsync::new(flash); |
| 21 | 22 | ||
diff --git a/examples/boot/application/stm32f7/src/bin/b.rs b/examples/boot/application/stm32f7/src/bin/b.rs index c89e8a310..16c94d845 100644 --- a/examples/boot/application/stm32f7/src/bin/b.rs +++ b/examples/boot/application/stm32f7/src/bin/b.rs | |||
| @@ -4,14 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | #[cfg(feature = "defmt-rtt")] | 5 | #[cfg(feature = "defmt-rtt")] |
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_executor::executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_executor::time::{Duration, Timer}; | ||
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 9 | use embassy_time::{Duration, Timer}; |
| 11 | use panic_reset as _; | 10 | use panic_reset as _; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | Timer::after(Duration::from_millis(300)).await; | 15 | Timer::after(Duration::from_millis(300)).await; |
| 16 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); |
| 17 | led.set_high(); | 17 | led.set_high(); |
diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml index c6420e8ad..65d34c70b 100644 --- a/examples/boot/application/stm32h7/Cargo.toml +++ b/examples/boot/application/stm32h7/Cargo.toml | |||
| @@ -5,7 +5,8 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] } |
| 10 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } | 11 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } |
| 11 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 12 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -15,7 +16,7 @@ defmt-rtt = { version = "0.3", optional = true } | |||
| 15 | panic-reset = { version = "0.1.1" } | 16 | panic-reset = { version = "0.1.1" } |
| 16 | embedded-hal = { version = "0.2.6" } | 17 | embedded-hal = { version = "0.2.6" } |
| 17 | 18 | ||
| 18 | cortex-m = "0.7.3" | 19 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 19 | cortex-m-rt = "0.7.0" | 20 | cortex-m-rt = "0.7.0" |
| 20 | 21 | ||
| 21 | [features] | 22 | [features] |
diff --git a/examples/boot/application/stm32h7/src/bin/a.rs b/examples/boot/application/stm32h7/src/bin/a.rs index cc363bb32..0ecf60348 100644 --- a/examples/boot/application/stm32h7/src/bin/a.rs +++ b/examples/boot/application/stm32h7/src/bin/a.rs | |||
| @@ -6,16 +6,17 @@ | |||
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_boot_stm32::FirmwareUpdater; | 7 | use embassy_boot_stm32::FirmwareUpdater; |
| 8 | use embassy_embedded_hal::adapter::BlockingAsync; | 8 | use embassy_embedded_hal::adapter::BlockingAsync; |
| 9 | use embassy_executor::Spawner; | ||
| 9 | use embassy_stm32::exti::ExtiInput; | 10 | use embassy_stm32::exti::ExtiInput; |
| 10 | use embassy_stm32::flash::Flash; | 11 | use embassy_stm32::flash::Flash; |
| 11 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 12 | use embassy_stm32::Peripherals; | ||
| 13 | use panic_reset as _; | 13 | use panic_reset as _; |
| 14 | 14 | ||
| 15 | static APP_B: &[u8] = include_bytes!("../../b.bin"); | 15 | static APP_B: &[u8] = include_bytes!("../../b.bin"); |
| 16 | 16 | ||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 18 | async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { | 18 | async fn main(_spawner: Spawner) { |
| 19 | let p = embassy_stm32::init(Default::default()); | ||
| 19 | let flash = Flash::unlock(p.FLASH); | 20 | let flash = Flash::unlock(p.FLASH); |
| 20 | let mut flash = BlockingAsync::new(flash); | 21 | let mut flash = BlockingAsync::new(flash); |
| 21 | 22 | ||
diff --git a/examples/boot/application/stm32h7/src/bin/b.rs b/examples/boot/application/stm32h7/src/bin/b.rs index 3fa63bdcf..34799279c 100644 --- a/examples/boot/application/stm32h7/src/bin/b.rs +++ b/examples/boot/application/stm32h7/src/bin/b.rs | |||
| @@ -4,14 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | #[cfg(feature = "defmt-rtt")] | 5 | #[cfg(feature = "defmt-rtt")] |
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_executor::executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_executor::time::{Duration, Timer}; | ||
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 9 | use embassy_time::{Duration, Timer}; |
| 11 | use panic_reset as _; | 10 | use panic_reset as _; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | Timer::after(Duration::from_millis(300)).await; | 15 | Timer::after(Duration::from_millis(300)).await; |
| 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); |
| 17 | led.set_high(); | 17 | led.set_high(); |
diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml index a6936419c..8f37869e3 100644 --- a/examples/boot/application/stm32l0/Cargo.toml +++ b/examples/boot/application/stm32l0/Cargo.toml | |||
| @@ -5,7 +5,8 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } |
| 10 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } | 11 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } |
| 11 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 12 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -15,7 +16,7 @@ defmt-rtt = { version = "0.3", optional = true } | |||
| 15 | panic-reset = { version = "0.1.1" } | 16 | panic-reset = { version = "0.1.1" } |
| 16 | embedded-hal = { version = "0.2.6" } | 17 | embedded-hal = { version = "0.2.6" } |
| 17 | 18 | ||
| 18 | cortex-m = "0.7.3" | 19 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 19 | cortex-m-rt = "0.7.0" | 20 | cortex-m-rt = "0.7.0" |
| 20 | 21 | ||
| 21 | [features] | 22 | [features] |
diff --git a/examples/boot/application/stm32l0/src/bin/a.rs b/examples/boot/application/stm32l0/src/bin/a.rs index fcf3f2ef1..f4f1d7119 100644 --- a/examples/boot/application/stm32l0/src/bin/a.rs +++ b/examples/boot/application/stm32l0/src/bin/a.rs | |||
| @@ -6,17 +6,18 @@ | |||
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_boot_stm32::FirmwareUpdater; | 7 | use embassy_boot_stm32::FirmwareUpdater; |
| 8 | use embassy_embedded_hal::adapter::BlockingAsync; | 8 | use embassy_embedded_hal::adapter::BlockingAsync; |
| 9 | use embassy_executor::time::{Duration, Timer}; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::exti::ExtiInput; | 10 | use embassy_stm32::exti::ExtiInput; |
| 11 | use embassy_stm32::flash::Flash; | 11 | use embassy_stm32::flash::Flash; |
| 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 13 | use embassy_stm32::Peripherals; | 13 | use embassy_time::{Duration, Timer}; |
| 14 | use panic_reset as _; | 14 | use panic_reset as _; |
| 15 | 15 | ||
| 16 | static APP_B: &[u8] = include_bytes!("../../b.bin"); | 16 | static APP_B: &[u8] = include_bytes!("../../b.bin"); |
| 17 | 17 | ||
| 18 | #[embassy_executor::main] | 18 | #[embassy_executor::main] |
| 19 | async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { | 19 | async fn main(_spawner: Spawner) { |
| 20 | let p = embassy_stm32::init(Default::default()); | ||
| 20 | let flash = Flash::unlock(p.FLASH); | 21 | let flash = Flash::unlock(p.FLASH); |
| 21 | let mut flash = BlockingAsync::new(flash); | 22 | let mut flash = BlockingAsync::new(flash); |
| 22 | 23 | ||
diff --git a/examples/boot/application/stm32l0/src/bin/b.rs b/examples/boot/application/stm32l0/src/bin/b.rs index 46e394c4c..ee40274ff 100644 --- a/examples/boot/application/stm32l0/src/bin/b.rs +++ b/examples/boot/application/stm32l0/src/bin/b.rs | |||
| @@ -4,14 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | #[cfg(feature = "defmt-rtt")] | 5 | #[cfg(feature = "defmt-rtt")] |
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_executor::executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_executor::time::{Duration, Timer}; | ||
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 9 | use embassy_time::{Duration, Timer}; |
| 11 | use panic_reset as _; | 10 | use panic_reset as _; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | let mut led = Output::new(p.PB6, Level::High, Speed::Low); | 15 | let mut led = Output::new(p.PB6, Level::High, Speed::Low); |
| 16 | 16 | ||
| 17 | loop { | 17 | loop { |
diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml index 5e53cd5f6..6abf1986d 100644 --- a/examples/boot/application/stm32l1/Cargo.toml +++ b/examples/boot/application/stm32l1/Cargo.toml | |||
| @@ -5,7 +5,8 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] } |
| 10 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } | 11 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } |
| 11 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 12 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -15,7 +16,7 @@ defmt-rtt = { version = "0.3", optional = true } | |||
| 15 | panic-reset = { version = "0.1.1" } | 16 | panic-reset = { version = "0.1.1" } |
| 16 | embedded-hal = { version = "0.2.6" } | 17 | embedded-hal = { version = "0.2.6" } |
| 17 | 18 | ||
| 18 | cortex-m = "0.7.3" | 19 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 19 | cortex-m-rt = "0.7.0" | 20 | cortex-m-rt = "0.7.0" |
| 20 | 21 | ||
| 21 | [features] | 22 | [features] |
diff --git a/examples/boot/application/stm32l1/src/bin/a.rs b/examples/boot/application/stm32l1/src/bin/a.rs index fcf3f2ef1..f4f1d7119 100644 --- a/examples/boot/application/stm32l1/src/bin/a.rs +++ b/examples/boot/application/stm32l1/src/bin/a.rs | |||
| @@ -6,17 +6,18 @@ | |||
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_boot_stm32::FirmwareUpdater; | 7 | use embassy_boot_stm32::FirmwareUpdater; |
| 8 | use embassy_embedded_hal::adapter::BlockingAsync; | 8 | use embassy_embedded_hal::adapter::BlockingAsync; |
| 9 | use embassy_executor::time::{Duration, Timer}; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::exti::ExtiInput; | 10 | use embassy_stm32::exti::ExtiInput; |
| 11 | use embassy_stm32::flash::Flash; | 11 | use embassy_stm32::flash::Flash; |
| 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 13 | use embassy_stm32::Peripherals; | 13 | use embassy_time::{Duration, Timer}; |
| 14 | use panic_reset as _; | 14 | use panic_reset as _; |
| 15 | 15 | ||
| 16 | static APP_B: &[u8] = include_bytes!("../../b.bin"); | 16 | static APP_B: &[u8] = include_bytes!("../../b.bin"); |
| 17 | 17 | ||
| 18 | #[embassy_executor::main] | 18 | #[embassy_executor::main] |
| 19 | async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { | 19 | async fn main(_spawner: Spawner) { |
| 20 | let p = embassy_stm32::init(Default::default()); | ||
| 20 | let flash = Flash::unlock(p.FLASH); | 21 | let flash = Flash::unlock(p.FLASH); |
| 21 | let mut flash = BlockingAsync::new(flash); | 22 | let mut flash = BlockingAsync::new(flash); |
| 22 | 23 | ||
diff --git a/examples/boot/application/stm32l1/src/bin/b.rs b/examples/boot/application/stm32l1/src/bin/b.rs index 46e394c4c..ee40274ff 100644 --- a/examples/boot/application/stm32l1/src/bin/b.rs +++ b/examples/boot/application/stm32l1/src/bin/b.rs | |||
| @@ -4,14 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | #[cfg(feature = "defmt-rtt")] | 5 | #[cfg(feature = "defmt-rtt")] |
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_executor::executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_executor::time::{Duration, Timer}; | ||
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 9 | use embassy_time::{Duration, Timer}; |
| 11 | use panic_reset as _; | 10 | use panic_reset as _; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | let mut led = Output::new(p.PB6, Level::High, Speed::Low); | 15 | let mut led = Output::new(p.PB6, Level::High, Speed::Low); |
| 16 | 16 | ||
| 17 | loop { | 17 | loop { |
diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml index bbb5e7e1d..6f2d12ff1 100644 --- a/examples/boot/application/stm32l4/Cargo.toml +++ b/examples/boot/application/stm32l4/Cargo.toml | |||
| @@ -5,7 +5,8 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] } |
| 10 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } | 11 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } |
| 11 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 12 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -15,7 +16,7 @@ defmt-rtt = { version = "0.3", optional = true } | |||
| 15 | panic-reset = { version = "0.1.1" } | 16 | panic-reset = { version = "0.1.1" } |
| 16 | embedded-hal = { version = "0.2.6" } | 17 | embedded-hal = { version = "0.2.6" } |
| 17 | 18 | ||
| 18 | cortex-m = "0.7.3" | 19 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 19 | cortex-m-rt = "0.7.0" | 20 | cortex-m-rt = "0.7.0" |
| 20 | 21 | ||
| 21 | [features] | 22 | [features] |
diff --git a/examples/boot/application/stm32l4/src/bin/a.rs b/examples/boot/application/stm32l4/src/bin/a.rs index f092f0239..178b2e04a 100644 --- a/examples/boot/application/stm32l4/src/bin/a.rs +++ b/examples/boot/application/stm32l4/src/bin/a.rs | |||
| @@ -6,16 +6,17 @@ | |||
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_boot_stm32::FirmwareUpdater; | 7 | use embassy_boot_stm32::FirmwareUpdater; |
| 8 | use embassy_embedded_hal::adapter::BlockingAsync; | 8 | use embassy_embedded_hal::adapter::BlockingAsync; |
| 9 | use embassy_executor::Spawner; | ||
| 9 | use embassy_stm32::exti::ExtiInput; | 10 | use embassy_stm32::exti::ExtiInput; |
| 10 | use embassy_stm32::flash::Flash; | 11 | use embassy_stm32::flash::Flash; |
| 11 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 12 | use embassy_stm32::Peripherals; | ||
| 13 | use panic_reset as _; | 13 | use panic_reset as _; |
| 14 | 14 | ||
| 15 | static APP_B: &[u8] = include_bytes!("../../b.bin"); | 15 | static APP_B: &[u8] = include_bytes!("../../b.bin"); |
| 16 | 16 | ||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 18 | async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { | 18 | async fn main(_spawner: Spawner) { |
| 19 | let p = embassy_stm32::init(Default::default()); | ||
| 19 | let flash = Flash::unlock(p.FLASH); | 20 | let flash = Flash::unlock(p.FLASH); |
| 20 | let mut flash = BlockingAsync::new(flash); | 21 | let mut flash = BlockingAsync::new(flash); |
| 21 | 22 | ||
diff --git a/examples/boot/application/stm32l4/src/bin/b.rs b/examples/boot/application/stm32l4/src/bin/b.rs index 934f862d9..a5862b1b0 100644 --- a/examples/boot/application/stm32l4/src/bin/b.rs +++ b/examples/boot/application/stm32l4/src/bin/b.rs | |||
| @@ -4,14 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | #[cfg(feature = "defmt-rtt")] | 5 | #[cfg(feature = "defmt-rtt")] |
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_executor::executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_executor::time::{Duration, Timer}; | ||
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 9 | use embassy_time::{Duration, Timer}; |
| 11 | use panic_reset as _; | 10 | use panic_reset as _; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | let mut led = Output::new(p.PA5, Level::High, Speed::Low); | 15 | let mut led = Output::new(p.PA5, Level::High, Speed::Low); |
| 16 | 16 | ||
| 17 | loop { | 17 | loop { |
diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml index 62123a870..be97d4ebb 100644 --- a/examples/boot/application/stm32wl/Cargo.toml +++ b/examples/boot/application/stm32wl/Cargo.toml | |||
| @@ -5,7 +5,8 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] } |
| 10 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } | 11 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } |
| 11 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 12 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -15,7 +16,7 @@ defmt-rtt = { version = "0.3", optional = true } | |||
| 15 | panic-reset = { version = "0.1.1" } | 16 | panic-reset = { version = "0.1.1" } |
| 16 | embedded-hal = { version = "0.2.6" } | 17 | embedded-hal = { version = "0.2.6" } |
| 17 | 18 | ||
| 18 | cortex-m = "0.7.3" | 19 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 19 | cortex-m-rt = "0.7.0" | 20 | cortex-m-rt = "0.7.0" |
| 20 | 21 | ||
| 21 | [features] | 22 | [features] |
diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs index 14408a90a..c71a42654 100644 --- a/examples/boot/application/stm32wl/src/bin/a.rs +++ b/examples/boot/application/stm32wl/src/bin/a.rs | |||
| @@ -6,16 +6,17 @@ | |||
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_boot_stm32::FirmwareUpdater; | 7 | use embassy_boot_stm32::FirmwareUpdater; |
| 8 | use embassy_embedded_hal::adapter::BlockingAsync; | 8 | use embassy_embedded_hal::adapter::BlockingAsync; |
| 9 | use embassy_executor::Spawner; | ||
| 9 | use embassy_stm32::exti::ExtiInput; | 10 | use embassy_stm32::exti::ExtiInput; |
| 10 | use embassy_stm32::flash::Flash; | 11 | use embassy_stm32::flash::Flash; |
| 11 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 12 | use embassy_stm32::Peripherals; | ||
| 13 | use panic_reset as _; | 13 | use panic_reset as _; |
| 14 | 14 | ||
| 15 | static APP_B: &[u8] = include_bytes!("../../b.bin"); | 15 | static APP_B: &[u8] = include_bytes!("../../b.bin"); |
| 16 | 16 | ||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 18 | async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) { | 18 | async fn main(_spawner: Spawner) { |
| 19 | let p = embassy_stm32::init(Default::default()); | ||
| 19 | let flash = Flash::unlock(p.FLASH); | 20 | let flash = Flash::unlock(p.FLASH); |
| 20 | let mut flash = BlockingAsync::new(flash); | 21 | let mut flash = BlockingAsync::new(flash); |
| 21 | 22 | ||
diff --git a/examples/boot/application/stm32wl/src/bin/b.rs b/examples/boot/application/stm32wl/src/bin/b.rs index e565fd7c6..f9f0ffc60 100644 --- a/examples/boot/application/stm32wl/src/bin/b.rs +++ b/examples/boot/application/stm32wl/src/bin/b.rs | |||
| @@ -4,14 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | #[cfg(feature = "defmt-rtt")] | 5 | #[cfg(feature = "defmt-rtt")] |
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_executor::executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_executor::time::{Duration, Timer}; | ||
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 9 | use embassy_time::{Duration, Timer}; |
| 11 | use panic_reset as _; | 10 | use panic_reset as _; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | let mut led = Output::new(p.PB15, Level::High, Speed::Low); | 15 | let mut led = Output::new(p.PB15, Level::High, Speed::Low); |
| 16 | 16 | ||
| 17 | loop { | 17 | loop { |
diff --git a/examples/boot/bootloader/nrf/Cargo.toml b/examples/boot/bootloader/nrf/Cargo.toml index 9683bff19..aa2a13ecb 100644 --- a/examples/boot/bootloader/nrf/Cargo.toml +++ b/examples/boot/bootloader/nrf/Cargo.toml | |||
| @@ -10,7 +10,7 @@ defmt-rtt = { version = "0.3", optional = true } | |||
| 10 | 10 | ||
| 11 | embassy-nrf = { path = "../../../../embassy-nrf", default-features = false, features = ["nightly"] } | 11 | embassy-nrf = { path = "../../../../embassy-nrf", default-features = false, features = ["nightly"] } |
| 12 | embassy-boot-nrf = { path = "../../../../embassy-boot/nrf", default-features = false } | 12 | embassy-boot-nrf = { path = "../../../../embassy-boot/nrf", default-features = false } |
| 13 | cortex-m = { version = "0.7" } | 13 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 14 | cortex-m-rt = { version = "0.7" } | 14 | cortex-m-rt = { version = "0.7" } |
| 15 | cfg-if = "1.0.0" | 15 | cfg-if = "1.0.0" |
| 16 | 16 | ||
diff --git a/examples/boot/bootloader/stm32/Cargo.toml b/examples/boot/bootloader/stm32/Cargo.toml index 4a3319528..491777103 100644 --- a/examples/boot/bootloader/stm32/Cargo.toml +++ b/examples/boot/bootloader/stm32/Cargo.toml | |||
| @@ -10,7 +10,7 @@ defmt-rtt = { version = "0.3", optional = true } | |||
| 10 | 10 | ||
| 11 | embassy-stm32 = { path = "../../../../embassy-stm32", default-features = false, features = ["nightly"] } | 11 | embassy-stm32 = { path = "../../../../embassy-stm32", default-features = false, features = ["nightly"] } |
| 12 | embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32", default-features = false } | 12 | embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32", default-features = false } |
| 13 | cortex-m = { version = "0.7" } | 13 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 14 | cortex-m-rt = { version = "0.7" } | 14 | cortex-m-rt = { version = "0.7" } |
| 15 | embedded-storage = "0.3.0" | 15 | embedded-storage = "0.3.0" |
| 16 | embedded-storage-async = "0.3.0" | 16 | embedded-storage-async = "0.3.0" |
diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml index 9c749a388..dad74235f 100644 --- a/examples/nrf-rtos-trace/Cargo.toml +++ b/examples/nrf-rtos-trace/Cargo.toml | |||
| @@ -5,38 +5,26 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [features] | 6 | [features] |
| 7 | default = ["log", "nightly"] | 7 | default = ["log", "nightly"] |
| 8 | nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unstable-traits", "embassy-usb", "embassy-usb-serial", "embassy-usb-hid", "embassy-usb-ncm", "embedded-io/async", "embassy-net"] | 8 | nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unstable-traits"] |
| 9 | log = [ | 9 | log = [ |
| 10 | "dep:log", | 10 | "dep:log", |
| 11 | "embassy-util/log", | 11 | "embassy-util/log", |
| 12 | "embassy-executor/log", | 12 | "embassy-executor/log", |
| 13 | "embassy-time/log", | ||
| 13 | "embassy-nrf/log", | 14 | "embassy-nrf/log", |
| 14 | "embassy-net/log", | ||
| 15 | "embassy-usb-ncm/log", | ||
| 16 | # Currently broken: | ||
| 17 | # "embassy-usb/log", | ||
| 18 | # "embassy-usb-serial/log", | ||
| 19 | # "embassy-usb-hid/log", | ||
| 20 | ] | 15 | ] |
| 21 | 16 | ||
| 22 | [dependencies] | 17 | [dependencies] |
| 23 | embassy-util = { version = "0.1.0", path = "../../embassy-util" } | 18 | embassy-util = { version = "0.1.0", path = "../../embassy-util" } |
| 24 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features=["rtos-trace", "rtos-trace-interrupt"] } | 19 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features=["rtos-trace", "rtos-trace-interrupt", "integrated-timers"] } |
| 20 | embassy-time = { version = "0.1.0", path = "../../embassy-time" } | ||
| 25 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } | 21 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } |
| 26 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true } | ||
| 27 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", optional = true } | ||
| 28 | embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", optional = true } | ||
| 29 | embassy-usb-hid = { version = "0.1.0", path = "../../embassy-usb-hid", optional = true } | ||
| 30 | embassy-usb-ncm = { version = "0.1.0", path = "../../embassy-usb-ncm", optional = true } | ||
| 31 | embedded-io = "0.3.0" | ||
| 32 | 22 | ||
| 33 | cortex-m = "0.7.3" | 23 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 34 | cortex-m-rt = "0.7.0" | 24 | cortex-m-rt = "0.7.0" |
| 35 | panic-probe = { version = "0.3" } | 25 | panic-probe = { version = "0.3" } |
| 36 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 26 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 37 | rand = { version = "0.8.4", default-features = false } | 27 | rand = { version = "0.8.4", default-features = false } |
| 38 | embedded-storage = "0.3.0" | ||
| 39 | usbd-hid = "0.5.2" | ||
| 40 | serde = { version = "1.0.136", default-features = false } | 28 | serde = { version = "1.0.136", default-features = false } |
| 41 | rtos-trace = "0.1.3" | 29 | rtos-trace = "0.1.3" |
| 42 | systemview-target = { version = "0.1.1", features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] } | 30 | systemview-target = { version = "0.1.1", features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] } |
diff --git a/examples/nrf-rtos-trace/src/bin/rtos_trace.rs b/examples/nrf-rtos-trace/src/bin/rtos_trace.rs index 5699fe8e2..7d1ad87c8 100644 --- a/examples/nrf-rtos-trace/src/bin/rtos_trace.rs +++ b/examples/nrf-rtos-trace/src/bin/rtos_trace.rs | |||
| @@ -4,9 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | 6 | ||
| 7 | use embassy_executor::executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_executor::time::{Duration, Instant, Timer}; | 8 | use embassy_time::{Duration, Instant, Timer}; |
| 9 | use embassy_nrf::Peripherals; | ||
| 10 | #[cfg(feature = "log")] | 9 | #[cfg(feature = "log")] |
| 11 | use log::*; | 10 | use log::*; |
| 12 | use panic_probe as _; | 11 | use panic_probe as _; |
| @@ -55,7 +54,8 @@ async fn run3() { | |||
| 55 | } | 54 | } |
| 56 | 55 | ||
| 57 | #[embassy_executor::main] | 56 | #[embassy_executor::main] |
| 58 | async fn main(spawner: Spawner, _p: Peripherals) { | 57 | async fn main(spawner: Spawner) { |
| 58 | let _p = embassy_nrf::init(Default::default()); | ||
| 59 | LOGGER.init(); | 59 | LOGGER.init(); |
| 60 | #[cfg(feature = "log")] | 60 | #[cfg(feature = "log")] |
| 61 | { | 61 | { |
diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index 91edbd36d..2fcc31221 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml | |||
| @@ -9,7 +9,8 @@ nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unsta | |||
| 9 | 9 | ||
| 10 | [dependencies] | 10 | [dependencies] |
| 11 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 11 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 12 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime"] } | 12 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 13 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | ||
| 13 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } | 14 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } |
| 14 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true } | 15 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true } |
| 15 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"], optional = true } | 16 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"], optional = true } |
| @@ -21,7 +22,7 @@ embedded-io = "0.3.0" | |||
| 21 | defmt = "0.3" | 22 | defmt = "0.3" |
| 22 | defmt-rtt = "0.3" | 23 | defmt-rtt = "0.3" |
| 23 | 24 | ||
| 24 | cortex-m = "0.7.3" | 25 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 25 | cortex-m-rt = "0.7.0" | 26 | cortex-m-rt = "0.7.0" |
| 26 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 27 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 27 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 28 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
diff --git a/examples/nrf/src/bin/awaitable_timer.rs b/examples/nrf/src/bin/awaitable_timer.rs index f2c1d9fa4..b32af236c 100644 --- a/examples/nrf/src/bin/awaitable_timer.rs +++ b/examples/nrf/src/bin/awaitable_timer.rs | |||
| @@ -3,13 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::interrupt; | ||
| 7 | use embassy_nrf::timer::Timer; | 8 | use embassy_nrf::timer::Timer; |
| 8 | use embassy_nrf::{interrupt, Peripherals}; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_nrf::init(Default::default()); | ||
| 13 | let mut t = Timer::new_awaitable(p.TIMER0, interrupt::take!(TIMER0)); | 14 | let mut t = Timer::new_awaitable(p.TIMER0, interrupt::take!(TIMER0)); |
| 14 | // default frequency is 1MHz, so this triggers every second | 15 | // default frequency is 1MHz, so this triggers every second |
| 15 | t.cc(0).write(1_000_000); | 16 | t.cc(0).write(1_000_000); |
diff --git a/examples/nrf/src/bin/blinky.rs b/examples/nrf/src/bin/blinky.rs index 98db6546c..513f6cd82 100644 --- a/examples/nrf/src/bin/blinky.rs +++ b/examples/nrf/src/bin/blinky.rs | |||
| @@ -2,14 +2,14 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use embassy_executor::executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_executor::time::{Duration, Timer}; | ||
| 7 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 6 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 8 | use embassy_nrf::Peripherals; | 7 | use embassy_time::{Duration, Timer}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 9 | ||
| 11 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner, p: Peripherals) { | 11 | async fn main(_spawner: Spawner) { |
| 12 | let p = embassy_nrf::init(Default::default()); | ||
| 13 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | 13 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); |
| 14 | 14 | ||
| 15 | loop { | 15 | loop { |
diff --git a/examples/nrf/src/bin/buffered_uart.rs b/examples/nrf/src/bin/buffered_uart.rs index f02b7d845..ea566f4b2 100644 --- a/examples/nrf/src/bin/buffered_uart.rs +++ b/examples/nrf/src/bin/buffered_uart.rs | |||
| @@ -3,15 +3,16 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::buffered_uarte::{BufferedUarte, State}; | 7 | use embassy_nrf::buffered_uarte::{BufferedUarte, State}; |
| 8 | use embassy_nrf::{interrupt, uarte, Peripherals}; | 8 | use embassy_nrf::{interrupt, uarte}; |
| 9 | use embedded_io::asynch::{BufRead, Write}; | 9 | use embedded_io::asynch::{BufRead, Write}; |
| 10 | use futures::pin_mut; | 10 | use futures::pin_mut; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 14 | async fn main(_spawner: Spawner) { |
| 15 | let p = embassy_nrf::init(Default::default()); | ||
| 15 | let mut config = uarte::Config::default(); | 16 | let mut config = uarte::Config::default(); |
| 16 | config.parity = uarte::Parity::EXCLUDED; | 17 | config.parity = uarte::Parity::EXCLUDED; |
| 17 | config.baudrate = uarte::Baudrate::BAUD115200; | 18 | config.baudrate = uarte::Baudrate::BAUD115200; |
diff --git a/examples/nrf/src/bin/channel.rs b/examples/nrf/src/bin/channel.rs index e97c6c5ee..195200988 100644 --- a/examples/nrf/src/bin/channel.rs +++ b/examples/nrf/src/bin/channel.rs | |||
| @@ -3,10 +3,9 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::unwrap; | 5 | use defmt::unwrap; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 7 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 9 | use embassy_nrf::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | 9 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; |
| 11 | use embassy_util::channel::mpmc::Channel; | 10 | use embassy_util::channel::mpmc::Channel; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -29,7 +28,8 @@ async fn my_task() { | |||
| 29 | } | 28 | } |
| 30 | 29 | ||
| 31 | #[embassy_executor::main] | 30 | #[embassy_executor::main] |
| 32 | async fn main(spawner: Spawner, p: Peripherals) { | 31 | async fn main(spawner: Spawner) { |
| 32 | let p = embassy_nrf::init(Default::default()); | ||
| 33 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | 33 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); |
| 34 | 34 | ||
| 35 | unwrap!(spawner.spawn(my_task())); | 35 | unwrap!(spawner.spawn(my_task())); |
diff --git a/examples/nrf/src/bin/channel_sender_receiver.rs b/examples/nrf/src/bin/channel_sender_receiver.rs index bca7bb248..c9c458aec 100644 --- a/examples/nrf/src/bin/channel_sender_receiver.rs +++ b/examples/nrf/src/bin/channel_sender_receiver.rs | |||
| @@ -3,10 +3,9 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::unwrap; | 5 | use defmt::unwrap; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; | 7 | use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; |
| 9 | use embassy_nrf::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use embassy_util::blocking_mutex::raw::NoopRawMutex; | 9 | use embassy_util::blocking_mutex::raw::NoopRawMutex; |
| 11 | use embassy_util::channel::mpmc::{Channel, Receiver, Sender}; | 10 | use embassy_util::channel::mpmc::{Channel, Receiver, Sender}; |
| 12 | use embassy_util::Forever; | 11 | use embassy_util::Forever; |
| @@ -42,7 +41,8 @@ async fn recv_task(led: AnyPin, receiver: Receiver<'static, NoopRawMutex, LedSta | |||
| 42 | } | 41 | } |
| 43 | 42 | ||
| 44 | #[embassy_executor::main] | 43 | #[embassy_executor::main] |
| 45 | async fn main(spawner: Spawner, p: Peripherals) { | 44 | async fn main(spawner: Spawner) { |
| 45 | let p = embassy_nrf::init(Default::default()); | ||
| 46 | let channel = CHANNEL.put(Channel::new()); | 46 | let channel = CHANNEL.put(Channel::new()); |
| 47 | 47 | ||
| 48 | unwrap!(spawner.spawn(send_task(channel.sender()))); | 48 | unwrap!(spawner.spawn(send_task(channel.sender()))); |
diff --git a/examples/nrf/src/bin/executor_fairness_test.rs b/examples/nrf/src/bin/executor_fairness_test.rs index b98454936..9ae030d07 100644 --- a/examples/nrf/src/bin/executor_fairness_test.rs +++ b/examples/nrf/src/bin/executor_fairness_test.rs | |||
| @@ -5,9 +5,8 @@ | |||
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | 6 | ||
| 7 | use defmt::{info, unwrap}; | 7 | use defmt::{info, unwrap}; |
| 8 | use embassy_executor::executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_executor::time::{Duration, Instant, Timer}; | 9 | use embassy_time::{Duration, Instant, Timer}; |
| 10 | use embassy_nrf::Peripherals; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| 13 | #[embassy_executor::task] | 12 | #[embassy_executor::task] |
| @@ -35,7 +34,8 @@ async fn run3() { | |||
| 35 | } | 34 | } |
| 36 | 35 | ||
| 37 | #[embassy_executor::main] | 36 | #[embassy_executor::main] |
| 38 | async fn main(spawner: Spawner, _p: Peripherals) { | 37 | async fn main(spawner: Spawner) { |
| 38 | let _p = embassy_nrf::init(Default::default()); | ||
| 39 | unwrap!(spawner.spawn(run1())); | 39 | unwrap!(spawner.spawn(run1())); |
| 40 | unwrap!(spawner.spawn(run2())); | 40 | unwrap!(spawner.spawn(run2())); |
| 41 | unwrap!(spawner.spawn(run3())); | 41 | unwrap!(spawner.spawn(run3())); |
diff --git a/examples/nrf/src/bin/gpiote_channel.rs b/examples/nrf/src/bin/gpiote_channel.rs index 65c7b4df7..5bfd02465 100644 --- a/examples/nrf/src/bin/gpiote_channel.rs +++ b/examples/nrf/src/bin/gpiote_channel.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::gpio::{Input, Pull}; | 7 | use embassy_nrf::gpio::{Input, Pull}; |
| 8 | use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; | 8 | use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; |
| 9 | use embassy_nrf::Peripherals; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_nrf::init(Default::default()); | ||
| 14 | info!("Starting!"); | 14 | info!("Starting!"); |
| 15 | 15 | ||
| 16 | let ch1 = InputChannel::new( | 16 | let ch1 = InputChannel::new( |
diff --git a/examples/nrf/src/bin/gpiote_port.rs b/examples/nrf/src/bin/gpiote_port.rs index 7746a7f96..0155d539e 100644 --- a/examples/nrf/src/bin/gpiote_port.rs +++ b/examples/nrf/src/bin/gpiote_port.rs | |||
| @@ -3,9 +3,8 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; | 7 | use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; |
| 8 | use embassy_nrf::Peripherals; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 9 | ||
| 11 | #[embassy_executor::task(pool_size = 4)] | 10 | #[embassy_executor::task(pool_size = 4)] |
| @@ -19,7 +18,8 @@ async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) { | |||
| 19 | } | 18 | } |
| 20 | 19 | ||
| 21 | #[embassy_executor::main] | 20 | #[embassy_executor::main] |
| 22 | async fn main(spawner: Spawner, p: Peripherals) { | 21 | async fn main(spawner: Spawner) { |
| 22 | let p = embassy_nrf::init(Default::default()); | ||
| 23 | info!("Starting!"); | 23 | info!("Starting!"); |
| 24 | 24 | ||
| 25 | let btn1 = Input::new(p.P0_11.degrade(), Pull::Up); | 25 | let btn1 = Input::new(p.P0_11.degrade(), Pull::Up); |
diff --git a/examples/nrf/src/bin/multiprio.rs b/examples/nrf/src/bin/multiprio.rs index 7050da378..b653689a7 100644 --- a/examples/nrf/src/bin/multiprio.rs +++ b/examples/nrf/src/bin/multiprio.rs | |||
| @@ -59,10 +59,10 @@ | |||
| 59 | 59 | ||
| 60 | use cortex_m_rt::entry; | 60 | use cortex_m_rt::entry; |
| 61 | use defmt::{info, unwrap}; | 61 | use defmt::{info, unwrap}; |
| 62 | use embassy_executor::time::{Duration, Instant, Timer}; | ||
| 63 | use embassy_nrf::executor::{Executor, InterruptExecutor}; | 62 | use embassy_nrf::executor::{Executor, InterruptExecutor}; |
| 64 | use embassy_nrf::interrupt; | 63 | use embassy_nrf::interrupt; |
| 65 | use embassy_nrf::interrupt::InterruptExt; | 64 | use embassy_nrf::interrupt::InterruptExt; |
| 65 | use embassy_time::{Duration, Instant, Timer}; | ||
| 66 | use embassy_util::Forever; | 66 | use embassy_util::Forever; |
| 67 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| 68 | 68 | ||
diff --git a/examples/nrf/src/bin/mutex.rs b/examples/nrf/src/bin/mutex.rs index 5fe7eadb9..876297883 100644 --- a/examples/nrf/src/bin/mutex.rs +++ b/examples/nrf/src/bin/mutex.rs | |||
| @@ -3,9 +3,8 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | 7 | use embassy_time::{Duration, Timer}; |
| 8 | use embassy_nrf::Peripherals; | ||
| 9 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | 8 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; |
| 10 | use embassy_util::mutex::Mutex; | 9 | use embassy_util::mutex::Mutex; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -30,7 +29,8 @@ async fn my_task() { | |||
| 30 | } | 29 | } |
| 31 | 30 | ||
| 32 | #[embassy_executor::main] | 31 | #[embassy_executor::main] |
| 33 | async fn main(spawner: Spawner, _p: Peripherals) { | 32 | async fn main(spawner: Spawner) { |
| 33 | let _p = embassy_nrf::init(Default::default()); | ||
| 34 | unwrap!(spawner.spawn(my_task())); | 34 | unwrap!(spawner.spawn(my_task())); |
| 35 | 35 | ||
| 36 | loop { | 36 | loop { |
diff --git a/examples/nrf/src/bin/nvmc.rs b/examples/nrf/src/bin/nvmc.rs index 1d4387de7..75d090fbb 100644 --- a/examples/nrf/src/bin/nvmc.rs +++ b/examples/nrf/src/bin/nvmc.rs | |||
| @@ -3,15 +3,15 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_nrf::nvmc::Nvmc; | 7 | use embassy_nrf::nvmc::Nvmc; |
| 9 | use embassy_nrf::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; | 9 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_nrf::init(Default::default()); | ||
| 15 | info!("Hello NVMC!"); | 15 | info!("Hello NVMC!"); |
| 16 | 16 | ||
| 17 | // probe-run breaks without this, I'm not sure why. | 17 | // probe-run breaks without this, I'm not sure why. |
diff --git a/examples/nrf/src/bin/ppi.rs b/examples/nrf/src/bin/ppi.rs index 9a60cc0a0..d74ce4064 100644 --- a/examples/nrf/src/bin/ppi.rs +++ b/examples/nrf/src/bin/ppi.rs | |||
| @@ -5,16 +5,16 @@ | |||
| 5 | use core::future::pending; | 5 | use core::future::pending; |
| 6 | 6 | ||
| 7 | use defmt::info; | 7 | use defmt::info; |
| 8 | use embassy_executor::executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; | 9 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; |
| 10 | use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity}; | 10 | use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity}; |
| 11 | use embassy_nrf::ppi::Ppi; | 11 | use embassy_nrf::ppi::Ppi; |
| 12 | use embassy_nrf::Peripherals; | ||
| 13 | use gpiote::{OutputChannel, OutputChannelPolarity}; | 12 | use gpiote::{OutputChannel, OutputChannelPolarity}; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 14 | ||
| 16 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| 17 | async fn main(_spawner: Spawner, p: Peripherals) { | 16 | async fn main(_spawner: Spawner) { |
| 17 | let p = embassy_nrf::init(Default::default()); | ||
| 18 | info!("Starting!"); | 18 | info!("Starting!"); |
| 19 | 19 | ||
| 20 | let button1 = InputChannel::new( | 20 | let button1 = InputChannel::new( |
diff --git a/examples/nrf/src/bin/pubsub.rs b/examples/nrf/src/bin/pubsub.rs index 5f33f3e0b..1d90217f2 100644 --- a/examples/nrf/src/bin/pubsub.rs +++ b/examples/nrf/src/bin/pubsub.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::unwrap; | 5 | use defmt::unwrap; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | 7 | use embassy_time::{Duration, Timer}; |
| 8 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | 8 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; |
| 9 | use embassy_util::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; | 9 | use embassy_util::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -20,7 +20,8 @@ enum Message { | |||
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | #[embassy_executor::main] | 22 | #[embassy_executor::main] |
| 23 | async fn main(spawner: Spawner, _p: embassy_nrf::Peripherals) { | 23 | async fn main(spawner: Spawner) { |
| 24 | let _p = embassy_nrf::init(Default::default()); | ||
| 24 | defmt::info!("Hello World!"); | 25 | defmt::info!("Hello World!"); |
| 25 | 26 | ||
| 26 | // It's good to set up the subscribers before publishing anything. | 27 | // It's good to set up the subscribers before publishing anything. |
diff --git a/examples/nrf/src/bin/pwm.rs b/examples/nrf/src/bin/pwm.rs index c8a083294..1698c0bc8 100644 --- a/examples/nrf/src/bin/pwm.rs +++ b/examples/nrf/src/bin/pwm.rs | |||
| @@ -3,10 +3,9 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; | 7 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; |
| 9 | use embassy_nrf::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | // for i in range(1024): print(int((math.sin(i/512*math.pi)*0.4+0.5)**2*32767), ', ', end='') | 11 | // 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] = [ | |||
| 71 | ]; | 70 | ]; |
| 72 | 71 | ||
| 73 | #[embassy_executor::main] | 72 | #[embassy_executor::main] |
| 74 | async fn main(_spawner: Spawner, p: Peripherals) { | 73 | async fn main(_spawner: Spawner) { |
| 74 | let p = embassy_nrf::init(Default::default()); | ||
| 75 | let mut pwm = SimplePwm::new_4ch(p.PWM0, p.P0_13, p.P0_14, p.P0_16, p.P0_15); | 75 | let mut pwm = SimplePwm::new_4ch(p.PWM0, p.P0_13, p.P0_14, p.P0_16, p.P0_15); |
| 76 | pwm.set_prescaler(Prescaler::Div1); | 76 | pwm.set_prescaler(Prescaler::Div1); |
| 77 | pwm.set_max_duty(32767); | 77 | pwm.set_max_duty(32767); |
diff --git a/examples/nrf/src/bin/pwm_double_sequence.rs b/examples/nrf/src/bin/pwm_double_sequence.rs index cfd8db86b..16e50e909 100644 --- a/examples/nrf/src/bin/pwm_double_sequence.rs +++ b/examples/nrf/src/bin/pwm_double_sequence.rs | |||
| @@ -3,16 +3,16 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_nrf::pwm::{ | 7 | use embassy_nrf::pwm::{ |
| 9 | Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, StartSequence, | 8 | Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, StartSequence, |
| 10 | }; | 9 | }; |
| 11 | use embassy_nrf::Peripherals; | 10 | use embassy_time::{Duration, Timer}; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 12 | ||
| 14 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 14 | async fn main(_spawner: Spawner) { |
| 15 | let p = embassy_nrf::init(Default::default()); | ||
| 16 | let seq_words_0: [u16; 5] = [1000, 250, 100, 50, 0]; | 16 | let seq_words_0: [u16; 5] = [1000, 250, 100, 50, 0]; |
| 17 | let seq_words_1: [u16; 4] = [50, 100, 250, 1000]; | 17 | let seq_words_1: [u16; 4] = [50, 100, 250, 1000]; |
| 18 | 18 | ||
diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index b7a04c036..b9aca9aaa 100644 --- a/examples/nrf/src/bin/pwm_sequence.rs +++ b/examples/nrf/src/bin/pwm_sequence.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; | 7 | use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; |
| 9 | use embassy_nrf::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_nrf::init(Default::default()); | ||
| 14 | let seq_words: [u16; 5] = [1000, 250, 100, 50, 0]; | 14 | let seq_words: [u16; 5] = [1000, 250, 100, 50, 0]; |
| 15 | 15 | ||
| 16 | let mut config = Config::default(); | 16 | let mut config = Config::default(); |
diff --git a/examples/nrf/src/bin/pwm_sequence_ppi.rs b/examples/nrf/src/bin/pwm_sequence_ppi.rs index f5c587c35..6594fa348 100644 --- a/examples/nrf/src/bin/pwm_sequence_ppi.rs +++ b/examples/nrf/src/bin/pwm_sequence_ppi.rs | |||
| @@ -5,16 +5,16 @@ | |||
| 5 | use core::future::pending; | 5 | use core::future::pending; |
| 6 | 6 | ||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy_executor::executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_nrf::gpio::{Input, Pull}; | 9 | use embassy_nrf::gpio::{Input, Pull}; |
| 10 | use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; | 10 | use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; |
| 11 | use embassy_nrf::ppi::Ppi; | 11 | use embassy_nrf::ppi::Ppi; |
| 12 | use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; | 12 | use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; |
| 13 | use embassy_nrf::Peripherals; | ||
| 14 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 14 | ||
| 16 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| 17 | async fn main(_spawner: Spawner, p: Peripherals) { | 16 | async fn main(_spawner: Spawner) { |
| 17 | let p = embassy_nrf::init(Default::default()); | ||
| 18 | let seq_words: [u16; 5] = [1000, 250, 100, 50, 0]; | 18 | let seq_words: [u16; 5] = [1000, 250, 100, 50, 0]; |
| 19 | 19 | ||
| 20 | let mut config = Config::default(); | 20 | let mut config = Config::default(); |
diff --git a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs index d6b3f005c..711c8a17b 100644 --- a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs +++ b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs | |||
| @@ -3,12 +3,11 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_nrf::pwm::{ | 7 | use embassy_nrf::pwm::{ |
| 9 | Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, SingleSequencer, | 8 | Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, SingleSequencer, |
| 10 | }; | 9 | }; |
| 11 | use embassy_nrf::Peripherals; | 10 | use embassy_time::{Duration, Timer}; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 12 | ||
| 14 | // WS2812B LED light demonstration. Drives just one light. | 13 | // WS2812B LED light demonstration. Drives just one light. |
| @@ -27,7 +26,8 @@ const RES: u16 = 0x8000; | |||
| 27 | // Provides data to a WS2812b (Neopixel) LED and makes it go blue. The data | 26 | // Provides data to a WS2812b (Neopixel) LED and makes it go blue. The data |
| 28 | // line is assumed to be P1_05. | 27 | // line is assumed to be P1_05. |
| 29 | #[embassy_executor::main] | 28 | #[embassy_executor::main] |
| 30 | async fn main(_spawner: Spawner, p: Peripherals) { | 29 | async fn main(_spawner: Spawner) { |
| 30 | let p = embassy_nrf::init(Default::default()); | ||
| 31 | let mut config = Config::default(); | 31 | let mut config = Config::default(); |
| 32 | config.sequence_load = SequenceLoad::Common; | 32 | config.sequence_load = SequenceLoad::Common; |
| 33 | config.prescaler = Prescaler::Div1; | 33 | config.prescaler = Prescaler::Div1; |
diff --git a/examples/nrf/src/bin/pwm_servo.rs b/examples/nrf/src/bin/pwm_servo.rs index d28a5a17e..19228f433 100644 --- a/examples/nrf/src/bin/pwm_servo.rs +++ b/examples/nrf/src/bin/pwm_servo.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; | 7 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; |
| 9 | use embassy_nrf::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_nrf::init(Default::default()); | ||
| 14 | let mut pwm = SimplePwm::new_1ch(p.PWM0, p.P0_05); | 14 | let mut pwm = SimplePwm::new_1ch(p.PWM0, p.P0_05); |
| 15 | // sg90 microervo requires 50hz or 20ms period | 15 | // sg90 microervo requires 50hz or 20ms period |
| 16 | // set_period can only set down to 125khz so we cant use it directly | 16 | // set_period can only set down to 125khz so we cant use it directly |
diff --git a/examples/nrf/src/bin/qdec.rs b/examples/nrf/src/bin/qdec.rs index 6bda82f78..600bba07a 100644 --- a/examples/nrf/src/bin/qdec.rs +++ b/examples/nrf/src/bin/qdec.rs | |||
| @@ -3,13 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::interrupt; | ||
| 7 | use embassy_nrf::qdec::{self, Qdec}; | 8 | use embassy_nrf::qdec::{self, Qdec}; |
| 8 | use embassy_nrf::{interrupt, Peripherals}; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_nrf::init(Default::default()); | ||
| 13 | let irq = interrupt::take!(QDEC); | 14 | let irq = interrupt::take!(QDEC); |
| 14 | let config = qdec::Config::default(); | 15 | let config = qdec::Config::default(); |
| 15 | let mut rotary_enc = Qdec::new(p.QDEC, irq, p.P0_31, p.P0_30, config); | 16 | let mut rotary_enc = Qdec::new(p.QDEC, irq, p.P0_31, p.P0_30, config); |
diff --git a/examples/nrf/src/bin/qspi.rs b/examples/nrf/src/bin/qspi.rs index 57e0fdbe2..bdcf710b8 100644 --- a/examples/nrf/src/bin/qspi.rs +++ b/examples/nrf/src/bin/qspi.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{assert_eq, info, unwrap}; | 5 | use defmt::{assert_eq, info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::{interrupt, qspi, Peripherals}; | 7 | use embassy_nrf::{interrupt, qspi}; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | const PAGE_SIZE: usize = 4096; | 10 | const PAGE_SIZE: usize = 4096; |
| @@ -15,7 +15,8 @@ const PAGE_SIZE: usize = 4096; | |||
| 15 | struct AlignedBuf([u8; 4096]); | 15 | struct AlignedBuf([u8; 4096]); |
| 16 | 16 | ||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 18 | async fn main(_spawner: Spawner, p: Peripherals) { | 18 | async fn main(_spawner: Spawner) { |
| 19 | let p = embassy_nrf::init(Default::default()); | ||
| 19 | // Config for the MX25R64 present in the nRF52840 DK | 20 | // Config for the MX25R64 present in the nRF52840 DK |
| 20 | let mut config = qspi::Config::default(); | 21 | let mut config = qspi::Config::default(); |
| 21 | config.read_opcode = qspi::ReadOpcode::READ4IO; | 22 | config.read_opcode = qspi::ReadOpcode::READ4IO; |
diff --git a/examples/nrf/src/bin/qspi_lowpower.rs b/examples/nrf/src/bin/qspi_lowpower.rs index 080b27a16..9341a2376 100644 --- a/examples/nrf/src/bin/qspi_lowpower.rs +++ b/examples/nrf/src/bin/qspi_lowpower.rs | |||
| @@ -5,9 +5,9 @@ | |||
| 5 | use core::mem; | 5 | use core::mem; |
| 6 | 6 | ||
| 7 | use defmt::{info, unwrap}; | 7 | use defmt::{info, unwrap}; |
| 8 | use embassy_executor::executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_executor::time::{Duration, Timer}; | 9 | use embassy_nrf::{interrupt, qspi}; |
| 10 | use embassy_nrf::{interrupt, qspi, Peripherals}; | 10 | use embassy_time::{Duration, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | // Workaround for alignment requirements. | 13 | // Workaround for alignment requirements. |
| @@ -16,7 +16,8 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 16 | struct AlignedBuf([u8; 64]); | 16 | struct AlignedBuf([u8; 64]); |
| 17 | 17 | ||
| 18 | #[embassy_executor::main] | 18 | #[embassy_executor::main] |
| 19 | async fn main(_spawner: Spawner, mut p: Peripherals) { | 19 | async fn main(_p: Spawner) { |
| 20 | let mut p = embassy_nrf::init(Default::default()); | ||
| 20 | let mut irq = interrupt::take!(QSPI); | 21 | let mut irq = interrupt::take!(QSPI); |
| 21 | 22 | ||
| 22 | loop { | 23 | loop { |
diff --git a/examples/nrf/src/bin/raw_spawn.rs b/examples/nrf/src/bin/raw_spawn.rs index 9199d3aeb..415579be7 100644 --- a/examples/nrf/src/bin/raw_spawn.rs +++ b/examples/nrf/src/bin/raw_spawn.rs | |||
| @@ -5,9 +5,9 @@ use core::mem; | |||
| 5 | 5 | ||
| 6 | use cortex_m_rt::entry; | 6 | use cortex_m_rt::entry; |
| 7 | use defmt::{info, unwrap}; | 7 | use defmt::{info, unwrap}; |
| 8 | use embassy_executor::executor::raw::TaskStorage; | 8 | use embassy_executor::raw::TaskStorage; |
| 9 | use embassy_executor::executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_executor::time::{Duration, Timer}; | 10 | use embassy_time::{Duration, Timer}; |
| 11 | use embassy_util::Forever; | 11 | use embassy_util::Forever; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
diff --git a/examples/nrf/src/bin/rng.rs b/examples/nrf/src/bin/rng.rs index a4314e8b9..647073949 100644 --- a/examples/nrf/src/bin/rng.rs +++ b/examples/nrf/src/bin/rng.rs | |||
| @@ -2,14 +2,15 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use embassy_executor::executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_nrf::interrupt; | ||
| 6 | use embassy_nrf::rng::Rng; | 7 | use embassy_nrf::rng::Rng; |
| 7 | use embassy_nrf::{interrupt, Peripherals}; | ||
| 8 | use rand::Rng as _; | 8 | use rand::Rng as _; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_nrf::init(Default::default()); | ||
| 13 | let mut rng = Rng::new(p.RNG, interrupt::take!(RNG)); | 14 | let mut rng = Rng::new(p.RNG, interrupt::take!(RNG)); |
| 14 | 15 | ||
| 15 | // Async API | 16 | // Async API |
diff --git a/examples/nrf/src/bin/saadc.rs b/examples/nrf/src/bin/saadc.rs index 65c78d842..7cf588090 100644 --- a/examples/nrf/src/bin/saadc.rs +++ b/examples/nrf/src/bin/saadc.rs | |||
| @@ -3,14 +3,15 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | 7 | use embassy_nrf::interrupt; |
| 8 | use embassy_nrf::saadc::{ChannelConfig, Config, Saadc}; | 8 | use embassy_nrf::saadc::{ChannelConfig, Config, Saadc}; |
| 9 | use embassy_nrf::{interrupt, Peripherals}; | 9 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, mut p: Peripherals) { | 13 | async fn main(_p: Spawner) { |
| 14 | let mut p = embassy_nrf::init(Default::default()); | ||
| 14 | let config = Config::default(); | 15 | let config = Config::default(); |
| 15 | let channel_config = ChannelConfig::single_ended(&mut p.P0_02); | 16 | let channel_config = ChannelConfig::single_ended(&mut p.P0_02); |
| 16 | let mut saadc = Saadc::new(p.SAADC, interrupt::take!(SAADC), config, [channel_config]); | 17 | let mut saadc = Saadc::new(p.SAADC, interrupt::take!(SAADC), config, [channel_config]); |
diff --git a/examples/nrf/src/bin/saadc_continuous.rs b/examples/nrf/src/bin/saadc_continuous.rs index d0305736f..bb50ac65e 100644 --- a/examples/nrf/src/bin/saadc_continuous.rs +++ b/examples/nrf/src/bin/saadc_continuous.rs | |||
| @@ -3,17 +3,18 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::Duration; | 7 | use embassy_nrf::interrupt; |
| 8 | use embassy_nrf::saadc::{ChannelConfig, Config, Saadc, SamplerState}; | 8 | use embassy_nrf::saadc::{ChannelConfig, Config, Saadc, SamplerState}; |
| 9 | use embassy_nrf::timer::Frequency; | 9 | use embassy_nrf::timer::Frequency; |
| 10 | use embassy_nrf::{interrupt, Peripherals}; | 10 | use embassy_time::Duration; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | // Demonstrates both continuous sampling and scanning multiple channels driven by a PPI linked timer | 13 | // Demonstrates both continuous sampling and scanning multiple channels driven by a PPI linked timer |
| 14 | 14 | ||
| 15 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| 16 | async fn main(_spawner: Spawner, mut p: Peripherals) { | 16 | async fn main(_p: Spawner) { |
| 17 | let mut p = embassy_nrf::init(Default::default()); | ||
| 17 | let config = Config::default(); | 18 | let config = Config::default(); |
| 18 | let channel_1_config = ChannelConfig::single_ended(&mut p.P0_02); | 19 | let channel_1_config = ChannelConfig::single_ended(&mut p.P0_02); |
| 19 | let channel_2_config = ChannelConfig::single_ended(&mut p.P0_03); | 20 | let channel_2_config = ChannelConfig::single_ended(&mut p.P0_03); |
| @@ -27,7 +28,7 @@ async fn main(_spawner: Spawner, mut p: Peripherals) { | |||
| 27 | 28 | ||
| 28 | // This delay demonstrates that starting the timer prior to running | 29 | // This delay demonstrates that starting the timer prior to running |
| 29 | // the task sampler is benign given the calibration that follows. | 30 | // the task sampler is benign given the calibration that follows. |
| 30 | embassy_executor::time::Timer::after(Duration::from_millis(500)).await; | 31 | embassy_time::Timer::after(Duration::from_millis(500)).await; |
| 31 | saadc.calibrate().await; | 32 | saadc.calibrate().await; |
| 32 | 33 | ||
| 33 | let mut bufs = [[[0; 3]; 500]; 2]; | 34 | let mut bufs = [[[0; 3]; 500]; 2]; |
diff --git a/examples/nrf/src/bin/self_spawn.rs b/examples/nrf/src/bin/self_spawn.rs index e0152802e..196255a52 100644 --- a/examples/nrf/src/bin/self_spawn.rs +++ b/examples/nrf/src/bin/self_spawn.rs | |||
| @@ -3,9 +3,8 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | 7 | use embassy_time::{Duration, Timer}; |
| 8 | use embassy_nrf::Peripherals; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 9 | ||
| 11 | #[embassy_executor::task(pool_size = 2)] | 10 | #[embassy_executor::task(pool_size = 2)] |
| @@ -16,7 +15,8 @@ async fn my_task(spawner: Spawner, n: u32) { | |||
| 16 | } | 15 | } |
| 17 | 16 | ||
| 18 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 19 | async fn main(spawner: Spawner, _p: Peripherals) { | 18 | async fn main(spawner: Spawner) { |
| 19 | let _p = embassy_nrf::init(Default::default()); | ||
| 20 | info!("Hello World!"); | 20 | info!("Hello World!"); |
| 21 | unwrap!(spawner.spawn(my_task(spawner, 0))); | 21 | unwrap!(spawner.spawn(my_task(spawner, 0))); |
| 22 | } | 22 | } |
diff --git a/examples/nrf/src/bin/self_spawn_current_executor.rs b/examples/nrf/src/bin/self_spawn_current_executor.rs index 1d8309d77..8a179886c 100644 --- a/examples/nrf/src/bin/self_spawn_current_executor.rs +++ b/examples/nrf/src/bin/self_spawn_current_executor.rs | |||
| @@ -3,9 +3,8 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | 7 | use embassy_time::{Duration, Timer}; |
| 8 | use embassy_nrf::Peripherals; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 9 | ||
| 11 | #[embassy_executor::task(pool_size = 2)] | 10 | #[embassy_executor::task(pool_size = 2)] |
| @@ -16,7 +15,8 @@ async fn my_task(n: u32) { | |||
| 16 | } | 15 | } |
| 17 | 16 | ||
| 18 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 19 | async fn main(spawner: Spawner, _p: Peripherals) { | 18 | async fn main(spawner: Spawner) { |
| 19 | let _p = embassy_nrf::init(Default::default()); | ||
| 20 | info!("Hello World!"); | 20 | info!("Hello World!"); |
| 21 | unwrap!(spawner.spawn(my_task(0))); | 21 | unwrap!(spawner.spawn(my_task(0))); |
| 22 | } | 22 | } |
diff --git a/examples/nrf/src/bin/spim.rs b/examples/nrf/src/bin/spim.rs index fd741b21c..132e01660 100644 --- a/examples/nrf/src/bin/spim.rs +++ b/examples/nrf/src/bin/spim.rs | |||
| @@ -3,13 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 7 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 8 | use embassy_nrf::{interrupt, spim, Peripherals}; | 8 | use embassy_nrf::{interrupt, spim}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_nrf::init(Default::default()); | ||
| 13 | info!("running!"); | 14 | info!("running!"); |
| 14 | 15 | ||
| 15 | let mut config = spim::Config::default(); | 16 | let mut config = spim::Config::default(); |
diff --git a/examples/nrf/src/bin/temp.rs b/examples/nrf/src/bin/temp.rs index 654098e0b..b06ac709e 100644 --- a/examples/nrf/src/bin/temp.rs +++ b/examples/nrf/src/bin/temp.rs | |||
| @@ -3,14 +3,15 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | 7 | use embassy_nrf::interrupt; |
| 8 | use embassy_nrf::temp::Temp; | 8 | use embassy_nrf::temp::Temp; |
| 9 | use embassy_nrf::{interrupt, Peripherals}; | 9 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_nrf::init(Default::default()); | ||
| 14 | let irq = interrupt::take!(TEMP); | 15 | let irq = interrupt::take!(TEMP); |
| 15 | let mut temp = Temp::new(p.TEMP, irq); | 16 | let mut temp = Temp::new(p.TEMP, irq); |
| 16 | 17 | ||
diff --git a/examples/nrf/src/bin/timer.rs b/examples/nrf/src/bin/timer.rs index 61ff1d6db..c22b5acd5 100644 --- a/examples/nrf/src/bin/timer.rs +++ b/examples/nrf/src/bin/timer.rs | |||
| @@ -3,9 +3,8 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | 7 | use embassy_time::{Duration, Timer}; |
| 8 | use embassy_nrf::Peripherals; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 9 | ||
| 11 | #[embassy_executor::task] | 10 | #[embassy_executor::task] |
| @@ -25,7 +24,8 @@ async fn run2() { | |||
| 25 | } | 24 | } |
| 26 | 25 | ||
| 27 | #[embassy_executor::main] | 26 | #[embassy_executor::main] |
| 28 | async fn main(spawner: Spawner, _p: Peripherals) { | 27 | async fn main(spawner: Spawner) { |
| 28 | let _p = embassy_nrf::init(Default::default()); | ||
| 29 | unwrap!(spawner.spawn(run1())); | 29 | unwrap!(spawner.spawn(run1())); |
| 30 | unwrap!(spawner.spawn(run2())); | 30 | unwrap!(spawner.spawn(run2())); |
| 31 | } | 31 | } |
diff --git a/examples/nrf/src/bin/twim.rs b/examples/nrf/src/bin/twim.rs index bb7ee9db4..a027cc1e7 100644 --- a/examples/nrf/src/bin/twim.rs +++ b/examples/nrf/src/bin/twim.rs | |||
| @@ -7,15 +7,16 @@ | |||
| 7 | #![feature(type_alias_impl_trait)] | 7 | #![feature(type_alias_impl_trait)] |
| 8 | 8 | ||
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy_executor::executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_nrf::interrupt; | ||
| 11 | use embassy_nrf::twim::{self, Twim}; | 12 | use embassy_nrf::twim::{self, Twim}; |
| 12 | use embassy_nrf::{interrupt, Peripherals}; | ||
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | const ADDRESS: u8 = 0x50; | 15 | const ADDRESS: u8 = 0x50; |
| 16 | 16 | ||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 18 | async fn main(_spawner: Spawner, p: Peripherals) { | 18 | async fn main(_spawner: Spawner) { |
| 19 | let p = embassy_nrf::init(Default::default()); | ||
| 19 | info!("Initializing TWI..."); | 20 | info!("Initializing TWI..."); |
| 20 | let config = twim::Config::default(); | 21 | let config = twim::Config::default(); |
| 21 | let irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); | 22 | let irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); |
diff --git a/examples/nrf/src/bin/twim_lowpower.rs b/examples/nrf/src/bin/twim_lowpower.rs index ebf3d7109..e30cc9688 100644 --- a/examples/nrf/src/bin/twim_lowpower.rs +++ b/examples/nrf/src/bin/twim_lowpower.rs | |||
| @@ -11,16 +11,17 @@ | |||
| 11 | use core::mem; | 11 | use core::mem; |
| 12 | 12 | ||
| 13 | use defmt::*; | 13 | use defmt::*; |
| 14 | use embassy_executor::executor::Spawner; | 14 | use embassy_executor::Spawner; |
| 15 | use embassy_executor::time::{Duration, Timer}; | 15 | use embassy_nrf::interrupt; |
| 16 | use embassy_nrf::twim::{self, Twim}; | 16 | use embassy_nrf::twim::{self, Twim}; |
| 17 | use embassy_nrf::{interrupt, Peripherals}; | 17 | use embassy_time::{Duration, Timer}; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | const ADDRESS: u8 = 0x50; | 20 | const ADDRESS: u8 = 0x50; |
| 21 | 21 | ||
| 22 | #[embassy_executor::main] | 22 | #[embassy_executor::main] |
| 23 | async fn main(_spawner: Spawner, mut p: Peripherals) { | 23 | async fn main(_p: Spawner) { |
| 24 | let mut p = embassy_nrf::init(Default::default()); | ||
| 24 | info!("Started!"); | 25 | info!("Started!"); |
| 25 | let mut irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); | 26 | let mut irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); |
| 26 | 27 | ||
diff --git a/examples/nrf/src/bin/uart.rs b/examples/nrf/src/bin/uart.rs index 5f363b69e..600f7a6ef 100644 --- a/examples/nrf/src/bin/uart.rs +++ b/examples/nrf/src/bin/uart.rs | |||
| @@ -3,12 +3,13 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::{interrupt, uarte, Peripherals}; | 7 | use embassy_nrf::{interrupt, uarte}; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| 11 | async fn main(_spawner: Spawner, p: Peripherals) { | 11 | async fn main(_spawner: Spawner) { |
| 12 | let p = embassy_nrf::init(Default::default()); | ||
| 12 | let mut config = uarte::Config::default(); | 13 | let mut config = uarte::Config::default(); |
| 13 | config.parity = uarte::Parity::EXCLUDED; | 14 | config.parity = uarte::Parity::EXCLUDED; |
| 14 | config.baudrate = uarte::Baudrate::BAUD115200; | 15 | config.baudrate = uarte::Baudrate::BAUD115200; |
diff --git a/examples/nrf/src/bin/uart_idle.rs b/examples/nrf/src/bin/uart_idle.rs index 0f455dffd..09ec624c0 100644 --- a/examples/nrf/src/bin/uart_idle.rs +++ b/examples/nrf/src/bin/uart_idle.rs | |||
| @@ -3,12 +3,13 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::{interrupt, uarte, Peripherals}; | 7 | use embassy_nrf::{interrupt, uarte}; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| 11 | async fn main(_spawner: Spawner, p: Peripherals) { | 11 | async fn main(_spawner: Spawner) { |
| 12 | let p = embassy_nrf::init(Default::default()); | ||
| 12 | let mut config = uarte::Config::default(); | 13 | let mut config = uarte::Config::default(); |
| 13 | config.parity = uarte::Parity::EXCLUDED; | 14 | config.parity = uarte::Parity::EXCLUDED; |
| 14 | config.baudrate = uarte::Baudrate::BAUD115200; | 15 | config.baudrate = uarte::Baudrate::BAUD115200; |
diff --git a/examples/nrf/src/bin/uart_split.rs b/examples/nrf/src/bin/uart_split.rs index 2de5f90c1..dab8e475d 100644 --- a/examples/nrf/src/bin/uart_split.rs +++ b/examples/nrf/src/bin/uart_split.rs | |||
| @@ -3,10 +3,10 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::peripherals::UARTE0; | 7 | use embassy_nrf::peripherals::UARTE0; |
| 8 | use embassy_nrf::uarte::UarteRx; | 8 | use embassy_nrf::uarte::UarteRx; |
| 9 | use embassy_nrf::{interrupt, uarte, Peripherals}; | 9 | use embassy_nrf::{interrupt, uarte}; |
| 10 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | 10 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; |
| 11 | use embassy_util::channel::mpmc::Channel; | 11 | use embassy_util::channel::mpmc::Channel; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -14,7 +14,8 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 14 | static CHANNEL: Channel<ThreadModeRawMutex, [u8; 8], 1> = Channel::new(); | 14 | static CHANNEL: Channel<ThreadModeRawMutex, [u8; 8], 1> = Channel::new(); |
| 15 | 15 | ||
| 16 | #[embassy_executor::main] | 16 | #[embassy_executor::main] |
| 17 | async fn main(spawner: Spawner, p: Peripherals) { | 17 | async fn main(spawner: Spawner) { |
| 18 | let p = embassy_nrf::init(Default::default()); | ||
| 18 | let mut config = uarte::Config::default(); | 19 | let mut config = uarte::Config::default(); |
| 19 | config.parity = uarte::Parity::EXCLUDED; | 20 | config.parity = uarte::Parity::EXCLUDED; |
| 20 | config.baudrate = uarte::Baudrate::BAUD115200; | 21 | config.baudrate = uarte::Baudrate::BAUD115200; |
diff --git a/examples/nrf/src/bin/usb_ethernet.rs b/examples/nrf/src/bin/usb_ethernet.rs index 93cb05907..f0a870317 100644 --- a/examples/nrf/src/bin/usb_ethernet.rs +++ b/examples/nrf/src/bin/usb_ethernet.rs | |||
| @@ -8,12 +8,12 @@ use core::sync::atomic::{AtomicBool, Ordering}; | |||
| 8 | use core::task::Waker; | 8 | use core::task::Waker; |
| 9 | 9 | ||
| 10 | use defmt::*; | 10 | use defmt::*; |
| 11 | use embassy_executor::executor::Spawner; | 11 | use embassy_executor::Spawner; |
| 12 | use embassy_net::tcp::TcpSocket; | 12 | use embassy_net::tcp::TcpSocket; |
| 13 | use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources}; | 13 | use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources}; |
| 14 | use embassy_nrf::rng::Rng; | 14 | use embassy_nrf::rng::Rng; |
| 15 | use embassy_nrf::usb::{Driver, PowerUsb}; | 15 | use embassy_nrf::usb::{Driver, PowerUsb}; |
| 16 | use embassy_nrf::{interrupt, pac, peripherals, Peripherals}; | 16 | use embassy_nrf::{interrupt, pac, peripherals}; |
| 17 | use embassy_usb::{Builder, Config, UsbDevice}; | 17 | use embassy_usb::{Builder, Config, UsbDevice}; |
| 18 | use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; | 18 | use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; |
| 19 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | 19 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; |
| @@ -82,7 +82,8 @@ async fn net_task(stack: &'static Stack<Device>) -> ! { | |||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | #[embassy_executor::main] | 84 | #[embassy_executor::main] |
| 85 | async fn main(spawner: Spawner, p: Peripherals) { | 85 | async fn main(spawner: Spawner) { |
| 86 | let p = embassy_nrf::init(Default::default()); | ||
| 86 | let clock: pac::CLOCK = unsafe { mem::transmute(()) }; | 87 | let clock: pac::CLOCK = unsafe { mem::transmute(()) }; |
| 87 | 88 | ||
| 88 | info!("Enabling ext hfosc..."); | 89 | info!("Enabling ext hfosc..."); |
diff --git a/examples/nrf/src/bin/usb_hid_keyboard.rs b/examples/nrf/src/bin/usb_hid_keyboard.rs index 863f3e5dd..cf0078eec 100644 --- a/examples/nrf/src/bin/usb_hid_keyboard.rs +++ b/examples/nrf/src/bin/usb_hid_keyboard.rs | |||
| @@ -7,10 +7,10 @@ use core::mem; | |||
| 7 | use core::sync::atomic::{AtomicBool, Ordering}; | 7 | use core::sync::atomic::{AtomicBool, Ordering}; |
| 8 | 8 | ||
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy_executor::executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_nrf::gpio::{Input, Pin, Pull}; | 11 | use embassy_nrf::gpio::{Input, Pin, Pull}; |
| 12 | use embassy_nrf::usb::{Driver, PowerUsb}; | 12 | use embassy_nrf::usb::{Driver, PowerUsb}; |
| 13 | use embassy_nrf::{interrupt, pac, Peripherals}; | 13 | use embassy_nrf::{interrupt, pac}; |
| 14 | use embassy_usb::control::OutResponse; | 14 | use embassy_usb::control::OutResponse; |
| 15 | use embassy_usb::{Builder, Config, DeviceStateHandler}; | 15 | use embassy_usb::{Builder, Config, DeviceStateHandler}; |
| 16 | use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State}; | 16 | use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State}; |
| @@ -23,7 +23,8 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 23 | static SUSPENDED: AtomicBool = AtomicBool::new(false); | 23 | static SUSPENDED: AtomicBool = AtomicBool::new(false); |
| 24 | 24 | ||
| 25 | #[embassy_executor::main] | 25 | #[embassy_executor::main] |
| 26 | async fn main(_spawner: Spawner, p: Peripherals) { | 26 | async fn main(_spawner: Spawner) { |
| 27 | let p = embassy_nrf::init(Default::default()); | ||
| 27 | let clock: pac::CLOCK = unsafe { mem::transmute(()) }; | 28 | let clock: pac::CLOCK = unsafe { mem::transmute(()) }; |
| 28 | 29 | ||
| 29 | info!("Enabling ext hfosc..."); | 30 | info!("Enabling ext hfosc..."); |
diff --git a/examples/nrf/src/bin/usb_hid_mouse.rs b/examples/nrf/src/bin/usb_hid_mouse.rs index 88bf87bd6..7cd2ece17 100644 --- a/examples/nrf/src/bin/usb_hid_mouse.rs +++ b/examples/nrf/src/bin/usb_hid_mouse.rs | |||
| @@ -6,10 +6,10 @@ | |||
| 6 | use core::mem; | 6 | use core::mem; |
| 7 | 7 | ||
| 8 | use defmt::*; | 8 | use defmt::*; |
| 9 | use embassy_executor::executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_executor::time::{Duration, Timer}; | ||
| 11 | use embassy_nrf::usb::{Driver, PowerUsb}; | 10 | use embassy_nrf::usb::{Driver, PowerUsb}; |
| 12 | use embassy_nrf::{interrupt, pac, Peripherals}; | 11 | use embassy_nrf::{interrupt, pac}; |
| 12 | use embassy_time::{Duration, Timer}; | ||
| 13 | use embassy_usb::control::OutResponse; | 13 | use embassy_usb::control::OutResponse; |
| 14 | use embassy_usb::{Builder, Config}; | 14 | use embassy_usb::{Builder, Config}; |
| 15 | use embassy_usb_hid::{HidWriter, ReportId, RequestHandler, State}; | 15 | use embassy_usb_hid::{HidWriter, ReportId, RequestHandler, State}; |
| @@ -18,7 +18,8 @@ use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; | |||
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | #[embassy_executor::main] | 20 | #[embassy_executor::main] |
| 21 | async fn main(_spawner: Spawner, p: Peripherals) { | 21 | async fn main(_spawner: Spawner) { |
| 22 | let p = embassy_nrf::init(Default::default()); | ||
| 22 | let clock: pac::CLOCK = unsafe { mem::transmute(()) }; | 23 | let clock: pac::CLOCK = unsafe { mem::transmute(()) }; |
| 23 | 24 | ||
| 24 | info!("Enabling ext hfosc..."); | 25 | info!("Enabling ext hfosc..."); |
diff --git a/examples/nrf/src/bin/usb_serial.rs b/examples/nrf/src/bin/usb_serial.rs index 7d233d24d..a68edb329 100644 --- a/examples/nrf/src/bin/usb_serial.rs +++ b/examples/nrf/src/bin/usb_serial.rs | |||
| @@ -6,9 +6,9 @@ | |||
| 6 | use core::mem; | 6 | use core::mem; |
| 7 | 7 | ||
| 8 | use defmt::{info, panic}; | 8 | use defmt::{info, panic}; |
| 9 | use embassy_executor::executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_nrf::usb::{Driver, Instance, PowerUsb, UsbSupply}; | 10 | use embassy_nrf::usb::{Driver, Instance, PowerUsb, UsbSupply}; |
| 11 | use embassy_nrf::{interrupt, pac, Peripherals}; | 11 | use embassy_nrf::{interrupt, pac}; |
| 12 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 13 | use embassy_usb::{Builder, Config}; | 13 | use embassy_usb::{Builder, Config}; |
| 14 | use embassy_usb_serial::{CdcAcmClass, State}; | 14 | use embassy_usb_serial::{CdcAcmClass, State}; |
| @@ -16,7 +16,8 @@ use futures::future::join; | |||
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 17 | ||
| 18 | #[embassy_executor::main] | 18 | #[embassy_executor::main] |
| 19 | async fn main(_spawner: Spawner, p: Peripherals) { | 19 | async fn main(_spawner: Spawner) { |
| 20 | let p = embassy_nrf::init(Default::default()); | ||
| 20 | let clock: pac::CLOCK = unsafe { mem::transmute(()) }; | 21 | let clock: pac::CLOCK = unsafe { mem::transmute(()) }; |
| 21 | 22 | ||
| 22 | info!("Enabling ext hfosc..."); | 23 | info!("Enabling ext hfosc..."); |
diff --git a/examples/nrf/src/bin/usb_serial_multitask.rs b/examples/nrf/src/bin/usb_serial_multitask.rs index 956315322..4c1a93087 100644 --- a/examples/nrf/src/bin/usb_serial_multitask.rs +++ b/examples/nrf/src/bin/usb_serial_multitask.rs | |||
| @@ -6,9 +6,9 @@ | |||
| 6 | use core::mem; | 6 | use core::mem; |
| 7 | 7 | ||
| 8 | use defmt::{info, panic, unwrap}; | 8 | use defmt::{info, panic, unwrap}; |
| 9 | use embassy_executor::executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_nrf::usb::{Driver, PowerUsb}; | 10 | use embassy_nrf::usb::{Driver, PowerUsb}; |
| 11 | use embassy_nrf::{interrupt, pac, peripherals, Peripherals}; | 11 | use embassy_nrf::{interrupt, pac, peripherals}; |
| 12 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 13 | use embassy_usb::{Builder, Config, UsbDevice}; | 13 | use embassy_usb::{Builder, Config, UsbDevice}; |
| 14 | use embassy_usb_serial::{CdcAcmClass, State}; | 14 | use embassy_usb_serial::{CdcAcmClass, State}; |
| @@ -33,7 +33,8 @@ async fn echo_task(mut class: CdcAcmClass<'static, MyDriver>) { | |||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | #[embassy_executor::main] | 35 | #[embassy_executor::main] |
| 36 | async fn main(spawner: Spawner, p: Peripherals) { | 36 | async fn main(spawner: Spawner) { |
| 37 | let p = embassy_nrf::init(Default::default()); | ||
| 37 | let clock: pac::CLOCK = unsafe { mem::transmute(()) }; | 38 | let clock: pac::CLOCK = unsafe { mem::transmute(()) }; |
| 38 | 39 | ||
| 39 | info!("Enabling ext hfosc..."); | 40 | info!("Enabling ext hfosc..."); |
diff --git a/examples/nrf/src/bin/wdt.rs b/examples/nrf/src/bin/wdt.rs index 560cb3567..b0b9c3b81 100644 --- a/examples/nrf/src/bin/wdt.rs +++ b/examples/nrf/src/bin/wdt.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::gpio::{Input, Pull}; | 7 | use embassy_nrf::gpio::{Input, Pull}; |
| 8 | use embassy_nrf::wdt::{Config, Watchdog}; | 8 | use embassy_nrf::wdt::{Config, Watchdog}; |
| 9 | use embassy_nrf::Peripherals; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_nrf::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut config = Config::default(); | 16 | let mut config = Config::default(); |
diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 94c3d8013..c2dcf429a 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml | |||
| @@ -6,14 +6,14 @@ version = "0.1.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 8 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime"] } | 9 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | ||
| 10 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac"] } | 11 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac"] } |
| 11 | atomic-polyfill = "0.1.5" | ||
| 12 | 12 | ||
| 13 | defmt = "0.3" | 13 | defmt = "0.3" |
| 14 | defmt-rtt = "0.3" | 14 | defmt-rtt = "0.3" |
| 15 | 15 | ||
| 16 | cortex-m = "0.7.3" | 16 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 17 | cortex-m-rt = "0.7.0" | 17 | cortex-m-rt = "0.7.0" |
| 18 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 18 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 19 | futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] } | 19 | futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] } |
diff --git a/examples/rp/src/bin/blinky.rs b/examples/rp/src/bin/blinky.rs index e53fca1af..7aa36a19f 100644 --- a/examples/rp/src/bin/blinky.rs +++ b/examples/rp/src/bin/blinky.rs | |||
| @@ -3,14 +3,15 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | 7 | use embassy_rp::gpio; |
| 8 | use embassy_rp::{gpio, Peripherals}; | 8 | use embassy_time::{Duration, Timer}; |
| 9 | use gpio::{Level, Output}; | 9 | use gpio::{Level, Output}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_rp::init(Default::default()); | ||
| 14 | let mut led = Output::new(p.PIN_25, Level::Low); | 15 | let mut led = Output::new(p.PIN_25, Level::Low); |
| 15 | 16 | ||
| 16 | loop { | 17 | loop { |
diff --git a/examples/rp/src/bin/button.rs b/examples/rp/src/bin/button.rs index 02cbc9416..c5422c616 100644 --- a/examples/rp/src/bin/button.rs +++ b/examples/rp/src/bin/button.rs | |||
| @@ -2,13 +2,13 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use embassy_executor::executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_rp::gpio::{Input, Level, Output, Pull}; | 6 | use embassy_rp::gpio::{Input, Level, Output, Pull}; |
| 7 | use embassy_rp::Peripherals; | ||
| 8 | use {defmt_rtt as _, panic_probe as _}; | 7 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 8 | ||
| 10 | #[embassy_executor::main] | 9 | #[embassy_executor::main] |
| 11 | async fn main(_spawner: Spawner, p: Peripherals) { | 10 | async fn main(_spawner: Spawner) { |
| 11 | let p = embassy_rp::init(Default::default()); | ||
| 12 | let button = Input::new(p.PIN_28, Pull::Up); | 12 | let button = Input::new(p.PIN_28, Pull::Up); |
| 13 | let mut led = Output::new(p.PIN_25, Level::Low); | 13 | let mut led = Output::new(p.PIN_25, Level::Low); |
| 14 | 14 | ||
diff --git a/examples/rp/src/bin/gpio_async.rs b/examples/rp/src/bin/gpio_async.rs index ba905b015..52d13a9d5 100644 --- a/examples/rp/src/bin/gpio_async.rs +++ b/examples/rp/src/bin/gpio_async.rs | |||
| @@ -3,9 +3,9 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | 7 | use embassy_rp::gpio; |
| 8 | use embassy_rp::{gpio, Peripherals}; | 8 | use embassy_time::{Duration, Timer}; |
| 9 | use gpio::{Input, Level, Output, Pull}; | 9 | use gpio::{Input, Level, Output, Pull}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| @@ -20,7 +20,8 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 20 | /// continue and turn off the LED, and then wait for 2 seconds before completing | 20 | /// continue and turn off the LED, and then wait for 2 seconds before completing |
| 21 | /// the loop and starting over again. | 21 | /// the loop and starting over again. |
| 22 | #[embassy_executor::main] | 22 | #[embassy_executor::main] |
| 23 | async fn main(_spawner: Spawner, p: Peripherals) { | 23 | async fn main(_spawner: Spawner) { |
| 24 | let p = embassy_rp::init(Default::default()); | ||
| 24 | let mut led = Output::new(p.PIN_25, Level::Low); | 25 | let mut led = Output::new(p.PIN_25, Level::Low); |
| 25 | let mut async_input = Input::new(p.PIN_16, Pull::None); | 26 | let mut async_input = Input::new(p.PIN_16, Pull::None); |
| 26 | 27 | ||
diff --git a/examples/rp/src/bin/spi.rs b/examples/rp/src/bin/spi.rs index a3160c106..88003ee17 100644 --- a/examples/rp/src/bin/spi.rs +++ b/examples/rp/src/bin/spi.rs | |||
| @@ -3,14 +3,15 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_rp::spi::Spi; | 7 | use embassy_rp::spi::Spi; |
| 8 | use embassy_rp::{gpio, spi, Peripherals}; | 8 | use embassy_rp::{gpio, spi}; |
| 9 | use gpio::{Level, Output}; | 9 | use gpio::{Level, Output}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_rp::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 15 | info!("Hello World!"); |
| 15 | 16 | ||
| 16 | // Example for resistive touch sensor in Waveshare Pico-ResTouch | 17 | // Example for resistive touch sensor in Waveshare Pico-ResTouch |
diff --git a/examples/rp/src/bin/spi_display.rs b/examples/rp/src/bin/spi_display.rs index 2760b23fa..f0e54d87f 100644 --- a/examples/rp/src/bin/spi_display.rs +++ b/examples/rp/src/bin/spi_display.rs | |||
| @@ -5,11 +5,11 @@ | |||
| 5 | use core::cell::RefCell; | 5 | use core::cell::RefCell; |
| 6 | 6 | ||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy_executor::executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_executor::time::Delay; | ||
| 10 | use embassy_rp::gpio::{Level, Output}; | 9 | use embassy_rp::gpio::{Level, Output}; |
| 10 | use embassy_rp::spi; | ||
| 11 | use embassy_rp::spi::Spi; | 11 | use embassy_rp::spi::Spi; |
| 12 | use embassy_rp::{spi, Peripherals}; | 12 | use embassy_time::Delay; |
| 13 | use embedded_graphics::image::{Image, ImageRawLE}; | 13 | use embedded_graphics::image::{Image, ImageRawLE}; |
| 14 | use embedded_graphics::mono_font::ascii::FONT_10X20; | 14 | use embedded_graphics::mono_font::ascii::FONT_10X20; |
| 15 | use embedded_graphics::mono_font::MonoTextStyle; | 15 | use embedded_graphics::mono_font::MonoTextStyle; |
| @@ -28,7 +28,8 @@ use crate::touch::Touch; | |||
| 28 | const TOUCH_FREQ: u32 = 200_000; | 28 | const TOUCH_FREQ: u32 = 200_000; |
| 29 | 29 | ||
| 30 | #[embassy_executor::main] | 30 | #[embassy_executor::main] |
| 31 | async fn main(_spawner: Spawner, p: Peripherals) { | 31 | async fn main(_spawner: Spawner) { |
| 32 | let p = embassy_rp::init(Default::default()); | ||
| 32 | info!("Hello World!"); | 33 | info!("Hello World!"); |
| 33 | 34 | ||
| 34 | let bl = p.PIN_13; | 35 | let bl = p.PIN_13; |
diff --git a/examples/rp/src/bin/uart.rs b/examples/rp/src/bin/uart.rs index 0d2954894..c63b31cae 100644 --- a/examples/rp/src/bin/uart.rs +++ b/examples/rp/src/bin/uart.rs | |||
| @@ -2,18 +2,19 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use embassy_executor::executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_rp::{uart, Peripherals}; | 6 | use embassy_rp::uart; |
| 7 | use {defmt_rtt as _, panic_probe as _}; | 7 | use {defmt_rtt as _, panic_probe as _}; |
| 8 | 8 | ||
| 9 | #[embassy_executor::main] | 9 | #[embassy_executor::main] |
| 10 | async fn main(_spawner: Spawner, p: Peripherals) { | 10 | async fn main(_spawner: Spawner) { |
| 11 | let p = embassy_rp::init(Default::default()); | ||
| 11 | let config = uart::Config::default(); | 12 | let config = uart::Config::default(); |
| 12 | let mut uart = uart::Uart::new(p.UART0, p.PIN_0, p.PIN_1, p.PIN_2, p.PIN_3, config); | 13 | let mut uart = uart::Uart::new_with_rtscts(p.UART0, p.PIN_0, p.PIN_1, p.PIN_2, p.PIN_3, config); |
| 13 | uart.send("Hello World!\r\n".as_bytes()); | 14 | uart.blocking_write("Hello World!\r\n".as_bytes()).unwrap(); |
| 14 | 15 | ||
| 15 | loop { | 16 | loop { |
| 16 | uart.send("hello there!\r\n".as_bytes()); | 17 | uart.blocking_write("hello there!\r\n".as_bytes()).unwrap(); |
| 17 | cortex_m::asm::delay(1_000_000); | 18 | cortex_m::asm::delay(1_000_000); |
| 18 | } | 19 | } |
| 19 | } | 20 | } |
diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 54499796b..b7009017c 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml | |||
| @@ -5,9 +5,11 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] } | 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "std", "time", "nightly"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "std", "nightly", "integrated-timers"] } |
| 9 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "log", "medium-ethernet", "tcp", "dhcpv4", "pool-16"] } | 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["log", "std", "nightly"] } |
| 10 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "log", "medium-ethernet", "tcp", "udp", "dhcpv4", "pool-16"] } | ||
| 10 | embedded-io = { version = "0.3.0", features = ["async", "std", "futures"] } | 11 | embedded-io = { version = "0.3.0", features = ["async", "std", "futures"] } |
| 12 | critical-section = { version = "1.1", features = ["std"] } | ||
| 11 | 13 | ||
| 12 | async-io = "1.6.0" | 14 | async-io = "1.6.0" |
| 13 | env_logger = "0.9.0" | 15 | env_logger = "0.9.0" |
diff --git a/examples/std/src/bin/net.rs b/examples/std/src/bin/net.rs index 202585289..528609260 100644 --- a/examples/std/src/bin/net.rs +++ b/examples/std/src/bin/net.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![feature(type_alias_impl_trait)] | 1 | #![feature(type_alias_impl_trait)] |
| 2 | 2 | ||
| 3 | use clap::Parser; | 3 | use clap::Parser; |
| 4 | use embassy_executor::executor::{Executor, Spawner}; | 4 | use embassy_executor::{Executor, Spawner}; |
| 5 | use embassy_net::tcp::TcpSocket; | 5 | use embassy_net::tcp::TcpSocket; |
| 6 | use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, Stack, StackResources}; | 6 | use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, Stack, StackResources}; |
| 7 | use embassy_util::Forever; | 7 | use embassy_util::Forever; |
diff --git a/examples/std/src/bin/net_udp.rs b/examples/std/src/bin/net_udp.rs new file mode 100644 index 000000000..07e11c385 --- /dev/null +++ b/examples/std/src/bin/net_udp.rs | |||
| @@ -0,0 +1,109 @@ | |||
| 1 | #![feature(type_alias_impl_trait)] | ||
| 2 | |||
| 3 | use clap::Parser; | ||
| 4 | use embassy_executor::{Executor, Spawner}; | ||
| 5 | use embassy_net::udp::UdpSocket; | ||
| 6 | use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, PacketMetadata, Stack, StackResources}; | ||
| 7 | use embassy_util::Forever; | ||
| 8 | use heapless::Vec; | ||
| 9 | use log::*; | ||
| 10 | use rand_core::{OsRng, RngCore}; | ||
| 11 | |||
| 12 | #[path = "../tuntap.rs"] | ||
| 13 | mod tuntap; | ||
| 14 | |||
| 15 | use crate::tuntap::TunTapDevice; | ||
| 16 | |||
| 17 | macro_rules! forever { | ||
| 18 | ($val:expr) => {{ | ||
| 19 | type T = impl Sized; | ||
| 20 | static FOREVER: Forever<T> = Forever::new(); | ||
| 21 | FOREVER.put_with(move || $val) | ||
| 22 | }}; | ||
| 23 | } | ||
| 24 | |||
| 25 | #[derive(Parser)] | ||
| 26 | #[clap(version = "1.0")] | ||
| 27 | struct Opts { | ||
| 28 | /// TAP device name | ||
| 29 | #[clap(long, default_value = "tap0")] | ||
| 30 | tap: String, | ||
| 31 | /// use a static IP instead of DHCP | ||
| 32 | #[clap(long)] | ||
| 33 | static_ip: bool, | ||
| 34 | } | ||
| 35 | |||
| 36 | #[embassy_executor::task] | ||
| 37 | async fn net_task(stack: &'static Stack<TunTapDevice>) -> ! { | ||
| 38 | stack.run().await | ||
| 39 | } | ||
| 40 | |||
| 41 | #[embassy_executor::task] | ||
| 42 | async fn main_task(spawner: Spawner) { | ||
| 43 | let opts: Opts = Opts::parse(); | ||
| 44 | |||
| 45 | // Init network device | ||
| 46 | let device = TunTapDevice::new(&opts.tap).unwrap(); | ||
| 47 | |||
| 48 | // Choose between dhcp or static ip | ||
| 49 | let config = if opts.static_ip { | ||
| 50 | ConfigStrategy::Static(embassy_net::Config { | ||
| 51 | address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), | ||
| 52 | dns_servers: Vec::new(), | ||
| 53 | gateway: Some(Ipv4Address::new(192, 168, 69, 1)), | ||
| 54 | }) | ||
| 55 | } else { | ||
| 56 | ConfigStrategy::Dhcp | ||
| 57 | }; | ||
| 58 | |||
| 59 | // Generate random seed | ||
| 60 | let mut seed = [0; 8]; | ||
| 61 | OsRng.fill_bytes(&mut seed); | ||
| 62 | let seed = u64::from_le_bytes(seed); | ||
| 63 | |||
| 64 | // Init network stack | ||
| 65 | let stack = &*forever!(Stack::new( | ||
| 66 | device, | ||
| 67 | config, | ||
| 68 | forever!(StackResources::<1, 2, 8>::new()), | ||
| 69 | seed | ||
| 70 | )); | ||
| 71 | |||
| 72 | // Launch network task | ||
| 73 | spawner.spawn(net_task(stack)).unwrap(); | ||
| 74 | |||
| 75 | // Then we can use it! | ||
| 76 | let mut rx_meta = [PacketMetadata::EMPTY; 16]; | ||
| 77 | let mut rx_buffer = [0; 4096]; | ||
| 78 | let mut tx_meta = [PacketMetadata::EMPTY; 16]; | ||
| 79 | let mut tx_buffer = [0; 4096]; | ||
| 80 | let mut buf = [0; 4096]; | ||
| 81 | |||
| 82 | let mut socket = UdpSocket::new(stack, &mut rx_meta, &mut rx_buffer, &mut tx_meta, &mut tx_buffer); | ||
| 83 | socket.bind(9400).unwrap(); | ||
| 84 | |||
| 85 | loop { | ||
| 86 | let (n, ep) = socket.recv_from(&mut buf).await.unwrap(); | ||
| 87 | if let Ok(s) = core::str::from_utf8(&buf[..n]) { | ||
| 88 | info!("ECHO (to {}): {}", ep, s); | ||
| 89 | } else { | ||
| 90 | info!("ECHO (to {}): bytearray len {}", ep, n); | ||
| 91 | } | ||
| 92 | socket.send_to(&buf[..n], ep).await.unwrap(); | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 96 | static EXECUTOR: Forever<Executor> = Forever::new(); | ||
| 97 | |||
| 98 | fn main() { | ||
| 99 | env_logger::builder() | ||
| 100 | .filter_level(log::LevelFilter::Debug) | ||
| 101 | .filter_module("async_io", log::LevelFilter::Info) | ||
| 102 | .format_timestamp_nanos() | ||
| 103 | .init(); | ||
| 104 | |||
| 105 | let executor = EXECUTOR.put(Executor::new()); | ||
| 106 | executor.run(|spawner| { | ||
| 107 | spawner.spawn(main_task(spawner)).unwrap(); | ||
| 108 | }); | ||
| 109 | } | ||
diff --git a/examples/std/src/bin/serial.rs b/examples/std/src/bin/serial.rs index b803d1ef7..35cba4cee 100644 --- a/examples/std/src/bin/serial.rs +++ b/examples/std/src/bin/serial.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | mod serial_port; | 4 | mod serial_port; |
| 5 | 5 | ||
| 6 | use async_io::Async; | 6 | use async_io::Async; |
| 7 | use embassy_executor::executor::Executor; | 7 | use embassy_executor::Executor; |
| 8 | use embassy_util::Forever; | 8 | use embassy_util::Forever; |
| 9 | use embedded_io::asynch::Read; | 9 | use embedded_io::asynch::Read; |
| 10 | use log::*; | 10 | use log::*; |
diff --git a/examples/std/src/bin/tick.rs b/examples/std/src/bin/tick.rs index 9ca900df8..b9de9d873 100644 --- a/examples/std/src/bin/tick.rs +++ b/examples/std/src/bin/tick.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![feature(type_alias_impl_trait)] | 1 | #![feature(type_alias_impl_trait)] |
| 2 | 2 | ||
| 3 | use embassy_executor::executor::Spawner; | 3 | use embassy_executor::Spawner; |
| 4 | use embassy_executor::time::{Duration, Timer}; | 4 | use embassy_time::{Duration, Timer}; |
| 5 | use log::*; | 5 | use log::*; |
| 6 | 6 | ||
| 7 | #[embassy_executor::task] | 7 | #[embassy_executor::task] |
diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index 3ba297636..8476200d4 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml | |||
| @@ -6,12 +6,13 @@ edition = "2021" | |||
| 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
| 7 | 7 | ||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | cortex-m = "0.7.3" | 9 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 10 | cortex-m-rt = "0.7.0" | 10 | cortex-m-rt = "0.7.0" |
| 11 | defmt = "0.3" | 11 | defmt = "0.3" |
| 12 | defmt-rtt = "0.3" | 12 | defmt-rtt = "0.3" |
| 13 | panic-probe = "0.3" | 13 | panic-probe = "0.3" |
| 14 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 14 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 15 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } | 15 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 16 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | ||
| 16 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "memory-x", "stm32f030f4", "time-driver-any"] } | 17 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "memory-x", "stm32f030f4", "time-driver-any"] } |
| 17 | 18 | ||
diff --git a/examples/stm32f0/src/bin/hello.rs b/examples/stm32f0/src/bin/hello.rs index c9081ea12..db78233ea 100644 --- a/examples/stm32f0/src/bin/hello.rs +++ b/examples/stm32f0/src/bin/hello.rs | |||
| @@ -3,13 +3,13 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | 7 | use embassy_time::{Duration, Timer}; |
| 8 | use embassy_stm32::Peripherals; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 9 | ||
| 11 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner, _p: Peripherals) -> ! { | 11 | async fn main(_spawner: Spawner) -> ! { |
| 12 | let _p = embassy_stm32::init(Default::default()); | ||
| 13 | loop { | 13 | loop { |
| 14 | Timer::after(Duration::from_secs(1)).await; | 14 | Timer::after(Duration::from_secs(1)).await; |
| 15 | info!("Hello"); | 15 | info!("Hello"); |
diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml index 9ce553b6d..fbc96400c 100644 --- a/examples/stm32f1/Cargo.toml +++ b/examples/stm32f1/Cargo.toml | |||
| @@ -5,7 +5,8 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any"] } |
| 10 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 11 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
| 11 | embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"] } | 12 | embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"] } |
| @@ -13,7 +14,7 @@ embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", fea | |||
| 13 | defmt = "0.3" | 14 | defmt = "0.3" |
| 14 | defmt-rtt = "0.3" | 15 | defmt-rtt = "0.3" |
| 15 | 16 | ||
| 16 | cortex-m = "0.7.3" | 17 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 17 | cortex-m-rt = "0.7.0" | 18 | cortex-m-rt = "0.7.0" |
| 18 | embedded-hal = "0.2.6" | 19 | embedded-hal = "0.2.6" |
| 19 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 20 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
diff --git a/examples/stm32f1/src/bin/adc.rs b/examples/stm32f1/src/bin/adc.rs index e54593fe5..2d6b4a0e9 100644 --- a/examples/stm32f1/src/bin/adc.rs +++ b/examples/stm32f1/src/bin/adc.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Delay, Duration, Timer}; | ||
| 8 | use embassy_stm32::adc::Adc; | 7 | use embassy_stm32::adc::Adc; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Delay, Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut adc = Adc::new(p.ADC1, &mut Delay); | 16 | let mut adc = Adc::new(p.ADC1, &mut Delay); |
diff --git a/examples/stm32f1/src/bin/blinky.rs b/examples/stm32f1/src/bin/blinky.rs index 5171043e8..b9b0ac238 100644 --- a/examples/stm32f1/src/bin/blinky.rs +++ b/examples/stm32f1/src/bin/blinky.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PC13, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PC13, Level::High, Speed::Low); |
diff --git a/examples/stm32f1/src/bin/hello.rs b/examples/stm32f1/src/bin/hello.rs index 549d1bfba..180b6aabd 100644 --- a/examples/stm32f1/src/bin/hello.rs +++ b/examples/stm32f1/src/bin/hello.rs | |||
| @@ -3,20 +3,18 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 9 | use embassy_stm32::{Config, Peripherals}; | 8 | use embassy_stm32::Config; |
| 9 | use embassy_time::{Duration, Timer}; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | fn config() -> Config { | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) -> ! { | ||
| 13 | let mut config = Config::default(); | 14 | let mut config = Config::default(); |
| 14 | config.rcc.sys_ck = Some(Hertz(36_000_000)); | 15 | config.rcc.sys_ck = Some(Hertz(36_000_000)); |
| 15 | config | 16 | let _p = embassy_stm32::init(config); |
| 16 | } | ||
| 17 | 17 | ||
| 18 | #[embassy_executor::main(config = "config()")] | ||
| 19 | async fn main(_spawner: Spawner, _p: Peripherals) -> ! { | ||
| 20 | loop { | 18 | loop { |
| 21 | info!("Hello World!"); | 19 | info!("Hello World!"); |
| 22 | Timer::after(Duration::from_secs(1)).await; | 20 | Timer::after(Duration::from_secs(1)).await; |
diff --git a/examples/stm32f1/src/bin/usb_serial.rs b/examples/stm32f1/src/bin/usb_serial.rs index cf7facb79..a9c46068f 100644 --- a/examples/stm32f1/src/bin/usb_serial.rs +++ b/examples/stm32f1/src/bin/usb_serial.rs | |||
| @@ -3,28 +3,26 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{panic, *}; | 5 | use defmt::{panic, *}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::time::Hertz; | 8 | use embassy_stm32::time::Hertz; |
| 10 | use embassy_stm32::usb::{Driver, Instance}; | 9 | use embassy_stm32::usb::{Driver, Instance}; |
| 11 | use embassy_stm32::{interrupt, Config, Peripherals}; | 10 | use embassy_stm32::{interrupt, Config}; |
| 11 | use embassy_time::{Duration, Timer}; | ||
| 12 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 13 | use embassy_usb::Builder; | 13 | use embassy_usb::Builder; |
| 14 | use embassy_usb_serial::{CdcAcmClass, State}; | 14 | use embassy_usb_serial::{CdcAcmClass, State}; |
| 15 | use futures::future::join; | 15 | use futures::future::join; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 17 | ||
| 18 | fn config() -> Config { | 18 | #[embassy_executor::main] |
| 19 | async fn main(_spawner: Spawner) { | ||
| 19 | let mut config = Config::default(); | 20 | let mut config = Config::default(); |
| 20 | config.rcc.hse = Some(Hertz(8_000_000)); | 21 | config.rcc.hse = Some(Hertz(8_000_000)); |
| 21 | config.rcc.sys_ck = Some(Hertz(48_000_000)); | 22 | config.rcc.sys_ck = Some(Hertz(48_000_000)); |
| 22 | config.rcc.pclk1 = Some(Hertz(24_000_000)); | 23 | config.rcc.pclk1 = Some(Hertz(24_000_000)); |
| 23 | config | 24 | let mut p = embassy_stm32::init(config); |
| 24 | } | ||
| 25 | 25 | ||
| 26 | #[embassy_executor::main(config = "config()")] | ||
| 27 | async fn main(_spawner: Spawner, mut p: Peripherals) { | ||
| 28 | info!("Hello World!"); | 26 | info!("Hello World!"); |
| 29 | 27 | ||
| 30 | { | 28 | { |
diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml index a3fb736da..27894df50 100644 --- a/examples/stm32f2/Cargo.toml +++ b/examples/stm32f2/Cargo.toml | |||
| @@ -5,13 +5,14 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } |
| 10 | 11 | ||
| 11 | defmt = "0.3" | 12 | defmt = "0.3" |
| 12 | defmt-rtt = "0.3" | 13 | defmt-rtt = "0.3" |
| 13 | 14 | ||
| 14 | cortex-m = "0.7.3" | 15 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 15 | cortex-m-rt = "0.7.0" | 16 | cortex-m-rt = "0.7.0" |
| 16 | embedded-hal = "0.2.6" | 17 | embedded-hal = "0.2.6" |
| 17 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 18 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
diff --git a/examples/stm32f2/src/bin/blinky.rs b/examples/stm32f2/src/bin/blinky.rs index 48ae2e711..d8c89a519 100644 --- a/examples/stm32f2/src/bin/blinky.rs +++ b/examples/stm32f2/src/bin/blinky.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); |
diff --git a/examples/stm32f2/src/bin/pll.rs b/examples/stm32f2/src/bin/pll.rs index 01e63b15e..17f09538c 100644 --- a/examples/stm32f2/src/bin/pll.rs +++ b/examples/stm32f2/src/bin/pll.rs | |||
| @@ -5,17 +5,19 @@ | |||
| 5 | use core::convert::TryFrom; | 5 | use core::convert::TryFrom; |
| 6 | 6 | ||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy_executor::executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_executor::time::{Duration, Timer}; | ||
| 10 | use embassy_stm32::rcc::{ | 9 | use embassy_stm32::rcc::{ |
| 11 | APBPrescaler, ClockSrc, HSEConfig, HSESrc, PLL48Div, PLLConfig, PLLMainDiv, PLLMul, PLLPreDiv, PLLSrc, | 10 | APBPrescaler, ClockSrc, HSEConfig, HSESrc, PLL48Div, PLLConfig, PLLMainDiv, PLLMul, PLLPreDiv, PLLSrc, |
| 12 | }; | 11 | }; |
| 13 | use embassy_stm32::time::Hertz; | 12 | use embassy_stm32::time::Hertz; |
| 14 | use embassy_stm32::{Config, Peripherals}; | 13 | use embassy_stm32::Config; |
| 14 | use embassy_time::{Duration, Timer}; | ||
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
| 17 | // Example config for maximum performance on a NUCLEO-F207ZG board | 17 | #[embassy_executor::main] |
| 18 | fn config() -> Config { | 18 | async fn main(_spawner: Spawner) { |
| 19 | // Example config for maximum performance on a NUCLEO-F207ZG board | ||
| 20 | |||
| 19 | let mut config = Config::default(); | 21 | let mut config = Config::default(); |
| 20 | // By default, HSE on the board comes from a 8 MHz clock signal (not a crystal) | 22 | // By default, HSE on the board comes from a 8 MHz clock signal (not a crystal) |
| 21 | config.rcc.hse = Some(HSEConfig { | 23 | config.rcc.hse = Some(HSEConfig { |
| @@ -40,11 +42,9 @@ fn config() -> Config { | |||
| 40 | config.rcc.apb1_pre = APBPrescaler::Div4; | 42 | config.rcc.apb1_pre = APBPrescaler::Div4; |
| 41 | // 120 MHz / 2 = 60 MHz APB2 frequency | 43 | // 120 MHz / 2 = 60 MHz APB2 frequency |
| 42 | config.rcc.apb2_pre = APBPrescaler::Div2; | 44 | config.rcc.apb2_pre = APBPrescaler::Div2; |
| 43 | config | ||
| 44 | } | ||
| 45 | 45 | ||
| 46 | #[embassy_executor::main(config = "config()")] | 46 | let _p = embassy_stm32::init(config); |
| 47 | async fn main(_spawner: Spawner, _p: Peripherals) { | 47 | |
| 48 | loop { | 48 | loop { |
| 49 | Timer::after(Duration::from_millis(1000)).await; | 49 | Timer::after(Duration::from_millis(1000)).await; |
| 50 | info!("1s elapsed"); | 50 | info!("1s elapsed"); |
diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index 410e9b3e0..b5ea28bb6 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml | |||
| @@ -5,7 +5,8 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } |
| 10 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 11 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
| 11 | embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"] } | 12 | embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"] } |
| @@ -14,7 +15,7 @@ embassy-usb-hid = { version = "0.1.0", path = "../../embassy-usb-hid", features | |||
| 14 | defmt = "0.3" | 15 | defmt = "0.3" |
| 15 | defmt-rtt = "0.3" | 16 | defmt-rtt = "0.3" |
| 16 | 17 | ||
| 17 | cortex-m = "0.7.3" | 18 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 18 | cortex-m-rt = "0.7.0" | 19 | cortex-m-rt = "0.7.0" |
| 19 | embedded-hal = "0.2.6" | 20 | embedded-hal = "0.2.6" |
| 20 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 21 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
diff --git a/examples/stm32f3/src/bin/blinky.rs b/examples/stm32f3/src/bin/blinky.rs index 7146eaa54..185785ceb 100644 --- a/examples/stm32f3/src/bin/blinky.rs +++ b/examples/stm32f3/src/bin/blinky.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PA5, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PA5, Level::High, Speed::Low); |
diff --git a/examples/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs index ef5110316..61fc6dcab 100644 --- a/examples/stm32f3/src/bin/button_events.rs +++ b/examples/stm32f3/src/bin/button_events.rs | |||
| @@ -11,12 +11,11 @@ | |||
| 11 | #![feature(type_alias_impl_trait)] | 11 | #![feature(type_alias_impl_trait)] |
| 12 | 12 | ||
| 13 | use defmt::*; | 13 | use defmt::*; |
| 14 | use embassy_executor::executor::Spawner; | 14 | use embassy_executor::Spawner; |
| 15 | use embassy_executor::time::{with_timeout, Duration, Timer}; | ||
| 16 | use embassy_stm32::exti::ExtiInput; | 15 | use embassy_stm32::exti::ExtiInput; |
| 17 | use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; | 16 | use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; |
| 18 | use embassy_stm32::peripherals::PA0; | 17 | use embassy_stm32::peripherals::PA0; |
| 19 | use embassy_stm32::Peripherals; | 18 | use embassy_time::{with_timeout, Duration, Timer}; |
| 20 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | 19 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; |
| 21 | use embassy_util::channel::mpmc::Channel; | 20 | use embassy_util::channel::mpmc::Channel; |
| 22 | use {defmt_rtt as _, panic_probe as _}; | 21 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -100,7 +99,8 @@ enum ButtonEvent { | |||
| 100 | static CHANNEL: Channel<ThreadModeRawMutex, ButtonEvent, 4> = Channel::new(); | 99 | static CHANNEL: Channel<ThreadModeRawMutex, ButtonEvent, 4> = Channel::new(); |
| 101 | 100 | ||
| 102 | #[embassy_executor::main] | 101 | #[embassy_executor::main] |
| 103 | async fn main(spawner: Spawner, p: Peripherals) { | 102 | async fn main(spawner: Spawner) { |
| 103 | let p = embassy_stm32::init(Default::default()); | ||
| 104 | let button = Input::new(p.PA0, Pull::Down); | 104 | let button = Input::new(p.PA0, Pull::Down); |
| 105 | let button = ExtiInput::new(button, p.EXTI0); | 105 | let button = ExtiInput::new(button, p.EXTI0); |
| 106 | info!("Press the USER button..."); | 106 | info!("Press the USER button..."); |
diff --git a/examples/stm32f3/src/bin/button_exti.rs b/examples/stm32f3/src/bin/button_exti.rs index dee06e5de..1266778c1 100644 --- a/examples/stm32f3/src/bin/button_exti.rs +++ b/examples/stm32f3/src/bin/button_exti.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::exti::ExtiInput; | 7 | use embassy_stm32::exti::ExtiInput; |
| 8 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 9 | use embassy_stm32::Peripherals; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let button = Input::new(p.PA0, Pull::Down); | 16 | let button = Input::new(p.PA0, Pull::Down); |
diff --git a/examples/stm32f3/src/bin/flash.rs b/examples/stm32f3/src/bin/flash.rs index be2f6f671..2cf24dbd3 100644 --- a/examples/stm32f3/src/bin/flash.rs +++ b/examples/stm32f3/src/bin/flash.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::flash::Flash; | 7 | use embassy_stm32::flash::Flash; |
| 8 | use embassy_stm32::Peripherals; | ||
| 9 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; | 8 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello Flash!"); | 14 | info!("Hello Flash!"); |
| 15 | 15 | ||
| 16 | const ADDR: u32 = 0x26000; | 16 | const ADDR: u32 = 0x26000; |
diff --git a/examples/stm32f3/src/bin/hello.rs b/examples/stm32f3/src/bin/hello.rs index bd9953a0e..65773210d 100644 --- a/examples/stm32f3/src/bin/hello.rs +++ b/examples/stm32f3/src/bin/hello.rs | |||
| @@ -3,21 +3,19 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 9 | use embassy_stm32::{Config, Peripherals}; | 8 | use embassy_stm32::Config; |
| 9 | use embassy_time::{Duration, Timer}; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | fn config() -> Config { | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) -> ! { | ||
| 13 | let mut config = Config::default(); | 14 | let mut config = Config::default(); |
| 14 | config.rcc.hse = Some(Hertz(8_000_000)); | 15 | config.rcc.hse = Some(Hertz(8_000_000)); |
| 15 | config.rcc.sysclk = Some(Hertz(16_000_000)); | 16 | config.rcc.sysclk = Some(Hertz(16_000_000)); |
| 16 | config | 17 | let _p = embassy_stm32::init(config); |
| 17 | } | ||
| 18 | 18 | ||
| 19 | #[embassy_executor::main(config = "config()")] | ||
| 20 | async fn main(_spawner: Spawner, _p: Peripherals) -> ! { | ||
| 21 | loop { | 19 | loop { |
| 22 | info!("Hello World!"); | 20 | info!("Hello World!"); |
| 23 | Timer::after(Duration::from_secs(1)).await; | 21 | Timer::after(Duration::from_secs(1)).await; |
diff --git a/examples/stm32f3/src/bin/multiprio.rs b/examples/stm32f3/src/bin/multiprio.rs index fba5b286e..e96c31249 100644 --- a/examples/stm32f3/src/bin/multiprio.rs +++ b/examples/stm32f3/src/bin/multiprio.rs | |||
| @@ -59,10 +59,10 @@ | |||
| 59 | 59 | ||
| 60 | use cortex_m_rt::entry; | 60 | use cortex_m_rt::entry; |
| 61 | use defmt::*; | 61 | use defmt::*; |
| 62 | use embassy_executor::time::{Duration, Instant, Timer}; | ||
| 63 | use embassy_stm32::executor::{Executor, InterruptExecutor}; | 62 | use embassy_stm32::executor::{Executor, InterruptExecutor}; |
| 64 | use embassy_stm32::interrupt; | 63 | use embassy_stm32::interrupt; |
| 65 | use embassy_stm32::interrupt::InterruptExt; | 64 | use embassy_stm32::interrupt::InterruptExt; |
| 65 | use embassy_time::{Duration, Instant, Timer}; | ||
| 66 | use embassy_util::Forever; | 66 | use embassy_util::Forever; |
| 67 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| 68 | 68 | ||
diff --git a/examples/stm32f3/src/bin/spi_dma.rs b/examples/stm32f3/src/bin/spi_dma.rs index f554c509a..95b2b6865 100644 --- a/examples/stm32f3/src/bin/spi_dma.rs +++ b/examples/stm32f3/src/bin/spi_dma.rs | |||
| @@ -6,15 +6,15 @@ use core::fmt::Write; | |||
| 6 | use core::str::from_utf8; | 6 | use core::str::from_utf8; |
| 7 | 7 | ||
| 8 | use defmt::*; | 8 | use defmt::*; |
| 9 | use embassy_executor::executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::spi::{Config, Spi}; | 10 | use embassy_stm32::spi::{Config, Spi}; |
| 11 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| 12 | use embassy_stm32::Peripherals; | ||
| 13 | use heapless::String; | 12 | use heapless::String; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 14 | ||
| 16 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| 17 | async fn main(_spawner: Spawner, p: Peripherals) { | 16 | async fn main(_spawner: Spawner) { |
| 17 | let p = embassy_stm32::init(Default::default()); | ||
| 18 | info!("Hello World!"); | 18 | info!("Hello World!"); |
| 19 | 19 | ||
| 20 | let mut spi = Spi::new( | 20 | let mut spi = Spi::new( |
diff --git a/examples/stm32f3/src/bin/usart_dma.rs b/examples/stm32f3/src/bin/usart_dma.rs index 62d165029..3bc5a287f 100644 --- a/examples/stm32f3/src/bin/usart_dma.rs +++ b/examples/stm32f3/src/bin/usart_dma.rs | |||
| @@ -5,15 +5,15 @@ | |||
| 5 | use core::fmt::Write; | 5 | use core::fmt::Write; |
| 6 | 6 | ||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy_executor::executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::dma::NoDma; | 9 | use embassy_stm32::dma::NoDma; |
| 10 | use embassy_stm32::usart::{Config, Uart}; | 10 | use embassy_stm32::usart::{Config, Uart}; |
| 11 | use embassy_stm32::Peripherals; | ||
| 12 | use heapless::String; | 11 | use heapless::String; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 13 | ||
| 15 | #[embassy_executor::main] | 14 | #[embassy_executor::main] |
| 16 | async fn main(_spawner: Spawner, p: Peripherals) { | 15 | async fn main(_spawner: Spawner) { |
| 16 | let p = embassy_stm32::init(Default::default()); | ||
| 17 | info!("Hello World!"); | 17 | info!("Hello World!"); |
| 18 | 18 | ||
| 19 | let config = Config::default(); | 19 | let config = Config::default(); |
diff --git a/examples/stm32f3/src/bin/usb_serial.rs b/examples/stm32f3/src/bin/usb_serial.rs index 87b1138f5..d3702fc35 100644 --- a/examples/stm32f3/src/bin/usb_serial.rs +++ b/examples/stm32f3/src/bin/usb_serial.rs | |||
| @@ -3,32 +3,28 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{panic, *}; | 5 | use defmt::{panic, *}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::time::mhz; | 8 | use embassy_stm32::time::mhz; |
| 10 | use embassy_stm32::usb::{Driver, Instance}; | 9 | use embassy_stm32::usb::{Driver, Instance}; |
| 11 | use embassy_stm32::{interrupt, Config, Peripherals}; | 10 | use embassy_stm32::{interrupt, Config}; |
| 11 | use embassy_time::{Duration, Timer}; | ||
| 12 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 13 | use embassy_usb::Builder; | 13 | use embassy_usb::Builder; |
| 14 | use embassy_usb_serial::{CdcAcmClass, State}; | 14 | use embassy_usb_serial::{CdcAcmClass, State}; |
| 15 | use futures::future::join; | 15 | use futures::future::join; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 17 | ||
| 18 | fn config() -> Config { | 18 | #[embassy_executor::main] |
| 19 | async fn main(_spawner: Spawner) { | ||
| 19 | let mut config = Config::default(); | 20 | let mut config = Config::default(); |
| 20 | |||
| 21 | config.rcc.hse = Some(mhz(8)); | 21 | config.rcc.hse = Some(mhz(8)); |
| 22 | config.rcc.sysclk = Some(mhz(48)); | 22 | config.rcc.sysclk = Some(mhz(48)); |
| 23 | config.rcc.pclk1 = Some(mhz(24)); | 23 | config.rcc.pclk1 = Some(mhz(24)); |
| 24 | config.rcc.pclk2 = Some(mhz(24)); | 24 | config.rcc.pclk2 = Some(mhz(24)); |
| 25 | config.rcc.pll48 = true; | 25 | config.rcc.pll48 = true; |
| 26 | let p = embassy_stm32::init(config); | ||
| 26 | 27 | ||
| 27 | config | ||
| 28 | } | ||
| 29 | |||
| 30 | #[embassy_executor::main(config = "config()")] | ||
| 31 | async fn main(_spawner: Spawner, p: Peripherals) { | ||
| 32 | info!("Hello World!"); | 28 | info!("Hello World!"); |
| 33 | 29 | ||
| 34 | // Needed for nucleo-stm32f303ze | 30 | // Needed for nucleo-stm32f303ze |
diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index 3c58320dd..04a217aff 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml | |||
| @@ -6,13 +6,14 @@ version = "0.1.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 8 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "time-tick-32768hz"] } | 9 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-32768hz"] } | ||
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti"] } |
| 11 | 12 | ||
| 12 | defmt = "0.3" | 13 | defmt = "0.3" |
| 13 | defmt-rtt = "0.3" | 14 | defmt-rtt = "0.3" |
| 14 | 15 | ||
| 15 | cortex-m = "0.7.3" | 16 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 16 | cortex-m-rt = "0.7.0" | 17 | cortex-m-rt = "0.7.0" |
| 17 | embedded-hal = "0.2.6" | 18 | embedded-hal = "0.2.6" |
| 18 | embedded-io = "0.3.0" | 19 | embedded-io = "0.3.0" |
diff --git a/examples/stm32f4/src/bin/adc.rs b/examples/stm32f4/src/bin/adc.rs index 27ed4fcc5..871185074 100644 --- a/examples/stm32f4/src/bin/adc.rs +++ b/examples/stm32f4/src/bin/adc.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Delay, Duration, Timer}; | ||
| 8 | use embassy_stm32::adc::Adc; | 7 | use embassy_stm32::adc::Adc; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Delay, Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut adc = Adc::new(p.ADC1, &mut Delay); | 16 | let mut adc = Adc::new(p.ADC1, &mut Delay); |
diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs index f71fe0989..b27bee4ce 100644 --- a/examples/stm32f4/src/bin/blinky.rs +++ b/examples/stm32f4/src/bin/blinky.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); |
diff --git a/examples/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs index 60dfb362b..dfe587d41 100644 --- a/examples/stm32f4/src/bin/button_exti.rs +++ b/examples/stm32f4/src/bin/button_exti.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::exti::ExtiInput; | 7 | use embassy_stm32::exti::ExtiInput; |
| 8 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 9 | use embassy_stm32::Peripherals; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let button = Input::new(p.PC13, Pull::Down); | 16 | let button = Input::new(p.PC13, Pull::Down); |
diff --git a/examples/stm32f4/src/bin/dac.rs b/examples/stm32f4/src/bin/dac.rs index 392f5bf4d..d97ae7082 100644 --- a/examples/stm32f4/src/bin/dac.rs +++ b/examples/stm32f4/src/bin/dac.rs | |||
| @@ -3,13 +3,13 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::dac::{Channel, Dac, Value}; | 7 | use embassy_stm32::dac::{Channel, Dac, Value}; |
| 8 | use embassy_stm32::Peripherals; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 9 | ||
| 11 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner, p: Peripherals) -> ! { | 11 | async fn main(_spawner: Spawner) -> ! { |
| 12 | let p = embassy_stm32::init(Default::default()); | ||
| 13 | info!("Hello World, dude!"); | 13 | info!("Hello World, dude!"); |
| 14 | 14 | ||
| 15 | let mut dac = Dac::new_1ch(p.DAC, p.PA4); | 15 | let mut dac = Dac::new_1ch(p.DAC, p.PA4); |
diff --git a/examples/stm32f4/src/bin/flash.rs b/examples/stm32f4/src/bin/flash.rs index 4f780656e..393d61e86 100644 --- a/examples/stm32f4/src/bin/flash.rs +++ b/examples/stm32f4/src/bin/flash.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::flash::Flash; | 7 | use embassy_stm32::flash::Flash; |
| 8 | use embassy_stm32::Peripherals; | ||
| 9 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; | 8 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello Flash!"); | 14 | info!("Hello Flash!"); |
| 15 | 15 | ||
| 16 | let mut f = Flash::unlock(p.FLASH); | 16 | let mut f = Flash::unlock(p.FLASH); |
diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs index f957656ef..c409703f5 100644 --- a/examples/stm32f4/src/bin/hello.rs +++ b/examples/stm32f4/src/bin/hello.rs | |||
| @@ -3,20 +3,18 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 9 | use embassy_stm32::{Config, Peripherals}; | 8 | use embassy_stm32::Config; |
| 9 | use embassy_time::{Duration, Timer}; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | fn config() -> Config { | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) -> ! { | ||
| 13 | let mut config = Config::default(); | 14 | let mut config = Config::default(); |
| 14 | config.rcc.sys_ck = Some(Hertz(84_000_000)); | 15 | config.rcc.sys_ck = Some(Hertz(84_000_000)); |
| 15 | config | 16 | let _p = embassy_stm32::init(config); |
| 16 | } | ||
| 17 | 17 | ||
| 18 | #[embassy_executor::main(config = "config()")] | ||
| 19 | async fn main(_spawner: Spawner, _p: Peripherals) -> ! { | ||
| 20 | loop { | 18 | loop { |
| 21 | info!("Hello World!"); | 19 | info!("Hello World!"); |
| 22 | Timer::after(Duration::from_secs(1)).await; | 20 | Timer::after(Duration::from_secs(1)).await; |
diff --git a/examples/stm32f4/src/bin/multiprio.rs b/examples/stm32f4/src/bin/multiprio.rs index fba5b286e..e96c31249 100644 --- a/examples/stm32f4/src/bin/multiprio.rs +++ b/examples/stm32f4/src/bin/multiprio.rs | |||
| @@ -59,10 +59,10 @@ | |||
| 59 | 59 | ||
| 60 | use cortex_m_rt::entry; | 60 | use cortex_m_rt::entry; |
| 61 | use defmt::*; | 61 | use defmt::*; |
| 62 | use embassy_executor::time::{Duration, Instant, Timer}; | ||
| 63 | use embassy_stm32::executor::{Executor, InterruptExecutor}; | 62 | use embassy_stm32::executor::{Executor, InterruptExecutor}; |
| 64 | use embassy_stm32::interrupt; | 63 | use embassy_stm32::interrupt; |
| 65 | use embassy_stm32::interrupt::InterruptExt; | 64 | use embassy_stm32::interrupt::InterruptExt; |
| 65 | use embassy_time::{Duration, Instant, Timer}; | ||
| 66 | use embassy_util::Forever; | 66 | use embassy_util::Forever; |
| 67 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| 68 | 68 | ||
diff --git a/examples/stm32f4/src/bin/pwm.rs b/examples/stm32f4/src/bin/pwm.rs index 0b352c2b7..7c5902052 100644 --- a/examples/stm32f4/src/bin/pwm.rs +++ b/examples/stm32f4/src/bin/pwm.rs | |||
| @@ -3,16 +3,16 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; | 7 | use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; |
| 9 | use embassy_stm32::pwm::Channel; | 8 | use embassy_stm32::pwm::Channel; |
| 10 | use embassy_stm32::time::khz; | 9 | use embassy_stm32::time::khz; |
| 11 | use embassy_stm32::Peripherals; | 10 | use embassy_time::{Duration, Timer}; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 12 | ||
| 14 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 14 | async fn main(_spawner: Spawner) { |
| 15 | let p = embassy_stm32::init(Default::default()); | ||
| 16 | info!("Hello World!"); | 16 | info!("Hello World!"); |
| 17 | 17 | ||
| 18 | let ch1 = PwmPin::new_ch1(p.PE9); | 18 | let ch1 = PwmPin::new_ch1(p.PE9); |
diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs index 6eef19963..0edd8a61a 100644 --- a/examples/stm32f4/src/bin/sdmmc.rs +++ b/examples/stm32f4/src/bin/sdmmc.rs | |||
| @@ -3,20 +3,17 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::sdmmc::Sdmmc; | 7 | use embassy_stm32::sdmmc::Sdmmc; |
| 8 | use embassy_stm32::time::mhz; | 8 | use embassy_stm32::time::mhz; |
| 9 | use embassy_stm32::{interrupt, Config, Peripherals}; | 9 | use embassy_stm32::{interrupt, Config}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | fn config() -> Config { | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) -> ! { | ||
| 13 | let mut config = Config::default(); | 14 | let mut config = Config::default(); |
| 14 | config.rcc.sys_ck = Some(mhz(48)); | 15 | config.rcc.sys_ck = Some(mhz(48)); |
| 15 | config | 16 | let p = embassy_stm32::init(config); |
| 16 | } | ||
| 17 | |||
| 18 | #[embassy_executor::main(config = "config()")] | ||
| 19 | async fn main(_spawner: Spawner, p: Peripherals) -> ! { | ||
| 20 | info!("Hello World!"); | 17 | info!("Hello World!"); |
| 21 | 18 | ||
| 22 | let irq = interrupt::take!(SDIO); | 19 | let irq = interrupt::take!(SDIO); |
diff --git a/examples/stm32f4/src/bin/spi_dma.rs b/examples/stm32f4/src/bin/spi_dma.rs index 023ca0971..3d2a1a1ae 100644 --- a/examples/stm32f4/src/bin/spi_dma.rs +++ b/examples/stm32f4/src/bin/spi_dma.rs | |||
| @@ -6,15 +6,15 @@ use core::fmt::Write; | |||
| 6 | use core::str::from_utf8; | 6 | use core::str::from_utf8; |
| 7 | 7 | ||
| 8 | use defmt::*; | 8 | use defmt::*; |
| 9 | use embassy_executor::executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::spi::{Config, Spi}; | 10 | use embassy_stm32::spi::{Config, Spi}; |
| 11 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| 12 | use embassy_stm32::Peripherals; | ||
| 13 | use heapless::String; | 12 | use heapless::String; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 14 | ||
| 16 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| 17 | async fn main(_spawner: Spawner, p: Peripherals) { | 16 | async fn main(_spawner: Spawner) { |
| 17 | let p = embassy_stm32::init(Default::default()); | ||
| 18 | info!("Hello World!"); | 18 | info!("Hello World!"); |
| 19 | 19 | ||
| 20 | let mut spi = Spi::new( | 20 | let mut spi = Spi::new( |
diff --git a/examples/stm32f4/src/bin/usart_buffered.rs b/examples/stm32f4/src/bin/usart_buffered.rs index 2555998ce..7bcecbd26 100644 --- a/examples/stm32f4/src/bin/usart_buffered.rs +++ b/examples/stm32f4/src/bin/usart_buffered.rs | |||
| @@ -3,15 +3,16 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::dma::NoDma; | 7 | use embassy_stm32::dma::NoDma; |
| 8 | use embassy_stm32::interrupt; | ||
| 8 | use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; | 9 | use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; |
| 9 | use embassy_stm32::{interrupt, Peripherals}; | ||
| 10 | use embedded_io::asynch::BufRead; | 10 | use embedded_io::asynch::BufRead; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 14 | async fn main(_spawner: Spawner) { |
| 15 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | info!("Hello World!"); | 16 | info!("Hello World!"); |
| 16 | 17 | ||
| 17 | let config = Config::default(); | 18 | let config = Config::default(); |
diff --git a/examples/stm32f4/src/bin/usart_dma.rs b/examples/stm32f4/src/bin/usart_dma.rs index 7859ba2ae..bb41b8b4f 100644 --- a/examples/stm32f4/src/bin/usart_dma.rs +++ b/examples/stm32f4/src/bin/usart_dma.rs | |||
| @@ -5,15 +5,15 @@ | |||
| 5 | use core::fmt::Write; | 5 | use core::fmt::Write; |
| 6 | 6 | ||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy_executor::executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::dma::NoDma; | 9 | use embassy_stm32::dma::NoDma; |
| 10 | use embassy_stm32::usart::{Config, Uart}; | 10 | use embassy_stm32::usart::{Config, Uart}; |
| 11 | use embassy_stm32::Peripherals; | ||
| 12 | use heapless::String; | 11 | use heapless::String; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 13 | ||
| 15 | #[embassy_executor::main] | 14 | #[embassy_executor::main] |
| 16 | async fn main(_spawner: Spawner, p: Peripherals) { | 15 | async fn main(_spawner: Spawner) { |
| 16 | let p = embassy_stm32::init(Default::default()); | ||
| 17 | info!("Hello World!"); | 17 | info!("Hello World!"); |
| 18 | 18 | ||
| 19 | let config = Config::default(); | 19 | let config = Config::default(); |
diff --git a/examples/stm32f4/src/bin/wdt.rs b/examples/stm32f4/src/bin/wdt.rs index 48394f4f1..b2c587fa1 100644 --- a/examples/stm32f4/src/bin/wdt.rs +++ b/examples/stm32f4/src/bin/wdt.rs | |||
| @@ -3,15 +3,15 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::wdg::IndependentWatchdog; | 8 | use embassy_stm32::wdg::IndependentWatchdog; |
| 10 | use embassy_stm32::Peripherals; | 9 | use embassy_time::{Duration, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | info!("Hello World!"); | 15 | info!("Hello World!"); |
| 16 | 16 | ||
| 17 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); | 17 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); |
diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 081bed84f..29d6da4d8 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml | |||
| @@ -5,7 +5,8 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "net", "stm32f767zi", "unstable-pac", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "net", "stm32f767zi", "unstable-pac", "time-driver-any", "exti"] } |
| 10 | embassy-net = { path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"] } | 11 | embassy-net = { path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"] } |
| 11 | embedded-io = { version = "0.3.0", features = ["async"] } | 12 | embedded-io = { version = "0.3.0", features = ["async"] } |
| @@ -13,7 +14,7 @@ embedded-io = { version = "0.3.0", features = ["async"] } | |||
| 13 | defmt = "0.3" | 14 | defmt = "0.3" |
| 14 | defmt-rtt = "0.3" | 15 | defmt-rtt = "0.3" |
| 15 | 16 | ||
| 16 | cortex-m = "0.7.3" | 17 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 17 | cortex-m-rt = "0.7.0" | 18 | cortex-m-rt = "0.7.0" |
| 18 | embedded-hal = "0.2.6" | 19 | embedded-hal = "0.2.6" |
| 19 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 20 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| @@ -21,5 +22,5 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa | |||
| 21 | heapless = { version = "0.7.5", default-features = false } | 22 | heapless = { version = "0.7.5", default-features = false } |
| 22 | nb = "1.0.0" | 23 | nb = "1.0.0" |
| 23 | rand_core = "0.6.3" | 24 | rand_core = "0.6.3" |
| 24 | critical-section = "0.2.3" | 25 | critical-section = "1.1" |
| 25 | embedded-storage = "0.3.0" | 26 | embedded-storage = "0.3.0" |
diff --git a/examples/stm32f7/src/bin/adc.rs b/examples/stm32f7/src/bin/adc.rs index 2a813c050..80fad8c41 100644 --- a/examples/stm32f7/src/bin/adc.rs +++ b/examples/stm32f7/src/bin/adc.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Delay, Duration, Timer}; | ||
| 8 | use embassy_stm32::adc::Adc; | 7 | use embassy_stm32::adc::Adc; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Delay, Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut adc = Adc::new(p.ADC1, &mut Delay); | 16 | let mut adc = Adc::new(p.ADC1, &mut Delay); |
diff --git a/examples/stm32f7/src/bin/blinky.rs b/examples/stm32f7/src/bin/blinky.rs index f71fe0989..b27bee4ce 100644 --- a/examples/stm32f7/src/bin/blinky.rs +++ b/examples/stm32f7/src/bin/blinky.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); |
diff --git a/examples/stm32f7/src/bin/button_exti.rs b/examples/stm32f7/src/bin/button_exti.rs index 60dfb362b..dfe587d41 100644 --- a/examples/stm32f7/src/bin/button_exti.rs +++ b/examples/stm32f7/src/bin/button_exti.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::exti::ExtiInput; | 7 | use embassy_stm32::exti::ExtiInput; |
| 8 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 9 | use embassy_stm32::Peripherals; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let button = Input::new(p.PC13, Pull::Down); | 16 | let button = Input::new(p.PC13, Pull::Down); |
diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index 33504af76..bdffabcb3 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs | |||
| @@ -3,8 +3,7 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_net::tcp::TcpSocket; | 7 | use embassy_net::tcp::TcpSocket; |
| 9 | use embassy_net::{Ipv4Address, Stack, StackResources}; | 8 | use embassy_net::{Ipv4Address, Stack, StackResources}; |
| 10 | use embassy_stm32::eth::generic_smi::GenericSMI; | 9 | use embassy_stm32::eth::generic_smi::GenericSMI; |
| @@ -12,7 +11,8 @@ use embassy_stm32::eth::{Ethernet, State}; | |||
| 12 | use embassy_stm32::peripherals::ETH; | 11 | use embassy_stm32::peripherals::ETH; |
| 13 | use embassy_stm32::rng::Rng; | 12 | use embassy_stm32::rng::Rng; |
| 14 | use embassy_stm32::time::mhz; | 13 | use embassy_stm32::time::mhz; |
| 15 | use embassy_stm32::{interrupt, Config, Peripherals}; | 14 | use embassy_stm32::{interrupt, Config}; |
| 15 | use embassy_time::{Duration, Timer}; | ||
| 16 | use embassy_util::Forever; | 16 | use embassy_util::Forever; |
| 17 | use embedded_io::asynch::Write; | 17 | use embedded_io::asynch::Write; |
| 18 | use rand_core::RngCore; | 18 | use rand_core::RngCore; |
| @@ -33,14 +33,12 @@ async fn net_task(stack: &'static Stack<Device>) -> ! { | |||
| 33 | stack.run().await | 33 | stack.run().await |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | fn config() -> Config { | 36 | #[embassy_executor::main] |
| 37 | async fn main(spawner: Spawner) -> ! { | ||
| 37 | let mut config = Config::default(); | 38 | let mut config = Config::default(); |
| 38 | config.rcc.sys_ck = Some(mhz(200)); | 39 | config.rcc.sys_ck = Some(mhz(200)); |
| 39 | config | 40 | let p = embassy_stm32::init(config); |
| 40 | } | ||
| 41 | 41 | ||
| 42 | #[embassy_executor::main(config = "config()")] | ||
| 43 | async fn main(spawner: Spawner, p: Peripherals) -> ! { | ||
| 44 | info!("Hello World!"); | 42 | info!("Hello World!"); |
| 45 | 43 | ||
| 46 | // Generate random seed. | 44 | // Generate random seed. |
diff --git a/examples/stm32f7/src/bin/flash.rs b/examples/stm32f7/src/bin/flash.rs index 15864cabb..c10781d0c 100644 --- a/examples/stm32f7/src/bin/flash.rs +++ b/examples/stm32f7/src/bin/flash.rs | |||
| @@ -3,15 +3,15 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::flash::Flash; | 7 | use embassy_stm32::flash::Flash; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; | 9 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | info!("Hello Flash!"); | 15 | info!("Hello Flash!"); |
| 16 | 16 | ||
| 17 | const ADDR: u32 = 0x8_0000; | 17 | const ADDR: u32 = 0x8_0000; |
diff --git a/examples/stm32f7/src/bin/hello.rs b/examples/stm32f7/src/bin/hello.rs index f957656ef..c409703f5 100644 --- a/examples/stm32f7/src/bin/hello.rs +++ b/examples/stm32f7/src/bin/hello.rs | |||
| @@ -3,20 +3,18 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 9 | use embassy_stm32::{Config, Peripherals}; | 8 | use embassy_stm32::Config; |
| 9 | use embassy_time::{Duration, Timer}; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | fn config() -> Config { | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) -> ! { | ||
| 13 | let mut config = Config::default(); | 14 | let mut config = Config::default(); |
| 14 | config.rcc.sys_ck = Some(Hertz(84_000_000)); | 15 | config.rcc.sys_ck = Some(Hertz(84_000_000)); |
| 15 | config | 16 | let _p = embassy_stm32::init(config); |
| 16 | } | ||
| 17 | 17 | ||
| 18 | #[embassy_executor::main(config = "config()")] | ||
| 19 | async fn main(_spawner: Spawner, _p: Peripherals) -> ! { | ||
| 20 | loop { | 18 | loop { |
| 21 | info!("Hello World!"); | 19 | info!("Hello World!"); |
| 22 | Timer::after(Duration::from_secs(1)).await; | 20 | Timer::after(Duration::from_secs(1)).await; |
diff --git a/examples/stm32f7/src/bin/sdmmc.rs b/examples/stm32f7/src/bin/sdmmc.rs index 1f321df17..3bf427eca 100644 --- a/examples/stm32f7/src/bin/sdmmc.rs +++ b/examples/stm32f7/src/bin/sdmmc.rs | |||
| @@ -3,20 +3,18 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::sdmmc::Sdmmc; | 7 | use embassy_stm32::sdmmc::Sdmmc; |
| 8 | use embassy_stm32::time::mhz; | 8 | use embassy_stm32::time::mhz; |
| 9 | use embassy_stm32::{interrupt, Config, Peripherals}; | 9 | use embassy_stm32::{interrupt, Config}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | fn config() -> Config { | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) -> ! { | ||
| 13 | let mut config = Config::default(); | 14 | let mut config = Config::default(); |
| 14 | config.rcc.sys_ck = Some(mhz(200)); | 15 | config.rcc.sys_ck = Some(mhz(200)); |
| 15 | config | 16 | let p = embassy_stm32::init(config); |
| 16 | } | ||
| 17 | 17 | ||
| 18 | #[embassy_executor::main(config = "config()")] | ||
| 19 | async fn main(_spawner: Spawner, p: Peripherals) -> ! { | ||
| 20 | info!("Hello World!"); | 18 | info!("Hello World!"); |
| 21 | 19 | ||
| 22 | let irq = interrupt::take!(SDMMC1); | 20 | let irq = interrupt::take!(SDMMC1); |
diff --git a/examples/stm32f7/src/bin/usart_dma.rs b/examples/stm32f7/src/bin/usart_dma.rs index 9884d1634..07270479c 100644 --- a/examples/stm32f7/src/bin/usart_dma.rs +++ b/examples/stm32f7/src/bin/usart_dma.rs | |||
| @@ -5,15 +5,15 @@ | |||
| 5 | use core::fmt::Write; | 5 | use core::fmt::Write; |
| 6 | 6 | ||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy_executor::executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::dma::NoDma; | 9 | use embassy_stm32::dma::NoDma; |
| 10 | use embassy_stm32::usart::{Config, Uart}; | 10 | use embassy_stm32::usart::{Config, Uart}; |
| 11 | use embassy_stm32::Peripherals; | ||
| 12 | use heapless::String; | 11 | use heapless::String; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 13 | ||
| 15 | #[embassy_executor::main] | 14 | #[embassy_executor::main] |
| 16 | async fn main(_spawner: Spawner, p: Peripherals) { | 15 | async fn main(_spawner: Spawner) { |
| 16 | let p = embassy_stm32::init(Default::default()); | ||
| 17 | let config = Config::default(); | 17 | let config = Config::default(); |
| 18 | let mut usart = Uart::new(p.UART7, p.PA8, p.PA15, p.DMA1_CH1, NoDma, config); | 18 | let mut usart = Uart::new(p.UART7, p.PA8, p.PA15, p.DMA1_CH1, NoDma, config); |
| 19 | 19 | ||
diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml index 3dedeac63..5c80d43eb 100644 --- a/examples/stm32g0/Cargo.toml +++ b/examples/stm32g0/Cargo.toml | |||
| @@ -5,13 +5,14 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } |
| 10 | 11 | ||
| 11 | defmt = "0.3" | 12 | defmt = "0.3" |
| 12 | defmt-rtt = "0.3" | 13 | defmt-rtt = "0.3" |
| 13 | 14 | ||
| 14 | cortex-m = "0.7.3" | 15 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 15 | cortex-m-rt = "0.7.0" | 16 | cortex-m-rt = "0.7.0" |
| 16 | embedded-hal = "0.2.6" | 17 | embedded-hal = "0.2.6" |
| 17 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 18 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
diff --git a/examples/stm32g0/src/bin/blinky.rs b/examples/stm32g0/src/bin/blinky.rs index f71fe0989..b27bee4ce 100644 --- a/examples/stm32g0/src/bin/blinky.rs +++ b/examples/stm32g0/src/bin/blinky.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); |
diff --git a/examples/stm32g0/src/bin/button_exti.rs b/examples/stm32g0/src/bin/button_exti.rs index 0832386ed..ef32d4c4a 100644 --- a/examples/stm32g0/src/bin/button_exti.rs +++ b/examples/stm32g0/src/bin/button_exti.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::exti::ExtiInput; | 7 | use embassy_stm32::exti::ExtiInput; |
| 8 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 9 | use embassy_stm32::Peripherals; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let button = Input::new(p.PC13, Pull::Up); | 16 | let button = Input::new(p.PC13, Pull::Up); |
diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml index 60c62ad1e..74c645cf5 100644 --- a/examples/stm32g4/Cargo.toml +++ b/examples/stm32g4/Cargo.toml | |||
| @@ -5,14 +5,15 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } |
| 10 | embassy-hal-common = {version = "0.1.0", path = "../../embassy-hal-common" } | 11 | embassy-hal-common = {version = "0.1.0", path = "../../embassy-hal-common" } |
| 11 | 12 | ||
| 12 | defmt = "0.3" | 13 | defmt = "0.3" |
| 13 | defmt-rtt = "0.3" | 14 | defmt-rtt = "0.3" |
| 14 | 15 | ||
| 15 | cortex-m = "0.7.3" | 16 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 16 | cortex-m-rt = "0.7.0" | 17 | cortex-m-rt = "0.7.0" |
| 17 | embedded-hal = "0.2.6" | 18 | embedded-hal = "0.2.6" |
| 18 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 19 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
diff --git a/examples/stm32g4/src/bin/blinky.rs b/examples/stm32g4/src/bin/blinky.rs index ea3c563b4..8a65b0692 100644 --- a/examples/stm32g4/src/bin/blinky.rs +++ b/examples/stm32g4/src/bin/blinky.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PA5, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PA5, Level::High, Speed::Low); |
diff --git a/examples/stm32g4/src/bin/button_exti.rs b/examples/stm32g4/src/bin/button_exti.rs index 60dfb362b..dfe587d41 100644 --- a/examples/stm32g4/src/bin/button_exti.rs +++ b/examples/stm32g4/src/bin/button_exti.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::exti::ExtiInput; | 7 | use embassy_stm32::exti::ExtiInput; |
| 8 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 9 | use embassy_stm32::Peripherals; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let button = Input::new(p.PC13, Pull::Down); | 16 | let button = Input::new(p.PC13, Pull::Down); |
diff --git a/examples/stm32g4/src/bin/pwm.rs b/examples/stm32g4/src/bin/pwm.rs index 7c16d0a3a..017e89e41 100644 --- a/examples/stm32g4/src/bin/pwm.rs +++ b/examples/stm32g4/src/bin/pwm.rs | |||
| @@ -3,16 +3,16 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; | 7 | use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; |
| 9 | use embassy_stm32::pwm::Channel; | 8 | use embassy_stm32::pwm::Channel; |
| 10 | use embassy_stm32::time::khz; | 9 | use embassy_stm32::time::khz; |
| 11 | use embassy_stm32::Peripherals; | 10 | use embassy_time::{Duration, Timer}; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 12 | ||
| 14 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 14 | async fn main(_spawner: Spawner) { |
| 15 | let p = embassy_stm32::init(Default::default()); | ||
| 16 | info!("Hello World!"); | 16 | info!("Hello World!"); |
| 17 | 17 | ||
| 18 | let ch1 = PwmPin::new_ch1(p.PA5); | 18 | let ch1 = PwmPin::new_ch1(p.PA5); |
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 8b1999b30..a416796ea 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml | |||
| @@ -5,24 +5,26 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "net", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "net", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } |
| 10 | embassy-net = { path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"] } | 11 | embassy-net = { path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16", "unstable-traits"] } |
| 11 | embedded-io = { version = "0.3.0", features = ["async"] } | 12 | embedded-io = { version = "0.3.0", features = ["async"] } |
| 12 | 13 | ||
| 13 | defmt = "0.3" | 14 | defmt = "0.3" |
| 14 | defmt-rtt = "0.3" | 15 | defmt-rtt = "0.3" |
| 15 | 16 | ||
| 16 | cortex-m = "0.7.3" | 17 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 17 | cortex-m-rt = "0.7.0" | 18 | cortex-m-rt = "0.7.0" |
| 18 | embedded-hal = "0.2.6" | 19 | embedded-hal = "0.2.6" |
| 19 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } | 20 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } |
| 20 | embedded-hal-async = { version = "0.1.0-alpha.1" } | 21 | embedded-hal-async = { version = "0.1.0-alpha.1" } |
| 22 | embedded-nal-async = "0.2.0" | ||
| 21 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 23 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 22 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 24 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 23 | heapless = { version = "0.7.5", default-features = false } | 25 | heapless = { version = "0.7.5", default-features = false } |
| 24 | rand_core = "0.6.3" | 26 | rand_core = "0.6.3" |
| 25 | critical-section = "0.2.5" | 27 | critical-section = "1.1" |
| 26 | micromath = "2.0.0" | 28 | micromath = "2.0.0" |
| 27 | stm32-fmc = "0.2.4" | 29 | stm32-fmc = "0.2.4" |
| 28 | embedded-storage = "0.3.0" | 30 | embedded-storage = "0.3.0" |
diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs index f50976a30..0e1e28c72 100644 --- a/examples/stm32h7/src/bin/adc.rs +++ b/examples/stm32h7/src/bin/adc.rs | |||
| @@ -3,25 +3,23 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Delay, Duration, Timer}; | ||
| 8 | use embassy_stm32::adc::{Adc, SampleTime}; | 7 | use embassy_stm32::adc::{Adc, SampleTime}; |
| 9 | use embassy_stm32::rcc::AdcClockSource; | 8 | use embassy_stm32::rcc::AdcClockSource; |
| 10 | use embassy_stm32::time::mhz; | 9 | use embassy_stm32::time::mhz; |
| 11 | use embassy_stm32::{Config, Peripherals}; | 10 | use embassy_stm32::Config; |
| 11 | use embassy_time::{Delay, Duration, Timer}; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | pub fn config() -> Config { | 14 | #[embassy_executor::main] |
| 15 | async fn main(_spawner: Spawner) { | ||
| 15 | let mut config = Config::default(); | 16 | let mut config = Config::default(); |
| 16 | config.rcc.sys_ck = Some(mhz(400)); | 17 | config.rcc.sys_ck = Some(mhz(400)); |
| 17 | config.rcc.hclk = Some(mhz(200)); | 18 | config.rcc.hclk = Some(mhz(200)); |
| 18 | config.rcc.per_ck = Some(mhz(64)); | 19 | config.rcc.per_ck = Some(mhz(64)); |
| 19 | config.rcc.adc_clock_source = AdcClockSource::PerCk; | 20 | config.rcc.adc_clock_source = AdcClockSource::PerCk; |
| 20 | config | 21 | let mut p = embassy_stm32::init(config); |
| 21 | } | ||
| 22 | 22 | ||
| 23 | #[embassy_executor::main(config = "config()")] | ||
| 24 | async fn main(_spawner: Spawner, mut p: Peripherals) { | ||
| 25 | info!("Hello World!"); | 23 | info!("Hello World!"); |
| 26 | 24 | ||
| 27 | let mut adc = Adc::new(p.ADC3, &mut Delay); | 25 | let mut adc = Adc::new(p.ADC3, &mut Delay); |
diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs index 98ce15cc6..12f08c0fd 100644 --- a/examples/stm32h7/src/bin/blinky.rs +++ b/examples/stm32h7/src/bin/blinky.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); |
diff --git a/examples/stm32h7/src/bin/button_exti.rs b/examples/stm32h7/src/bin/button_exti.rs index 60dfb362b..dfe587d41 100644 --- a/examples/stm32h7/src/bin/button_exti.rs +++ b/examples/stm32h7/src/bin/button_exti.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::exti::ExtiInput; | 7 | use embassy_stm32::exti::ExtiInput; |
| 8 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 9 | use embassy_stm32::Peripherals; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let button = Input::new(p.PC13, Pull::Down); | 16 | 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 69187182f..9c443b83a 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs | |||
| @@ -2,18 +2,24 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use embassy_executor::executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_executor::time::{Duration, Timer}; | ||
| 7 | use embassy_stm32::dcmi::{self, *}; | 6 | use embassy_stm32::dcmi::{self, *}; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::i2c::I2c; | 8 | use embassy_stm32::i2c::I2c; |
| 10 | use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; | 9 | use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; |
| 11 | use embassy_stm32::time::{khz, mhz}; | 10 | use embassy_stm32::time::{khz, mhz}; |
| 12 | use embassy_stm32::{interrupt, Config, Peripherals}; | 11 | use embassy_stm32::{interrupt, Config}; |
| 12 | use embassy_time::{Duration, Timer}; | ||
| 13 | use ov7725::*; | ||
| 13 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 15 | ||
| 15 | #[allow(unused)] | 16 | const WIDTH: usize = 100; |
| 16 | pub fn config() -> Config { | 17 | const HEIGHT: usize = 100; |
| 18 | |||
| 19 | static mut FRAME: [u32; WIDTH * HEIGHT / 2] = [0u32; WIDTH * HEIGHT / 2]; | ||
| 20 | |||
| 21 | #[embassy_executor::main] | ||
| 22 | async fn main(_spawner: Spawner) { | ||
| 17 | let mut config = Config::default(); | 23 | let mut config = Config::default(); |
| 18 | config.rcc.sys_ck = Some(mhz(400)); | 24 | config.rcc.sys_ck = Some(mhz(400)); |
| 19 | config.rcc.hclk = Some(mhz(400)); | 25 | config.rcc.hclk = Some(mhz(400)); |
| @@ -22,24 +28,23 @@ pub fn config() -> Config { | |||
| 22 | config.rcc.pclk2 = Some(mhz(100)); | 28 | config.rcc.pclk2 = Some(mhz(100)); |
| 23 | config.rcc.pclk3 = Some(mhz(100)); | 29 | config.rcc.pclk3 = Some(mhz(100)); |
| 24 | config.rcc.pclk4 = Some(mhz(100)); | 30 | config.rcc.pclk4 = Some(mhz(100)); |
| 25 | config | 31 | let p = embassy_stm32::init(config); |
| 26 | } | ||
| 27 | 32 | ||
| 28 | use ov7725::*; | ||
| 29 | |||
| 30 | const WIDTH: usize = 100; | ||
| 31 | const HEIGHT: usize = 100; | ||
| 32 | |||
| 33 | static mut FRAME: [u32; WIDTH * HEIGHT / 2] = [0u32; WIDTH * HEIGHT / 2]; | ||
| 34 | |||
| 35 | #[embassy_executor::main(config = "config()")] | ||
| 36 | async fn main(_spawner: Spawner, p: Peripherals) { | ||
| 37 | defmt::info!("Hello World!"); | 33 | defmt::info!("Hello World!"); |
| 38 | let mco = Mco::new(p.MCO1, p.PA8, Mco1Source::Hsi, McoClock::Divided(3)); | 34 | let mco = Mco::new(p.MCO1, p.PA8, Mco1Source::Hsi, McoClock::Divided(3)); |
| 39 | 35 | ||
| 40 | let mut led = Output::new(p.PE3, Level::High, Speed::Low); | 36 | let mut led = Output::new(p.PE3, Level::High, Speed::Low); |
| 41 | let i2c_irq = interrupt::take!(I2C1_EV); | 37 | let i2c_irq = interrupt::take!(I2C1_EV); |
| 42 | let cam_i2c = I2c::new(p.I2C1, p.PB8, p.PB9, i2c_irq, p.DMA1_CH1, p.DMA1_CH2, khz(100)); | 38 | let cam_i2c = I2c::new( |
| 39 | p.I2C1, | ||
| 40 | p.PB8, | ||
| 41 | p.PB9, | ||
| 42 | i2c_irq, | ||
| 43 | p.DMA1_CH1, | ||
| 44 | p.DMA1_CH2, | ||
| 45 | khz(100), | ||
| 46 | Default::default(), | ||
| 47 | ); | ||
| 43 | 48 | ||
| 44 | let mut camera = Ov7725::new(cam_i2c, mco); | 49 | let mut camera = Ov7725::new(cam_i2c, mco); |
| 45 | 50 | ||
| @@ -78,8 +83,8 @@ mod ov7725 { | |||
| 78 | use core::marker::PhantomData; | 83 | use core::marker::PhantomData; |
| 79 | 84 | ||
| 80 | use defmt::Format; | 85 | use defmt::Format; |
| 81 | use embassy_executor::time::{Duration, Timer}; | ||
| 82 | use embassy_stm32::rcc::{Mco, McoInstance}; | 86 | use embassy_stm32::rcc::{Mco, McoInstance}; |
| 87 | use embassy_time::{Duration, Timer}; | ||
| 83 | use embedded_hal_async::i2c::I2c; | 88 | use embedded_hal_async::i2c::I2c; |
| 84 | 89 | ||
| 85 | #[repr(u8)] | 90 | #[repr(u8)] |
diff --git a/examples/stm32h7/src/bin/dac.rs b/examples/stm32h7/src/bin/dac.rs index dece74bba..f12716370 100644 --- a/examples/stm32h7/src/bin/dac.rs +++ b/examples/stm32h7/src/bin/dac.rs | |||
| @@ -9,19 +9,15 @@ use embassy_stm32::time::mhz; | |||
| 9 | use embassy_stm32::Config; | 9 | use embassy_stm32::Config; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | pub fn config() -> Config { | ||
| 13 | let mut config = Config::default(); | ||
| 14 | config.rcc.sys_ck = Some(mhz(400)); | ||
| 15 | config.rcc.hclk = Some(mhz(200)); | ||
| 16 | config.rcc.pll1.q_ck = Some(mhz(100)); | ||
| 17 | config | ||
| 18 | } | ||
| 19 | |||
| 20 | #[entry] | 12 | #[entry] |
| 21 | fn main() -> ! { | 13 | fn main() -> ! { |
| 22 | info!("Hello World, dude!"); | 14 | info!("Hello World, dude!"); |
| 23 | 15 | ||
| 24 | let p = embassy_stm32::init(config()); | 16 | let mut config = Config::default(); |
| 17 | config.rcc.sys_ck = Some(mhz(400)); | ||
| 18 | config.rcc.hclk = Some(mhz(200)); | ||
| 19 | config.rcc.pll1.q_ck = Some(mhz(100)); | ||
| 20 | let p = embassy_stm32::init(config); | ||
| 25 | 21 | ||
| 26 | let mut dac = Dac::new_1ch(p.DAC1, p.PA4); | 22 | let mut dac = Dac::new_1ch(p.DAC1, p.PA4); |
| 27 | 23 | ||
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 4282fcedd..83210bcb5 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs | |||
| @@ -3,8 +3,7 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_net::tcp::TcpSocket; | 7 | use embassy_net::tcp::TcpSocket; |
| 9 | use embassy_net::{Ipv4Address, Stack, StackResources}; | 8 | use embassy_net::{Ipv4Address, Stack, StackResources}; |
| 10 | use embassy_stm32::eth::generic_smi::GenericSMI; | 9 | use embassy_stm32::eth::generic_smi::GenericSMI; |
| @@ -12,7 +11,8 @@ use embassy_stm32::eth::{Ethernet, State}; | |||
| 12 | use embassy_stm32::peripherals::ETH; | 11 | use embassy_stm32::peripherals::ETH; |
| 13 | use embassy_stm32::rng::Rng; | 12 | use embassy_stm32::rng::Rng; |
| 14 | use embassy_stm32::time::mhz; | 13 | use embassy_stm32::time::mhz; |
| 15 | use embassy_stm32::{interrupt, Config, Peripherals}; | 14 | use embassy_stm32::{interrupt, Config}; |
| 15 | use embassy_time::{Duration, Timer}; | ||
| 16 | use embassy_util::Forever; | 16 | use embassy_util::Forever; |
| 17 | use embedded_io::asynch::Write; | 17 | use embedded_io::asynch::Write; |
| 18 | use rand_core::RngCore; | 18 | use rand_core::RngCore; |
| @@ -33,16 +33,13 @@ async fn net_task(stack: &'static Stack<Device>) -> ! { | |||
| 33 | stack.run().await | 33 | stack.run().await |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | pub fn config() -> Config { | 36 | #[embassy_executor::main] |
| 37 | async fn main(spawner: Spawner) -> ! { | ||
| 37 | let mut config = Config::default(); | 38 | let mut config = Config::default(); |
| 38 | config.rcc.sys_ck = Some(mhz(400)); | 39 | config.rcc.sys_ck = Some(mhz(400)); |
| 39 | config.rcc.hclk = Some(mhz(200)); | 40 | config.rcc.hclk = Some(mhz(200)); |
| 40 | config.rcc.pll1.q_ck = Some(mhz(100)); | 41 | config.rcc.pll1.q_ck = Some(mhz(100)); |
| 41 | config | 42 | let p = embassy_stm32::init(config); |
| 42 | } | ||
| 43 | |||
| 44 | #[embassy_executor::main(config = "config()")] | ||
| 45 | async fn main(spawner: Spawner, p: Peripherals) -> ! { | ||
| 46 | info!("Hello World!"); | 43 | info!("Hello World!"); |
| 47 | 44 | ||
| 48 | // Generate random seed. | 45 | // Generate random seed. |
diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs new file mode 100644 index 000000000..99946f504 --- /dev/null +++ b/examples/stm32h7/src/bin/eth_client.rs | |||
| @@ -0,0 +1,122 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_net::tcp::client::{TcpClient, TcpClientState}; | ||
| 8 | use embassy_net::{Stack, StackResources}; | ||
| 9 | use embassy_stm32::eth::generic_smi::GenericSMI; | ||
| 10 | use embassy_stm32::eth::{Ethernet, State}; | ||
| 11 | use embassy_stm32::peripherals::ETH; | ||
| 12 | use embassy_stm32::rng::Rng; | ||
| 13 | use embassy_stm32::time::mhz; | ||
| 14 | use embassy_stm32::{interrupt, Config}; | ||
| 15 | use embassy_time::{Duration, Timer}; | ||
| 16 | use embassy_util::Forever; | ||
| 17 | use embedded_io::asynch::Write; | ||
| 18 | use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; | ||
| 19 | use rand_core::RngCore; | ||
| 20 | use {defmt_rtt as _, panic_probe as _}; | ||
| 21 | |||
| 22 | macro_rules! forever { | ||
| 23 | ($val:expr) => {{ | ||
| 24 | type T = impl Sized; | ||
| 25 | static FOREVER: Forever<T> = Forever::new(); | ||
| 26 | FOREVER.put_with(move || $val) | ||
| 27 | }}; | ||
| 28 | } | ||
| 29 | |||
| 30 | type Device = Ethernet<'static, ETH, GenericSMI, 4, 4>; | ||
| 31 | |||
| 32 | #[embassy_executor::task] | ||
| 33 | async fn net_task(stack: &'static Stack<Device>) -> ! { | ||
| 34 | stack.run().await | ||
| 35 | } | ||
| 36 | |||
| 37 | #[embassy_executor::main] | ||
| 38 | async fn main(spawner: Spawner) -> ! { | ||
| 39 | let mut config = Config::default(); | ||
| 40 | config.rcc.sys_ck = Some(mhz(400)); | ||
| 41 | config.rcc.hclk = Some(mhz(200)); | ||
| 42 | config.rcc.pll1.q_ck = Some(mhz(100)); | ||
| 43 | let p = embassy_stm32::init(config); | ||
| 44 | info!("Hello World!"); | ||
| 45 | |||
| 46 | // Generate random seed. | ||
| 47 | let mut rng = Rng::new(p.RNG); | ||
| 48 | let mut seed = [0; 8]; | ||
| 49 | rng.fill_bytes(&mut seed); | ||
| 50 | let seed = u64::from_le_bytes(seed); | ||
| 51 | |||
| 52 | let eth_int = interrupt::take!(ETH); | ||
| 53 | let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; | ||
| 54 | |||
| 55 | let device = unsafe { | ||
| 56 | Ethernet::new( | ||
| 57 | forever!(State::new()), | ||
| 58 | p.ETH, | ||
| 59 | eth_int, | ||
| 60 | p.PA1, | ||
| 61 | p.PA2, | ||
| 62 | p.PC1, | ||
| 63 | p.PA7, | ||
| 64 | p.PC4, | ||
| 65 | p.PC5, | ||
| 66 | p.PG13, | ||
| 67 | p.PB13, | ||
| 68 | p.PG11, | ||
| 69 | GenericSMI, | ||
| 70 | mac_addr, | ||
| 71 | 0, | ||
| 72 | ) | ||
| 73 | }; | ||
| 74 | |||
| 75 | let config = embassy_net::ConfigStrategy::Dhcp; | ||
| 76 | //let config = embassy_net::ConfigStrategy::Static(embassy_net::Config { | ||
| 77 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), | ||
| 78 | // dns_servers: Vec::new(), | ||
| 79 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), | ||
| 80 | //}); | ||
| 81 | |||
| 82 | // Init network stack | ||
| 83 | let stack = &*forever!(Stack::new( | ||
| 84 | device, | ||
| 85 | config, | ||
| 86 | forever!(StackResources::<1, 2, 8>::new()), | ||
| 87 | seed | ||
| 88 | )); | ||
| 89 | |||
| 90 | // Launch network task | ||
| 91 | unwrap!(spawner.spawn(net_task(&stack))); | ||
| 92 | |||
| 93 | info!("Network task initialized"); | ||
| 94 | |||
| 95 | // To ensure DHCP configuration before trying connect | ||
| 96 | Timer::after(Duration::from_secs(20)).await; | ||
| 97 | |||
| 98 | static STATE: TcpClientState<1, 1024, 1024> = TcpClientState::new(); | ||
| 99 | let client = TcpClient::new(&stack, &STATE); | ||
| 100 | |||
| 101 | loop { | ||
| 102 | let addr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(10, 42, 0, 1), 8000)); | ||
| 103 | |||
| 104 | info!("connecting..."); | ||
| 105 | let r = client.connect(addr).await; | ||
| 106 | if let Err(e) = r { | ||
| 107 | info!("connect error: {:?}", e); | ||
| 108 | Timer::after(Duration::from_secs(1)).await; | ||
| 109 | continue; | ||
| 110 | } | ||
| 111 | let mut connection = r.unwrap(); | ||
| 112 | info!("connected!"); | ||
| 113 | loop { | ||
| 114 | let r = connection.write_all(b"Hello\n").await; | ||
| 115 | if let Err(e) = r { | ||
| 116 | info!("write error: {:?}", e); | ||
| 117 | return; | ||
| 118 | } | ||
| 119 | Timer::after(Duration::from_secs(1)).await; | ||
| 120 | } | ||
| 121 | } | ||
| 122 | } | ||
diff --git a/examples/stm32h7/src/bin/flash.rs b/examples/stm32h7/src/bin/flash.rs index 0c477deba..6682c64d5 100644 --- a/examples/stm32h7/src/bin/flash.rs +++ b/examples/stm32h7/src/bin/flash.rs | |||
| @@ -3,15 +3,15 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::flash::Flash; | 7 | use embassy_stm32::flash::Flash; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; | 9 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | info!("Hello Flash!"); | 15 | info!("Hello Flash!"); |
| 16 | 16 | ||
| 17 | const ADDR: u32 = 0x08_0000; | 17 | const ADDR: u32 = 0x08_0000; |
diff --git a/examples/stm32h7/src/bin/fmc.rs b/examples/stm32h7/src/bin/fmc.rs index 5140a6e22..85c690fe6 100644 --- a/examples/stm32h7/src/bin/fmc.rs +++ b/examples/stm32h7/src/bin/fmc.rs | |||
| @@ -3,23 +3,21 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Delay, Duration, Timer}; | ||
| 8 | use embassy_stm32::fmc::Fmc; | 7 | use embassy_stm32::fmc::Fmc; |
| 9 | use embassy_stm32::time::mhz; | 8 | use embassy_stm32::time::mhz; |
| 10 | use embassy_stm32::{Config, Peripherals}; | 9 | use embassy_stm32::Config; |
| 10 | use embassy_time::{Delay, Duration, Timer}; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | pub fn config() -> Config { | 13 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner) { | ||
| 14 | let mut config = Config::default(); | 15 | let mut config = Config::default(); |
| 15 | config.rcc.sys_ck = Some(mhz(400)); | 16 | config.rcc.sys_ck = Some(mhz(400)); |
| 16 | config.rcc.hclk = Some(mhz(200)); | 17 | config.rcc.hclk = Some(mhz(200)); |
| 17 | config.rcc.pll1.q_ck = Some(mhz(100)); | 18 | config.rcc.pll1.q_ck = Some(mhz(100)); |
| 18 | config | 19 | let p = embassy_stm32::init(config); |
| 19 | } | ||
| 20 | 20 | ||
| 21 | #[embassy_executor::main(config = "config()")] | ||
| 22 | async fn main(_spawner: Spawner, p: Peripherals) { | ||
| 23 | info!("Hello World!"); | 21 | info!("Hello World!"); |
| 24 | 22 | ||
| 25 | let mut core_peri = cortex_m::Peripherals::take().unwrap(); | 23 | let mut core_peri = cortex_m::Peripherals::take().unwrap(); |
diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index f2477c7a7..1972f8ff2 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs | |||
| @@ -3,16 +3,17 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::low_level::AFType; | 7 | use embassy_stm32::gpio::low_level::AFType; |
| 9 | use embassy_stm32::gpio::Speed; | 8 | use embassy_stm32::gpio::Speed; |
| 10 | use embassy_stm32::pwm::*; | 9 | use embassy_stm32::pwm::*; |
| 11 | use embassy_stm32::time::{khz, mhz, Hertz}; | 10 | use embassy_stm32::time::{khz, mhz, Hertz}; |
| 12 | use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef, Peripherals}; | 11 | use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef}; |
| 12 | use embassy_time::{Duration, Timer}; | ||
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | pub fn config() -> Config { | 15 | #[embassy_executor::main] |
| 16 | async fn main(_spawner: Spawner) { | ||
| 16 | let mut config = Config::default(); | 17 | let mut config = Config::default(); |
| 17 | config.rcc.sys_ck = Some(mhz(400)); | 18 | config.rcc.sys_ck = Some(mhz(400)); |
| 18 | config.rcc.hclk = Some(mhz(400)); | 19 | config.rcc.hclk = Some(mhz(400)); |
| @@ -21,11 +22,8 @@ pub fn config() -> Config { | |||
| 21 | config.rcc.pclk2 = Some(mhz(100)); | 22 | config.rcc.pclk2 = Some(mhz(100)); |
| 22 | config.rcc.pclk3 = Some(mhz(100)); | 23 | config.rcc.pclk3 = Some(mhz(100)); |
| 23 | config.rcc.pclk4 = Some(mhz(100)); | 24 | config.rcc.pclk4 = Some(mhz(100)); |
| 24 | config | 25 | let p = embassy_stm32::init(config); |
| 25 | } | ||
| 26 | 26 | ||
| 27 | #[embassy_executor::main(config = "config()")] | ||
| 28 | async fn main(_spawner: Spawner, p: Peripherals) { | ||
| 29 | info!("Hello World!"); | 27 | info!("Hello World!"); |
| 30 | 28 | ||
| 31 | let mut pwm = SimplePwm32::new(p.TIM5, p.PA0, p.PA1, p.PA2, p.PA3, khz(10)); | 29 | let mut pwm = SimplePwm32::new(p.TIM5, p.PA0, p.PA1, p.PA2, p.PA3, khz(10)); |
diff --git a/examples/stm32h7/src/bin/mco.rs b/examples/stm32h7/src/bin/mco.rs index 83ba3742b..036455d5e 100644 --- a/examples/stm32h7/src/bin/mco.rs +++ b/examples/stm32h7/src/bin/mco.rs | |||
| @@ -3,15 +3,15 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; | 8 | use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; |
| 10 | use embassy_stm32::Peripherals; | 9 | use embassy_time::{Duration, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | info!("Hello World!"); | 15 | info!("Hello World!"); |
| 16 | 16 | ||
| 17 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); | 17 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); |
diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index 36ed2e4a4..c5c0dd290 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs | |||
| @@ -3,15 +3,16 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; | 7 | use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; |
| 9 | use embassy_stm32::pwm::Channel; | 8 | use embassy_stm32::pwm::Channel; |
| 10 | use embassy_stm32::time::{khz, mhz}; | 9 | use embassy_stm32::time::{khz, mhz}; |
| 11 | use embassy_stm32::{Config, Peripherals}; | 10 | use embassy_stm32::Config; |
| 11 | use embassy_time::{Duration, Timer}; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | pub fn config() -> Config { | 14 | #[embassy_executor::main] |
| 15 | async fn main(_spawner: Spawner) { | ||
| 15 | let mut config = Config::default(); | 16 | let mut config = Config::default(); |
| 16 | config.rcc.sys_ck = Some(mhz(400)); | 17 | config.rcc.sys_ck = Some(mhz(400)); |
| 17 | config.rcc.hclk = Some(mhz(400)); | 18 | config.rcc.hclk = Some(mhz(400)); |
| @@ -20,11 +21,7 @@ pub fn config() -> Config { | |||
| 20 | config.rcc.pclk2 = Some(mhz(100)); | 21 | config.rcc.pclk2 = Some(mhz(100)); |
| 21 | config.rcc.pclk3 = Some(mhz(100)); | 22 | config.rcc.pclk3 = Some(mhz(100)); |
| 22 | config.rcc.pclk4 = Some(mhz(100)); | 23 | config.rcc.pclk4 = Some(mhz(100)); |
| 23 | config | 24 | let p = embassy_stm32::init(config); |
| 24 | } | ||
| 25 | |||
| 26 | #[embassy_executor::main(config = "config()")] | ||
| 27 | async fn main(_spawner: Spawner, p: Peripherals) { | ||
| 28 | info!("Hello World!"); | 25 | info!("Hello World!"); |
| 29 | 26 | ||
| 30 | let ch1 = PwmPin::new_ch1(p.PA6); | 27 | let ch1 = PwmPin::new_ch1(p.PA6); |
diff --git a/examples/stm32h7/src/bin/rng.rs b/examples/stm32h7/src/bin/rng.rs index 81fb3d162..af9be0b62 100644 --- a/examples/stm32h7/src/bin/rng.rs +++ b/examples/stm32h7/src/bin/rng.rs | |||
| @@ -3,13 +3,13 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rng::Rng; | 7 | use embassy_stm32::rng::Rng; |
| 8 | use embassy_stm32::Peripherals; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 9 | ||
| 11 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner, p: Peripherals) { | 11 | async fn main(_spawner: Spawner) { |
| 12 | let p = embassy_stm32::init(Default::default()); | ||
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let mut rng = Rng::new(p.RNG); | 15 | let mut rng = Rng::new(p.RNG); |
diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs index 19ae5ade1..26d1db01e 100644 --- a/examples/stm32h7/src/bin/sdmmc.rs +++ b/examples/stm32h7/src/bin/sdmmc.rs | |||
| @@ -3,20 +3,17 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::sdmmc::Sdmmc; | 7 | use embassy_stm32::sdmmc::Sdmmc; |
| 8 | use embassy_stm32::time::mhz; | 8 | use embassy_stm32::time::mhz; |
| 9 | use embassy_stm32::{interrupt, Config, Peripherals}; | 9 | use embassy_stm32::{interrupt, Config}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | fn config() -> Config { | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) -> ! { | ||
| 13 | let mut config = Config::default(); | 14 | let mut config = Config::default(); |
| 14 | config.rcc.sys_ck = Some(mhz(200)); | 15 | config.rcc.sys_ck = Some(mhz(200)); |
| 15 | config | 16 | let p = embassy_stm32::init(config); |
| 16 | } | ||
| 17 | |||
| 18 | #[embassy_executor::main(config = "config()")] | ||
| 19 | async fn main(_spawner: Spawner, p: Peripherals) -> ! { | ||
| 20 | info!("Hello World!"); | 17 | info!("Hello World!"); |
| 21 | 18 | ||
| 22 | let irq = interrupt::take!(SDMMC1); | 19 | let irq = interrupt::take!(SDMMC1); |
diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs index 2fc75c7af..be2ac268e 100644 --- a/examples/stm32h7/src/bin/signal.rs +++ b/examples/stm32h7/src/bin/signal.rs | |||
| @@ -3,9 +3,8 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | 7 | use embassy_time::{Duration, Timer}; |
| 8 | use embassy_stm32::Peripherals; | ||
| 9 | use embassy_util::channel::signal::Signal; | 8 | use embassy_util::channel::signal::Signal; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| @@ -25,7 +24,8 @@ async fn my_sending_task() { | |||
| 25 | } | 24 | } |
| 26 | 25 | ||
| 27 | #[embassy_executor::main] | 26 | #[embassy_executor::main] |
| 28 | async fn main(spawner: Spawner, _p: Peripherals) { | 27 | async fn main(spawner: Spawner) { |
| 28 | let _p = embassy_stm32::init(Default::default()); | ||
| 29 | unwrap!(spawner.spawn(my_sending_task())); | 29 | unwrap!(spawner.spawn(my_sending_task())); |
| 30 | 30 | ||
| 31 | loop { | 31 | loop { |
diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index dc8cb7f47..c28f937a8 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs | |||
| @@ -7,7 +7,7 @@ use core::str::from_utf8; | |||
| 7 | 7 | ||
| 8 | use cortex_m_rt::entry; | 8 | use cortex_m_rt::entry; |
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy_executor::executor::Executor; | 10 | use embassy_executor::Executor; |
| 11 | use embassy_stm32::dma::NoDma; | 11 | use embassy_stm32::dma::NoDma; |
| 12 | use embassy_stm32::peripherals::SPI3; | 12 | use embassy_stm32::peripherals::SPI3; |
| 13 | use embassy_stm32::time::mhz; | 13 | use embassy_stm32::time::mhz; |
| @@ -16,14 +16,6 @@ use embassy_util::Forever; | |||
| 16 | use heapless::String; | 16 | use heapless::String; |
| 17 | use {defmt_rtt as _, panic_probe as _}; | 17 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | 18 | ||
| 19 | pub fn config() -> Config { | ||
| 20 | let mut config = Config::default(); | ||
| 21 | config.rcc.sys_ck = Some(mhz(400)); | ||
| 22 | config.rcc.hclk = Some(mhz(200)); | ||
| 23 | config.rcc.pll1.q_ck = Some(mhz(100)); | ||
| 24 | config | ||
| 25 | } | ||
| 26 | |||
| 27 | #[embassy_executor::task] | 19 | #[embassy_executor::task] |
| 28 | async fn main_task(mut spi: spi::Spi<'static, SPI3, NoDma, NoDma>) { | 20 | async fn main_task(mut spi: spi::Spi<'static, SPI3, NoDma, NoDma>) { |
| 29 | for n in 0u32.. { | 21 | for n in 0u32.. { |
| @@ -45,7 +37,11 @@ static EXECUTOR: Forever<Executor> = Forever::new(); | |||
| 45 | fn main() -> ! { | 37 | fn main() -> ! { |
| 46 | info!("Hello World!"); | 38 | info!("Hello World!"); |
| 47 | 39 | ||
| 48 | let p = embassy_stm32::init(config()); | 40 | let mut config = Config::default(); |
| 41 | config.rcc.sys_ck = Some(mhz(400)); | ||
| 42 | config.rcc.hclk = Some(mhz(200)); | ||
| 43 | config.rcc.pll1.q_ck = Some(mhz(100)); | ||
| 44 | let p = embassy_stm32::init(config); | ||
| 49 | 45 | ||
| 50 | let spi = spi::Spi::new( | 46 | let spi = spi::Spi::new( |
| 51 | p.SPI3, | 47 | p.SPI3, |
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index 2631ed30c..6c78c194f 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs | |||
| @@ -7,7 +7,7 @@ use core::str::from_utf8; | |||
| 7 | 7 | ||
| 8 | use cortex_m_rt::entry; | 8 | use cortex_m_rt::entry; |
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy_executor::executor::Executor; | 10 | use embassy_executor::Executor; |
| 11 | use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; | 11 | use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; |
| 12 | use embassy_stm32::time::mhz; | 12 | use embassy_stm32::time::mhz; |
| 13 | use embassy_stm32::{spi, Config}; | 13 | use embassy_stm32::{spi, Config}; |
| @@ -15,14 +15,6 @@ use embassy_util::Forever; | |||
| 15 | use heapless::String; | 15 | use heapless::String; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 17 | ||
| 18 | pub fn config() -> Config { | ||
| 19 | let mut config = Config::default(); | ||
| 20 | config.rcc.sys_ck = Some(mhz(400)); | ||
| 21 | config.rcc.hclk = Some(mhz(200)); | ||
| 22 | config.rcc.pll1.q_ck = Some(mhz(100)); | ||
| 23 | config | ||
| 24 | } | ||
| 25 | |||
| 26 | #[embassy_executor::task] | 18 | #[embassy_executor::task] |
| 27 | async fn main_task(mut spi: spi::Spi<'static, SPI3, DMA1_CH3, DMA1_CH4>) { | 19 | async fn main_task(mut spi: spi::Spi<'static, SPI3, DMA1_CH3, DMA1_CH4>) { |
| 28 | for n in 0u32.. { | 20 | for n in 0u32.. { |
| @@ -41,7 +33,11 @@ static EXECUTOR: Forever<Executor> = Forever::new(); | |||
| 41 | fn main() -> ! { | 33 | fn main() -> ! { |
| 42 | info!("Hello World!"); | 34 | info!("Hello World!"); |
| 43 | 35 | ||
| 44 | let p = embassy_stm32::init(config()); | 36 | let mut config = Config::default(); |
| 37 | config.rcc.sys_ck = Some(mhz(400)); | ||
| 38 | config.rcc.hclk = Some(mhz(200)); | ||
| 39 | config.rcc.pll1.q_ck = Some(mhz(100)); | ||
| 40 | let p = embassy_stm32::init(config); | ||
| 45 | 41 | ||
| 46 | let spi = spi::Spi::new( | 42 | let spi = spi::Spi::new( |
| 47 | p.SPI3, | 43 | p.SPI3, |
diff --git a/examples/stm32h7/src/bin/usart.rs b/examples/stm32h7/src/bin/usart.rs index e491fb39d..1384d54c6 100644 --- a/examples/stm32h7/src/bin/usart.rs +++ b/examples/stm32h7/src/bin/usart.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use cortex_m_rt::entry; | 5 | use cortex_m_rt::entry; |
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::executor::Executor; | 7 | use embassy_executor::Executor; |
| 8 | use embassy_stm32::dma::NoDma; | 8 | use embassy_stm32::dma::NoDma; |
| 9 | use embassy_stm32::usart::{Config, Uart}; | 9 | use embassy_stm32::usart::{Config, Uart}; |
| 10 | use embassy_util::Forever; | 10 | use embassy_util::Forever; |
diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs index aacda45bc..f8d58bb84 100644 --- a/examples/stm32h7/src/bin/usart_dma.rs +++ b/examples/stm32h7/src/bin/usart_dma.rs | |||
| @@ -6,7 +6,7 @@ use core::fmt::Write; | |||
| 6 | 6 | ||
| 7 | use cortex_m_rt::entry; | 7 | use cortex_m_rt::entry; |
| 8 | use defmt::*; | 8 | use defmt::*; |
| 9 | use embassy_executor::executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_stm32::dma::NoDma; | 10 | use embassy_stm32::dma::NoDma; |
| 11 | use embassy_stm32::usart::{Config, Uart}; | 11 | use embassy_stm32::usart::{Config, Uart}; |
| 12 | use embassy_util::Forever; | 12 | use embassy_util::Forever; |
diff --git a/examples/stm32h7/src/bin/usart_split.rs b/examples/stm32h7/src/bin/usart_split.rs index 12bb0ce9c..64080ec45 100644 --- a/examples/stm32h7/src/bin/usart_split.rs +++ b/examples/stm32h7/src/bin/usart_split.rs | |||
| @@ -3,11 +3,10 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::dma::NoDma; | 7 | use embassy_stm32::dma::NoDma; |
| 8 | use embassy_stm32::peripherals::{DMA1_CH1, UART7}; | 8 | use embassy_stm32::peripherals::{DMA1_CH1, UART7}; |
| 9 | use embassy_stm32::usart::{Config, Uart, UartRx}; | 9 | use embassy_stm32::usart::{Config, Uart, UartRx}; |
| 10 | use embassy_stm32::Peripherals; | ||
| 11 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | 10 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; |
| 12 | use embassy_util::channel::mpmc::Channel; | 11 | use embassy_util::channel::mpmc::Channel; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -27,7 +26,8 @@ async fn writer(mut usart: Uart<'static, UART7, NoDma, NoDma>) { | |||
| 27 | static CHANNEL: Channel<ThreadModeRawMutex, [u8; 8], 1> = Channel::new(); | 26 | static CHANNEL: Channel<ThreadModeRawMutex, [u8; 8], 1> = Channel::new(); |
| 28 | 27 | ||
| 29 | #[embassy_executor::main] | 28 | #[embassy_executor::main] |
| 30 | async fn main(spawner: Spawner, p: Peripherals) -> ! { | 29 | async fn main(spawner: Spawner) -> ! { |
| 30 | let p = embassy_stm32::init(Default::default()); | ||
| 31 | info!("Hello World!"); | 31 | info!("Hello World!"); |
| 32 | 32 | ||
| 33 | let config = Config::default(); | 33 | let config = Config::default(); |
diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 7edda042d..fdb716d15 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml | |||
| @@ -9,7 +9,8 @@ nightly = ["embassy-stm32/nightly", "embassy-lora", "lorawan-device", "lorawan", | |||
| 9 | 9 | ||
| 10 | [dependencies] | 10 | [dependencies] |
| 11 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 11 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 12 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } | 12 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 13 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | ||
| 13 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } | 14 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } |
| 14 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt"], optional = true} | 15 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt"], optional = true} |
| 15 | 16 | ||
| @@ -22,7 +23,7 @@ defmt-rtt = "0.3" | |||
| 22 | embedded-storage = "0.3.0" | 23 | embedded-storage = "0.3.0" |
| 23 | embedded-io = "0.3.0" | 24 | embedded-io = "0.3.0" |
| 24 | 25 | ||
| 25 | cortex-m = "0.7.3" | 26 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 26 | cortex-m-rt = "0.7.0" | 27 | cortex-m-rt = "0.7.0" |
| 27 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 28 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 28 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 29 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
diff --git a/examples/stm32l0/src/bin/blinky.rs b/examples/stm32l0/src/bin/blinky.rs index 8cf21effb..07fad07c6 100644 --- a/examples/stm32l0/src/bin/blinky.rs +++ b/examples/stm32l0/src/bin/blinky.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PB5, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB5, Level::High, Speed::Low); |
diff --git a/examples/stm32l0/src/bin/button.rs b/examples/stm32l0/src/bin/button.rs index a5e05c3a3..9d194471e 100644 --- a/examples/stm32l0/src/bin/button.rs +++ b/examples/stm32l0/src/bin/button.rs | |||
| @@ -3,13 +3,13 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 7 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 8 | use embassy_stm32::Peripherals; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 9 | ||
| 11 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner, p: Peripherals) { | 11 | async fn main(_spawner: Spawner) { |
| 12 | let p = embassy_stm32::init(Default::default()); | ||
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let button = Input::new(p.PB2, Pull::Up); | 15 | let button = Input::new(p.PB2, Pull::Up); |
diff --git a/examples/stm32l0/src/bin/button_exti.rs b/examples/stm32l0/src/bin/button_exti.rs index 22a096af8..af82b9955 100644 --- a/examples/stm32l0/src/bin/button_exti.rs +++ b/examples/stm32l0/src/bin/button_exti.rs | |||
| @@ -3,20 +3,18 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::exti::ExtiInput; | 7 | use embassy_stm32::exti::ExtiInput; |
| 8 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 9 | use embassy_stm32::Peripherals; | 9 | use embassy_stm32::Config; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | fn config() -> embassy_stm32::Config { | 12 | #[embassy_executor::main] |
| 13 | let mut config = embassy_stm32::Config::default(); | 13 | async fn main(_spawner: Spawner) { |
| 14 | let mut config = Config::default(); | ||
| 14 | config.rcc.enable_hsi48 = true; | 15 | config.rcc.enable_hsi48 = true; |
| 15 | config | 16 | let p = embassy_stm32::init(config); |
| 16 | } | ||
| 17 | 17 | ||
| 18 | #[embassy_executor::main(config = "config()")] | ||
| 19 | async fn main(_spawner: Spawner, p: Peripherals) { | ||
| 20 | let button = Input::new(p.PB2, Pull::Up); | 18 | let button = Input::new(p.PB2, Pull::Up); |
| 21 | let mut button = ExtiInput::new(button, p.EXTI2); | 19 | let mut button = ExtiInput::new(button, p.EXTI2); |
| 22 | 20 | ||
diff --git a/examples/stm32l0/src/bin/flash.rs b/examples/stm32l0/src/bin/flash.rs index 7ad5ae3aa..867cb4d3e 100644 --- a/examples/stm32l0/src/bin/flash.rs +++ b/examples/stm32l0/src/bin/flash.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::flash::Flash; | 7 | use embassy_stm32::flash::Flash; |
| 8 | use embassy_stm32::Peripherals; | ||
| 9 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; | 8 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello Flash!"); | 14 | info!("Hello Flash!"); |
| 15 | 15 | ||
| 16 | const ADDR: u32 = 0x26000; | 16 | const ADDR: u32 = 0x26000; |
diff --git a/examples/stm32l0/src/bin/lorawan.rs b/examples/stm32l0/src/bin/lorawan.rs index 29e54c1be..303558b96 100644 --- a/examples/stm32l0/src/bin/lorawan.rs +++ b/examples/stm32l0/src/bin/lorawan.rs | |||
| @@ -6,26 +6,25 @@ | |||
| 6 | #![feature(generic_associated_types)] | 6 | #![feature(generic_associated_types)] |
| 7 | #![feature(type_alias_impl_trait)] | 7 | #![feature(type_alias_impl_trait)] |
| 8 | 8 | ||
| 9 | use embassy_executor::Spawner; | ||
| 9 | use embassy_lora::sx127x::*; | 10 | use embassy_lora::sx127x::*; |
| 10 | use embassy_lora::LoraTimer; | 11 | use embassy_lora::LoraTimer; |
| 11 | use embassy_stm32::exti::ExtiInput; | 12 | use embassy_stm32::exti::ExtiInput; |
| 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 13 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 13 | use embassy_stm32::rng::Rng; | 14 | use embassy_stm32::rng::Rng; |
| 15 | use embassy_stm32::spi; | ||
| 14 | use embassy_stm32::time::khz; | 16 | use embassy_stm32::time::khz; |
| 15 | use embassy_stm32::{spi, Peripherals}; | ||
| 16 | use lorawan::default_crypto::DefaultFactory as Crypto; | 17 | use lorawan::default_crypto::DefaultFactory as Crypto; |
| 17 | use lorawan_device::async_device::{region, Device, JoinMode}; | 18 | use lorawan_device::async_device::{region, Device, JoinMode}; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 20 | ||
| 20 | fn config() -> embassy_stm32::Config { | 21 | #[embassy_executor::main] |
| 22 | async fn main(_spawner: Spawner) { | ||
| 21 | let mut config = embassy_stm32::Config::default(); | 23 | let mut config = embassy_stm32::Config::default(); |
| 22 | config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; | 24 | config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; |
| 23 | config.rcc.enable_hsi48 = true; | 25 | config.rcc.enable_hsi48 = true; |
| 24 | config | 26 | let p = embassy_stm32::init(config); |
| 25 | } | ||
| 26 | 27 | ||
| 27 | #[embassy_executor::main(config = "config()")] | ||
| 28 | async fn main(_spawner: embassy_executor::executor::Spawner, p: Peripherals) { | ||
| 29 | // SPI for sx127x | 28 | // SPI for sx127x |
| 30 | let spi = spi::Spi::new( | 29 | let spi = spi::Spi::new( |
| 31 | p.SPI1, | 30 | p.SPI1, |
diff --git a/examples/stm32l0/src/bin/raw_spawn.rs b/examples/stm32l0/src/bin/raw_spawn.rs index cd711a430..bd87e62a4 100644 --- a/examples/stm32l0/src/bin/raw_spawn.rs +++ b/examples/stm32l0/src/bin/raw_spawn.rs | |||
| @@ -5,9 +5,9 @@ use core::mem; | |||
| 5 | 5 | ||
| 6 | use cortex_m_rt::entry; | 6 | use cortex_m_rt::entry; |
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy_executor::executor::raw::TaskStorage; | 8 | use embassy_executor::raw::TaskStorage; |
| 9 | use embassy_executor::executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_executor::time::{Duration, Timer}; | 10 | use embassy_time::{Duration, Timer}; |
| 11 | use embassy_util::Forever; | 11 | use embassy_util::Forever; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
diff --git a/examples/stm32l0/src/bin/spi.rs b/examples/stm32l0/src/bin/spi.rs index 74694295c..9b5b3e27d 100644 --- a/examples/stm32l0/src/bin/spi.rs +++ b/examples/stm32l0/src/bin/spi.rs | |||
| @@ -3,16 +3,16 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::dma::NoDma; | 7 | use embassy_stm32::dma::NoDma; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::spi::{Config, Spi}; | 9 | use embassy_stm32::spi::{Config, Spi}; |
| 10 | use embassy_stm32::time::Hertz; | 10 | use embassy_stm32::time::Hertz; |
| 11 | use embassy_stm32::Peripherals; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 12 | ||
| 14 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 14 | async fn main(_spawner: Spawner) { |
| 15 | let p = embassy_stm32::init(Default::default()); | ||
| 16 | info!("Hello World, folks!"); | 16 | info!("Hello World, folks!"); |
| 17 | 17 | ||
| 18 | let mut spi = Spi::new( | 18 | let mut spi = Spi::new( |
diff --git a/examples/stm32l0/src/bin/usart_dma.rs b/examples/stm32l0/src/bin/usart_dma.rs index 1c5ce94d7..66657d0f0 100644 --- a/examples/stm32l0/src/bin/usart_dma.rs +++ b/examples/stm32l0/src/bin/usart_dma.rs | |||
| @@ -3,13 +3,13 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::usart::{Config, Uart}; | 7 | use embassy_stm32::usart::{Config, Uart}; |
| 8 | use embassy_stm32::Peripherals; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 9 | ||
| 11 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner, p: Peripherals) { | 11 | async fn main(_spawner: Spawner) { |
| 12 | let p = embassy_stm32::init(Default::default()); | ||
| 13 | let mut usart = Uart::new(p.USART1, p.PB7, p.PB6, p.DMA1_CH2, p.DMA1_CH3, Config::default()); | 13 | let mut usart = Uart::new(p.USART1, p.PB7, p.PB6, p.DMA1_CH2, p.DMA1_CH3, Config::default()); |
| 14 | 14 | ||
| 15 | usart.write(b"Hello Embassy World!\r\n").await.unwrap(); | 15 | usart.write(b"Hello Embassy World!\r\n").await.unwrap(); |
diff --git a/examples/stm32l0/src/bin/usart_irq.rs b/examples/stm32l0/src/bin/usart_irq.rs index b77d97f85..0e2237388 100644 --- a/examples/stm32l0/src/bin/usart_irq.rs +++ b/examples/stm32l0/src/bin/usart_irq.rs | |||
| @@ -3,15 +3,16 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::dma::NoDma; | 7 | use embassy_stm32::dma::NoDma; |
| 8 | use embassy_stm32::interrupt; | ||
| 8 | use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; | 9 | use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; |
| 9 | use embassy_stm32::{interrupt, Peripherals}; | ||
| 10 | use embedded_io::asynch::{Read, Write}; | 10 | use embedded_io::asynch::{Read, Write}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 14 | async fn main(_spawner: Spawner) { |
| 15 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | info!("Hi!"); | 16 | info!("Hi!"); |
| 16 | 17 | ||
| 17 | static mut TX_BUFFER: [u8; 8] = [0; 8]; | 18 | static mut TX_BUFFER: [u8; 8] = [0; 8]; |
diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml index d69de9c53..43f844b67 100644 --- a/examples/stm32l1/Cargo.toml +++ b/examples/stm32l1/Cargo.toml | |||
| @@ -5,13 +5,14 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } |
| 10 | 11 | ||
| 11 | defmt = "0.3" | 12 | defmt = "0.3" |
| 12 | defmt-rtt = "0.3" | 13 | defmt-rtt = "0.3" |
| 13 | 14 | ||
| 14 | cortex-m = "0.7.3" | 15 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 15 | cortex-m-rt = "0.7.0" | 16 | cortex-m-rt = "0.7.0" |
| 16 | embedded-hal = "0.2.6" | 17 | embedded-hal = "0.2.6" |
| 17 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 18 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
diff --git a/examples/stm32l1/src/bin/blinky.rs b/examples/stm32l1/src/bin/blinky.rs index 58306be94..8a345d235 100644 --- a/examples/stm32l1/src/bin/blinky.rs +++ b/examples/stm32l1/src/bin/blinky.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PA12, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PA12, Level::High, Speed::Low); |
diff --git a/examples/stm32l1/src/bin/flash.rs b/examples/stm32l1/src/bin/flash.rs index 78938fe3e..a76b9879f 100644 --- a/examples/stm32l1/src/bin/flash.rs +++ b/examples/stm32l1/src/bin/flash.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::flash::Flash; | 7 | use embassy_stm32::flash::Flash; |
| 8 | use embassy_stm32::Peripherals; | ||
| 9 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; | 8 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello Flash!"); | 14 | info!("Hello Flash!"); |
| 15 | 15 | ||
| 16 | const ADDR: u32 = 0x26000; | 16 | const ADDR: u32 = 0x26000; |
diff --git a/examples/stm32l1/src/bin/spi.rs b/examples/stm32l1/src/bin/spi.rs index 05e869e71..0a532e8e3 100644 --- a/examples/stm32l1/src/bin/spi.rs +++ b/examples/stm32l1/src/bin/spi.rs | |||
| @@ -3,16 +3,16 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::dma::NoDma; | 7 | use embassy_stm32::dma::NoDma; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::spi::{Config, Spi}; | 9 | use embassy_stm32::spi::{Config, Spi}; |
| 10 | use embassy_stm32::time::Hertz; | 10 | use embassy_stm32::time::Hertz; |
| 11 | use embassy_stm32::Peripherals; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 12 | ||
| 14 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 14 | async fn main(_spawner: Spawner) { |
| 15 | let p = embassy_stm32::init(Default::default()); | ||
| 16 | info!("Hello World, folks!"); | 16 | info!("Hello World, folks!"); |
| 17 | 17 | ||
| 18 | let mut spi = Spi::new( | 18 | let mut spi = Spi::new( |
diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index 8ac974c92..eaffa253e 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml | |||
| @@ -7,14 +7,15 @@ version = "0.1.0" | |||
| 7 | 7 | ||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 9 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 10 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } | 10 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 11 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | ||
| 11 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } | 12 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } |
| 12 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l4s5vi", "time-driver-any", "exti", "unstable-traits"] } | 13 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l4s5vi", "time-driver-any", "exti", "unstable-traits"] } |
| 13 | 14 | ||
| 14 | defmt = "0.3" | 15 | defmt = "0.3" |
| 15 | defmt-rtt = "0.3" | 16 | defmt-rtt = "0.3" |
| 16 | 17 | ||
| 17 | cortex-m = "0.7.3" | 18 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 18 | cortex-m-rt = "0.7.0" | 19 | cortex-m-rt = "0.7.0" |
| 19 | embedded-hal = "0.2.6" | 20 | embedded-hal = "0.2.6" |
| 20 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } | 21 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } |
diff --git a/examples/stm32l4/src/bin/adc.rs b/examples/stm32l4/src/bin/adc.rs index 93a20d5ea..281346e5f 100644 --- a/examples/stm32l4/src/bin/adc.rs +++ b/examples/stm32l4/src/bin/adc.rs | |||
| @@ -3,9 +3,9 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::time::Delay; | ||
| 7 | use embassy_stm32::adc::{Adc, Resolution}; | 6 | use embassy_stm32::adc::{Adc, Resolution}; |
| 8 | use embassy_stm32::pac; | 7 | use embassy_stm32::pac; |
| 8 | use embassy_time::Delay; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[cortex_m_rt::entry] | 11 | #[cortex_m_rt::entry] |
diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs index 3d689b5ee..033292fff 100644 --- a/examples/stm32l4/src/bin/blinky.rs +++ b/examples/stm32l4/src/bin/blinky.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); |
diff --git a/examples/stm32l4/src/bin/button_exti.rs b/examples/stm32l4/src/bin/button_exti.rs index 0832386ed..ef32d4c4a 100644 --- a/examples/stm32l4/src/bin/button_exti.rs +++ b/examples/stm32l4/src/bin/button_exti.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::exti::ExtiInput; | 7 | use embassy_stm32::exti::ExtiInput; |
| 8 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 9 | use embassy_stm32::Peripherals; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let button = Input::new(p.PC13, Pull::Up); | 16 | 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 058529ecf..d54c080c7 100644 --- a/examples/stm32l4/src/bin/i2c.rs +++ b/examples/stm32l4/src/bin/i2c.rs | |||
| @@ -3,20 +3,30 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::dma::NoDma; | 7 | use embassy_stm32::dma::NoDma; |
| 8 | use embassy_stm32::i2c::I2c; | 8 | use embassy_stm32::i2c::I2c; |
| 9 | use embassy_stm32::interrupt; | ||
| 9 | use embassy_stm32::time::Hertz; | 10 | use embassy_stm32::time::Hertz; |
| 10 | use embassy_stm32::{interrupt, Peripherals}; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | const ADDRESS: u8 = 0x5F; | 13 | const ADDRESS: u8 = 0x5F; |
| 14 | const WHOAMI: u8 = 0x0F; | 14 | const WHOAMI: u8 = 0x0F; |
| 15 | 15 | ||
| 16 | #[embassy_executor::main] | 16 | #[embassy_executor::main] |
| 17 | async fn main(_spawner: Spawner, p: Peripherals) -> ! { | 17 | async fn main(_spawner: Spawner) -> ! { |
| 18 | let p = embassy_stm32::init(Default::default()); | ||
| 18 | let irq = interrupt::take!(I2C2_EV); | 19 | let irq = interrupt::take!(I2C2_EV); |
| 19 | let mut i2c = I2c::new(p.I2C2, p.PB10, p.PB11, irq, NoDma, NoDma, Hertz(100_000)); | 20 | let mut i2c = I2c::new( |
| 21 | p.I2C2, | ||
| 22 | p.PB10, | ||
| 23 | p.PB11, | ||
| 24 | irq, | ||
| 25 | NoDma, | ||
| 26 | NoDma, | ||
| 27 | Hertz(100_000), | ||
| 28 | Default::default(), | ||
| 29 | ); | ||
| 20 | 30 | ||
| 21 | let mut data = [0u8; 1]; | 31 | let mut data = [0u8; 1]; |
| 22 | unwrap!(i2c.blocking_write_read(ADDRESS, &[WHOAMI], &mut data)); | 32 | unwrap!(i2c.blocking_write_read(ADDRESS, &[WHOAMI], &mut data)); |
diff --git a/examples/stm32l4/src/bin/i2c_blocking_async.rs b/examples/stm32l4/src/bin/i2c_blocking_async.rs index 2dae9c2d5..35a86660d 100644 --- a/examples/stm32l4/src/bin/i2c_blocking_async.rs +++ b/examples/stm32l4/src/bin/i2c_blocking_async.rs | |||
| @@ -4,11 +4,11 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_embedded_hal::adapter::BlockingAsync; | 6 | use embassy_embedded_hal::adapter::BlockingAsync; |
| 7 | use embassy_executor::executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::dma::NoDma; | 8 | use embassy_stm32::dma::NoDma; |
| 9 | use embassy_stm32::i2c::I2c; | 9 | use embassy_stm32::i2c::I2c; |
| 10 | use embassy_stm32::interrupt; | ||
| 10 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| 11 | use embassy_stm32::{interrupt, Peripherals}; | ||
| 12 | use embedded_hal_async::i2c::I2c as I2cTrait; | 12 | use embedded_hal_async::i2c::I2c as I2cTrait; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| @@ -16,9 +16,19 @@ const ADDRESS: u8 = 0x5F; | |||
| 16 | const WHOAMI: u8 = 0x0F; | 16 | const WHOAMI: u8 = 0x0F; |
| 17 | 17 | ||
| 18 | #[embassy_executor::main] | 18 | #[embassy_executor::main] |
| 19 | async fn main(_spawner: Spawner, p: Peripherals) -> ! { | 19 | async fn main(_spawner: Spawner) -> ! { |
| 20 | let p = embassy_stm32::init(Default::default()); | ||
| 20 | let irq = interrupt::take!(I2C2_EV); | 21 | let irq = interrupt::take!(I2C2_EV); |
| 21 | let i2c = I2c::new(p.I2C2, p.PB10, p.PB11, irq, NoDma, NoDma, Hertz(100_000)); | 22 | let i2c = I2c::new( |
| 23 | p.I2C2, | ||
| 24 | p.PB10, | ||
| 25 | p.PB11, | ||
| 26 | irq, | ||
| 27 | NoDma, | ||
| 28 | NoDma, | ||
| 29 | Hertz(100_000), | ||
| 30 | Default::default(), | ||
| 31 | ); | ||
| 22 | let mut i2c = BlockingAsync::new(i2c); | 32 | let mut i2c = BlockingAsync::new(i2c); |
| 23 | 33 | ||
| 24 | let mut data = [0u8; 1]; | 34 | let mut data = [0u8; 1]; |
diff --git a/examples/stm32l4/src/bin/i2c_dma.rs b/examples/stm32l4/src/bin/i2c_dma.rs index 9e71d404b..3ce9398a4 100644 --- a/examples/stm32l4/src/bin/i2c_dma.rs +++ b/examples/stm32l4/src/bin/i2c_dma.rs | |||
| @@ -3,19 +3,29 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::i2c::I2c; | 7 | use embassy_stm32::i2c::I2c; |
| 8 | use embassy_stm32::interrupt; | ||
| 8 | use embassy_stm32::time::Hertz; | 9 | use embassy_stm32::time::Hertz; |
| 9 | use embassy_stm32::{interrupt, Peripherals}; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | const ADDRESS: u8 = 0x5F; | 12 | const ADDRESS: u8 = 0x5F; |
| 13 | const WHOAMI: u8 = 0x0F; | 13 | const WHOAMI: u8 = 0x0F; |
| 14 | 14 | ||
| 15 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| 16 | async fn main(_spawner: Spawner, p: Peripherals) -> ! { | 16 | async fn main(_spawner: Spawner) -> ! { |
| 17 | let p = embassy_stm32::init(Default::default()); | ||
| 17 | let irq = interrupt::take!(I2C2_EV); | 18 | let irq = interrupt::take!(I2C2_EV); |
| 18 | let mut i2c = I2c::new(p.I2C2, p.PB10, p.PB11, irq, p.DMA1_CH4, p.DMA1_CH5, Hertz(100_000)); | 19 | let mut i2c = I2c::new( |
| 20 | p.I2C2, | ||
| 21 | p.PB10, | ||
| 22 | p.PB11, | ||
| 23 | irq, | ||
| 24 | p.DMA1_CH4, | ||
| 25 | p.DMA1_CH5, | ||
| 26 | Hertz(100_000), | ||
| 27 | Default::default(), | ||
| 28 | ); | ||
| 19 | 29 | ||
| 20 | let mut data = [0u8; 1]; | 30 | let mut data = [0u8; 1]; |
| 21 | unwrap!(i2c.write_read(ADDRESS, &[WHOAMI], &mut data).await); | 31 | unwrap!(i2c.write_read(ADDRESS, &[WHOAMI], &mut data).await); |
diff --git a/examples/stm32l4/src/bin/rng.rs b/examples/stm32l4/src/bin/rng.rs index ed47fc6c9..c9302bb99 100644 --- a/examples/stm32l4/src/bin/rng.rs +++ b/examples/stm32l4/src/bin/rng.rs | |||
| @@ -3,13 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; | 7 | use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; |
| 8 | use embassy_stm32::rng::Rng; | 8 | use embassy_stm32::rng::Rng; |
| 9 | use embassy_stm32::{Config, Peripherals}; | 9 | use embassy_stm32::Config; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | fn config() -> Config { | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) { | ||
| 13 | let mut config = Config::default(); | 14 | let mut config = Config::default(); |
| 14 | // 72Mhz clock (16 / 1 * 18 / 4) | 15 | // 72Mhz clock (16 / 1 * 18 / 4) |
| 15 | config.rcc.mux = ClockSrc::PLL( | 16 | config.rcc.mux = ClockSrc::PLL( |
| @@ -19,11 +20,8 @@ fn config() -> Config { | |||
| 19 | PLLMul::Mul18, | 20 | PLLMul::Mul18, |
| 20 | Some(PLLClkDiv::Div6), // 48Mhz (16 / 1 * 18 / 6) | 21 | Some(PLLClkDiv::Div6), // 48Mhz (16 / 1 * 18 / 6) |
| 21 | ); | 22 | ); |
| 22 | config | 23 | let p = embassy_stm32::init(config); |
| 23 | } | ||
| 24 | 24 | ||
| 25 | #[embassy_executor::main(config = "config()")] | ||
| 26 | async fn main(_spawner: Spawner, p: Peripherals) { | ||
| 27 | info!("Hello World!"); | 25 | info!("Hello World!"); |
| 28 | 26 | ||
| 29 | let mut rng = Rng::new(p.RNG); | 27 | let mut rng = Rng::new(p.RNG); |
diff --git a/examples/stm32l4/src/bin/spi_blocking_async.rs b/examples/stm32l4/src/bin/spi_blocking_async.rs index e06b29b81..62ef0130e 100644 --- a/examples/stm32l4/src/bin/spi_blocking_async.rs +++ b/examples/stm32l4/src/bin/spi_blocking_async.rs | |||
| @@ -4,17 +4,17 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_embedded_hal::adapter::BlockingAsync; | 6 | use embassy_embedded_hal::adapter::BlockingAsync; |
| 7 | use embassy_executor::executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::dma::NoDma; | 8 | use embassy_stm32::dma::NoDma; |
| 9 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 9 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 10 | use embassy_stm32::spi::{Config, Spi}; | 10 | use embassy_stm32::spi::{Config, Spi}; |
| 11 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| 12 | use embassy_stm32::Peripherals; | ||
| 13 | use embedded_hal_async::spi::SpiBus; | 12 | use embedded_hal_async::spi::SpiBus; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 14 | ||
| 16 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| 17 | async fn main(_spawner: Spawner, p: Peripherals) { | 16 | async fn main(_spawner: Spawner) { |
| 17 | let p = embassy_stm32::init(Default::default()); | ||
| 18 | info!("Hello World!"); | 18 | info!("Hello World!"); |
| 19 | 19 | ||
| 20 | let spi = Spi::new( | 20 | let spi = Spi::new( |
diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index e44754bec..89471db5a 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs | |||
| @@ -3,15 +3,15 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 7 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 8 | use embassy_stm32::spi::{Config, Spi}; | 8 | use embassy_stm32::spi::{Config, Spi}; |
| 9 | use embassy_stm32::time::Hertz; | 9 | use embassy_stm32::time::Hertz; |
| 10 | use embassy_stm32::Peripherals; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | info!("Hello World!"); | 15 | info!("Hello World!"); |
| 16 | 16 | ||
| 17 | let mut spi = Spi::new( | 17 | let mut spi = Spi::new( |
diff --git a/examples/stm32l4/src/bin/usart_dma.rs b/examples/stm32l4/src/bin/usart_dma.rs index fdd5a85e6..728906897 100644 --- a/examples/stm32l4/src/bin/usart_dma.rs +++ b/examples/stm32l4/src/bin/usart_dma.rs | |||
| @@ -5,15 +5,15 @@ | |||
| 5 | use core::fmt::Write; | 5 | use core::fmt::Write; |
| 6 | 6 | ||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy_executor::executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::dma::NoDma; | 9 | use embassy_stm32::dma::NoDma; |
| 10 | use embassy_stm32::usart::{Config, Uart}; | 10 | use embassy_stm32::usart::{Config, Uart}; |
| 11 | use embassy_stm32::Peripherals; | ||
| 12 | use heapless::String; | 11 | use heapless::String; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 13 | ||
| 15 | #[embassy_executor::main] | 14 | #[embassy_executor::main] |
| 16 | async fn main(_spawner: Spawner, p: Peripherals) { | 15 | async fn main(_spawner: Spawner) { |
| 16 | let p = embassy_stm32::init(Default::default()); | ||
| 17 | info!("Hello World!"); | 17 | info!("Hello World!"); |
| 18 | 18 | ||
| 19 | let config = Config::default(); | 19 | let config = Config::default(); |
diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index 6466994ed..4d96d31fc 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml | |||
| @@ -7,7 +7,8 @@ version = "0.1.0" | |||
| 7 | 7 | ||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 9 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 10 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } | 10 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 11 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | ||
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "unstable-traits", "memory-x"] } | 12 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "unstable-traits", "memory-x"] } |
| 12 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 13 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
| 13 | embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"] } | 14 | embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"] } |
| @@ -20,7 +21,7 @@ defmt = "0.3" | |||
| 20 | defmt-rtt = "0.3" | 21 | defmt-rtt = "0.3" |
| 21 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 22 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 22 | 23 | ||
| 23 | cortex-m = "0.7.3" | 24 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 24 | cortex-m-rt = "0.7.0" | 25 | cortex-m-rt = "0.7.0" |
| 25 | embedded-hal = "0.2.6" | 26 | embedded-hal = "0.2.6" |
| 26 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 27 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
diff --git a/examples/stm32l5/src/bin/button_exti.rs b/examples/stm32l5/src/bin/button_exti.rs index 99462e597..e80ad2b3a 100644 --- a/examples/stm32l5/src/bin/button_exti.rs +++ b/examples/stm32l5/src/bin/button_exti.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::exti::ExtiInput; | 7 | use embassy_stm32::exti::ExtiInput; |
| 8 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 9 | use embassy_stm32::Peripherals; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let button = Input::new(p.PC13, Pull::Down); | 16 | let button = Input::new(p.PC13, Pull::Down); |
diff --git a/examples/stm32l5/src/bin/rng.rs b/examples/stm32l5/src/bin/rng.rs index 45094374b..d359847e8 100644 --- a/examples/stm32l5/src/bin/rng.rs +++ b/examples/stm32l5/src/bin/rng.rs | |||
| @@ -3,13 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; | 7 | use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; |
| 8 | use embassy_stm32::rng::Rng; | 8 | use embassy_stm32::rng::Rng; |
| 9 | use embassy_stm32::{Config, Peripherals}; | 9 | use embassy_stm32::Config; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | fn config() -> Config { | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) { | ||
| 13 | let mut config = Config::default(); | 14 | let mut config = Config::default(); |
| 14 | config.rcc.mux = ClockSrc::PLL( | 15 | config.rcc.mux = ClockSrc::PLL( |
| 15 | PLLSource::HSI16, | 16 | PLLSource::HSI16, |
| @@ -18,11 +19,8 @@ fn config() -> Config { | |||
| 18 | PLLMul::Mul8, | 19 | PLLMul::Mul8, |
| 19 | Some(PLLClkDiv::Div2), | 20 | Some(PLLClkDiv::Div2), |
| 20 | ); | 21 | ); |
| 21 | config | 22 | let p = embassy_stm32::init(config); |
| 22 | } | ||
| 23 | 23 | ||
| 24 | #[embassy_executor::main(config = "config()")] | ||
| 25 | async fn main(_spawner: Spawner, p: Peripherals) { | ||
| 26 | info!("Hello World!"); | 24 | info!("Hello World!"); |
| 27 | 25 | ||
| 28 | let mut rng = Rng::new(p.RNG); | 26 | let mut rng = Rng::new(p.RNG); |
diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index 9e1df15dd..7c53d03cc 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs | |||
| @@ -7,14 +7,14 @@ use core::sync::atomic::{AtomicBool, Ordering}; | |||
| 7 | use core::task::Waker; | 7 | use core::task::Waker; |
| 8 | 8 | ||
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy_executor::executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_net::tcp::TcpSocket; | 11 | use embassy_net::tcp::TcpSocket; |
| 12 | use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources}; | 12 | use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources}; |
| 13 | use embassy_stm32::rcc::*; | 13 | use embassy_stm32::rcc::*; |
| 14 | use embassy_stm32::rng::Rng; | 14 | use embassy_stm32::rng::Rng; |
| 15 | use embassy_stm32::time::Hertz; | 15 | use embassy_stm32::time::Hertz; |
| 16 | use embassy_stm32::usb::Driver; | 16 | use embassy_stm32::usb::Driver; |
| 17 | use embassy_stm32::{interrupt, Config, Peripherals}; | 17 | use embassy_stm32::{interrupt, Config}; |
| 18 | use embassy_usb::{Builder, UsbDevice}; | 18 | use embassy_usb::{Builder, UsbDevice}; |
| 19 | use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; | 19 | use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; |
| 20 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | 20 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; |
| @@ -83,18 +83,13 @@ async fn net_task(stack: &'static Stack<Device>) -> ! { | |||
| 83 | stack.run().await | 83 | stack.run().await |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | fn config() -> Config { | 86 | #[embassy_executor::main] |
| 87 | async fn main(spawner: Spawner) { | ||
| 87 | let mut config = Config::default(); | 88 | let mut config = Config::default(); |
| 88 | config.rcc.mux = ClockSrc::HSE(Hertz(16_000_000)); | ||
| 89 | |||
| 90 | config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); | 89 | config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); |
| 91 | config.rcc.hsi48 = true; | 90 | config.rcc.hsi48 = true; |
| 91 | let p = embassy_stm32::init(config); | ||
| 92 | 92 | ||
| 93 | config | ||
| 94 | } | ||
| 95 | |||
| 96 | #[embassy_executor::main(config = "config()")] | ||
| 97 | async fn main(spawner: Spawner, p: Peripherals) { | ||
| 98 | // Create the driver, from the HAL. | 93 | // Create the driver, from the HAL. |
| 99 | let irq = interrupt::take!(USB_FS); | 94 | let irq = interrupt::take!(USB_FS); |
| 100 | let driver = Driver::new(p.USB, irq, p.PA12, p.PA11); | 95 | let driver = Driver::new(p.USB, irq, p.PA12, p.PA11); |
diff --git a/examples/stm32l5/src/bin/usb_hid_mouse.rs b/examples/stm32l5/src/bin/usb_hid_mouse.rs index 6aac00881..f7e3d93e3 100644 --- a/examples/stm32l5/src/bin/usb_hid_mouse.rs +++ b/examples/stm32l5/src/bin/usb_hid_mouse.rs | |||
| @@ -4,12 +4,12 @@ | |||
| 4 | #![feature(type_alias_impl_trait)] | 4 | #![feature(type_alias_impl_trait)] |
| 5 | 5 | ||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_executor::time::{Duration, Timer}; | ||
| 9 | use embassy_stm32::rcc::*; | 8 | use embassy_stm32::rcc::*; |
| 10 | use embassy_stm32::time::Hertz; | 9 | use embassy_stm32::time::Hertz; |
| 11 | use embassy_stm32::usb::Driver; | 10 | use embassy_stm32::usb::Driver; |
| 12 | use embassy_stm32::{interrupt, Config, Peripherals}; | 11 | use embassy_stm32::{interrupt, Config, Peripherals}; |
| 12 | use embassy_time::{Duration, Timer}; | ||
| 13 | use embassy_usb::control::OutResponse; | 13 | use embassy_usb::control::OutResponse; |
| 14 | use embassy_usb::Builder; | 14 | use embassy_usb::Builder; |
| 15 | use embassy_usb_hid::{HidWriter, ReportId, RequestHandler, State}; | 15 | use embassy_usb_hid::{HidWriter, ReportId, RequestHandler, State}; |
| @@ -17,18 +17,13 @@ use futures::future::join; | |||
| 17 | use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; | 17 | use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | fn config() -> Config { | 20 | #[embassy_executor::main] |
| 21 | async fn main(_spawner: Spawner) { | ||
| 21 | let mut config = Config::default(); | 22 | let mut config = Config::default(); |
| 22 | config.rcc.mux = ClockSrc::HSE(Hertz(16_000_000)); | ||
| 23 | |||
| 24 | config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); | 23 | config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); |
| 25 | config.rcc.hsi48 = true; | 24 | config.rcc.hsi48 = true; |
| 25 | let p = embassy_stm32::init(config); | ||
| 26 | 26 | ||
| 27 | config | ||
| 28 | } | ||
| 29 | |||
| 30 | #[embassy_executor::main(config = "config()")] | ||
| 31 | async fn main(_spawner: Spawner, p: Peripherals) { | ||
| 32 | // Create the driver, from the HAL. | 27 | // Create the driver, from the HAL. |
| 33 | let irq = interrupt::take!(USB_FS); | 28 | let irq = interrupt::take!(USB_FS); |
| 34 | let driver = Driver::new(p.USB, irq, p.PA12, p.PA11); | 29 | let driver = Driver::new(p.USB, irq, p.PA12, p.PA11); |
diff --git a/examples/stm32l5/src/bin/usb_serial.rs b/examples/stm32l5/src/bin/usb_serial.rs index 508bce8a8..323db6557 100644 --- a/examples/stm32l5/src/bin/usb_serial.rs +++ b/examples/stm32l5/src/bin/usb_serial.rs | |||
| @@ -3,29 +3,24 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{panic, *}; | 5 | use defmt::{panic, *}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rcc::*; | 7 | use embassy_stm32::rcc::*; |
| 8 | use embassy_stm32::time::Hertz; | 8 | use embassy_stm32::time::Hertz; |
| 9 | use embassy_stm32::usb::{Driver, Instance}; | 9 | use embassy_stm32::usb::{Driver, Instance}; |
| 10 | use embassy_stm32::{interrupt, Config, Peripherals}; | 10 | use embassy_stm32::{interrupt, Config}; |
| 11 | use embassy_usb::driver::EndpointError; | 11 | use embassy_usb::driver::EndpointError; |
| 12 | use embassy_usb::Builder; | 12 | use embassy_usb::Builder; |
| 13 | use embassy_usb_serial::{CdcAcmClass, State}; | 13 | use embassy_usb_serial::{CdcAcmClass, State}; |
| 14 | use futures::future::join; | 14 | use futures::future::join; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
| 17 | fn config() -> Config { | 17 | #[embassy_executor::main] |
| 18 | async fn main(_spawner: Spawner) { | ||
| 18 | let mut config = Config::default(); | 19 | let mut config = Config::default(); |
| 19 | config.rcc.mux = ClockSrc::HSE(Hertz(16_000_000)); | ||
| 20 | |||
| 21 | config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); | 20 | config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); |
| 22 | config.rcc.hsi48 = true; | 21 | config.rcc.hsi48 = true; |
| 22 | let p = embassy_stm32::init(config); | ||
| 23 | 23 | ||
| 24 | config | ||
| 25 | } | ||
| 26 | |||
| 27 | #[embassy_executor::main(config = "config()")] | ||
| 28 | async fn main(_spawner: Spawner, p: Peripherals) { | ||
| 29 | info!("Hello World!"); | 24 | info!("Hello World!"); |
| 30 | 25 | ||
| 31 | // Create the driver, from the HAL. | 26 | // Create the driver, from the HAL. |
diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml index 4ce95be4c..48833664a 100644 --- a/examples/stm32u5/Cargo.toml +++ b/examples/stm32u5/Cargo.toml | |||
| @@ -5,13 +5,14 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } |
| 10 | 11 | ||
| 11 | defmt = "0.3" | 12 | defmt = "0.3" |
| 12 | defmt-rtt = "0.3" | 13 | defmt-rtt = "0.3" |
| 13 | 14 | ||
| 14 | cortex-m = "0.7.3" | 15 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 15 | cortex-m-rt = "0.7.0" | 16 | cortex-m-rt = "0.7.0" |
| 16 | embedded-hal = "0.2.6" | 17 | embedded-hal = "0.2.6" |
| 17 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 18 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
diff --git a/examples/stm32u5/src/bin/blinky.rs b/examples/stm32u5/src/bin/blinky.rs index 4f3eabc5e..976fb0b9a 100644 --- a/examples/stm32u5/src/bin/blinky.rs +++ b/examples/stm32u5/src/bin/blinky.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) -> ! { | 12 | async fn main(_spawner: Spawner) -> ! { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PH7, Level::Low, Speed::Medium); | 16 | let mut led = Output::new(p.PH7, Level::Low, Speed::Medium); |
diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index dc9107dd0..b46300764 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml | |||
| @@ -5,13 +5,14 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55cc", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55cc", "time-driver-any", "exti"] } |
| 10 | 11 | ||
| 11 | defmt = "0.3" | 12 | defmt = "0.3" |
| 12 | defmt-rtt = "0.3" | 13 | defmt-rtt = "0.3" |
| 13 | 14 | ||
| 14 | cortex-m = "0.7.3" | 15 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 15 | cortex-m-rt = "0.7.0" | 16 | cortex-m-rt = "0.7.0" |
| 16 | embedded-hal = "0.2.6" | 17 | embedded-hal = "0.2.6" |
| 17 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 18 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
diff --git a/examples/stm32wb/src/bin/blinky.rs b/examples/stm32wb/src/bin/blinky.rs index 3d8e8391d..f9bf90d2e 100644 --- a/examples/stm32wb/src/bin/blinky.rs +++ b/examples/stm32wb/src/bin/blinky.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PB0, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB0, Level::High, Speed::Low); |
diff --git a/examples/stm32wb/src/bin/button_exti.rs b/examples/stm32wb/src/bin/button_exti.rs index 41afaf4d6..3648db6ff 100644 --- a/examples/stm32wb/src/bin/button_exti.rs +++ b/examples/stm32wb/src/bin/button_exti.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::exti::ExtiInput; | 7 | use embassy_stm32::exti::ExtiInput; |
| 8 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 9 | use embassy_stm32::Peripherals; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let button = Input::new(p.PC4, Pull::Up); | 16 | let button = Input::new(p.PC4, Pull::Up); |
diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 00d63f02d..ae33478af 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml | |||
| @@ -5,7 +5,8 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "subghz", "unstable-pac", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "subghz", "unstable-pac", "exti"] } |
| 10 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time", "defmt"] } | 11 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time", "defmt"] } |
| 11 | 12 | ||
| @@ -15,7 +16,7 @@ lorawan = { version = "0.7.1", default-features = false, features = ["default-cr | |||
| 15 | defmt = "0.3" | 16 | defmt = "0.3" |
| 16 | defmt-rtt = "0.3" | 17 | defmt-rtt = "0.3" |
| 17 | 18 | ||
| 18 | cortex-m = "0.7.3" | 19 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 19 | cortex-m-rt = "0.7.0" | 20 | cortex-m-rt = "0.7.0" |
| 20 | embedded-hal = "0.2.6" | 21 | embedded-hal = "0.2.6" |
| 21 | embedded-storage = "0.3.0" | 22 | embedded-storage = "0.3.0" |
diff --git a/examples/stm32wl/src/bin/blinky.rs b/examples/stm32wl/src/bin/blinky.rs index e764b4cc3..6af5099ce 100644 --- a/examples/stm32wl/src/bin/blinky.rs +++ b/examples/stm32wl/src/bin/blinky.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PB15, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB15, Level::High, Speed::Low); |
diff --git a/examples/stm32wl/src/bin/button_exti.rs b/examples/stm32wl/src/bin/button_exti.rs index 9f143597d..1f02db5cf 100644 --- a/examples/stm32wl/src/bin/button_exti.rs +++ b/examples/stm32wl/src/bin/button_exti.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::exti::ExtiInput; | 7 | use embassy_stm32::exti::ExtiInput; |
| 8 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 9 | use embassy_stm32::Peripherals; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let button = Input::new(p.PA0, Pull::Up); | 16 | let button = Input::new(p.PA0, Pull::Up); |
diff --git a/examples/stm32wl/src/bin/flash.rs b/examples/stm32wl/src/bin/flash.rs index 46183b8a2..eb7489760 100644 --- a/examples/stm32wl/src/bin/flash.rs +++ b/examples/stm32wl/src/bin/flash.rs | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::flash::Flash; | 7 | use embassy_stm32::flash::Flash; |
| 8 | use embassy_stm32::Peripherals; | ||
| 9 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; | 8 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello Flash!"); | 14 | info!("Hello Flash!"); |
| 15 | 15 | ||
| 16 | const ADDR: u32 = 0x36000; | 16 | const ADDR: u32 = 0x36000; |
diff --git a/examples/stm32wl/src/bin/lorawan.rs b/examples/stm32wl/src/bin/lorawan.rs index 2db022ea2..7e8a8946d 100644 --- a/examples/stm32wl/src/bin/lorawan.rs +++ b/examples/stm32wl/src/bin/lorawan.rs | |||
| @@ -5,26 +5,25 @@ | |||
| 5 | #![feature(generic_associated_types)] | 5 | #![feature(generic_associated_types)] |
| 6 | #![feature(type_alias_impl_trait)] | 6 | #![feature(type_alias_impl_trait)] |
| 7 | 7 | ||
| 8 | use embassy_executor::Spawner; | ||
| 8 | use embassy_lora::stm32wl::*; | 9 | use embassy_lora::stm32wl::*; |
| 9 | use embassy_lora::LoraTimer; | 10 | use embassy_lora::LoraTimer; |
| 10 | use embassy_stm32::dma::NoDma; | 11 | use embassy_stm32::dma::NoDma; |
| 11 | use embassy_stm32::gpio::{Level, Output, Pin, Speed}; | 12 | use embassy_stm32::gpio::{Level, Output, Pin, Speed}; |
| 12 | use embassy_stm32::rng::Rng; | 13 | use embassy_stm32::rng::Rng; |
| 13 | use embassy_stm32::subghz::*; | 14 | use embassy_stm32::subghz::*; |
| 14 | use embassy_stm32::{interrupt, pac, Peripherals}; | 15 | use embassy_stm32::{interrupt, pac}; |
| 15 | use lorawan::default_crypto::DefaultFactory as Crypto; | 16 | use lorawan::default_crypto::DefaultFactory as Crypto; |
| 16 | use lorawan_device::async_device::{region, Device, JoinMode}; | 17 | use lorawan_device::async_device::{region, Device, JoinMode}; |
| 17 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | 19 | ||
| 19 | fn config() -> embassy_stm32::Config { | 20 | #[embassy_executor::main] |
| 21 | async fn main(_spawner: Spawner) { | ||
| 20 | let mut config = embassy_stm32::Config::default(); | 22 | let mut config = embassy_stm32::Config::default(); |
| 21 | config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; | 23 | config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; |
| 22 | config.rcc.enable_lsi = true; | 24 | config.rcc.enable_lsi = true; |
| 23 | config | 25 | let p = embassy_stm32::init(config); |
| 24 | } | ||
| 25 | 26 | ||
| 26 | #[embassy_executor::main(config = "config()")] | ||
| 27 | async fn main(_spawner: embassy_executor::executor::Spawner, p: Peripherals) { | ||
| 28 | unsafe { pac::RCC.ccipr().modify(|w| w.set_rngsel(0b01)) } | 27 | unsafe { pac::RCC.ccipr().modify(|w| w.set_rngsel(0b01)) } |
| 29 | 28 | ||
| 30 | let ctrl1 = Output::new(p.PC3.degrade(), Level::High, Speed::High); | 29 | let ctrl1 = Output::new(p.PC3.degrade(), Level::High, Speed::High); |
diff --git a/examples/stm32wl/src/bin/subghz.rs b/examples/stm32wl/src/bin/subghz.rs index 775dfbbfc..d16e3f5e4 100644 --- a/examples/stm32wl/src/bin/subghz.rs +++ b/examples/stm32wl/src/bin/subghz.rs | |||
| @@ -6,12 +6,13 @@ | |||
| 6 | #![feature(type_alias_impl_trait)] | 6 | #![feature(type_alias_impl_trait)] |
| 7 | 7 | ||
| 8 | use defmt::*; | 8 | use defmt::*; |
| 9 | use embassy_executor::Spawner; | ||
| 9 | use embassy_stm32::dma::NoDma; | 10 | use embassy_stm32::dma::NoDma; |
| 10 | use embassy_stm32::exti::ExtiInput; | 11 | use embassy_stm32::exti::ExtiInput; |
| 11 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 13 | use embassy_stm32::interrupt; | ||
| 12 | use embassy_stm32::interrupt::{Interrupt, InterruptExt}; | 14 | use embassy_stm32::interrupt::{Interrupt, InterruptExt}; |
| 13 | use embassy_stm32::subghz::*; | 15 | use embassy_stm32::subghz::*; |
| 14 | use embassy_stm32::{interrupt, Peripherals}; | ||
| 15 | use embassy_util::channel::signal::Signal; | 16 | use embassy_util::channel::signal::Signal; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 17 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 18 | ||
| @@ -51,14 +52,12 @@ const TCXO_MODE: TcxoMode = TcxoMode::new() | |||
| 51 | 52 | ||
| 52 | const TX_PARAMS: TxParams = TxParams::new().set_power(0x0D).set_ramp_time(RampTime::Micros40); | 53 | const TX_PARAMS: TxParams = TxParams::new().set_power(0x0D).set_ramp_time(RampTime::Micros40); |
| 53 | 54 | ||
| 54 | fn config() -> embassy_stm32::Config { | 55 | #[embassy_executor::main] |
| 56 | async fn main(_spawner: Spawner) { | ||
| 55 | let mut config = embassy_stm32::Config::default(); | 57 | let mut config = embassy_stm32::Config::default(); |
| 56 | config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; | 58 | config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; |
| 57 | config | 59 | let p = embassy_stm32::init(config); |
| 58 | } | ||
| 59 | 60 | ||
| 60 | #[embassy_executor::main(config = "config()")] | ||
| 61 | async fn main(_spawner: embassy_executor::executor::Spawner, p: Peripherals) { | ||
| 62 | let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); | 61 | let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); |
| 63 | let mut led2 = Output::new(p.PB9, Level::Low, Speed::Low); | 62 | let mut led2 = Output::new(p.PB9, Level::Low, Speed::Low); |
| 64 | let mut led3 = Output::new(p.PB11, Level::Low, Speed::Low); | 63 | let mut led3 = Output::new(p.PB11, Level::Low, Speed::Low); |
diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml index 4e26f023c..c7f980366 100644 --- a/examples/wasm/Cargo.toml +++ b/examples/wasm/Cargo.toml | |||
| @@ -8,10 +8,11 @@ crate-type = ["cdylib"] | |||
| 8 | 8 | ||
| 9 | [dependencies] | 9 | [dependencies] |
| 10 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] } | 10 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] } |
| 11 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "wasm", "nightly"] } | 11 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "wasm", "nightly", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["log", "wasm", "nightly"] } | ||
| 12 | 13 | ||
| 13 | wasm-logger = "0.2.0" | 14 | wasm-logger = "0.2.0" |
| 14 | wasm-bindgen = "0.2" | 15 | wasm-bindgen = "0.2" |
| 15 | web-sys = { version = "0.3", features = ["Document", "Element", "HtmlElement", "Node", "Window" ] } | 16 | web-sys = { version = "0.3", features = ["Document", "Element", "HtmlElement", "Node", "Window" ] } |
| 16 | log = "0.4.11" | 17 | log = "0.4.11" |
| 17 | critical-section = "0.2.5" | 18 | critical-section = "1.1" |
diff --git a/examples/wasm/src/lib.rs b/examples/wasm/src/lib.rs index 2e961e65a..d44c020b6 100644 --- a/examples/wasm/src/lib.rs +++ b/examples/wasm/src/lib.rs | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | #![feature(type_alias_impl_trait)] | 1 | #![feature(type_alias_impl_trait)] |
| 2 | #![allow(incomplete_features)] | 2 | #![allow(incomplete_features)] |
| 3 | 3 | ||
| 4 | use embassy_executor::executor::Spawner; | 4 | use embassy_executor::Spawner; |
| 5 | use embassy_executor::time::{Duration, Timer}; | 5 | use embassy_time::{Duration, Timer}; |
| 6 | 6 | ||
| 7 | #[embassy_executor::task] | 7 | #[embassy_executor::task] |
| 8 | async fn ticker() { | 8 | async fn ticker() { |
