diff options
281 files changed, 1373 insertions, 1155 deletions
| @@ -16,7 +16,7 @@ Rust's <a href="https://rust-lang.github.io/async-book/">async/await</a> allows | |||
| 16 | - <a href="https://docs.embassy.dev/embassy-nrf/">embassy-nrf</a>, for the Nordic Semiconductor nRF52, nRF53, nRF91 series. | 16 | - <a href="https://docs.embassy.dev/embassy-nrf/">embassy-nrf</a>, for the Nordic Semiconductor nRF52, nRF53, nRF91 series. |
| 17 | 17 | ||
| 18 | - **Time that Just Works** - | 18 | - **Time that Just Works** - |
| 19 | No more messing with hardware timers. <a href="https://docs.embassy.dev/embassy/git/thumbv7em-none-eabihf/time/index.html">embassy_executor::time</a> provides Instant, Duration and Timer types that are globally available and never overflow. | 19 | No more messing with hardware timers. <a href="https://docs.embassy.dev/embassy-time">embassy_time</a> provides Instant, Duration and Timer types that are globally available and never overflow. |
| 20 | 20 | ||
| 21 | - **Real-time ready** - | 21 | - **Real-time ready** - |
| 22 | Tasks on the same async executor run cooperatively, but you can create multiple executors with different priorities, so that higher priority tasks preempt lower priority ones. See the <a href="https://github.com/embassy-rs/embassy/blob/master/examples/nrf/src/bin/multiprio.rs">example</a>. | 22 | Tasks on the same async executor run cooperatively, but you can create multiple executors with different priorities, so that higher priority tasks preempt lower priority ones. See the <a href="https://github.com/embassy-rs/embassy/blob/master/examples/nrf/src/bin/multiprio.rs">example</a>. |
| @@ -44,8 +44,8 @@ The <a href="https://github.com/embassy-rs/nrf-softdevice">nrf-softdevice</a> cr | |||
| 44 | 44 | ||
| 45 | ```rust,ignore | 45 | ```rust,ignore |
| 46 | use defmt::info; | 46 | use defmt::info; |
| 47 | use embassy_executor::executor::Spawner; | 47 | use embassy_executor::Spawner; |
| 48 | use embassy_executor::time::{Duration, Timer}; | 48 | use embassy_time::{Duration, Timer}; |
| 49 | use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull}; | 49 | use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull}; |
| 50 | use embassy_nrf::Peripherals; | 50 | use embassy_nrf::Peripherals; |
| 51 | 51 | ||
| @@ -65,7 +65,9 @@ async fn blink(pin: AnyPin) { | |||
| 65 | 65 | ||
| 66 | // Main is itself an async task as well. | 66 | // Main is itself an async task as well. |
| 67 | #[embassy_executor::main] | 67 | #[embassy_executor::main] |
| 68 | async fn main(spawner: Spawner, p: Peripherals) { | 68 | async fn main(spawner: Spawner) { |
| 69 | let p = embassy_nrf::init(Default::default()); | ||
| 70 | |||
| 69 | // Spawned tasks run in the background, concurrently. | 71 | // Spawned tasks run in the background, concurrently. |
| 70 | spawner.spawn(blink(p.P0_13.degrade())).unwrap(); | 72 | spawner.spawn(blink(p.P0_13.degrade())).unwrap(); |
| 71 | 73 | ||
| @@ -54,25 +54,25 @@ cargo batch \ | |||
| 54 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits,log \ | 54 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits,log \ |
| 55 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits \ | 55 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits \ |
| 56 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly \ | 56 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly \ |
| 57 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f410tb,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 57 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f410tb,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 58 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f411ce,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 58 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f411ce,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 59 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f429zi,log,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 59 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f429zi,log,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 60 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 60 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 61 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h7b3ai,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 61 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h7b3ai,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 62 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32l476vg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 62 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32l476vg,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 63 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wb15cc,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 63 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wb15cc,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 64 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l072cz,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 64 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l072cz,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 65 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l041f6,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 65 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l041f6,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 66 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32l151cb-a,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 66 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32l151cb-a,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 67 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f398ve,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 67 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f398ve,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 68 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32g0c1ve,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 68 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32g0c1ve,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 69 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f217zg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 69 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f217zg,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 70 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,stm32l552ze,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 70 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,stm32l552ze,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 71 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32wl54jc-cm0p,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 71 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32wl54jc-cm0p,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 72 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wle5ub,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 72 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wle5ub,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 73 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f107vc,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 73 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f107vc,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 74 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f103re,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 74 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f103re,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 75 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f100c4,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 75 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f100c4,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 76 | --- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \ | 76 | --- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \ |
| 77 | --- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \ | 77 | --- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \ |
| 78 | --- build --release --manifest-path docs/modules/ROOT/examples/basic/Cargo.toml --target thumbv7em-none-eabi \ | 78 | --- build --release --manifest-path docs/modules/ROOT/examples/basic/Cargo.toml --target thumbv7em-none-eabi \ |
diff --git a/ci_stable.sh b/ci_stable.sh index 7521827d8..d388cfee3 100755 --- a/ci_stable.sh +++ b/ci_stable.sh | |||
| @@ -30,38 +30,38 @@ cargo batch \ | |||
| 30 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,defmt \ | 30 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,defmt \ |
| 31 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,log \ | 31 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,log \ |
| 32 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi \ | 32 | --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi \ |
| 33 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 33 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 34 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 34 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 35 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 35 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 36 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55vy,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 36 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55vy,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 37 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wl55uc-cm4,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 37 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wl55uc-cm4,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 38 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l4r9zi,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 38 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l4r9zi,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 39 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f303vc,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 39 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f303vc,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 40 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ | 40 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy-time?/tick-32768hz \ |
| 41 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 41 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 42 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy-executor/time-tick-32768hz \ | 42 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy-time?/tick-32768hz \ |
| 43 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 43 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 44 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ | 44 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,embassy-time?/tick-32768hz \ |
| 45 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 45 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 46 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ | 46 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy-time?/tick-32768hz \ |
| 47 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 47 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 48 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ | 48 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy-time?/tick-32768hz \ |
| 49 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 49 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 50 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ | 50 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,embassy-time?/tick-32768hz \ |
| 51 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 51 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 52 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ | 52 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \ |
| 53 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 53 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 54 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embassy-executor/time-tick-32768hz \ | 54 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embassy-time?/tick-32768hz \ |
| 55 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 55 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 56 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ | 56 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \ |
| 57 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 57 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 58 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ | 58 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \ |
| 59 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 59 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 60 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ | 60 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \ |
| 61 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 61 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 62 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ | 62 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \ |
| 63 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 63 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 64 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ | 64 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \ |
| 65 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ | 65 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ |
| 66 | --- build --release --manifest-path examples/nrf/Cargo.toml --target thumbv7em-none-eabi --no-default-features --out-dir out/examples/nrf --bin raw_spawn \ | 66 | --- build --release --manifest-path examples/nrf/Cargo.toml --target thumbv7em-none-eabi --no-default-features --out-dir out/examples/nrf --bin raw_spawn \ |
| 67 | --- build --release --manifest-path examples/stm32l0/Cargo.toml --target thumbv6m-none-eabi --no-default-features --out-dir out/examples/stm32l0 --bin raw_spawn \ | 67 | --- build --release --manifest-path examples/stm32l0/Cargo.toml --target thumbv6m-none-eabi --no-default-features --out-dir out/examples/stm32l0 --bin raw_spawn \ |
diff --git a/docs/modules/ROOT/examples/basic/Cargo.toml b/docs/modules/ROOT/examples/basic/Cargo.toml index 59e1a437a..ae124a871 100644 --- a/docs/modules/ROOT/examples/basic/Cargo.toml +++ b/docs/modules/ROOT/examples/basic/Cargo.toml | |||
| @@ -6,6 +6,7 @@ version = "0.1.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../../embassy-executor", features = ["defmt", "nightly"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../../embassy-executor", features = ["defmt", "nightly"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../../embassy-time", features = ["defmt", "nightly"] } | ||
| 9 | embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "nightly"] } | 10 | embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "nightly"] } |
| 10 | 11 | ||
| 11 | defmt = "0.3" | 12 | defmt = "0.3" |
diff --git a/docs/modules/ROOT/examples/basic/src/main.rs b/docs/modules/ROOT/examples/basic/src/main.rs index cec39fd91..04170db55 100644 --- a/docs/modules/ROOT/examples/basic/src/main.rs +++ b/docs/modules/ROOT/examples/basic/src/main.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_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::P0_13; | 8 | use embassy_nrf::peripherals::P0_13; |
| 10 | use embassy_nrf::Peripherals; | 9 | use embassy_time::{Duration, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; // global logger | 10 | use {defmt_rtt as _, panic_probe as _}; // global logger |
| 12 | 11 | ||
| 13 | #[embassy_executor::task] | 12 | #[embassy_executor::task] |
| @@ -21,7 +20,9 @@ async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) { | |||
| 21 | } | 20 | } |
| 22 | 21 | ||
| 23 | #[embassy_executor::main] | 22 | #[embassy_executor::main] |
| 24 | async fn main(spawner: Spawner, p: Peripherals) { | 23 | async fn main(spawner: Spawner) { |
| 24 | let p = embassy_nrf::init(Default::default()); | ||
| 25 | |||
| 25 | let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | 26 | let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); |
| 26 | unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300)))); | 27 | unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300)))); |
| 27 | } | 28 | } |
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs index b944a7994..8df632240 100644 --- a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs +++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs | |||
| @@ -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_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 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(_s: Spawner, p: Peripherals) { | 11 | async fn main(_spawner: Spawner) { |
| 12 | let p = embassy_stm32::init(Default::default()); | ||
| 13 | let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh); | 13 | let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh); |
| 14 | let mut button = ExtiInput::new(Input::new(p.PC13, Pull::Up), p.EXTI13); | 14 | let mut button = ExtiInput::new(Input::new(p.PC13, Pull::Up), p.EXTI13); |
| 15 | 15 | ||
diff --git a/embassy-boot/nrf/Cargo.toml b/embassy-boot/nrf/Cargo.toml index 4db6892b9..b06e8102c 100644 --- a/embassy-boot/nrf/Cargo.toml +++ b/embassy-boot/nrf/Cargo.toml | |||
| @@ -18,7 +18,7 @@ defmt = { version = "0.3", optional = true } | |||
| 18 | embassy-util = { path = "../../embassy-util" } | 18 | embassy-util = { path = "../../embassy-util" } |
| 19 | embassy-nrf = { path = "../../embassy-nrf", default-features = false, features = ["nightly"] } | 19 | embassy-nrf = { path = "../../embassy-nrf", default-features = false, features = ["nightly"] } |
| 20 | embassy-boot = { path = "../boot", default-features = false } | 20 | embassy-boot = { path = "../boot", default-features = false } |
| 21 | cortex-m = { version = "0.7" } | 21 | cortex-m = { version = "0.7.6" } |
| 22 | cortex-m-rt = { version = "0.7" } | 22 | cortex-m-rt = { version = "0.7" } |
| 23 | embedded-storage = "0.3.0" | 23 | embedded-storage = "0.3.0" |
| 24 | embedded-storage-async = "0.3.0" | 24 | embedded-storage-async = "0.3.0" |
diff --git a/embassy-boot/stm32/Cargo.toml b/embassy-boot/stm32/Cargo.toml index f891f7691..d8f492531 100644 --- a/embassy-boot/stm32/Cargo.toml +++ b/embassy-boot/stm32/Cargo.toml | |||
| @@ -20,7 +20,7 @@ log = { version = "0.4", optional = true } | |||
| 20 | embassy-util = { path = "../../embassy-util" } | 20 | embassy-util = { path = "../../embassy-util" } |
| 21 | embassy-stm32 = { path = "../../embassy-stm32", default-features = false, features = ["nightly"] } | 21 | embassy-stm32 = { path = "../../embassy-stm32", default-features = false, features = ["nightly"] } |
| 22 | embassy-boot = { path = "../boot", default-features = false } | 22 | embassy-boot = { path = "../boot", default-features = false } |
| 23 | cortex-m = { version = "0.7" } | 23 | cortex-m = { version = "0.7.6" } |
| 24 | cortex-m-rt = { version = "0.7" } | 24 | cortex-m-rt = { version = "0.7" } |
| 25 | embedded-storage = "0.3.0" | 25 | embedded-storage = "0.3.0" |
| 26 | embedded-storage-async = "0.3.0" | 26 | embedded-storage-async = "0.3.0" |
diff --git a/embassy-cortex-m/Cargo.toml b/embassy-cortex-m/Cargo.toml index 454f34e0b..1f16da31b 100644 --- a/embassy-cortex-m/Cargo.toml +++ b/embassy-cortex-m/Cargo.toml | |||
| @@ -39,8 +39,8 @@ embassy-util = { version = "0.1.0", path = "../embassy-util" } | |||
| 39 | embassy-executor = { version = "0.1.0", path = "../embassy-executor"} | 39 | embassy-executor = { version = "0.1.0", path = "../embassy-executor"} |
| 40 | embassy-macros = { version = "0.1.0", path = "../embassy-macros"} | 40 | embassy-macros = { version = "0.1.0", path = "../embassy-macros"} |
| 41 | embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common"} | 41 | embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common"} |
| 42 | atomic-polyfill = "0.1.5" | 42 | atomic-polyfill = "1.0.1" |
| 43 | critical-section = "0.2.5" | 43 | critical-section = "1.1" |
| 44 | cfg-if = "1.0.0" | 44 | cfg-if = "1.0.0" |
| 45 | cortex-m = "0.7.3" | 45 | cortex-m = "0.7.6" |
| 46 | 46 | ||
diff --git a/embassy-cortex-m/src/executor.rs b/embassy-cortex-m/src/executor.rs index 4a3fa9903..80c452f84 100644 --- a/embassy-cortex-m/src/executor.rs +++ b/embassy-cortex-m/src/executor.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | //! Executor specific to cortex-m devices. | 1 | //! Executor specific to cortex-m devices. |
| 2 | use core::marker::PhantomData; | 2 | use core::marker::PhantomData; |
| 3 | 3 | ||
| 4 | pub use embassy_executor::executor::*; | 4 | pub use embassy_executor::*; |
| 5 | 5 | ||
| 6 | use crate::interrupt::{Interrupt, InterruptExt}; | 6 | use crate::interrupt::{Interrupt, InterruptExt}; |
| 7 | 7 | ||
| @@ -60,11 +60,11 @@ impl<I: Interrupt> InterruptExecutor<I> { | |||
| 60 | /// The executor keeps running in the background through the interrupt. | 60 | /// The executor keeps running in the background through the interrupt. |
| 61 | /// | 61 | /// |
| 62 | /// This returns a [`SendSpawner`] you can use to spawn tasks on it. A [`SendSpawner`] | 62 | /// This returns a [`SendSpawner`] you can use to spawn tasks on it. A [`SendSpawner`] |
| 63 | /// is returned instead of a [`Spawner`](embassy_executor::executor::Spawner) because the executor effectively runs in a | 63 | /// is returned instead of a [`Spawner`](embassy_executor::Spawner) because the executor effectively runs in a |
| 64 | /// different "thread" (the interrupt), so spawning tasks on it is effectively | 64 | /// different "thread" (the interrupt), so spawning tasks on it is effectively |
| 65 | /// sending them. | 65 | /// sending them. |
| 66 | /// | 66 | /// |
| 67 | /// To obtain a [`Spawner`](embassy_executor::executor::Spawner) for this executor, use [`Spawner::for_current_executor()`](embassy_executor::executor::Spawner::for_current_executor()) from | 67 | /// To obtain a [`Spawner`](embassy_executor::Spawner) for this executor, use [`Spawner::for_current_executor()`](embassy_executor::Spawner::for_current_executor()) from |
| 68 | /// a task running in it. | 68 | /// a task running in it. |
| 69 | /// | 69 | /// |
| 70 | /// This function requires `&'static mut self`. This means you have to store the | 70 | /// This function requires `&'static mut self`. This means you have to store the |
diff --git a/embassy-cortex-m/src/interrupt.rs b/embassy-cortex-m/src/interrupt.rs index be11c5eba..1df8671b9 100644 --- a/embassy-cortex-m/src/interrupt.rs +++ b/embassy-cortex-m/src/interrupt.rs | |||
| @@ -6,10 +6,11 @@ use cortex_m::peripheral::NVIC; | |||
| 6 | use embassy_hal_common::Peripheral; | 6 | use embassy_hal_common::Peripheral; |
| 7 | pub use embassy_macros::cortex_m_interrupt_take as take; | 7 | pub use embassy_macros::cortex_m_interrupt_take as take; |
| 8 | 8 | ||
| 9 | /// Do not use. Used for macros only. Not covered by semver guarantees. | 9 | /// Do not use. Used for macros and HALs only. Not covered by semver guarantees. |
| 10 | #[doc(hidden)] | 10 | #[doc(hidden)] |
| 11 | pub mod _export { | 11 | pub mod _export { |
| 12 | pub use atomic_polyfill as atomic; | 12 | pub use atomic_polyfill as atomic; |
| 13 | pub use embassy_macros::{cortex_m_interrupt as interrupt, cortex_m_interrupt_declare as declare}; | ||
| 13 | } | 14 | } |
| 14 | 15 | ||
| 15 | /// Implementation detail, do not use outside embassy crates. | 16 | /// Implementation detail, do not use outside embassy crates. |
diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml index d8ac4ac00..25c3f0abd 100644 --- a/embassy-executor/Cargo.toml +++ b/embassy-executor/Cargo.toml | |||
| @@ -7,7 +7,7 @@ edition = "2021" | |||
| 7 | [package.metadata.embassy_docs] | 7 | [package.metadata.embassy_docs] |
| 8 | src_base = "https://github.com/embassy-rs/embassy/blob/embassy-executor-v$VERSION/embassy-executor/src/" | 8 | src_base = "https://github.com/embassy-rs/embassy/blob/embassy-executor-v$VERSION/embassy-executor/src/" |
| 9 | src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-executor/src/" | 9 | src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-executor/src/" |
| 10 | features = ["nightly", "defmt", "unstable-traits", "time", "time-tick-1mhz"] | 10 | features = ["nightly", "defmt", "unstable-traits"] |
| 11 | flavors = [ | 11 | flavors = [ |
| 12 | { name = "std", target = "x86_64-unknown-linux-gnu", features = ["std"] }, | 12 | { name = "std", target = "x86_64-unknown-linux-gnu", features = ["std"] }, |
| 13 | { name = "wasm", target = "wasm32-unknown-unknown", features = ["wasm"] }, | 13 | { name = "wasm", target = "wasm32-unknown-unknown", features = ["wasm"] }, |
| @@ -22,49 +22,25 @@ flavors = [ | |||
| 22 | 22 | ||
| 23 | [features] | 23 | [features] |
| 24 | default = [] | 24 | default = [] |
| 25 | std = ["time", "time-tick-1mhz", "embassy-macros/std"] | 25 | std = ["embassy-macros/std"] |
| 26 | wasm = ["wasm-bindgen", "js-sys", "embassy-macros/wasm", "wasm-timer", "time", "time-tick-1mhz"] | 26 | wasm = ["dep:wasm-bindgen", "dep:js-sys", "embassy-macros/wasm"] |
| 27 | 27 | ||
| 28 | # Enable nightly-only features | 28 | # Enable nightly-only features |
| 29 | nightly = ["embedded-hal-async"] | 29 | nightly = [] |
| 30 | 30 | ||
| 31 | # Implement embedded-hal 1.0 alpha and embedded-hal-async traits. | 31 | integrated-timers = ["dep:embassy-time"] |
| 32 | # Implement embedded-hal-async traits if `nightly` is set as well. | ||
| 33 | unstable-traits = ["embedded-hal-1"] | ||
| 34 | |||
| 35 | # Display a timestamp of the number of seconds since startup next to defmt log messages | ||
| 36 | # To use this you must have a time driver provided. | ||
| 37 | defmt-timestamp-uptime = ["defmt"] | ||
| 38 | |||
| 39 | # Enable `embassy_executor::time` module. | ||
| 40 | # NOTE: This feature is only intended to be enabled by crates providing the time driver implementation. | ||
| 41 | # Enabling it directly without supplying a time driver will fail to link. | ||
| 42 | time = [] | ||
| 43 | |||
| 44 | # Set the `embassy_executor::time` tick rate. | ||
| 45 | # NOTE: This feature is only intended to be enabled by crates providing the time driver implementation. | ||
| 46 | # If you're not writing your own driver, check the driver documentation to customize the tick rate. | ||
| 47 | # If you're writing a driver and your tick rate is not listed here, please add it and send a PR! | ||
| 48 | time-tick-32768hz = ["time"] | ||
| 49 | time-tick-1000hz = ["time"] | ||
| 50 | time-tick-1mhz = ["time"] | ||
| 51 | time-tick-16mhz = ["time"] | ||
| 52 | 32 | ||
| 53 | [dependencies] | 33 | [dependencies] |
| 54 | defmt = { version = "0.3", optional = true } | 34 | defmt = { version = "0.3", optional = true } |
| 55 | log = { version = "0.4.14", optional = true } | 35 | log = { version = "0.4.14", optional = true } |
| 56 | 36 | ||
| 57 | embedded-hal-02 = { package = "embedded-hal", version = "0.2.6" } | ||
| 58 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true} | ||
| 59 | embedded-hal-async = { version = "0.1.0-alpha.1", optional = true} | ||
| 60 | |||
| 61 | futures-util = { version = "0.3.17", default-features = false } | 37 | futures-util = { version = "0.3.17", default-features = false } |
| 62 | embassy-macros = { version = "0.1.0", path = "../embassy-macros"} | 38 | embassy-macros = { version = "0.1.0", path = "../embassy-macros"} |
| 63 | atomic-polyfill = "0.1.5" | 39 | embassy-time = { version = "0.1.0", path = "../embassy-time", optional = true} |
| 64 | critical-section = "0.2.5" | 40 | atomic-polyfill = "1.0.1" |
| 41 | critical-section = "1.1" | ||
| 65 | cfg-if = "1.0.0" | 42 | cfg-if = "1.0.0" |
| 66 | 43 | ||
| 67 | # WASM dependencies | 44 | # WASM dependencies |
| 68 | wasm-bindgen = { version = "0.2.76", features = ["nightly"], optional = true } | 45 | wasm-bindgen = { version = "0.2.76", features = ["nightly"], optional = true } |
| 69 | js-sys = { version = "0.3", optional = true } | 46 | js-sys = { version = "0.3", optional = true } \ No newline at end of file |
| 70 | wasm-timer = { version = "0.2.5", optional = true } \ No newline at end of file | ||
diff --git a/embassy-executor/README.md b/embassy-executor/README.md new file mode 100644 index 000000000..47d0cb8a2 --- /dev/null +++ b/embassy-executor/README.md | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | # embassy-executor | ||
| 2 | |||
| 3 | An async/await executor designed for embedded usage. | ||
| 4 | |||
| 5 | - No `alloc`, no heap needed. Task futures are statically allocated. | ||
| 6 | - No "fixed capacity" data structures, executor works with 1 or 1000 tasks without needing config/tuning. | ||
| 7 | - Integrated timer queue: sleeping is easy, just do `Timer::after(Duration::from_secs(1)).await;`. | ||
| 8 | - No busy-loop polling: CPU sleeps when there's no work to do, using interrupts or `WFE/SEV`. | ||
| 9 | - Efficient polling: a wake will only poll the woken task, not all of them. | ||
| 10 | - Fair: a task can't monopolize CPU time even if it's constantly being woken. All other tasks get a chance to run before a given task gets polled for the second time. | ||
| 11 | - Creating multiple executor instances is supported, to run tasks with multiple priority levels. This allows higher-priority tasks to preempt lower-priority tasks. | ||
diff --git a/embassy-executor/src/executor/arch/cortex_m.rs b/embassy-executor/src/arch/cortex_m.rs index d6e758dfb..d6e758dfb 100644 --- a/embassy-executor/src/executor/arch/cortex_m.rs +++ b/embassy-executor/src/arch/cortex_m.rs | |||
diff --git a/embassy-executor/src/executor/arch/riscv32.rs b/embassy-executor/src/arch/riscv32.rs index 7a7d5698c..7a7d5698c 100644 --- a/embassy-executor/src/executor/arch/riscv32.rs +++ b/embassy-executor/src/arch/riscv32.rs | |||
diff --git a/embassy-executor/src/executor/arch/std.rs b/embassy-executor/src/arch/std.rs index b93ab8a79..b93ab8a79 100644 --- a/embassy-executor/src/executor/arch/std.rs +++ b/embassy-executor/src/arch/std.rs | |||
diff --git a/embassy-executor/src/executor/arch/wasm.rs b/embassy-executor/src/arch/wasm.rs index 9d5aa31ed..9d5aa31ed 100644 --- a/embassy-executor/src/executor/arch/wasm.rs +++ b/embassy-executor/src/arch/wasm.rs | |||
diff --git a/embassy-executor/src/executor/arch/xtensa.rs b/embassy-executor/src/arch/xtensa.rs index 20bd7b8a5..20bd7b8a5 100644 --- a/embassy-executor/src/executor/arch/xtensa.rs +++ b/embassy-executor/src/arch/xtensa.rs | |||
diff --git a/embassy-executor/src/executor/mod.rs b/embassy-executor/src/executor/mod.rs deleted file mode 100644 index 45d00c568..000000000 --- a/embassy-executor/src/executor/mod.rs +++ /dev/null | |||
| @@ -1,44 +0,0 @@ | |||
| 1 | //! Async task executor. | ||
| 2 | //! | ||
| 3 | //! This module provides an async/await executor designed for embedded usage. | ||
| 4 | //! | ||
| 5 | //! - No `alloc`, no heap needed. Task futures are statically allocated. | ||
| 6 | //! - No "fixed capacity" data structures, executor works with 1 or 1000 tasks without needing config/tuning. | ||
| 7 | //! - Integrated timer queue: sleeping is easy, just do `Timer::after(Duration::from_secs(1)).await;`. | ||
| 8 | //! - No busy-loop polling: CPU sleeps when there's no work to do, using interrupts or `WFE/SEV`. | ||
| 9 | //! - Efficient polling: a wake will only poll the woken task, not all of them. | ||
| 10 | //! - Fair: a task can't monopolize CPU time even if it's constantly being woken. All other tasks get a chance to run before a given task gets polled for the second time. | ||
| 11 | //! - Creating multiple executor instances is supported, to run tasks with multiple priority levels. This allows higher-priority tasks to preempt lower-priority tasks. | ||
| 12 | |||
| 13 | cfg_if::cfg_if! { | ||
| 14 | if #[cfg(cortex_m)] { | ||
| 15 | #[path="arch/cortex_m.rs"] | ||
| 16 | mod arch; | ||
| 17 | pub use arch::*; | ||
| 18 | } | ||
| 19 | else if #[cfg(target_arch="riscv32")] { | ||
| 20 | #[path="arch/riscv32.rs"] | ||
| 21 | mod arch; | ||
| 22 | pub use arch::*; | ||
| 23 | } | ||
| 24 | else if #[cfg(all(target_arch="xtensa", feature = "nightly"))] { | ||
| 25 | #[path="arch/xtensa.rs"] | ||
| 26 | mod arch; | ||
| 27 | pub use arch::*; | ||
| 28 | } | ||
| 29 | else if #[cfg(feature="wasm")] { | ||
| 30 | #[path="arch/wasm.rs"] | ||
| 31 | mod arch; | ||
| 32 | pub use arch::*; | ||
| 33 | } | ||
| 34 | else if #[cfg(feature="std")] { | ||
| 35 | #[path="arch/std.rs"] | ||
| 36 | mod arch; | ||
| 37 | pub use arch::*; | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | pub mod raw; | ||
| 42 | |||
| 43 | mod spawner; | ||
| 44 | pub use spawner::*; | ||
diff --git a/embassy-executor/src/fmt.rs b/embassy-executor/src/fmt.rs index f8bb0a035..066970813 100644 --- a/embassy-executor/src/fmt.rs +++ b/embassy-executor/src/fmt.rs | |||
| @@ -195,9 +195,6 @@ macro_rules! unwrap { | |||
| 195 | } | 195 | } |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | #[cfg(feature = "defmt-timestamp-uptime")] | ||
| 199 | defmt::timestamp! {"{=u64:us}", crate::time::Instant::now().as_micros() } | ||
| 200 | |||
| 201 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | 198 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] |
| 202 | pub struct NoneError; | 199 | pub struct NoneError; |
| 203 | 200 | ||
diff --git a/embassy-executor/src/lib.rs b/embassy-executor/src/lib.rs index 69e4aeb4b..9328a7378 100644 --- a/embassy-executor/src/lib.rs +++ b/embassy-executor/src/lib.rs | |||
| @@ -1,22 +1,44 @@ | |||
| 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] | 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] |
| 2 | #![cfg_attr(feature = "nightly", feature(generic_associated_types, type_alias_impl_trait))] | ||
| 3 | #![cfg_attr(all(feature = "nightly", target_arch = "xtensa"), feature(asm_experimental_arch))] | 2 | #![cfg_attr(all(feature = "nightly", target_arch = "xtensa"), feature(asm_experimental_arch))] |
| 4 | #![allow(clippy::new_without_default)] | 3 | #![allow(clippy::new_without_default)] |
| 5 | #![doc = include_str!("../../README.md")] | 4 | #![doc = include_str!("../README.md")] |
| 6 | #![warn(missing_docs)] | 5 | #![warn(missing_docs)] |
| 7 | 6 | ||
| 8 | // This mod MUST go first, so that the others see its macros. | 7 | // This mod MUST go first, so that the others see its macros. |
| 9 | pub(crate) mod fmt; | 8 | pub(crate) mod fmt; |
| 10 | 9 | ||
| 11 | pub mod executor; | ||
| 12 | #[cfg(feature = "time")] | ||
| 13 | pub mod time; | ||
| 14 | |||
| 15 | #[cfg(feature = "nightly")] | 10 | #[cfg(feature = "nightly")] |
| 16 | pub use embassy_macros::{main, task}; | 11 | pub use embassy_macros::{main, task}; |
| 17 | 12 | ||
| 18 | #[doc(hidden)] | 13 | cfg_if::cfg_if! { |
| 19 | /// Implementation details for embassy macros. DO NOT USE. | 14 | if #[cfg(cortex_m)] { |
| 20 | pub mod export { | 15 | #[path="arch/cortex_m.rs"] |
| 21 | pub use atomic_polyfill as atomic; | 16 | mod arch; |
| 17 | pub use arch::*; | ||
| 18 | } | ||
| 19 | else if #[cfg(target_arch="riscv32")] { | ||
| 20 | #[path="arch/riscv32.rs"] | ||
| 21 | mod arch; | ||
| 22 | pub use arch::*; | ||
| 23 | } | ||
| 24 | else if #[cfg(all(target_arch="xtensa", feature = "nightly"))] { | ||
| 25 | #[path="arch/xtensa.rs"] | ||
| 26 | mod arch; | ||
| 27 | pub use arch::*; | ||
| 28 | } | ||
| 29 | else if #[cfg(feature="wasm")] { | ||
| 30 | #[path="arch/wasm.rs"] | ||
| 31 | mod arch; | ||
| 32 | pub use arch::*; | ||
| 33 | } | ||
| 34 | else if #[cfg(feature="std")] { | ||
| 35 | #[path="arch/std.rs"] | ||
| 36 | mod arch; | ||
| 37 | pub use arch::*; | ||
| 38 | } | ||
| 22 | } | 39 | } |
| 40 | |||
| 41 | pub mod raw; | ||
| 42 | |||
| 43 | mod spawner; | ||
| 44 | pub use spawner::*; | ||
diff --git a/embassy-executor/src/executor/raw/mod.rs b/embassy-executor/src/raw/mod.rs index fb4cc6288..afe67decb 100644 --- a/embassy-executor/src/executor/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | //! executor wrappers in [`executor`](crate::executor) and the [`embassy_executor::task`](embassy_macros::task) macro, which are fully safe. | 8 | //! executor wrappers in [`executor`](crate::executor) and the [`embassy_executor::task`](embassy_macros::task) macro, which are fully safe. |
| 9 | 9 | ||
| 10 | mod run_queue; | 10 | mod run_queue; |
| 11 | #[cfg(feature = "time")] | 11 | #[cfg(feature = "integrated-timers")] |
| 12 | mod timer_queue; | 12 | mod timer_queue; |
| 13 | pub(crate) mod util; | 13 | pub(crate) mod util; |
| 14 | mod waker; | 14 | mod waker; |
| @@ -22,22 +22,22 @@ use core::{mem, ptr}; | |||
| 22 | 22 | ||
| 23 | use atomic_polyfill::{AtomicU32, Ordering}; | 23 | use atomic_polyfill::{AtomicU32, Ordering}; |
| 24 | use critical_section::CriticalSection; | 24 | use critical_section::CriticalSection; |
| 25 | #[cfg(feature = "integrated-timers")] | ||
| 26 | use embassy_time::driver::{self, AlarmHandle}; | ||
| 27 | #[cfg(feature = "integrated-timers")] | ||
| 28 | use embassy_time::Instant; | ||
| 25 | 29 | ||
| 26 | use self::run_queue::{RunQueue, RunQueueItem}; | 30 | use self::run_queue::{RunQueue, RunQueueItem}; |
| 27 | use self::util::UninitCell; | 31 | use self::util::UninitCell; |
| 28 | pub use self::waker::task_from_waker; | 32 | pub use self::waker::task_from_waker; |
| 29 | use super::SpawnToken; | 33 | use super::SpawnToken; |
| 30 | #[cfg(feature = "time")] | ||
| 31 | use crate::time::driver::{self, AlarmHandle}; | ||
| 32 | #[cfg(feature = "time")] | ||
| 33 | use crate::time::Instant; | ||
| 34 | 34 | ||
| 35 | /// Task is spawned (has a future) | 35 | /// Task is spawned (has a future) |
| 36 | pub(crate) const STATE_SPAWNED: u32 = 1 << 0; | 36 | pub(crate) const STATE_SPAWNED: u32 = 1 << 0; |
| 37 | /// Task is in the executor run queue | 37 | /// Task is in the executor run queue |
| 38 | pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1; | 38 | pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1; |
| 39 | /// Task is in the executor timer queue | 39 | /// Task is in the executor timer queue |
| 40 | #[cfg(feature = "time")] | 40 | #[cfg(feature = "integrated-timers")] |
| 41 | pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 2; | 41 | pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 2; |
| 42 | 42 | ||
| 43 | /// Raw task header for use in task pointers. | 43 | /// Raw task header for use in task pointers. |
| @@ -50,9 +50,9 @@ pub struct TaskHeader { | |||
| 50 | pub(crate) executor: Cell<*const Executor>, // Valid if state != 0 | 50 | pub(crate) executor: Cell<*const Executor>, // Valid if state != 0 |
| 51 | pub(crate) poll_fn: UninitCell<unsafe fn(NonNull<TaskHeader>)>, // Valid if STATE_SPAWNED | 51 | pub(crate) poll_fn: UninitCell<unsafe fn(NonNull<TaskHeader>)>, // Valid if STATE_SPAWNED |
| 52 | 52 | ||
| 53 | #[cfg(feature = "time")] | 53 | #[cfg(feature = "integrated-timers")] |
| 54 | pub(crate) expires_at: Cell<Instant>, | 54 | pub(crate) expires_at: Cell<Instant>, |
| 55 | #[cfg(feature = "time")] | 55 | #[cfg(feature = "integrated-timers")] |
| 56 | pub(crate) timer_queue_item: timer_queue::TimerQueueItem, | 56 | pub(crate) timer_queue_item: timer_queue::TimerQueueItem, |
| 57 | } | 57 | } |
| 58 | 58 | ||
| @@ -64,9 +64,9 @@ impl TaskHeader { | |||
| 64 | executor: Cell::new(ptr::null()), | 64 | executor: Cell::new(ptr::null()), |
| 65 | poll_fn: UninitCell::uninit(), | 65 | poll_fn: UninitCell::uninit(), |
| 66 | 66 | ||
| 67 | #[cfg(feature = "time")] | 67 | #[cfg(feature = "integrated-timers")] |
| 68 | expires_at: Cell::new(Instant::from_ticks(0)), | 68 | expires_at: Cell::new(Instant::from_ticks(0)), |
| 69 | #[cfg(feature = "time")] | 69 | #[cfg(feature = "integrated-timers")] |
| 70 | timer_queue_item: timer_queue::TimerQueueItem::new(), | 70 | timer_queue_item: timer_queue::TimerQueueItem::new(), |
| 71 | } | 71 | } |
| 72 | } | 72 | } |
| @@ -267,9 +267,9 @@ pub struct Executor { | |||
| 267 | signal_fn: fn(*mut ()), | 267 | signal_fn: fn(*mut ()), |
| 268 | signal_ctx: *mut (), | 268 | signal_ctx: *mut (), |
| 269 | 269 | ||
| 270 | #[cfg(feature = "time")] | 270 | #[cfg(feature = "integrated-timers")] |
| 271 | pub(crate) timer_queue: timer_queue::TimerQueue, | 271 | pub(crate) timer_queue: timer_queue::TimerQueue, |
| 272 | #[cfg(feature = "time")] | 272 | #[cfg(feature = "integrated-timers")] |
| 273 | alarm: AlarmHandle, | 273 | alarm: AlarmHandle, |
| 274 | } | 274 | } |
| 275 | 275 | ||
| @@ -281,9 +281,9 @@ impl Executor { | |||
| 281 | /// | 281 | /// |
| 282 | /// See [`Executor`] docs for details on `signal_fn`. | 282 | /// See [`Executor`] docs for details on `signal_fn`. |
| 283 | pub fn new(signal_fn: fn(*mut ()), signal_ctx: *mut ()) -> Self { | 283 | pub fn new(signal_fn: fn(*mut ()), signal_ctx: *mut ()) -> Self { |
| 284 | #[cfg(feature = "time")] | 284 | #[cfg(feature = "integrated-timers")] |
| 285 | let alarm = unsafe { unwrap!(driver::allocate_alarm()) }; | 285 | let alarm = unsafe { unwrap!(driver::allocate_alarm()) }; |
| 286 | #[cfg(feature = "time")] | 286 | #[cfg(feature = "integrated-timers")] |
| 287 | driver::set_alarm_callback(alarm, signal_fn, signal_ctx); | 287 | driver::set_alarm_callback(alarm, signal_fn, signal_ctx); |
| 288 | 288 | ||
| 289 | Self { | 289 | Self { |
| @@ -291,9 +291,9 @@ impl Executor { | |||
| 291 | signal_fn, | 291 | signal_fn, |
| 292 | signal_ctx, | 292 | signal_ctx, |
| 293 | 293 | ||
| 294 | #[cfg(feature = "time")] | 294 | #[cfg(feature = "integrated-timers")] |
| 295 | timer_queue: timer_queue::TimerQueue::new(), | 295 | timer_queue: timer_queue::TimerQueue::new(), |
| 296 | #[cfg(feature = "time")] | 296 | #[cfg(feature = "integrated-timers")] |
| 297 | alarm, | 297 | alarm, |
| 298 | } | 298 | } |
| 299 | } | 299 | } |
| @@ -346,13 +346,13 @@ impl Executor { | |||
| 346 | /// somehow schedule for `poll()` to be called later, at a time you know for sure there's | 346 | /// somehow schedule for `poll()` to be called later, at a time you know for sure there's |
| 347 | /// no `poll()` already running. | 347 | /// no `poll()` already running. |
| 348 | pub unsafe fn poll(&'static self) { | 348 | pub unsafe fn poll(&'static self) { |
| 349 | #[cfg(feature = "time")] | 349 | #[cfg(feature = "integrated-timers")] |
| 350 | self.timer_queue.dequeue_expired(Instant::now(), |task| wake_task(task)); | 350 | self.timer_queue.dequeue_expired(Instant::now(), |task| wake_task(task)); |
| 351 | 351 | ||
| 352 | self.run_queue.dequeue_all(|p| { | 352 | self.run_queue.dequeue_all(|p| { |
| 353 | let task = p.as_ref(); | 353 | let task = p.as_ref(); |
| 354 | 354 | ||
| 355 | #[cfg(feature = "time")] | 355 | #[cfg(feature = "integrated-timers")] |
| 356 | task.expires_at.set(Instant::MAX); | 356 | task.expires_at.set(Instant::MAX); |
| 357 | 357 | ||
| 358 | let state = task.state.fetch_and(!STATE_RUN_QUEUED, Ordering::AcqRel); | 358 | let state = task.state.fetch_and(!STATE_RUN_QUEUED, Ordering::AcqRel); |
| @@ -369,11 +369,11 @@ impl Executor { | |||
| 369 | task.poll_fn.read()(p as _); | 369 | task.poll_fn.read()(p as _); |
| 370 | 370 | ||
| 371 | // Enqueue or update into timer_queue | 371 | // Enqueue or update into timer_queue |
| 372 | #[cfg(feature = "time")] | 372 | #[cfg(feature = "integrated-timers")] |
| 373 | self.timer_queue.update(p); | 373 | self.timer_queue.update(p); |
| 374 | }); | 374 | }); |
| 375 | 375 | ||
| 376 | #[cfg(feature = "time")] | 376 | #[cfg(feature = "integrated-timers")] |
| 377 | { | 377 | { |
| 378 | // If this is already in the past, set_alarm will immediately trigger the alarm. | 378 | // If this is already in the past, set_alarm will immediately trigger the alarm. |
| 379 | // This will cause `signal_fn` to be called, which will cause `poll()` to be called again, | 379 | // This will cause `signal_fn` to be called, which will cause `poll()` to be called again, |
| @@ -418,8 +418,9 @@ pub unsafe fn wake_task(task: NonNull<TaskHeader>) { | |||
| 418 | }) | 418 | }) |
| 419 | } | 419 | } |
| 420 | 420 | ||
| 421 | #[cfg(feature = "time")] | 421 | #[cfg(feature = "integrated-timers")] |
| 422 | pub(crate) unsafe fn register_timer(at: Instant, waker: &core::task::Waker) { | 422 | #[no_mangle] |
| 423 | unsafe fn _embassy_time_schedule_wake(at: Instant, waker: &core::task::Waker) { | ||
| 423 | let task = waker::task_from_waker(waker); | 424 | let task = waker::task_from_waker(waker); |
| 424 | let task = task.as_ref(); | 425 | let task = task.as_ref(); |
| 425 | let expires_at = task.expires_at.get(); | 426 | let expires_at = task.expires_at.get(); |
diff --git a/embassy-executor/src/executor/raw/run_queue.rs b/embassy-executor/src/raw/run_queue.rs index ed8c82a5c..ed8c82a5c 100644 --- a/embassy-executor/src/executor/raw/run_queue.rs +++ b/embassy-executor/src/raw/run_queue.rs | |||
diff --git a/embassy-executor/src/executor/raw/timer_queue.rs b/embassy-executor/src/raw/timer_queue.rs index 62fcfc531..24c31892a 100644 --- a/embassy-executor/src/executor/raw/timer_queue.rs +++ b/embassy-executor/src/raw/timer_queue.rs | |||
| @@ -4,9 +4,9 @@ use core::ptr; | |||
| 4 | use core::ptr::NonNull; | 4 | use core::ptr::NonNull; |
| 5 | 5 | ||
| 6 | use atomic_polyfill::Ordering; | 6 | use atomic_polyfill::Ordering; |
| 7 | use embassy_time::Instant; | ||
| 7 | 8 | ||
| 8 | use super::{TaskHeader, STATE_TIMER_QUEUED}; | 9 | use super::{TaskHeader, STATE_TIMER_QUEUED}; |
| 9 | use crate::time::Instant; | ||
| 10 | 10 | ||
| 11 | pub(crate) struct TimerQueueItem { | 11 | pub(crate) struct TimerQueueItem { |
| 12 | next: Cell<*mut TaskHeader>, | 12 | next: Cell<*mut TaskHeader>, |
diff --git a/embassy-executor/src/executor/raw/util.rs b/embassy-executor/src/raw/util.rs index ed5822188..ed5822188 100644 --- a/embassy-executor/src/executor/raw/util.rs +++ b/embassy-executor/src/raw/util.rs | |||
diff --git a/embassy-executor/src/executor/raw/waker.rs b/embassy-executor/src/raw/waker.rs index 6b9c03a62..5765259f2 100644 --- a/embassy-executor/src/executor/raw/waker.rs +++ b/embassy-executor/src/raw/waker.rs | |||
| @@ -40,7 +40,7 @@ pub fn task_from_waker(waker: &Waker) -> NonNull<TaskHeader> { | |||
| 40 | // TODO use waker_getters when stable. https://github.com/rust-lang/rust/issues/96992 | 40 | // TODO use waker_getters when stable. https://github.com/rust-lang/rust/issues/96992 |
| 41 | let hack: &WakerHack = unsafe { mem::transmute(waker) }; | 41 | let hack: &WakerHack = unsafe { mem::transmute(waker) }; |
| 42 | if hack.vtable != &VTABLE { | 42 | if hack.vtable != &VTABLE { |
| 43 | panic!("Found waker not created by the Embassy executor. `embassy_executor::time::Timer` only works with the Embassy executor.") | 43 | panic!("Found waker not created by the Embassy executor. `embassy_time::Timer` only works with the Embassy executor.") |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | // safety: we never create a waker with a null data pointer. | 46 | // safety: we never create a waker with a null data pointer. |
diff --git a/embassy-executor/src/executor/spawner.rs b/embassy-executor/src/spawner.rs index 25a0d7dbb..25a0d7dbb 100644 --- a/embassy-executor/src/executor/spawner.rs +++ b/embassy-executor/src/spawner.rs | |||
diff --git a/embassy-hal-common/Cargo.toml b/embassy-hal-common/Cargo.toml index 4a6a61003..58f0af6ab 100644 --- a/embassy-hal-common/Cargo.toml +++ b/embassy-hal-common/Cargo.toml | |||
| @@ -9,5 +9,4 @@ edition = "2021" | |||
| 9 | defmt = { version = "0.3", optional = true } | 9 | defmt = { version = "0.3", optional = true } |
| 10 | log = { version = "0.4.14", optional = true } | 10 | log = { version = "0.4.14", optional = true } |
| 11 | 11 | ||
| 12 | embassy-util = { version = "0.1.0", path = "../embassy-util" } | ||
| 13 | num-traits = { version = "0.2.14", default-features = false } | 12 | num-traits = { version = "0.2.14", default-features = false } |
diff --git a/embassy-lora/Cargo.toml b/embassy-lora/Cargo.toml index 6c1b01e67..c7435ab3e 100644 --- a/embassy-lora/Cargo.toml +++ b/embassy-lora/Cargo.toml | |||
| @@ -8,8 +8,8 @@ src_base = "https://github.com/embassy-rs/embassy/blob/embassy-lora-v$VERSION/em | |||
| 8 | src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-lora/src/" | 8 | src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-lora/src/" |
| 9 | features = ["time", "defmt"] | 9 | features = ["time", "defmt"] |
| 10 | flavors = [ | 10 | flavors = [ |
| 11 | { name = "sx127x", target = "thumbv7em-none-eabihf", features = ["sx127x", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy-executor/time-tick-32768hz"] }, | 11 | { name = "sx127x", target = "thumbv7em-none-eabihf", features = ["sx127x", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy-time/tick-32768hz"] }, |
| 12 | { name = "stm32wl", target = "thumbv7em-none-eabihf", features = ["stm32wl", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy-executor/time-tick-32768hz"] }, | 12 | { name = "stm32wl", target = "thumbv7em-none-eabihf", features = ["stm32wl", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy-time/tick-32768hz"] }, |
| 13 | ] | 13 | ] |
| 14 | 14 | ||
| 15 | [lib] | 15 | [lib] |
| @@ -24,7 +24,7 @@ time = [] | |||
| 24 | defmt = { version = "0.3", optional = true } | 24 | defmt = { version = "0.3", optional = true } |
| 25 | log = { version = "0.4.14", optional = true } | 25 | log = { version = "0.4.14", optional = true } |
| 26 | 26 | ||
| 27 | embassy-executor = { version = "0.1.0", path = "../embassy-executor" } | 27 | embassy-time = { version = "0.1.0", path = "../embassy-time" } |
| 28 | embassy-util = { version = "0.1.0", path = "../embassy-util" } | 28 | embassy-util = { version = "0.1.0", path = "../embassy-util" } |
| 29 | embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true } | 29 | embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true } |
| 30 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } | 30 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } |
diff --git a/embassy-lora/src/lib.rs b/embassy-lora/src/lib.rs index 29ea45863..1b2dd45c2 100644 --- a/embassy-lora/src/lib.rs +++ b/embassy-lora/src/lib.rs | |||
| @@ -18,6 +18,6 @@ pub struct LoraTimer; | |||
| 18 | impl lorawan_device::async_device::radio::Timer for LoraTimer { | 18 | impl lorawan_device::async_device::radio::Timer for LoraTimer { |
| 19 | type DelayFuture<'m> = impl core::future::Future<Output = ()> + 'm; | 19 | type DelayFuture<'m> = impl core::future::Future<Output = ()> + 'm; |
| 20 | fn delay_ms<'m>(&'m mut self, millis: u64) -> Self::DelayFuture<'m> { | 20 | fn delay_ms<'m>(&'m mut self, millis: u64) -> Self::DelayFuture<'m> { |
| 21 | embassy_executor::time::Timer::after(embassy_executor::time::Duration::from_millis(millis)) | 21 | embassy_time::Timer::after(embassy_time::Duration::from_millis(millis)) |
| 22 | } | 22 | } |
| 23 | } | 23 | } |
diff --git a/embassy-lora/src/sx127x/sx127x_lora/mod.rs b/embassy-lora/src/sx127x/sx127x_lora/mod.rs index b3636d097..aacc9da22 100644 --- a/embassy-lora/src/sx127x/sx127x_lora/mod.rs +++ b/embassy-lora/src/sx127x/sx127x_lora/mod.rs | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | #![allow(dead_code)] | 6 | #![allow(dead_code)] |
| 7 | 7 | ||
| 8 | use bit_field::BitField; | 8 | use bit_field::BitField; |
| 9 | use embassy_executor::time::{Duration, Timer}; | 9 | use embassy_time::{Duration, Timer}; |
| 10 | use embedded_hal::digital::v2::OutputPin; | 10 | use embedded_hal::digital::v2::OutputPin; |
| 11 | use embedded_hal_async::spi::SpiBus; | 11 | use embedded_hal_async::spi::SpiBus; |
| 12 | 12 | ||
diff --git a/embassy-macros/Cargo.toml b/embassy-macros/Cargo.toml index 6abafa581..19a3e9de2 100644 --- a/embassy-macros/Cargo.toml +++ b/embassy-macros/Cargo.toml | |||
| @@ -13,8 +13,5 @@ proc-macro2 = "1.0.29" | |||
| 13 | proc-macro = true | 13 | proc-macro = true |
| 14 | 14 | ||
| 15 | [features] | 15 | [features] |
| 16 | nrf = [] | ||
| 17 | stm32 = [] | ||
| 18 | rp = [] | ||
| 19 | std = [] | 16 | std = [] |
| 20 | wasm = [] | 17 | wasm = [] |
diff --git a/embassy-macros/src/macros/main.rs b/embassy-macros/src/macros/main.rs index b040edc5a..52987d7d2 100644 --- a/embassy-macros/src/macros/main.rs +++ b/embassy-macros/src/macros/main.rs | |||
| @@ -5,11 +5,7 @@ use quote::quote; | |||
| 5 | use crate::util::ctxt::Ctxt; | 5 | use crate::util::ctxt::Ctxt; |
| 6 | 6 | ||
| 7 | #[derive(Debug, FromMeta)] | 7 | #[derive(Debug, FromMeta)] |
| 8 | struct Args { | 8 | struct Args {} |
| 9 | #[allow(unused)] | ||
| 10 | #[darling(default)] | ||
| 11 | config: Option<syn::LitStr>, | ||
| 12 | } | ||
| 13 | 9 | ||
| 14 | pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, TokenStream> { | 10 | pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, TokenStream> { |
| 15 | #[allow(unused_variables)] | 11 | #[allow(unused_variables)] |
| @@ -20,26 +16,14 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke | |||
| 20 | let ctxt = Ctxt::new(); | 16 | let ctxt = Ctxt::new(); |
| 21 | 17 | ||
| 22 | if f.sig.asyncness.is_none() { | 18 | if f.sig.asyncness.is_none() { |
| 23 | ctxt.error_spanned_by(&f.sig, "task functions must be async"); | 19 | ctxt.error_spanned_by(&f.sig, "main function must be async"); |
| 24 | } | 20 | } |
| 25 | if !f.sig.generics.params.is_empty() { | 21 | if !f.sig.generics.params.is_empty() { |
| 26 | ctxt.error_spanned_by(&f.sig, "task functions must not be generic"); | 22 | ctxt.error_spanned_by(&f.sig, "main function must not be generic"); |
| 27 | } | 23 | } |
| 28 | 24 | ||
| 29 | #[cfg(feature = "stm32")] | 25 | if fargs.len() != 1 { |
| 30 | let hal = Some(quote!(::embassy_stm32)); | 26 | ctxt.error_spanned_by(&f.sig, "main function must have 1 argument: the spawner."); |
| 31 | #[cfg(feature = "nrf")] | ||
| 32 | let hal = Some(quote!(::embassy_nrf)); | ||
| 33 | #[cfg(feature = "rp")] | ||
| 34 | let hal = Some(quote!(::embassy_rp)); | ||
| 35 | #[cfg(not(any(feature = "stm32", feature = "nrf", feature = "rp")))] | ||
| 36 | let hal: Option<TokenStream> = None; | ||
| 37 | |||
| 38 | if hal.is_some() && fargs.len() != 2 { | ||
| 39 | ctxt.error_spanned_by(&f.sig, "main function must have 2 arguments"); | ||
| 40 | } | ||
| 41 | if hal.is_none() && fargs.len() != 1 { | ||
| 42 | ctxt.error_spanned_by(&f.sig, "main function must have 1 argument"); | ||
| 43 | } | 27 | } |
| 44 | 28 | ||
| 45 | ctxt.check()?; | 29 | ctxt.check()?; |
| @@ -50,8 +34,8 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke | |||
| 50 | let main = quote! { | 34 | let main = quote! { |
| 51 | #[wasm_bindgen::prelude::wasm_bindgen(start)] | 35 | #[wasm_bindgen::prelude::wasm_bindgen(start)] |
| 52 | pub fn main() -> Result<(), wasm_bindgen::JsValue> { | 36 | pub fn main() -> Result<(), wasm_bindgen::JsValue> { |
| 53 | static EXECUTOR: ::embassy_util::Forever<::embassy_executor::executor::Executor> = ::embassy_util::Forever::new(); | 37 | static EXECUTOR: ::embassy_util::Forever<::embassy_executor::Executor> = ::embassy_util::Forever::new(); |
| 54 | let executor = EXECUTOR.put(::embassy_executor::executor::Executor::new()); | 38 | let executor = EXECUTOR.put(::embassy_executor::Executor::new()); |
| 55 | 39 | ||
| 56 | executor.start(|spawner| { | 40 | executor.start(|spawner| { |
| 57 | spawner.spawn(__embassy_main(spawner)).unwrap(); | 41 | spawner.spawn(__embassy_main(spawner)).unwrap(); |
| @@ -64,7 +48,7 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke | |||
| 64 | #[cfg(all(feature = "std", not(feature = "wasm")))] | 48 | #[cfg(all(feature = "std", not(feature = "wasm")))] |
| 65 | let main = quote! { | 49 | let main = quote! { |
| 66 | fn main() -> ! { | 50 | fn main() -> ! { |
| 67 | let mut executor = ::embassy_executor::executor::Executor::new(); | 51 | let mut executor = ::embassy_executor::Executor::new(); |
| 68 | let executor = unsafe { __make_static(&mut executor) }; | 52 | let executor = unsafe { __make_static(&mut executor) }; |
| 69 | 53 | ||
| 70 | executor.run(|spawner| { | 54 | executor.run(|spawner| { |
| @@ -74,35 +58,15 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke | |||
| 74 | }; | 58 | }; |
| 75 | 59 | ||
| 76 | #[cfg(all(not(feature = "std"), not(feature = "wasm")))] | 60 | #[cfg(all(not(feature = "std"), not(feature = "wasm")))] |
| 77 | let main = { | 61 | let main = quote! { |
| 78 | let config = args.config.map(|s| s.parse::<syn::Expr>().unwrap()).unwrap_or_else(|| { | 62 | #[cortex_m_rt::entry] |
| 79 | syn::Expr::Verbatim(quote! { | 63 | fn main() -> ! { |
| 80 | Default::default() | 64 | let mut executor = ::embassy_executor::Executor::new(); |
| 65 | let executor = unsafe { __make_static(&mut executor) }; | ||
| 66 | |||
| 67 | executor.run(|spawner| { | ||
| 68 | spawner.must_spawn(__embassy_main(spawner)); | ||
| 81 | }) | 69 | }) |
| 82 | }); | ||
| 83 | |||
| 84 | let (hal_setup, peris_arg) = match hal { | ||
| 85 | Some(hal) => ( | ||
| 86 | quote!( | ||
| 87 | let p = #hal::init(#config); | ||
| 88 | ), | ||
| 89 | quote!(p), | ||
| 90 | ), | ||
| 91 | None => (quote!(), quote!()), | ||
| 92 | }; | ||
| 93 | |||
| 94 | quote! { | ||
| 95 | #[cortex_m_rt::entry] | ||
| 96 | fn main() -> ! { | ||
| 97 | #hal_setup | ||
| 98 | |||
| 99 | let mut executor = ::embassy_executor::executor::Executor::new(); | ||
| 100 | let executor = unsafe { __make_static(&mut executor) }; | ||
| 101 | |||
| 102 | executor.run(|spawner| { | ||
| 103 | spawner.must_spawn(__embassy_main(spawner, #peris_arg)); | ||
| 104 | }) | ||
| 105 | } | ||
| 106 | } | 70 | } |
| 107 | }; | 71 | }; |
| 108 | 72 | ||
diff --git a/embassy-macros/src/macros/task.rs b/embassy-macros/src/macros/task.rs index 414e5cb09..573776f8c 100644 --- a/embassy-macros/src/macros/task.rs +++ b/embassy-macros/src/macros/task.rs | |||
| @@ -64,9 +64,9 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke | |||
| 64 | // in the user's code. | 64 | // in the user's code. |
| 65 | #task_inner | 65 | #task_inner |
| 66 | 66 | ||
| 67 | #visibility fn #task_ident(#fargs) -> ::embassy_executor::executor::SpawnToken<impl Sized> { | 67 | #visibility fn #task_ident(#fargs) -> ::embassy_executor::SpawnToken<impl Sized> { |
| 68 | type Fut = impl ::core::future::Future + 'static; | 68 | type Fut = impl ::core::future::Future + 'static; |
| 69 | static POOL: ::embassy_executor::executor::raw::TaskPool<Fut, #pool_size> = ::embassy_executor::executor::raw::TaskPool::new(); | 69 | static POOL: ::embassy_executor::raw::TaskPool<Fut, #pool_size> = ::embassy_executor::raw::TaskPool::new(); |
| 70 | unsafe { POOL._spawn_async_fn(move || #task_inner_ident(#(#arg_names,)*)) } | 70 | unsafe { POOL._spawn_async_fn(move || #task_inner_ident(#(#arg_names,)*)) } |
| 71 | } | 71 | } |
| 72 | }; | 72 | }; |
diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index 11e39a871..9f9bb2261 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml | |||
| @@ -7,7 +7,7 @@ edition = "2021" | |||
| 7 | [package.metadata.embassy_docs] | 7 | [package.metadata.embassy_docs] |
| 8 | src_base = "https://github.com/embassy-rs/embassy/blob/embassy-net-v$VERSION/embassy-net/src/" | 8 | src_base = "https://github.com/embassy-rs/embassy/blob/embassy-net-v$VERSION/embassy-net/src/" |
| 9 | src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-net/src/" | 9 | src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-net/src/" |
| 10 | features = [ "pool-4", "defmt", "tcp", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "embassy-executor/time", "embassy-executor/time-tick-1mhz"] | 10 | features = [ "pool-4", "defmt", "tcp", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "embassy-time/tick-1mhz"] |
| 11 | target = "thumbv7em-none-eabi" | 11 | target = "thumbv7em-none-eabi" |
| 12 | 12 | ||
| 13 | [features] | 13 | [features] |
| @@ -37,18 +37,18 @@ unstable-traits = [] | |||
| 37 | defmt = { version = "0.3", optional = true } | 37 | defmt = { version = "0.3", optional = true } |
| 38 | log = { version = "0.4.14", optional = true } | 38 | log = { version = "0.4.14", optional = true } |
| 39 | 39 | ||
| 40 | embassy-executor = { version = "0.1.0", path = "../embassy-executor" } | 40 | embassy-time = { version = "0.1.0", path = "../embassy-time" } |
| 41 | embassy-util = { version = "0.1.0", path = "../embassy-util" } | 41 | embassy-util = { version = "0.1.0", path = "../embassy-util" } |
| 42 | embedded-io = { version = "0.3.0", features = [ "async" ] } | 42 | embedded-io = { version = "0.3.0", features = [ "async" ] } |
| 43 | 43 | ||
| 44 | managed = { version = "0.8.0", default-features = false, features = [ "map" ] } | 44 | managed = { version = "0.8.0", default-features = false, features = [ "map" ] } |
| 45 | heapless = { version = "0.7.5", default-features = false } | 45 | heapless = { version = "0.7.5", default-features = false } |
| 46 | as-slice = "0.2.1" | 46 | as-slice = "0.2.1" |
| 47 | generic-array = { version = "0.14.4", default-features = false } | 47 | generic-array = { version = "0.14.4", default-features = false } |
| 48 | stable_deref_trait = { version = "1.2.0", default-features = false } | 48 | stable_deref_trait = { version = "1.2.0", default-features = false } |
| 49 | futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] } | 49 | futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] } |
| 50 | atomic-pool = "0.2.1" | 50 | atomic-pool = "1.0" |
| 51 | atomic-polyfill = "0.1.5" | 51 | atomic-polyfill = "1.0.1" |
| 52 | embedded-nal-async = "0.2.0" | 52 | embedded-nal-async = "0.2.0" |
| 53 | 53 | ||
| 54 | [dependencies.smoltcp] | 54 | [dependencies.smoltcp] |
diff --git a/embassy-net/src/stack.rs b/embassy-net/src/stack.rs index 06bb732ff..4b6a7ae2a 100644 --- a/embassy-net/src/stack.rs +++ b/embassy-net/src/stack.rs | |||
| @@ -2,7 +2,7 @@ use core::cell::UnsafeCell; | |||
| 2 | use core::future::Future; | 2 | use core::future::Future; |
| 3 | use core::task::{Context, Poll}; | 3 | use core::task::{Context, Poll}; |
| 4 | 4 | ||
| 5 | use embassy_executor::time::{Instant, Timer}; | 5 | use embassy_time::{Instant, Timer}; |
| 6 | use embassy_util::waitqueue::WakerRegistration; | 6 | use embassy_util::waitqueue::WakerRegistration; |
| 7 | use futures::future::poll_fn; | 7 | use futures::future::poll_fn; |
| 8 | use futures::pin_mut; | 8 | use futures::pin_mut; |
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 75780d417..0ef7f5bbd 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml | |||
| @@ -16,7 +16,7 @@ flavors = [ | |||
| 16 | 16 | ||
| 17 | [features] | 17 | [features] |
| 18 | 18 | ||
| 19 | time = ["embassy-executor/time"] | 19 | time = ["dep:embassy-time"] |
| 20 | 20 | ||
| 21 | defmt = ["dep:defmt", "embassy-executor/defmt", "embassy-util/defmt", "embassy-usb?/defmt", "embedded-io?/defmt", "embassy-embedded-hal/defmt"] | 21 | defmt = ["dep:defmt", "embassy-executor/defmt", "embassy-util/defmt", "embassy-usb?/defmt", "embedded-io?/defmt", "embassy-embedded-hal/defmt"] |
| 22 | 22 | ||
| @@ -57,7 +57,7 @@ _nrf5340-net = ["_nrf5340", "nrf5340-net-pac"] | |||
| 57 | _nrf5340 = ["_gpio-p1", "_dppi"] | 57 | _nrf5340 = ["_gpio-p1", "_dppi"] |
| 58 | _nrf9160 = ["nrf9160-pac", "_dppi"] | 58 | _nrf9160 = ["nrf9160-pac", "_dppi"] |
| 59 | 59 | ||
| 60 | _time-driver = ["embassy-executor/time-tick-32768hz", "time"] | 60 | _time-driver = ["dep:embassy-time", "embassy-time?/tick-32768hz"] |
| 61 | 61 | ||
| 62 | _ppi = [] | 62 | _ppi = [] |
| 63 | _dppi = [] | 63 | _dppi = [] |
| @@ -65,9 +65,9 @@ _gpio-p1 = [] | |||
| 65 | 65 | ||
| 66 | [dependencies] | 66 | [dependencies] |
| 67 | embassy-executor = { version = "0.1.0", path = "../embassy-executor", optional = true } | 67 | embassy-executor = { version = "0.1.0", path = "../embassy-executor", optional = true } |
| 68 | embassy-time = { version = "0.1.0", path = "../embassy-time", optional = true } | ||
| 68 | embassy-util = { version = "0.1.0", path = "../embassy-util" } | 69 | embassy-util = { version = "0.1.0", path = "../embassy-util" } |
| 69 | embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]} | 70 | embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]} |
| 70 | embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["nrf"]} | ||
| 71 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } | 71 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } |
| 72 | embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } | 72 | embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } |
| 73 | embassy-usb = {version = "0.1.0", path = "../embassy-usb", optional=true } | 73 | embassy-usb = {version = "0.1.0", path = "../embassy-usb", optional=true } |
| @@ -80,9 +80,9 @@ embedded-io = { version = "0.3.0", features = ["async"], optional = true } | |||
| 80 | defmt = { version = "0.3", optional = true } | 80 | defmt = { version = "0.3", optional = true } |
| 81 | log = { version = "0.4.14", optional = true } | 81 | log = { version = "0.4.14", optional = true } |
| 82 | cortex-m-rt = ">=0.6.15,<0.8" | 82 | cortex-m-rt = ">=0.6.15,<0.8" |
| 83 | cortex-m = "0.7.3" | 83 | cortex-m = "0.7.6" |
| 84 | futures = { version = "0.3.17", default-features = false } | 84 | futures = { version = "0.3.17", default-features = false } |
| 85 | critical-section = "0.2.5" | 85 | critical-section = "1.1" |
| 86 | rand_core = "0.6.3" | 86 | rand_core = "0.6.3" |
| 87 | fixed = "1.10.0" | 87 | fixed = "1.10.0" |
| 88 | embedded-storage = "0.3.0" | 88 | embedded-storage = "0.3.0" |
diff --git a/embassy-nrf/src/chips/nrf52805.rs b/embassy-nrf/src/chips/nrf52805.rs index 8fca4da1a..d078fa0ad 100644 --- a/embassy-nrf/src/chips/nrf52805.rs +++ b/embassy-nrf/src/chips/nrf52805.rs | |||
| @@ -197,7 +197,7 @@ impl_saadc_input!(P0_04, ANALOGINPUT2); | |||
| 197 | impl_saadc_input!(P0_05, ANALOGINPUT3); | 197 | impl_saadc_input!(P0_05, ANALOGINPUT3); |
| 198 | 198 | ||
| 199 | pub mod irqs { | 199 | pub mod irqs { |
| 200 | use embassy_macros::cortex_m_interrupt_declare as declare; | 200 | use embassy_cortex_m::interrupt::_export::declare; |
| 201 | 201 | ||
| 202 | use crate::pac::Interrupt as InterruptEnum; | 202 | use crate::pac::Interrupt as InterruptEnum; |
| 203 | 203 | ||
diff --git a/embassy-nrf/src/chips/nrf52810.rs b/embassy-nrf/src/chips/nrf52810.rs index 538a617d2..faa52d8fb 100644 --- a/embassy-nrf/src/chips/nrf52810.rs +++ b/embassy-nrf/src/chips/nrf52810.rs | |||
| @@ -218,7 +218,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6); | |||
| 218 | impl_saadc_input!(P0_31, ANALOGINPUT7); | 218 | impl_saadc_input!(P0_31, ANALOGINPUT7); |
| 219 | 219 | ||
| 220 | pub mod irqs { | 220 | pub mod irqs { |
| 221 | use embassy_macros::cortex_m_interrupt_declare as declare; | 221 | use embassy_cortex_m::interrupt::_export::declare; |
| 222 | 222 | ||
| 223 | use crate::pac::Interrupt as InterruptEnum; | 223 | use crate::pac::Interrupt as InterruptEnum; |
| 224 | 224 | ||
diff --git a/embassy-nrf/src/chips/nrf52811.rs b/embassy-nrf/src/chips/nrf52811.rs index 808adf517..bbdf1cbe5 100644 --- a/embassy-nrf/src/chips/nrf52811.rs +++ b/embassy-nrf/src/chips/nrf52811.rs | |||
| @@ -219,7 +219,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6); | |||
| 219 | impl_saadc_input!(P0_31, ANALOGINPUT7); | 219 | impl_saadc_input!(P0_31, ANALOGINPUT7); |
| 220 | 220 | ||
| 221 | pub mod irqs { | 221 | pub mod irqs { |
| 222 | use embassy_macros::cortex_m_interrupt_declare as declare; | 222 | use embassy_cortex_m::interrupt::_export::declare; |
| 223 | 223 | ||
| 224 | use crate::pac::Interrupt as InterruptEnum; | 224 | use crate::pac::Interrupt as InterruptEnum; |
| 225 | 225 | ||
diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs index 6be5bd361..dba033b0f 100644 --- a/embassy-nrf/src/chips/nrf52820.rs +++ b/embassy-nrf/src/chips/nrf52820.rs | |||
| @@ -211,7 +211,7 @@ impl_ppi_channel!(PPI_CH30, 30 => static); | |||
| 211 | impl_ppi_channel!(PPI_CH31, 31 => static); | 211 | impl_ppi_channel!(PPI_CH31, 31 => static); |
| 212 | 212 | ||
| 213 | pub mod irqs { | 213 | pub mod irqs { |
| 214 | use embassy_macros::cortex_m_interrupt_declare as declare; | 214 | use embassy_cortex_m::interrupt::_export::declare; |
| 215 | 215 | ||
| 216 | use crate::pac::Interrupt as InterruptEnum; | 216 | use crate::pac::Interrupt as InterruptEnum; |
| 217 | 217 | ||
diff --git a/embassy-nrf/src/chips/nrf52832.rs b/embassy-nrf/src/chips/nrf52832.rs index cdc644d6e..18b8eda67 100644 --- a/embassy-nrf/src/chips/nrf52832.rs +++ b/embassy-nrf/src/chips/nrf52832.rs | |||
| @@ -235,7 +235,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6); | |||
| 235 | impl_saadc_input!(P0_31, ANALOGINPUT7); | 235 | impl_saadc_input!(P0_31, ANALOGINPUT7); |
| 236 | 236 | ||
| 237 | pub mod irqs { | 237 | pub mod irqs { |
| 238 | use embassy_macros::cortex_m_interrupt_declare as declare; | 238 | use embassy_cortex_m::interrupt::_export::declare; |
| 239 | 239 | ||
| 240 | use crate::pac::Interrupt as InterruptEnum; | 240 | use crate::pac::Interrupt as InterruptEnum; |
| 241 | 241 | ||
diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs index 4c3c5574d..39a0f93f9 100644 --- a/embassy-nrf/src/chips/nrf52833.rs +++ b/embassy-nrf/src/chips/nrf52833.rs | |||
| @@ -278,7 +278,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6); | |||
| 278 | impl_saadc_input!(P0_31, ANALOGINPUT7); | 278 | impl_saadc_input!(P0_31, ANALOGINPUT7); |
| 279 | 279 | ||
| 280 | pub mod irqs { | 280 | pub mod irqs { |
| 281 | use embassy_macros::cortex_m_interrupt_declare as declare; | 281 | use embassy_cortex_m::interrupt::_export::declare; |
| 282 | 282 | ||
| 283 | use crate::pac::Interrupt as InterruptEnum; | 283 | use crate::pac::Interrupt as InterruptEnum; |
| 284 | 284 | ||
diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs index bdaeadb9b..e3d8f34a1 100644 --- a/embassy-nrf/src/chips/nrf52840.rs +++ b/embassy-nrf/src/chips/nrf52840.rs | |||
| @@ -283,7 +283,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6); | |||
| 283 | impl_saadc_input!(P0_31, ANALOGINPUT7); | 283 | impl_saadc_input!(P0_31, ANALOGINPUT7); |
| 284 | 284 | ||
| 285 | pub mod irqs { | 285 | pub mod irqs { |
| 286 | use embassy_macros::cortex_m_interrupt_declare as declare; | 286 | use embassy_cortex_m::interrupt::_export::declare; |
| 287 | 287 | ||
| 288 | use crate::pac::Interrupt as InterruptEnum; | 288 | use crate::pac::Interrupt as InterruptEnum; |
| 289 | 289 | ||
diff --git a/embassy-nrf/src/chips/nrf5340_app.rs b/embassy-nrf/src/chips/nrf5340_app.rs index 26dc56bdb..edf800ef3 100644 --- a/embassy-nrf/src/chips/nrf5340_app.rs +++ b/embassy-nrf/src/chips/nrf5340_app.rs | |||
| @@ -468,7 +468,7 @@ impl_saadc_input!(P0_19, ANALOGINPUT6); | |||
| 468 | impl_saadc_input!(P0_20, ANALOGINPUT7); | 468 | impl_saadc_input!(P0_20, ANALOGINPUT7); |
| 469 | 469 | ||
| 470 | pub mod irqs { | 470 | pub mod irqs { |
| 471 | use embassy_macros::cortex_m_interrupt_declare as declare; | 471 | use embassy_cortex_m::interrupt::_export::declare; |
| 472 | 472 | ||
| 473 | use crate::pac::Interrupt as InterruptEnum; | 473 | use crate::pac::Interrupt as InterruptEnum; |
| 474 | 474 | ||
diff --git a/embassy-nrf/src/chips/nrf5340_net.rs b/embassy-nrf/src/chips/nrf5340_net.rs index e28cfe013..ae136e09d 100644 --- a/embassy-nrf/src/chips/nrf5340_net.rs +++ b/embassy-nrf/src/chips/nrf5340_net.rs | |||
| @@ -328,7 +328,7 @@ impl_ppi_channel!(PPI_CH30, 30 => configurable); | |||
| 328 | impl_ppi_channel!(PPI_CH31, 31 => configurable); | 328 | impl_ppi_channel!(PPI_CH31, 31 => configurable); |
| 329 | 329 | ||
| 330 | pub mod irqs { | 330 | pub mod irqs { |
| 331 | use embassy_macros::cortex_m_interrupt_declare as declare; | 331 | use embassy_cortex_m::interrupt::_export::declare; |
| 332 | 332 | ||
| 333 | use crate::pac::Interrupt as InterruptEnum; | 333 | use crate::pac::Interrupt as InterruptEnum; |
| 334 | 334 | ||
diff --git a/embassy-nrf/src/chips/nrf9160.rs b/embassy-nrf/src/chips/nrf9160.rs index 1a0bd10fe..a4be8564e 100644 --- a/embassy-nrf/src/chips/nrf9160.rs +++ b/embassy-nrf/src/chips/nrf9160.rs | |||
| @@ -346,7 +346,7 @@ impl_saadc_input!(P0_19, ANALOGINPUT6); | |||
| 346 | impl_saadc_input!(P0_20, ANALOGINPUT7); | 346 | impl_saadc_input!(P0_20, ANALOGINPUT7); |
| 347 | 347 | ||
| 348 | pub mod irqs { | 348 | pub mod irqs { |
| 349 | use embassy_macros::cortex_m_interrupt_declare as declare; | 349 | use embassy_cortex_m::interrupt::_export::declare; |
| 350 | 350 | ||
| 351 | use crate::pac::Interrupt as InterruptEnum; | 351 | use crate::pac::Interrupt as InterruptEnum; |
| 352 | 352 | ||
diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index ad6c16c1f..f3b3ca0ca 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs | |||
| @@ -135,8 +135,8 @@ pub use chip::pac; | |||
| 135 | pub(crate) use chip::pac; | 135 | pub(crate) use chip::pac; |
| 136 | pub use chip::{peripherals, Peripherals}; | 136 | pub use chip::{peripherals, Peripherals}; |
| 137 | pub use embassy_cortex_m::executor; | 137 | pub use embassy_cortex_m::executor; |
| 138 | pub use embassy_cortex_m::interrupt::_export::interrupt; | ||
| 138 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 139 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 139 | pub use embassy_macros::cortex_m_interrupt as interrupt; | ||
| 140 | 140 | ||
| 141 | pub mod config { | 141 | pub mod config { |
| 142 | //! Configuration options used when initializing the HAL. | 142 | //! Configuration options used when initializing the HAL. |
diff --git a/embassy-nrf/src/time_driver.rs b/embassy-nrf/src/time_driver.rs index 05fa0aea8..b961d65a0 100644 --- a/embassy-nrf/src/time_driver.rs +++ b/embassy-nrf/src/time_driver.rs | |||
| @@ -3,7 +3,7 @@ use core::sync::atomic::{compiler_fence, AtomicU32, AtomicU8, Ordering}; | |||
| 3 | use core::{mem, ptr}; | 3 | use core::{mem, ptr}; |
| 4 | 4 | ||
| 5 | use critical_section::CriticalSection; | 5 | use critical_section::CriticalSection; |
| 6 | use embassy_executor::time::driver::{AlarmHandle, Driver}; | 6 | use embassy_time::driver::{AlarmHandle, Driver}; |
| 7 | use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex; | 7 | use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex; |
| 8 | use embassy_util::blocking_mutex::CriticalSectionMutex as Mutex; | 8 | use embassy_util::blocking_mutex::CriticalSectionMutex as Mutex; |
| 9 | 9 | ||
| @@ -119,7 +119,7 @@ struct RtcDriver { | |||
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | const ALARM_STATE_NEW: AlarmState = AlarmState::new(); | 121 | const ALARM_STATE_NEW: AlarmState = AlarmState::new(); |
| 122 | embassy_executor::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver { | 122 | embassy_time::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver { |
| 123 | period: AtomicU32::new(0), | 123 | period: AtomicU32::new(0), |
| 124 | alarm_count: AtomicU8::new(0), | 124 | alarm_count: AtomicU8::new(0), |
| 125 | alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [ALARM_STATE_NEW; ALARM_COUNT]), | 125 | alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [ALARM_STATE_NEW; ALARM_COUNT]), |
diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index 494abe0cc..9587d1f40 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs | |||
| @@ -12,9 +12,9 @@ use core::sync::atomic::Ordering::SeqCst; | |||
| 12 | use core::task::Poll; | 12 | use core::task::Poll; |
| 13 | 13 | ||
| 14 | use embassy_embedded_hal::SetConfig; | 14 | use embassy_embedded_hal::SetConfig; |
| 15 | #[cfg(feature = "time")] | ||
| 16 | use embassy_executor::time::{Duration, Instant}; | ||
| 17 | use embassy_hal_common::{into_ref, PeripheralRef}; | 15 | use embassy_hal_common::{into_ref, PeripheralRef}; |
| 16 | #[cfg(feature = "time")] | ||
| 17 | use embassy_time::{Duration, Instant}; | ||
| 18 | use embassy_util::waitqueue::AtomicWaker; | 18 | use embassy_util::waitqueue::AtomicWaker; |
| 19 | use futures::future::poll_fn; | 19 | use futures::future::poll_fn; |
| 20 | 20 | ||
diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index b4dab7f46..af7c8ee6e 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml | |||
| @@ -28,19 +28,19 @@ unstable-traits = ["embedded-hal-1"] | |||
| 28 | 28 | ||
| 29 | [dependencies] | 29 | [dependencies] |
| 30 | embassy-util = { version = "0.1.0", path = "../embassy-util" } | 30 | embassy-util = { version = "0.1.0", path = "../embassy-util" } |
| 31 | embassy-executor = { version = "0.1.0", path = "../embassy-executor", features = [ "time-tick-1mhz" ] } | 31 | embassy-executor = { version = "0.1.0", path = "../embassy-executor" } |
| 32 | embassy-time = { version = "0.1.0", path = "../embassy-time", features = [ "tick-1mhz" ] } | ||
| 32 | embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]} | 33 | embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]} |
| 33 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } | 34 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } |
| 34 | embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } | 35 | embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } |
| 35 | embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["rp"]} | 36 | atomic-polyfill = "1.0.1" |
| 36 | atomic-polyfill = "0.1.5" | ||
| 37 | defmt = { version = "0.3", optional = true } | 37 | defmt = { version = "0.3", optional = true } |
| 38 | log = { version = "0.4.14", optional = true } | 38 | log = { version = "0.4.14", optional = true } |
| 39 | nb = "1.0.0" | 39 | nb = "1.0.0" |
| 40 | cfg-if = "1.0.0" | 40 | cfg-if = "1.0.0" |
| 41 | cortex-m-rt = ">=0.6.15,<0.8" | 41 | cortex-m-rt = ">=0.6.15,<0.8" |
| 42 | cortex-m = "0.7.3" | 42 | cortex-m = "0.7.6" |
| 43 | critical-section = "0.2.5" | 43 | critical-section = "1.1" |
| 44 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 44 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 45 | 45 | ||
| 46 | rp2040-pac2 = { git = "https://github.com/embassy-rs/rp2040-pac2", rev="9ad7223a48a065e612bc7dc7be5bf5bd0b41cfc4", features = ["rt"] } | 46 | rp2040-pac2 = { git = "https://github.com/embassy-rs/rp2040-pac2", rev="9ad7223a48a065e612bc7dc7be5bf5bd0b41cfc4", features = ["rt"] } |
diff --git a/embassy-rp/src/interrupt.rs b/embassy-rp/src/interrupt.rs index d652a8c71..f21a5433b 100644 --- a/embassy-rp/src/interrupt.rs +++ b/embassy-rp/src/interrupt.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | //! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. | 4 | //! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. |
| 5 | 5 | ||
| 6 | // Re-exports | 6 | // Re-exports |
| 7 | use embassy_cortex_m::interrupt::_export::declare; | ||
| 7 | pub use embassy_cortex_m::interrupt::*; | 8 | pub use embassy_cortex_m::interrupt::*; |
| 8 | use embassy_macros::cortex_m_interrupt_declare as declare; | ||
| 9 | 9 | ||
| 10 | use crate::pac::Interrupt as InterruptEnum; | 10 | use crate::pac::Interrupt as InterruptEnum; |
| 11 | declare!(TIMER_IRQ_0); | 11 | declare!(TIMER_IRQ_0); |
diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs index 44150be0d..8c053a4f7 100644 --- a/embassy-rp/src/lib.rs +++ b/embassy-rp/src/lib.rs | |||
| @@ -17,8 +17,8 @@ mod reset; | |||
| 17 | // Reexports | 17 | // Reexports |
| 18 | 18 | ||
| 19 | pub use embassy_cortex_m::executor; | 19 | pub use embassy_cortex_m::executor; |
| 20 | pub use embassy_cortex_m::interrupt::_export::interrupt; | ||
| 20 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 21 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 21 | pub use embassy_macros::cortex_m_interrupt as interrupt; | ||
| 22 | #[cfg(feature = "unstable-pac")] | 22 | #[cfg(feature = "unstable-pac")] |
| 23 | pub use rp2040_pac2 as pac; | 23 | pub use rp2040_pac2 as pac; |
| 24 | #[cfg(not(feature = "unstable-pac"))] | 24 | #[cfg(not(feature = "unstable-pac"))] |
diff --git a/embassy-rp/src/timer.rs b/embassy-rp/src/timer.rs index 142fd410d..5bc1f66c8 100644 --- a/embassy-rp/src/timer.rs +++ b/embassy-rp/src/timer.rs | |||
| @@ -2,7 +2,7 @@ use core::cell::Cell; | |||
| 2 | 2 | ||
| 3 | use atomic_polyfill::{AtomicU8, Ordering}; | 3 | use atomic_polyfill::{AtomicU8, Ordering}; |
| 4 | use critical_section::CriticalSection; | 4 | use critical_section::CriticalSection; |
| 5 | use embassy_executor::time::driver::{AlarmHandle, Driver}; | 5 | use embassy_time::driver::{AlarmHandle, Driver}; |
| 6 | use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex; | 6 | use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex; |
| 7 | use embassy_util::blocking_mutex::Mutex; | 7 | use embassy_util::blocking_mutex::Mutex; |
| 8 | 8 | ||
| @@ -26,7 +26,7 @@ struct TimerDriver { | |||
| 26 | next_alarm: AtomicU8, | 26 | next_alarm: AtomicU8, |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | embassy_executor::time_driver_impl!(static DRIVER: TimerDriver = TimerDriver{ | 29 | embassy_time::time_driver_impl!(static DRIVER: TimerDriver = TimerDriver{ |
| 30 | alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [DUMMY_ALARM; ALARM_COUNT]), | 30 | alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [DUMMY_ALARM; ALARM_COUNT]), |
| 31 | next_alarm: AtomicU8::new(0), | 31 | next_alarm: AtomicU8::new(0), |
| 32 | }); | 32 | }); |
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index ff228cc85..c47ea0bca 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml | |||
| @@ -10,7 +10,7 @@ src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-stm32 | |||
| 10 | # TODO: sdmmc | 10 | # TODO: sdmmc |
| 11 | # TODO: net | 11 | # TODO: net |
| 12 | # TODO: subghz | 12 | # TODO: subghz |
| 13 | features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "embassy-executor/time-tick-32768hz"] | 13 | features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "embassy-time/tick-32768hz"] |
| 14 | flavors = [ | 14 | flavors = [ |
| 15 | { regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" }, | 15 | { regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" }, |
| 16 | { regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" }, | 16 | { regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" }, |
| @@ -33,8 +33,8 @@ flavors = [ | |||
| 33 | [dependencies] | 33 | [dependencies] |
| 34 | embassy-util = { version = "0.1.0", path = "../embassy-util" } | 34 | embassy-util = { version = "0.1.0", path = "../embassy-util" } |
| 35 | embassy-executor = { version = "0.1.0", path = "../embassy-executor" } | 35 | embassy-executor = { version = "0.1.0", path = "../embassy-executor" } |
| 36 | embassy-time = { version = "0.1.0", path = "../embassy-time", optional = true } | ||
| 36 | embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-4"]} | 37 | embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-4"]} |
| 37 | embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["stm32"] } | ||
| 38 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } | 38 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } |
| 39 | embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } | 39 | embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } |
| 40 | embassy-net = { version = "0.1.0", path = "../embassy-net", optional = true } | 40 | embassy-net = { version = "0.1.0", path = "../embassy-net", optional = true } |
| @@ -50,14 +50,13 @@ embedded-storage-async = { version = "0.3.0", optional = true } | |||
| 50 | defmt = { version = "0.3", optional = true } | 50 | defmt = { version = "0.3", optional = true } |
| 51 | log = { version = "0.4.14", optional = true } | 51 | log = { version = "0.4.14", optional = true } |
| 52 | cortex-m-rt = ">=0.6.15,<0.8" | 52 | cortex-m-rt = ">=0.6.15,<0.8" |
| 53 | cortex-m = "0.7.3" | 53 | cortex-m = "0.7.6" |
| 54 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 54 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 55 | rand_core = "0.6.3" | 55 | rand_core = "0.6.3" |
| 56 | sdio-host = "0.5.0" | 56 | sdio-host = "0.5.0" |
| 57 | embedded-sdmmc = { git = "https://github.com/thalesfragoso/embedded-sdmmc-rs", branch = "async", optional = true } | 57 | embedded-sdmmc = { git = "https://github.com/thalesfragoso/embedded-sdmmc-rs", branch = "async", optional = true } |
| 58 | critical-section = "0.2.5" | 58 | critical-section = "1.1" |
| 59 | bare-metal = "1.0.0" | 59 | atomic-polyfill = "1.0.1" |
| 60 | atomic-polyfill = "0.1.5" | ||
| 61 | stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", features = ["rt"] } | 60 | stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", features = ["rt"] } |
| 62 | vcell = "0.1.3" | 61 | vcell = "0.1.3" |
| 63 | bxcan = "0.7.0" | 62 | bxcan = "0.7.0" |
| @@ -82,7 +81,7 @@ exti = [] | |||
| 82 | 81 | ||
| 83 | # Features starting with `_` are for internal use only. They're not intended | 82 | # Features starting with `_` are for internal use only. They're not intended |
| 84 | # to be enabled by other crates, and are not covered by semver guarantees. | 83 | # to be enabled by other crates, and are not covered by semver guarantees. |
| 85 | _time-driver = ["embassy-executor/time"] | 84 | _time-driver = ["dep:embassy-time"] |
| 86 | time-driver-any = ["_time-driver"] | 85 | time-driver-any = ["_time-driver"] |
| 87 | time-driver-tim2 = ["_time-driver"] | 86 | time-driver-tim2 = ["_time-driver"] |
| 88 | time-driver-tim3 = ["_time-driver"] | 87 | time-driver-tim3 = ["_time-driver"] |
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 3b4aa5dfd..c892007a3 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -96,7 +96,7 @@ fn main() { | |||
| 96 | g.extend(quote! { | 96 | g.extend(quote! { |
| 97 | pub mod interrupt { | 97 | pub mod interrupt { |
| 98 | use crate::pac::Interrupt as InterruptEnum; | 98 | use crate::pac::Interrupt as InterruptEnum; |
| 99 | use embassy_macros::cortex_m_interrupt_declare as declare; | 99 | use embassy_cortex_m::interrupt::_export::declare; |
| 100 | #( | 100 | #( |
| 101 | declare!(#irqs); | 101 | declare!(#irqs); |
| 102 | )* | 102 | )* |
diff --git a/embassy-stm32/src/interrupt.rs b/embassy-stm32/src/interrupt.rs index 9dc1f2044..b66e4c7ef 100644 --- a/embassy-stm32/src/interrupt.rs +++ b/embassy-stm32/src/interrupt.rs | |||
| @@ -1,5 +1,4 @@ | |||
| 1 | pub use bare_metal::Mutex; | 1 | pub use critical_section::{CriticalSection, Mutex}; |
| 2 | pub use critical_section::CriticalSection; | ||
| 3 | pub use embassy_cortex_m::interrupt::*; | 2 | pub use embassy_cortex_m::interrupt::*; |
| 4 | 3 | ||
| 5 | pub use crate::_generated::interrupt::*; | 4 | pub use crate::_generated::interrupt::*; |
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 78025f3db..30ff02d56 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -75,8 +75,8 @@ pub(crate) mod _generated { | |||
| 75 | // Reexports | 75 | // Reexports |
| 76 | pub use _generated::{peripherals, Peripherals}; | 76 | pub use _generated::{peripherals, Peripherals}; |
| 77 | pub use embassy_cortex_m::executor; | 77 | pub use embassy_cortex_m::executor; |
| 78 | pub use embassy_cortex_m::interrupt::_export::interrupt; | ||
| 78 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 79 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 79 | pub use embassy_macros::cortex_m_interrupt as interrupt; | ||
| 80 | #[cfg(feature = "unstable-pac")] | 80 | #[cfg(feature = "unstable-pac")] |
| 81 | pub use stm32_metapac as pac; | 81 | pub use stm32_metapac as pac; |
| 82 | #[cfg(not(feature = "unstable-pac"))] | 82 | #[cfg(not(feature = "unstable-pac"))] |
diff --git a/embassy-stm32/src/subghz/mod.rs b/embassy-stm32/src/subghz/mod.rs index 4e53efed5..a74f9a6d5 100644 --- a/embassy-stm32/src/subghz/mod.rs +++ b/embassy-stm32/src/subghz/mod.rs | |||
| @@ -504,7 +504,7 @@ impl<'d> SubGhz<'d, NoDma, NoDma> { | |||
| 504 | /// | 504 | /// |
| 505 | /// sg.set_standby(StandbyClk::Rc)?; | 505 | /// sg.set_standby(StandbyClk::Rc)?; |
| 506 | /// unsafe { sg.set_sleep(SleepCfg::default())? }; | 506 | /// unsafe { sg.set_sleep(SleepCfg::default())? }; |
| 507 | /// embassy_executor::time::Timer::after(embassy_executor::time::Duration::from_micros(500)).await; | 507 | /// embassy_time::Timer::after(embassy_time::Duration::from_micros(500)).await; |
| 508 | /// unsafe { wakeup() }; | 508 | /// unsafe { wakeup() }; |
| 509 | /// # Ok::<(), embassy_stm32::subghz::Error>(()) | 509 | /// # Ok::<(), embassy_stm32::subghz::Error>(()) |
| 510 | /// ``` | 510 | /// ``` |
diff --git a/embassy-stm32/src/subghz/timeout.rs b/embassy-stm32/src/subghz/timeout.rs index b8d6ad8f9..28b3b0c21 100644 --- a/embassy-stm32/src/subghz/timeout.rs +++ b/embassy-stm32/src/subghz/timeout.rs | |||
| @@ -439,9 +439,9 @@ impl From<Timeout> for [u8; 3] { | |||
| 439 | } | 439 | } |
| 440 | } | 440 | } |
| 441 | 441 | ||
| 442 | impl From<Timeout> for embassy_executor::time::Duration { | 442 | impl From<Timeout> for embassy_time::Duration { |
| 443 | fn from(to: Timeout) -> Self { | 443 | fn from(to: Timeout) -> Self { |
| 444 | embassy_executor::time::Duration::from_micros(to.as_micros().into()) | 444 | embassy_time::Duration::from_micros(to.as_micros().into()) |
| 445 | } | 445 | } |
| 446 | } | 446 | } |
| 447 | 447 | ||
diff --git a/embassy-stm32/src/subghz/tx_params.rs b/embassy-stm32/src/subghz/tx_params.rs index a72c060f3..cede6f2c1 100644 --- a/embassy-stm32/src/subghz/tx_params.rs +++ b/embassy-stm32/src/subghz/tx_params.rs | |||
| @@ -44,17 +44,17 @@ impl From<RampTime> for core::time::Duration { | |||
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | impl From<RampTime> for embassy_executor::time::Duration { | 47 | impl From<RampTime> for embassy_time::Duration { |
| 48 | fn from(rt: RampTime) -> Self { | 48 | fn from(rt: RampTime) -> Self { |
| 49 | match rt { | 49 | match rt { |
| 50 | RampTime::Micros10 => embassy_executor::time::Duration::from_micros(10), | 50 | RampTime::Micros10 => embassy_time::Duration::from_micros(10), |
| 51 | RampTime::Micros20 => embassy_executor::time::Duration::from_micros(20), | 51 | RampTime::Micros20 => embassy_time::Duration::from_micros(20), |
| 52 | RampTime::Micros40 => embassy_executor::time::Duration::from_micros(40), | 52 | RampTime::Micros40 => embassy_time::Duration::from_micros(40), |
| 53 | RampTime::Micros80 => embassy_executor::time::Duration::from_micros(80), | 53 | RampTime::Micros80 => embassy_time::Duration::from_micros(80), |
| 54 | RampTime::Micros200 => embassy_executor::time::Duration::from_micros(200), | 54 | RampTime::Micros200 => embassy_time::Duration::from_micros(200), |
| 55 | RampTime::Micros800 => embassy_executor::time::Duration::from_micros(800), | 55 | RampTime::Micros800 => embassy_time::Duration::from_micros(800), |
| 56 | RampTime::Micros1700 => embassy_executor::time::Duration::from_micros(1700), | 56 | RampTime::Micros1700 => embassy_time::Duration::from_micros(1700), |
| 57 | RampTime::Micros3400 => embassy_executor::time::Duration::from_micros(3400), | 57 | RampTime::Micros3400 => embassy_time::Duration::from_micros(3400), |
| 58 | } | 58 | } |
| 59 | } | 59 | } |
| 60 | } | 60 | } |
diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs index 6cea43f18..7f4723162 100644 --- a/embassy-stm32/src/time_driver.rs +++ b/embassy-stm32/src/time_driver.rs | |||
| @@ -4,8 +4,8 @@ use core::sync::atomic::{compiler_fence, Ordering}; | |||
| 4 | use core::{mem, ptr}; | 4 | use core::{mem, ptr}; |
| 5 | 5 | ||
| 6 | use atomic_polyfill::{AtomicU32, AtomicU8}; | 6 | use atomic_polyfill::{AtomicU32, AtomicU8}; |
| 7 | use embassy_executor::time::driver::{AlarmHandle, Driver}; | 7 | use embassy_time::driver::{AlarmHandle, Driver}; |
| 8 | use embassy_executor::time::TICKS_PER_SECOND; | 8 | use embassy_time::TICKS_PER_SECOND; |
| 9 | use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex; | 9 | use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex; |
| 10 | use embassy_util::blocking_mutex::Mutex; | 10 | use embassy_util::blocking_mutex::Mutex; |
| 11 | use stm32_metapac::timer::regs; | 11 | use stm32_metapac::timer::regs; |
| @@ -133,7 +133,7 @@ struct RtcDriver { | |||
| 133 | 133 | ||
| 134 | const ALARM_STATE_NEW: AlarmState = AlarmState::new(); | 134 | const ALARM_STATE_NEW: AlarmState = AlarmState::new(); |
| 135 | 135 | ||
| 136 | embassy_executor::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver { | 136 | embassy_time::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver { |
| 137 | period: AtomicU32::new(0), | 137 | period: AtomicU32::new(0), |
| 138 | alarm_count: AtomicU8::new(0), | 138 | alarm_count: AtomicU8::new(0), |
| 139 | alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [ALARM_STATE_NEW; ALARM_COUNT]), | 139 | alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [ALARM_STATE_NEW; ALARM_COUNT]), |
diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index 764b21461..3861e42d0 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs | |||
| @@ -5,8 +5,8 @@ use core::sync::atomic::Ordering; | |||
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | 6 | ||
| 7 | use atomic_polyfill::{AtomicBool, AtomicU8}; | 7 | use atomic_polyfill::{AtomicBool, AtomicU8}; |
| 8 | use embassy_executor::time::{block_for, Duration}; | ||
| 9 | use embassy_hal_common::into_ref; | 8 | use embassy_hal_common::into_ref; |
| 9 | use embassy_time::{block_for, Duration}; | ||
| 10 | use embassy_usb::driver::{self, EndpointAllocError, EndpointError, Event, Unsupported}; | 10 | use embassy_usb::driver::{self, EndpointAllocError, EndpointError, Event, Unsupported}; |
| 11 | use embassy_usb::types::{EndpointAddress, EndpointInfo, EndpointType, UsbDirection}; | 11 | use embassy_usb::types::{EndpointAddress, EndpointInfo, EndpointType, UsbDirection}; |
| 12 | use embassy_util::waitqueue::AtomicWaker; | 12 | use embassy_util::waitqueue::AtomicWaker; |
diff --git a/embassy-time/Cargo.toml b/embassy-time/Cargo.toml new file mode 100644 index 000000000..161c101fe --- /dev/null +++ b/embassy-time/Cargo.toml | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | [package] | ||
| 2 | name = "embassy-time" | ||
| 3 | version = "0.1.0" | ||
| 4 | edition = "2021" | ||
| 5 | |||
| 6 | |||
| 7 | [package.metadata.embassy_docs] | ||
| 8 | src_base = "https://github.com/embassy-rs/embassy/blob/embassy-time-v$VERSION/embassy-time/src/" | ||
| 9 | src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-time/src/" | ||
| 10 | features = ["nightly", "defmt", "unstable-traits", "std"] | ||
| 11 | target = "x86_64-unknown-linux-gnu" | ||
| 12 | |||
| 13 | [features] | ||
| 14 | std = ["tick-1mhz"] | ||
| 15 | wasm = ["dep:wasm-bindgen", "dep:js-sys", "dep:wasm-timer", "tick-1mhz"] | ||
| 16 | |||
| 17 | # Enable nightly-only features | ||
| 18 | nightly = ["embedded-hal-async"] | ||
| 19 | |||
| 20 | # Implement embedded-hal 1.0 alpha and embedded-hal-async traits. | ||
| 21 | # Implement embedded-hal-async traits if `nightly` is set as well. | ||
| 22 | unstable-traits = ["embedded-hal-1"] | ||
| 23 | |||
| 24 | # Display a timestamp of the number of seconds since startup next to defmt log messages | ||
| 25 | # To use this you must have a time driver provided. | ||
| 26 | defmt-timestamp-uptime = ["defmt"] | ||
| 27 | |||
| 28 | # Set the `embassy_time` tick rate. | ||
| 29 | # NOTE: This feature is only intended to be enabled by crates providing the time driver implementation. | ||
| 30 | # If you're not writing your own driver, check the driver documentation to customize the tick rate. | ||
| 31 | # If you're writing a driver and your tick rate is not listed here, please add it and send a PR! | ||
| 32 | tick-32768hz = [] | ||
| 33 | tick-1000hz = [] | ||
| 34 | tick-1mhz = [] | ||
| 35 | tick-16mhz = [] | ||
| 36 | |||
| 37 | [dependencies] | ||
| 38 | defmt = { version = "0.3", optional = true } | ||
| 39 | log = { version = "0.4.14", optional = true } | ||
| 40 | |||
| 41 | embedded-hal-02 = { package = "embedded-hal", version = "0.2.6" } | ||
| 42 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true} | ||
| 43 | embedded-hal-async = { version = "0.1.0-alpha.1", optional = true} | ||
| 44 | |||
| 45 | futures-util = { version = "0.3.17", default-features = false } | ||
| 46 | embassy-macros = { version = "0.1.0", path = "../embassy-macros"} | ||
| 47 | atomic-polyfill = "1.0.1" | ||
| 48 | critical-section = "1.1" | ||
| 49 | cfg-if = "1.0.0" | ||
| 50 | |||
| 51 | # WASM dependencies | ||
| 52 | wasm-bindgen = { version = "0.2.76", features = ["nightly"], optional = true } | ||
| 53 | js-sys = { version = "0.3", optional = true } | ||
| 54 | wasm-timer = { version = "0.2.5", optional = true } \ No newline at end of file | ||
diff --git a/embassy-executor/src/time/delay.rs b/embassy-time/src/delay.rs index d76ed32eb..d010fff98 100644 --- a/embassy-executor/src/time/delay.rs +++ b/embassy-time/src/delay.rs | |||
| @@ -33,7 +33,7 @@ mod eh1 { | |||
| 33 | 33 | ||
| 34 | cfg_if::cfg_if! { | 34 | cfg_if::cfg_if! { |
| 35 | if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] { | 35 | if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] { |
| 36 | use crate::time::Timer; | 36 | use crate::Timer; |
| 37 | use core::future::Future; | 37 | use core::future::Future; |
| 38 | use futures_util::FutureExt; | 38 | use futures_util::FutureExt; |
| 39 | 39 | ||
diff --git a/embassy-executor/src/time/driver.rs b/embassy-time/src/driver.rs index 48e2f1c7d..216b27408 100644 --- a/embassy-executor/src/time/driver.rs +++ b/embassy-time/src/driver.rs | |||
| @@ -1,17 +1,17 @@ | |||
| 1 | //! Time driver interface | 1 | //! Time driver interface |
| 2 | //! | 2 | //! |
| 3 | //! This module defines the interface a driver needs to implement to power the `embassy_executor::time` module. | 3 | //! This module defines the interface a driver needs to implement to power the `embassy_time` module. |
| 4 | //! | 4 | //! |
| 5 | //! # Implementing a driver | 5 | //! # Implementing a driver |
| 6 | //! | 6 | //! |
| 7 | //! - Define a struct `MyDriver` | 7 | //! - Define a struct `MyDriver` |
| 8 | //! - Implement [`Driver`] for it | 8 | //! - Implement [`Driver`] for it |
| 9 | //! - Register it as the global driver with [`time_driver_impl`]. | 9 | //! - Register it as the global driver with [`time_driver_impl`]. |
| 10 | //! - Enable the Cargo features `embassy-executor/time` and one of `embassy-executor/time-tick-*` corresponding to the | 10 | //! - Enable the Cargo features `embassy-executor/time` and one of `embassy-time/tick-*` corresponding to the |
| 11 | //! tick rate of your driver. | 11 | //! tick rate of your driver. |
| 12 | //! | 12 | //! |
| 13 | //! If you wish to make the tick rate configurable by the end user, you should do so by exposing your own | 13 | //! If you wish to make the tick rate configurable by the end user, you should do so by exposing your own |
| 14 | //! Cargo features and having each enable the corresponding `embassy-executor/time-tick-*`. | 14 | //! Cargo features and having each enable the corresponding `embassy-time/tick-*`. |
| 15 | //! | 15 | //! |
| 16 | //! # Linkage details | 16 | //! # Linkage details |
| 17 | //! | 17 | //! |
| @@ -34,10 +34,10 @@ | |||
| 34 | //! # Example | 34 | //! # Example |
| 35 | //! | 35 | //! |
| 36 | //! ``` | 36 | //! ``` |
| 37 | //! use embassy_executor::time::driver::{Driver, AlarmHandle}; | 37 | //! use embassy_time::driver::{Driver, AlarmHandle}; |
| 38 | //! | 38 | //! |
| 39 | //! struct MyDriver{}; // not public! | 39 | //! struct MyDriver{}; // not public! |
| 40 | //! embassy_executor::time_driver_impl!(static DRIVER: MyDriver = MyDriver{}); | 40 | //! embassy_time::time_driver_impl!(static DRIVER: MyDriver = MyDriver{}); |
| 41 | //! | 41 | //! |
| 42 | //! impl Driver for MyDriver { | 42 | //! impl Driver for MyDriver { |
| 43 | //! fn now(&self) -> u64 { | 43 | //! fn now(&self) -> u64 { |
| @@ -121,17 +121,25 @@ extern "Rust" { | |||
| 121 | fn _embassy_time_set_alarm(alarm: AlarmHandle, timestamp: u64); | 121 | fn _embassy_time_set_alarm(alarm: AlarmHandle, timestamp: u64); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | pub(crate) fn now() -> u64 { | 124 | /// See [`Driver::now`] |
| 125 | pub fn now() -> u64 { | ||
| 125 | unsafe { _embassy_time_now() } | 126 | unsafe { _embassy_time_now() } |
| 126 | } | 127 | } |
| 128 | |||
| 129 | /// See [`Driver::allocate_alarm`] | ||
| 130 | /// | ||
| 127 | /// Safety: it is UB to make the alarm fire before setting a callback. | 131 | /// Safety: it is UB to make the alarm fire before setting a callback. |
| 128 | pub(crate) unsafe fn allocate_alarm() -> Option<AlarmHandle> { | 132 | pub unsafe fn allocate_alarm() -> Option<AlarmHandle> { |
| 129 | _embassy_time_allocate_alarm() | 133 | _embassy_time_allocate_alarm() |
| 130 | } | 134 | } |
| 131 | pub(crate) fn set_alarm_callback(alarm: AlarmHandle, callback: fn(*mut ()), ctx: *mut ()) { | 135 | |
| 136 | /// See [`Driver::set_alarm_callback`] | ||
| 137 | pub fn set_alarm_callback(alarm: AlarmHandle, callback: fn(*mut ()), ctx: *mut ()) { | ||
| 132 | unsafe { _embassy_time_set_alarm_callback(alarm, callback, ctx) } | 138 | unsafe { _embassy_time_set_alarm_callback(alarm, callback, ctx) } |
| 133 | } | 139 | } |
| 134 | pub(crate) fn set_alarm(alarm: AlarmHandle, timestamp: u64) { | 140 | |
| 141 | /// See [`Driver::set_alarm`] | ||
| 142 | pub fn set_alarm(alarm: AlarmHandle, timestamp: u64) { | ||
| 135 | unsafe { _embassy_time_set_alarm(alarm, timestamp) } | 143 | unsafe { _embassy_time_set_alarm(alarm, timestamp) } |
| 136 | } | 144 | } |
| 137 | 145 | ||
| @@ -145,26 +153,22 @@ macro_rules! time_driver_impl { | |||
| 145 | 153 | ||
| 146 | #[no_mangle] | 154 | #[no_mangle] |
| 147 | fn _embassy_time_now() -> u64 { | 155 | fn _embassy_time_now() -> u64 { |
| 148 | <$t as $crate::time::driver::Driver>::now(&$name) | 156 | <$t as $crate::driver::Driver>::now(&$name) |
| 149 | } | 157 | } |
| 150 | 158 | ||
| 151 | #[no_mangle] | 159 | #[no_mangle] |
| 152 | unsafe fn _embassy_time_allocate_alarm() -> Option<$crate::time::driver::AlarmHandle> { | 160 | unsafe fn _embassy_time_allocate_alarm() -> Option<$crate::driver::AlarmHandle> { |
| 153 | <$t as $crate::time::driver::Driver>::allocate_alarm(&$name) | 161 | <$t as $crate::driver::Driver>::allocate_alarm(&$name) |
| 154 | } | 162 | } |
| 155 | 163 | ||
| 156 | #[no_mangle] | 164 | #[no_mangle] |
| 157 | fn _embassy_time_set_alarm_callback( | 165 | fn _embassy_time_set_alarm_callback(alarm: $crate::driver::AlarmHandle, callback: fn(*mut ()), ctx: *mut ()) { |
| 158 | alarm: $crate::time::driver::AlarmHandle, | 166 | <$t as $crate::driver::Driver>::set_alarm_callback(&$name, alarm, callback, ctx) |
| 159 | callback: fn(*mut ()), | ||
| 160 | ctx: *mut (), | ||
| 161 | ) { | ||
| 162 | <$t as $crate::time::driver::Driver>::set_alarm_callback(&$name, alarm, callback, ctx) | ||
| 163 | } | 167 | } |
| 164 | 168 | ||
| 165 | #[no_mangle] | 169 | #[no_mangle] |
| 166 | fn _embassy_time_set_alarm(alarm: $crate::time::driver::AlarmHandle, timestamp: u64) { | 170 | fn _embassy_time_set_alarm(alarm: $crate::driver::AlarmHandle, timestamp: u64) { |
| 167 | <$t as $crate::time::driver::Driver>::set_alarm(&$name, alarm, timestamp) | 171 | <$t as $crate::driver::Driver>::set_alarm(&$name, alarm, timestamp) |
| 168 | } | 172 | } |
| 169 | }; | 173 | }; |
| 170 | } | 174 | } |
diff --git a/embassy-executor/src/time/driver_std.rs b/embassy-time/src/driver_std.rs index cb66f7c19..2ddb2e604 100644 --- a/embassy-executor/src/time/driver_std.rs +++ b/embassy-time/src/driver_std.rs | |||
| @@ -6,7 +6,7 @@ use std::{mem, ptr, thread}; | |||
| 6 | 6 | ||
| 7 | use atomic_polyfill::{AtomicU8, Ordering}; | 7 | use atomic_polyfill::{AtomicU8, Ordering}; |
| 8 | 8 | ||
| 9 | use crate::time::driver::{AlarmHandle, Driver}; | 9 | use crate::driver::{AlarmHandle, Driver}; |
| 10 | 10 | ||
| 11 | const ALARM_COUNT: usize = 4; | 11 | const ALARM_COUNT: usize = 4; |
| 12 | 12 | ||
diff --git a/embassy-executor/src/time/driver_wasm.rs b/embassy-time/src/driver_wasm.rs index 5f585a19a..e4497e6a2 100644 --- a/embassy-executor/src/time/driver_wasm.rs +++ b/embassy-time/src/driver_wasm.rs | |||
| @@ -7,7 +7,7 @@ use atomic_polyfill::{AtomicU8, Ordering}; | |||
| 7 | use wasm_bindgen::prelude::*; | 7 | use wasm_bindgen::prelude::*; |
| 8 | use wasm_timer::Instant as StdInstant; | 8 | use wasm_timer::Instant as StdInstant; |
| 9 | 9 | ||
| 10 | use crate::time::driver::{AlarmHandle, Driver}; | 10 | use crate::driver::{AlarmHandle, Driver}; |
| 11 | 11 | ||
| 12 | const ALARM_COUNT: usize = 4; | 12 | const ALARM_COUNT: usize = 4; |
| 13 | 13 | ||
diff --git a/embassy-executor/src/time/duration.rs b/embassy-time/src/duration.rs index dc4f16bd4..dc4f16bd4 100644 --- a/embassy-executor/src/time/duration.rs +++ b/embassy-time/src/duration.rs | |||
diff --git a/embassy-time/src/fmt.rs b/embassy-time/src/fmt.rs new file mode 100644 index 000000000..066970813 --- /dev/null +++ b/embassy-time/src/fmt.rs | |||
| @@ -0,0 +1,225 @@ | |||
| 1 | #![macro_use] | ||
| 2 | #![allow(unused_macros)] | ||
| 3 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | ||
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | ||
| 6 | |||
| 7 | macro_rules! assert { | ||
| 8 | ($($x:tt)*) => { | ||
| 9 | { | ||
| 10 | #[cfg(not(feature = "defmt"))] | ||
| 11 | ::core::assert!($($x)*); | ||
| 12 | #[cfg(feature = "defmt")] | ||
| 13 | ::defmt::assert!($($x)*); | ||
| 14 | } | ||
| 15 | }; | ||
| 16 | } | ||
| 17 | |||
| 18 | macro_rules! assert_eq { | ||
| 19 | ($($x:tt)*) => { | ||
| 20 | { | ||
| 21 | #[cfg(not(feature = "defmt"))] | ||
| 22 | ::core::assert_eq!($($x)*); | ||
| 23 | #[cfg(feature = "defmt")] | ||
| 24 | ::defmt::assert_eq!($($x)*); | ||
| 25 | } | ||
| 26 | }; | ||
| 27 | } | ||
| 28 | |||
| 29 | macro_rules! assert_ne { | ||
| 30 | ($($x:tt)*) => { | ||
| 31 | { | ||
| 32 | #[cfg(not(feature = "defmt"))] | ||
| 33 | ::core::assert_ne!($($x)*); | ||
| 34 | #[cfg(feature = "defmt")] | ||
| 35 | ::defmt::assert_ne!($($x)*); | ||
| 36 | } | ||
| 37 | }; | ||
| 38 | } | ||
| 39 | |||
| 40 | macro_rules! debug_assert { | ||
| 41 | ($($x:tt)*) => { | ||
| 42 | { | ||
| 43 | #[cfg(not(feature = "defmt"))] | ||
| 44 | ::core::debug_assert!($($x)*); | ||
| 45 | #[cfg(feature = "defmt")] | ||
| 46 | ::defmt::debug_assert!($($x)*); | ||
| 47 | } | ||
| 48 | }; | ||
| 49 | } | ||
| 50 | |||
| 51 | macro_rules! debug_assert_eq { | ||
| 52 | ($($x:tt)*) => { | ||
| 53 | { | ||
| 54 | #[cfg(not(feature = "defmt"))] | ||
| 55 | ::core::debug_assert_eq!($($x)*); | ||
| 56 | #[cfg(feature = "defmt")] | ||
| 57 | ::defmt::debug_assert_eq!($($x)*); | ||
| 58 | } | ||
| 59 | }; | ||
| 60 | } | ||
| 61 | |||
| 62 | macro_rules! debug_assert_ne { | ||
| 63 | ($($x:tt)*) => { | ||
| 64 | { | ||
| 65 | #[cfg(not(feature = "defmt"))] | ||
| 66 | ::core::debug_assert_ne!($($x)*); | ||
| 67 | #[cfg(feature = "defmt")] | ||
| 68 | ::defmt::debug_assert_ne!($($x)*); | ||
| 69 | } | ||
| 70 | }; | ||
| 71 | } | ||
| 72 | |||
| 73 | macro_rules! todo { | ||
| 74 | ($($x:tt)*) => { | ||
| 75 | { | ||
| 76 | #[cfg(not(feature = "defmt"))] | ||
| 77 | ::core::todo!($($x)*); | ||
| 78 | #[cfg(feature = "defmt")] | ||
| 79 | ::defmt::todo!($($x)*); | ||
| 80 | } | ||
| 81 | }; | ||
| 82 | } | ||
| 83 | |||
| 84 | macro_rules! unreachable { | ||
| 85 | ($($x:tt)*) => { | ||
| 86 | { | ||
| 87 | #[cfg(not(feature = "defmt"))] | ||
| 88 | ::core::unreachable!($($x)*); | ||
| 89 | #[cfg(feature = "defmt")] | ||
| 90 | ::defmt::unreachable!($($x)*); | ||
| 91 | } | ||
| 92 | }; | ||
| 93 | } | ||
| 94 | |||
| 95 | macro_rules! panic { | ||
| 96 | ($($x:tt)*) => { | ||
| 97 | { | ||
| 98 | #[cfg(not(feature = "defmt"))] | ||
| 99 | ::core::panic!($($x)*); | ||
| 100 | #[cfg(feature = "defmt")] | ||
| 101 | ::defmt::panic!($($x)*); | ||
| 102 | } | ||
| 103 | }; | ||
| 104 | } | ||
| 105 | |||
| 106 | macro_rules! trace { | ||
| 107 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 108 | { | ||
| 109 | #[cfg(feature = "log")] | ||
| 110 | ::log::trace!($s $(, $x)*); | ||
| 111 | #[cfg(feature = "defmt")] | ||
| 112 | ::defmt::trace!($s $(, $x)*); | ||
| 113 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 114 | let _ = ($( & $x ),*); | ||
| 115 | } | ||
| 116 | }; | ||
| 117 | } | ||
| 118 | |||
| 119 | macro_rules! debug { | ||
| 120 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 121 | { | ||
| 122 | #[cfg(feature = "log")] | ||
| 123 | ::log::debug!($s $(, $x)*); | ||
| 124 | #[cfg(feature = "defmt")] | ||
| 125 | ::defmt::debug!($s $(, $x)*); | ||
| 126 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 127 | let _ = ($( & $x ),*); | ||
| 128 | } | ||
| 129 | }; | ||
| 130 | } | ||
| 131 | |||
| 132 | macro_rules! info { | ||
| 133 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 134 | { | ||
| 135 | #[cfg(feature = "log")] | ||
| 136 | ::log::info!($s $(, $x)*); | ||
| 137 | #[cfg(feature = "defmt")] | ||
| 138 | ::defmt::info!($s $(, $x)*); | ||
| 139 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 140 | let _ = ($( & $x ),*); | ||
| 141 | } | ||
| 142 | }; | ||
| 143 | } | ||
| 144 | |||
| 145 | macro_rules! warn { | ||
| 146 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 147 | { | ||
| 148 | #[cfg(feature = "log")] | ||
| 149 | ::log::warn!($s $(, $x)*); | ||
| 150 | #[cfg(feature = "defmt")] | ||
| 151 | ::defmt::warn!($s $(, $x)*); | ||
| 152 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 153 | let _ = ($( & $x ),*); | ||
| 154 | } | ||
| 155 | }; | ||
| 156 | } | ||
| 157 | |||
| 158 | macro_rules! error { | ||
| 159 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 160 | { | ||
| 161 | #[cfg(feature = "log")] | ||
| 162 | ::log::error!($s $(, $x)*); | ||
| 163 | #[cfg(feature = "defmt")] | ||
| 164 | ::defmt::error!($s $(, $x)*); | ||
| 165 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 166 | let _ = ($( & $x ),*); | ||
| 167 | } | ||
| 168 | }; | ||
| 169 | } | ||
| 170 | |||
| 171 | #[cfg(feature = "defmt")] | ||
| 172 | macro_rules! unwrap { | ||
| 173 | ($($x:tt)*) => { | ||
| 174 | ::defmt::unwrap!($($x)*) | ||
| 175 | }; | ||
| 176 | } | ||
| 177 | |||
| 178 | #[cfg(not(feature = "defmt"))] | ||
| 179 | macro_rules! unwrap { | ||
| 180 | ($arg:expr) => { | ||
| 181 | match $crate::fmt::Try::into_result($arg) { | ||
| 182 | ::core::result::Result::Ok(t) => t, | ||
| 183 | ::core::result::Result::Err(e) => { | ||
| 184 | ::core::panic!("unwrap of `{}` failed: {:?}", ::core::stringify!($arg), e); | ||
| 185 | } | ||
| 186 | } | ||
| 187 | }; | ||
| 188 | ($arg:expr, $($msg:expr),+ $(,)? ) => { | ||
| 189 | match $crate::fmt::Try::into_result($arg) { | ||
| 190 | ::core::result::Result::Ok(t) => t, | ||
| 191 | ::core::result::Result::Err(e) => { | ||
| 192 | ::core::panic!("unwrap of `{}` failed: {}: {:?}", ::core::stringify!($arg), ::core::format_args!($($msg,)*), e); | ||
| 193 | } | ||
| 194 | } | ||
| 195 | } | ||
| 196 | } | ||
| 197 | |||
| 198 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
| 199 | pub struct NoneError; | ||
| 200 | |||
| 201 | pub trait Try { | ||
| 202 | type Ok; | ||
| 203 | type Error; | ||
| 204 | fn into_result(self) -> Result<Self::Ok, Self::Error>; | ||
| 205 | } | ||
| 206 | |||
| 207 | impl<T> Try for Option<T> { | ||
| 208 | type Ok = T; | ||
| 209 | type Error = NoneError; | ||
| 210 | |||
| 211 | #[inline] | ||
| 212 | fn into_result(self) -> Result<T, NoneError> { | ||
| 213 | self.ok_or(NoneError) | ||
| 214 | } | ||
| 215 | } | ||
| 216 | |||
| 217 | impl<T, E> Try for Result<T, E> { | ||
| 218 | type Ok = T; | ||
| 219 | type Error = E; | ||
| 220 | |||
| 221 | #[inline] | ||
| 222 | fn into_result(self) -> Self { | ||
| 223 | self | ||
| 224 | } | ||
| 225 | } | ||
diff --git a/embassy-executor/src/time/instant.rs b/embassy-time/src/instant.rs index 6a4925f47..6a4925f47 100644 --- a/embassy-executor/src/time/instant.rs +++ b/embassy-time/src/instant.rs | |||
diff --git a/embassy-executor/src/time/mod.rs b/embassy-time/src/lib.rs index b787a5cf2..a6454d55e 100644 --- a/embassy-executor/src/time/mod.rs +++ b/embassy-time/src/lib.rs | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] | ||
| 2 | #![cfg_attr(feature = "nightly", feature(generic_associated_types, type_alias_impl_trait))] | ||
| 3 | #![allow(clippy::new_without_default)] | ||
| 4 | #![warn(missing_docs)] | ||
| 5 | |||
| 1 | //! Timekeeping, delays and timeouts. | 6 | //! Timekeeping, delays and timeouts. |
| 2 | //! | 7 | //! |
| 3 | //! Timekeeping is done with elapsed time since system boot. Time is represented in | 8 | //! Timekeeping is done with elapsed time since system boot. Time is represented in |
| @@ -26,7 +31,7 @@ | |||
| 26 | //! like `2021-08-24 13:33:21`). | 31 | //! like `2021-08-24 13:33:21`). |
| 27 | //! | 32 | //! |
| 28 | //! If persistence across reboots is not needed, support can be built on top of | 33 | //! If persistence across reboots is not needed, support can be built on top of |
| 29 | //! `embassy_executor::time` by storing the offset between "seconds elapsed since boot" | 34 | //! `embassy_time` by storing the offset between "seconds elapsed since boot" |
| 30 | //! and "seconds since unix epoch". | 35 | //! and "seconds since unix epoch". |
| 31 | //! | 36 | //! |
| 32 | //! # Time driver | 37 | //! # Time driver |
| @@ -35,12 +40,13 @@ | |||
| 35 | //! Only one driver can be active in a program. | 40 | //! Only one driver can be active in a program. |
| 36 | //! | 41 | //! |
| 37 | //! All methods and structs transparently call into the active driver. This makes it | 42 | //! All methods and structs transparently call into the active driver. This makes it |
| 38 | //! possible for libraries to use `embassy_executor::time` in a driver-agnostic way without | 43 | //! possible for libraries to use `embassy_time` in a driver-agnostic way without |
| 39 | //! requiring generic parameters. | 44 | //! requiring generic parameters. |
| 40 | //! | 45 | //! |
| 41 | //! For more details, check the [`driver`] module. | 46 | //! For more details, check the [`driver`] module. |
| 42 | 47 | ||
| 43 | #![deny(missing_docs)] | 48 | // This mod MUST go first, so that the others see its macros. |
| 49 | pub(crate) mod fmt; | ||
| 44 | 50 | ||
| 45 | mod delay; | 51 | mod delay; |
| 46 | pub mod driver; | 52 | pub mod driver; |
| @@ -50,7 +56,6 @@ mod timer; | |||
| 50 | 56 | ||
| 51 | #[cfg(feature = "std")] | 57 | #[cfg(feature = "std")] |
| 52 | mod driver_std; | 58 | mod driver_std; |
| 53 | |||
| 54 | #[cfg(feature = "wasm")] | 59 | #[cfg(feature = "wasm")] |
| 55 | mod driver_wasm; | 60 | mod driver_wasm; |
| 56 | 61 | ||
| @@ -59,24 +64,24 @@ pub use duration::Duration; | |||
| 59 | pub use instant::Instant; | 64 | pub use instant::Instant; |
| 60 | pub use timer::{with_timeout, Ticker, TimeoutError, Timer}; | 65 | pub use timer::{with_timeout, Ticker, TimeoutError, Timer}; |
| 61 | 66 | ||
| 62 | #[cfg(feature = "time-tick-1000hz")] | 67 | #[cfg(feature = "tick-1000hz")] |
| 63 | const TPS: u64 = 1_000; | 68 | const TPS: u64 = 1_000; |
| 64 | 69 | ||
| 65 | #[cfg(feature = "time-tick-32768hz")] | 70 | #[cfg(feature = "tick-32768hz")] |
| 66 | const TPS: u64 = 32_768; | 71 | const TPS: u64 = 32_768; |
| 67 | 72 | ||
| 68 | #[cfg(feature = "time-tick-1mhz")] | 73 | #[cfg(feature = "tick-1mhz")] |
| 69 | const TPS: u64 = 1_000_000; | 74 | const TPS: u64 = 1_000_000; |
| 70 | 75 | ||
| 71 | #[cfg(feature = "time-tick-16mhz")] | 76 | #[cfg(feature = "tick-16mhz")] |
| 72 | const TPS: u64 = 16_000_000; | 77 | const TPS: u64 = 16_000_000; |
| 73 | 78 | ||
| 74 | /// Ticks per second of the global timebase. | 79 | /// Ticks per second of the global timebase. |
| 75 | /// | 80 | /// |
| 76 | /// This value is specified by the `time-tick-*` Cargo features, which | 81 | /// This value is specified by the `tick-*` Cargo features, which |
| 77 | /// should be set by the time driver. Some drivers support a fixed tick rate, others | 82 | /// should be set by the time driver. Some drivers support a fixed tick rate, others |
| 78 | /// allow you to choose a tick rate with Cargo features of their own. You should not | 83 | /// allow you to choose a tick rate with Cargo features of their own. You should not |
| 79 | /// set the `time-tick-*` features for embassy yourself as an end user. | 84 | /// set the `tick-*` features for embassy yourself as an end user. |
| 80 | pub const TICKS_PER_SECOND: u64 = TPS; | 85 | pub const TICKS_PER_SECOND: u64 = TPS; |
| 81 | 86 | ||
| 82 | const fn gcd(a: u64, b: u64) -> u64 { | 87 | const fn gcd(a: u64, b: u64) -> u64 { |
| @@ -89,3 +94,6 @@ const fn gcd(a: u64, b: u64) -> u64 { | |||
| 89 | 94 | ||
| 90 | pub(crate) const GCD_1K: u64 = gcd(TICKS_PER_SECOND, 1_000); | 95 | pub(crate) const GCD_1K: u64 = gcd(TICKS_PER_SECOND, 1_000); |
| 91 | pub(crate) const GCD_1M: u64 = gcd(TICKS_PER_SECOND, 1_000_000); | 96 | pub(crate) const GCD_1M: u64 = gcd(TICKS_PER_SECOND, 1_000_000); |
| 97 | |||
| 98 | #[cfg(feature = "defmt-timestamp-uptime")] | ||
| 99 | defmt::timestamp! {"{=u64:us}", Instant::now().as_micros() } | ||
diff --git a/embassy-executor/src/time/timer.rs b/embassy-time/src/timer.rs index b9cdb1be5..bd791b817 100644 --- a/embassy-executor/src/time/timer.rs +++ b/embassy-time/src/timer.rs | |||
| @@ -1,12 +1,11 @@ | |||
| 1 | use core::future::Future; | 1 | use core::future::Future; |
| 2 | use core::pin::Pin; | 2 | use core::pin::Pin; |
| 3 | use core::task::{Context, Poll}; | 3 | use core::task::{Context, Poll, Waker}; |
| 4 | 4 | ||
| 5 | use futures_util::future::{select, Either}; | 5 | use futures_util::future::{select, Either}; |
| 6 | use futures_util::{pin_mut, Stream}; | 6 | use futures_util::{pin_mut, Stream}; |
| 7 | 7 | ||
| 8 | use crate::executor::raw; | 8 | use crate::{Duration, Instant}; |
| 9 | use crate::time::{Duration, Instant}; | ||
| 10 | 9 | ||
| 11 | /// Error returned by [`with_timeout`] on timeout. | 10 | /// Error returned by [`with_timeout`] on timeout. |
| 12 | #[derive(Debug, Clone, PartialEq, Eq)] | 11 | #[derive(Debug, Clone, PartialEq, Eq)] |
| @@ -49,7 +48,7 @@ impl Timer { | |||
| 49 | /// # #![feature(type_alias_impl_trait)] | 48 | /// # #![feature(type_alias_impl_trait)] |
| 50 | /// # | 49 | /// # |
| 51 | /// # fn foo() {} | 50 | /// # fn foo() {} |
| 52 | /// use embassy_executor::time::{Duration, Timer}; | 51 | /// use embassy_time::{Duration, Timer}; |
| 53 | /// | 52 | /// |
| 54 | /// #[embassy_executor::task] | 53 | /// #[embassy_executor::task] |
| 55 | /// async fn demo_sleep_seconds() { | 54 | /// async fn demo_sleep_seconds() { |
| @@ -73,7 +72,7 @@ impl Future for Timer { | |||
| 73 | if self.yielded_once && self.expires_at <= Instant::now() { | 72 | if self.yielded_once && self.expires_at <= Instant::now() { |
| 74 | Poll::Ready(()) | 73 | Poll::Ready(()) |
| 75 | } else { | 74 | } else { |
| 76 | unsafe { raw::register_timer(self.expires_at, cx.waker()) }; | 75 | schedule_wake(self.expires_at, cx.waker()); |
| 77 | self.yielded_once = true; | 76 | self.yielded_once = true; |
| 78 | Poll::Pending | 77 | Poll::Pending |
| 79 | } | 78 | } |
| @@ -88,7 +87,7 @@ impl Future for Timer { | |||
| 88 | /// ``` no_run | 87 | /// ``` no_run |
| 89 | /// # #![feature(type_alias_impl_trait)] | 88 | /// # #![feature(type_alias_impl_trait)] |
| 90 | /// # | 89 | /// # |
| 91 | /// use embassy_executor::time::{Duration, Timer}; | 90 | /// use embassy_time::{Duration, Timer}; |
| 92 | /// # fn foo() {} | 91 | /// # fn foo() {} |
| 93 | /// | 92 | /// |
| 94 | /// #[embassy_executor::task] | 93 | /// #[embassy_executor::task] |
| @@ -108,7 +107,7 @@ impl Future for Timer { | |||
| 108 | /// ``` no_run | 107 | /// ``` no_run |
| 109 | /// # #![feature(type_alias_impl_trait)] | 108 | /// # #![feature(type_alias_impl_trait)] |
| 110 | /// # | 109 | /// # |
| 111 | /// use embassy_executor::time::{Duration, Ticker}; | 110 | /// use embassy_time::{Duration, Ticker}; |
| 112 | /// use futures::StreamExt; | 111 | /// use futures::StreamExt; |
| 113 | /// # fn foo(){} | 112 | /// # fn foo(){} |
| 114 | /// | 113 | /// |
| @@ -144,8 +143,16 @@ impl Stream for Ticker { | |||
| 144 | self.expires_at += dur; | 143 | self.expires_at += dur; |
| 145 | Poll::Ready(Some(())) | 144 | Poll::Ready(Some(())) |
| 146 | } else { | 145 | } else { |
| 147 | unsafe { raw::register_timer(self.expires_at, cx.waker()) }; | 146 | schedule_wake(self.expires_at, cx.waker()); |
| 148 | Poll::Pending | 147 | Poll::Pending |
| 149 | } | 148 | } |
| 150 | } | 149 | } |
| 151 | } | 150 | } |
| 151 | |||
| 152 | extern "Rust" { | ||
| 153 | fn _embassy_time_schedule_wake(at: Instant, waker: &Waker); | ||
| 154 | } | ||
| 155 | |||
| 156 | fn schedule_wake(at: Instant, waker: &Waker) { | ||
| 157 | unsafe { _embassy_time_schedule_wake(at, waker) } | ||
| 158 | } | ||
diff --git a/embassy-util/Cargo.toml b/embassy-util/Cargo.toml index 00de5e850..d4708d735 100644 --- a/embassy-util/Cargo.toml +++ b/embassy-util/Cargo.toml | |||
| @@ -17,8 +17,8 @@ defmt = { version = "0.3", optional = true } | |||
| 17 | log = { version = "0.4.14", optional = true } | 17 | log = { version = "0.4.14", optional = true } |
| 18 | 18 | ||
| 19 | futures-util = { version = "0.3.17", default-features = false } | 19 | futures-util = { version = "0.3.17", default-features = false } |
| 20 | atomic-polyfill = "0.1.5" | 20 | atomic-polyfill = "1.0.1" |
| 21 | critical-section = "0.2.5" | 21 | critical-section = "1.1" |
| 22 | heapless = "0.7.5" | 22 | heapless = "0.7.5" |
| 23 | cfg-if = "1.0.0" | 23 | cfg-if = "1.0.0" |
| 24 | embedded-io = "0.3.0" | 24 | embedded-io = "0.3.0" |
| @@ -28,3 +28,6 @@ futures-executor = { version = "0.3.17", features = [ "thread-pool" ] } | |||
| 28 | futures-test = "0.3.17" | 28 | futures-test = "0.3.17" |
| 29 | futures-timer = "3.0.2" | 29 | futures-timer = "3.0.2" |
| 30 | futures-util = { version = "0.3.17", features = [ "channel" ] } | 30 | futures-util = { version = "0.3.17", features = [ "channel" ] } |
| 31 | |||
| 32 | # Enable critical-section implementation for std, for tests | ||
| 33 | critical-section = { version = "1.1", features = ["std"] } | ||
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/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 b7014c55a..c63b31cae 100644 --- a/examples/rp/src/bin/uart.rs +++ b/examples/rp/src/bin/uart.rs | |||
| @@ -2,12 +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::{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_with_rtscts(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.blocking_write("Hello World!\r\n".as_bytes()).unwrap(); | 14 | uart.blocking_write("Hello World!\r\n".as_bytes()).unwrap(); |
diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 427b93438..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-time = { version = "0.1.0", path = "../../embassy-time", features = ["log", "std", "nightly"] } | ||
| 9 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "log", "medium-ethernet", "tcp", "udp", "dhcpv4", "pool-16"] } | 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 index 7fe36e233..07e11c385 100644 --- a/examples/std/src/bin/net_udp.rs +++ b/examples/std/src/bin/net_udp.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::udp::UdpSocket; | 5 | use embassy_net::udp::UdpSocket; |
| 6 | use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, PacketMetadata, Stack, StackResources}; | 6 | use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, PacketMetadata, Stack, StackResources}; |
| 7 | use embassy_util::Forever; | 7 | use embassy_util::Forever; |
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 896046759..a416796ea 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/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 = ["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", "unstable-traits"] } | 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"] } |
| @@ -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 | 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" } |
| @@ -23,7 +24,7 @@ panic-probe = { version = "0.3", features = ["print-defmt"] } | |||
| 23 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 24 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 24 | heapless = { version = "0.7.5", default-features = false } | 25 | heapless = { version = "0.7.5", default-features = false } |
| 25 | rand_core = "0.6.3" | 26 | rand_core = "0.6.3" |
| 26 | critical-section = "0.2.5" | 27 | critical-section = "1.1" |
| 27 | micromath = "2.0.0" | 28 | micromath = "2.0.0" |
| 28 | stm32-fmc = "0.2.4" | 29 | stm32-fmc = "0.2.4" |
| 29 | 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 a3bb2d5e2..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,18 +28,8 @@ 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 | |||
| 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 | 32 | ||
| 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 | ||
| @@ -87,8 +83,8 @@ mod ov7725 { | |||
| 87 | use core::marker::PhantomData; | 83 | use core::marker::PhantomData; |
| 88 | 84 | ||
| 89 | use defmt::Format; | 85 | use defmt::Format; |
| 90 | use embassy_executor::time::{Duration, Timer}; | ||
| 91 | use embassy_stm32::rcc::{Mco, McoInstance}; | 86 | use embassy_stm32::rcc::{Mco, McoInstance}; |
| 87 | use embassy_time::{Duration, Timer}; | ||
| 92 | use embedded_hal_async::i2c::I2c; | 88 | use embedded_hal_async::i2c::I2c; |
| 93 | 89 | ||
| 94 | #[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 index a66c6f196..99946f504 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.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::client::{TcpClient, TcpClientState}; | 7 | use embassy_net::tcp::client::{TcpClient, TcpClientState}; |
| 9 | use embassy_net::{Stack, StackResources}; | 8 | use embassy_net::{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 embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; | 18 | use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; |
| @@ -34,16 +34,13 @@ async fn net_task(stack: &'static Stack<Device>) -> ! { | |||
| 34 | stack.run().await | 34 | stack.run().await |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | pub fn config() -> Config { | 37 | #[embassy_executor::main] |
| 38 | async fn main(spawner: Spawner) -> ! { | ||
| 38 | let mut config = Config::default(); | 39 | let mut config = Config::default(); |
| 39 | config.rcc.sys_ck = Some(mhz(400)); | 40 | config.rcc.sys_ck = Some(mhz(400)); |
| 40 | config.rcc.hclk = Some(mhz(200)); | 41 | config.rcc.hclk = Some(mhz(200)); |
| 41 | config.rcc.pll1.q_ck = Some(mhz(100)); | 42 | config.rcc.pll1.q_ck = Some(mhz(100)); |
| 42 | config | 43 | let p = embassy_stm32::init(config); |
| 43 | } | ||
| 44 | |||
| 45 | #[embassy_executor::main(config = "config()")] | ||
| 46 | async fn main(spawner: Spawner, p: Peripherals) -> ! { | ||
| 47 | info!("Hello World!"); | 44 | info!("Hello World!"); |
| 48 | 45 | ||
| 49 | // Generate random seed. | 46 | // Generate random seed. |
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 5bfa560dc..d54c080c7 100644 --- a/examples/stm32l4/src/bin/i2c.rs +++ b/examples/stm32l4/src/bin/i2c.rs | |||
| @@ -3,18 +3,19 @@ | |||
| 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( | 20 | let mut i2c = I2c::new( |
| 20 | p.I2C2, | 21 | p.I2C2, |
diff --git a/examples/stm32l4/src/bin/i2c_blocking_async.rs b/examples/stm32l4/src/bin/i2c_blocking_async.rs index c924bc9c5..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,7 +16,8 @@ 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( | 22 | let i2c = I2c::new( |
| 22 | p.I2C2, | 23 | p.I2C2, |
diff --git a/examples/stm32l4/src/bin/i2c_dma.rs b/examples/stm32l4/src/bin/i2c_dma.rs index 2b338427b..3ce9398a4 100644 --- a/examples/stm32l4/src/bin/i2c_dma.rs +++ b/examples/stm32l4/src/bin/i2c_dma.rs | |||
| @@ -3,17 +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::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( | 19 | let mut i2c = I2c::new( |
| 19 | p.I2C2, | 20 | p.I2C2, |
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() { |
diff --git a/stm32-metapac/Cargo.toml b/stm32-metapac/Cargo.toml index 31d707785..9d5aba0c0 100644 --- a/stm32-metapac/Cargo.toml +++ b/stm32-metapac/Cargo.toml | |||
| @@ -40,7 +40,7 @@ flavors = [ | |||
| 40 | ] | 40 | ] |
| 41 | 41 | ||
| 42 | [dependencies] | 42 | [dependencies] |
| 43 | cortex-m = "0.7.3" | 43 | cortex-m = "0.7.6" |
| 44 | cortex-m-rt = { version = ">=0.6.15,<0.8", optional = true } | 44 | cortex-m-rt = { version = ">=0.6.15,<0.8", optional = true } |
| 45 | 45 | ||
| 46 | # BEGIN BUILD DEPENDENCIES | 46 | # BEGIN BUILD DEPENDENCIES |
diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index d19243b9d..8740cc488 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/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"] } | 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"] } | ||
| 9 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightly", "defmt", "unstable-pac", "unstable-traits"] } | 10 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightly", "defmt", "unstable-pac", "unstable-traits"] } |
| 10 | 11 | ||
| 11 | defmt = "0.3.0" | 12 | defmt = "0.3.0" |
| 12 | defmt-rtt = "0.3.0" | 13 | defmt-rtt = "0.3.0" |
| 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 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } | 18 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } |
diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs index 6f6baf77a..af22fe27d 100644 --- a/tests/rp/src/bin/gpio.rs +++ b/tests/rp/src/bin/gpio.rs | |||
| @@ -3,13 +3,13 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{assert, *}; | 5 | use defmt::{assert, *}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_rp::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull}; | 7 | use embassy_rp::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull}; |
| 8 | use embassy_rp::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_rp::init(Default::default()); | ||
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let (mut a, mut b) = (p.PIN_0, p.PIN_1); | 15 | let (mut a, mut b) = (p.PIN_0, p.PIN_1); |
diff --git a/tests/rp/src/bin/gpio_async.rs b/tests/rp/src/bin/gpio_async.rs index 1098682af..1eeaac1f6 100644 --- a/tests/rp/src/bin/gpio_async.rs +++ b/tests/rp/src/bin/gpio_async.rs | |||
| @@ -3,15 +3,15 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{assert, *}; | 5 | use defmt::{assert, *}; |
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Instant, Timer}; | ||
| 8 | use embassy_rp::gpio::{Input, Level, Output, Pull}; | 7 | use embassy_rp::gpio::{Input, Level, Output, Pull}; |
| 9 | use embassy_rp::Peripherals; | 8 | use embassy_time::{Duration, Instant, Timer}; |
| 10 | use futures::future::join; | 9 | use futures::future::join; |
| 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_rp::init(Default::default()); | ||
| 15 | info!("embassy-rp gpio_async test"); | 15 | info!("embassy-rp gpio_async test"); |
| 16 | 16 | ||
| 17 | // On the CI device the following pins are connected with each other. | 17 | // On the CI device the following pins are connected with each other. |
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index c1cca99d1..1d12995a2 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml | |||
| @@ -14,13 +14,14 @@ stm32u585ai = ["embassy-stm32/stm32u585ai"] # IoT board | |||
| 14 | 14 | ||
| 15 | [dependencies] | 15 | [dependencies] |
| 16 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 16 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } |
| 17 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "time-tick-32768hz"] } | 17 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 18 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "tick-32768hz"] } | ||
| 18 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "memory-x", "time-driver-tim2"] } | 19 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "memory-x", "time-driver-tim2"] } |
| 19 | 20 | ||
| 20 | defmt = "0.3.0" | 21 | defmt = "0.3.0" |
| 21 | defmt-rtt = "0.3.0" | 22 | defmt-rtt = "0.3.0" |
| 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 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } | 27 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } |
diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index 8eab731bf..18fd85d44 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs | |||
| @@ -5,13 +5,13 @@ | |||
| 5 | #[path = "../example_common.rs"] | 5 | #[path = "../example_common.rs"] |
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use defmt::assert; | 7 | use defmt::assert; |
| 8 | use embassy_executor::executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull, Speed}; | 9 | use embassy_stm32::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull, Speed}; |
| 10 | use embassy_stm32::Peripherals; | ||
| 11 | use example_common::*; | 10 | use example_common::*; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main(config = "config()")] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(config()); | ||
| 15 | info!("Hello World!"); | 15 | info!("Hello World!"); |
| 16 | 16 | ||
| 17 | // Arduino pins D0 and D1 | 17 | // Arduino pins D0 and D1 |
diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index 6d38b0bbf..1c5dc87c0 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs | |||
| @@ -5,15 +5,15 @@ | |||
| 5 | #[path = "../example_common.rs"] | 5 | #[path = "../example_common.rs"] |
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use defmt::assert_eq; | 7 | use defmt::assert_eq; |
| 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::spi::{self, Spi}; | 10 | use embassy_stm32::spi::{self, Spi}; |
| 11 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| 12 | use embassy_stm32::Peripherals; | ||
| 13 | use example_common::*; | 12 | use example_common::*; |
| 14 | 13 | ||
| 15 | #[embassy_executor::main(config = "config()")] | 14 | #[embassy_executor::main] |
| 16 | async fn main(_spawner: Spawner, p: Peripherals) { | 15 | async fn main(_spawner: Spawner) { |
| 16 | let p = embassy_stm32::init(config()); | ||
| 17 | info!("Hello World!"); | 17 | info!("Hello World!"); |
| 18 | 18 | ||
| 19 | #[cfg(feature = "stm32f103c8")] | 19 | #[cfg(feature = "stm32f103c8")] |
diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index 8147c5f08..cb2152e0b 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs | |||
| @@ -5,14 +5,14 @@ | |||
| 5 | #[path = "../example_common.rs"] | 5 | #[path = "../example_common.rs"] |
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use defmt::assert_eq; | 7 | use defmt::assert_eq; |
| 8 | use embassy_executor::executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::spi::{self, Spi}; | 9 | use embassy_stm32::spi::{self, Spi}; |
| 10 | use embassy_stm32::time::Hertz; | 10 | use embassy_stm32::time::Hertz; |
| 11 | use embassy_stm32::Peripherals; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy_executor::main(config = "config()")] | 13 | #[embassy_executor::main] |
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 14 | async fn main(_spawner: Spawner) { |
| 15 | let p = embassy_stm32::init(config()); | ||
| 16 | info!("Hello World!"); | 16 | info!("Hello World!"); |
| 17 | 17 | ||
| 18 | #[cfg(feature = "stm32f103c8")] | 18 | #[cfg(feature = "stm32f103c8")] |
diff --git a/tests/stm32/src/bin/timer.rs b/tests/stm32/src/bin/timer.rs index 76b07ca15..e00e43bf1 100644 --- a/tests/stm32/src/bin/timer.rs +++ b/tests/stm32/src/bin/timer.rs | |||
| @@ -5,13 +5,13 @@ | |||
| 5 | #[path = "../example_common.rs"] | 5 | #[path = "../example_common.rs"] |
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use defmt::assert; | 7 | use defmt::assert; |
| 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_stm32::Peripherals; | ||
| 11 | use example_common::*; | 10 | use example_common::*; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main(config = "config()")] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, _p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let _p = embassy_stm32::init(config()); | ||
| 15 | info!("Hello World!"); | 15 | info!("Hello World!"); |
| 16 | 16 | ||
| 17 | let start = Instant::now(); | 17 | let start = Instant::now(); |
diff --git a/tests/stm32/src/bin/usart.rs b/tests/stm32/src/bin/usart.rs index 7b60e4b28..fb4b3fcca 100644 --- a/tests/stm32/src/bin/usart.rs +++ b/tests/stm32/src/bin/usart.rs | |||
| @@ -5,14 +5,14 @@ | |||
| 5 | #[path = "../example_common.rs"] | 5 | #[path = "../example_common.rs"] |
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use defmt::assert_eq; | 7 | use defmt::assert_eq; |
| 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 example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy_executor::main(config = "config()")] | 13 | #[embassy_executor::main] |
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 14 | async fn main(_spawner: Spawner) { |
| 15 | let p = embassy_stm32::init(config()); | ||
| 16 | info!("Hello World!"); | 16 | info!("Hello World!"); |
| 17 | 17 | ||
| 18 | #[cfg(feature = "stm32wb55rg")] | 18 | #[cfg(feature = "stm32wb55rg")] |
diff --git a/tests/stm32/src/bin/usart_dma.rs b/tests/stm32/src/bin/usart_dma.rs index 323c41cae..09382a022 100644 --- a/tests/stm32/src/bin/usart_dma.rs +++ b/tests/stm32/src/bin/usart_dma.rs | |||
| @@ -5,13 +5,13 @@ | |||
| 5 | #[path = "../example_common.rs"] | 5 | #[path = "../example_common.rs"] |
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use defmt::assert_eq; | 7 | use defmt::assert_eq; |
| 8 | use embassy_executor::executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::usart::{Config, Uart}; | 9 | use embassy_stm32::usart::{Config, Uart}; |
| 10 | use embassy_stm32::Peripherals; | ||
| 11 | use example_common::*; | 10 | use example_common::*; |
| 12 | 11 | ||
| 13 | #[embassy_executor::main(config = "config()")] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(config()); | ||
| 15 | info!("Hello World!"); | 15 | info!("Hello World!"); |
| 16 | 16 | ||
| 17 | #[cfg(feature = "stm32wb55rg")] | 17 | #[cfg(feature = "stm32wb55rg")] |
