Merge branch 'master' of https://github.com/embassy-rs/embassy into embassy-rp/dma
This commit is contained in:
commit
a7d6bc7ba5
10
README.md
10
README.md
@ -16,7 +16,7 @@ Rust's <a href="https://rust-lang.github.io/async-book/">async/await</a> allows
|
|||||||
- <a href="https://docs.embassy.dev/embassy-nrf/">embassy-nrf</a>, for the Nordic Semiconductor nRF52, nRF53, nRF91 series.
|
- <a href="https://docs.embassy.dev/embassy-nrf/">embassy-nrf</a>, for the Nordic Semiconductor nRF52, nRF53, nRF91 series.
|
||||||
|
|
||||||
- **Time that Just Works** -
|
- **Time that Just Works** -
|
||||||
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.
|
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.
|
||||||
|
|
||||||
- **Real-time ready** -
|
- **Real-time ready** -
|
||||||
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>.
|
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
|
|||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
use defmt::info;
|
use defmt::info;
|
||||||
use embassy_executor::executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_executor::time::{Duration, Timer};
|
use embassy_time::{Duration, Timer};
|
||||||
use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull};
|
use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull};
|
||||||
use embassy_nrf::Peripherals;
|
use embassy_nrf::Peripherals;
|
||||||
|
|
||||||
@ -65,7 +65,9 @@ async fn blink(pin: AnyPin) {
|
|||||||
|
|
||||||
// Main is itself an async task as well.
|
// Main is itself an async task as well.
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(spawner: Spawner, p: Peripherals) {
|
async fn main(spawner: Spawner) {
|
||||||
|
let p = embassy_nrf::init(Default::default());
|
||||||
|
|
||||||
// Spawned tasks run in the background, concurrently.
|
// Spawned tasks run in the background, concurrently.
|
||||||
spawner.spawn(blink(p.P0_13.degrade())).unwrap();
|
spawner.spawn(blink(p.P0_13.degrade())).unwrap();
|
||||||
|
|
||||||
|
38
ci.sh
38
ci.sh
@ -54,25 +54,25 @@ cargo batch \
|
|||||||
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits,log \
|
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits,log \
|
||||||
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits \
|
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits \
|
||||||
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly \
|
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \
|
--- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \
|
||||||
--- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \
|
--- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \
|
||||||
--- build --release --manifest-path docs/modules/ROOT/examples/basic/Cargo.toml --target thumbv7em-none-eabi \
|
--- build --release --manifest-path docs/modules/ROOT/examples/basic/Cargo.toml --target thumbv7em-none-eabi \
|
||||||
|
66
ci_stable.sh
66
ci_stable.sh
@ -30,38 +30,38 @@ cargo batch \
|
|||||||
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,defmt \
|
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,defmt \
|
||||||
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,log \
|
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,log \
|
||||||
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi \
|
--- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy-executor/time-tick-32768hz \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy-time?/tick-32768hz \
|
||||||
--- 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 \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy-executor/time-tick-32768hz \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy-time?/tick-32768hz \
|
||||||
--- 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 \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,embassy-executor/time-tick-32768hz \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,embassy-time?/tick-32768hz \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy-executor/time-tick-32768hz \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy-time?/tick-32768hz \
|
||||||
--- 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 \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy-executor/time-tick-32768hz \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy-time?/tick-32768hz \
|
||||||
--- 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 \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,embassy-executor/time-tick-32768hz \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,embassy-time?/tick-32768hz \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embassy-executor/time-tick-32768hz \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embassy-time?/tick-32768hz \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- 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 \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \
|
||||||
--- 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 \
|
--- 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 \
|
||||||
--- build --release --manifest-path examples/nrf/Cargo.toml --target thumbv7em-none-eabi --no-default-features --out-dir out/examples/nrf --bin raw_spawn \
|
--- build --release --manifest-path examples/nrf/Cargo.toml --target thumbv7em-none-eabi --no-default-features --out-dir out/examples/nrf --bin raw_spawn \
|
||||||
--- build --release --manifest-path examples/stm32l0/Cargo.toml --target thumbv6m-none-eabi --no-default-features --out-dir out/examples/stm32l0 --bin raw_spawn \
|
--- build --release --manifest-path examples/stm32l0/Cargo.toml --target thumbv6m-none-eabi --no-default-features --out-dir out/examples/stm32l0 --bin raw_spawn \
|
||||||
|
@ -6,6 +6,7 @@ version = "0.1.0"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embassy-executor = { version = "0.1.0", path = "../../../../../embassy-executor", features = ["defmt", "nightly"] }
|
embassy-executor = { version = "0.1.0", path = "../../../../../embassy-executor", features = ["defmt", "nightly"] }
|
||||||
|
embassy-time = { version = "0.1.0", path = "../../../../../embassy-time", features = ["defmt", "nightly"] }
|
||||||
embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "nightly"] }
|
embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "nightly"] }
|
||||||
|
|
||||||
defmt = "0.3"
|
defmt = "0.3"
|
||||||
|
@ -3,11 +3,10 @@
|
|||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_executor::time::{Duration, Timer};
|
|
||||||
use embassy_nrf::gpio::{Level, Output, OutputDrive};
|
use embassy_nrf::gpio::{Level, Output, OutputDrive};
|
||||||
use embassy_nrf::peripherals::P0_13;
|
use embassy_nrf::peripherals::P0_13;
|
||||||
use embassy_nrf::Peripherals;
|
use embassy_time::{Duration, Timer};
|
||||||
use {defmt_rtt as _, panic_probe as _}; // global logger
|
use {defmt_rtt as _, panic_probe as _}; // global logger
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
@ -21,7 +20,9 @@ async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(spawner: Spawner, p: Peripherals) {
|
async fn main(spawner: Spawner) {
|
||||||
|
let p = embassy_nrf::init(Default::default());
|
||||||
|
|
||||||
let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
|
let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
|
||||||
unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300))));
|
unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300))));
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
#![no_main]
|
#![no_main]
|
||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
use embassy_executor::executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_s: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh);
|
let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh);
|
||||||
let mut button = ExtiInput::new(Input::new(p.PC13, Pull::Up), p.EXTI13);
|
let mut button = ExtiInput::new(Input::new(p.PC13, Pull::Up), p.EXTI13);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ defmt = { version = "0.3", optional = true }
|
|||||||
embassy-util = { path = "../../embassy-util" }
|
embassy-util = { path = "../../embassy-util" }
|
||||||
embassy-nrf = { path = "../../embassy-nrf", default-features = false, features = ["nightly"] }
|
embassy-nrf = { path = "../../embassy-nrf", default-features = false, features = ["nightly"] }
|
||||||
embassy-boot = { path = "../boot", default-features = false }
|
embassy-boot = { path = "../boot", default-features = false }
|
||||||
cortex-m = { version = "0.7" }
|
cortex-m = { version = "0.7.6" }
|
||||||
cortex-m-rt = { version = "0.7" }
|
cortex-m-rt = { version = "0.7" }
|
||||||
embedded-storage = "0.3.0"
|
embedded-storage = "0.3.0"
|
||||||
embedded-storage-async = "0.3.0"
|
embedded-storage-async = "0.3.0"
|
||||||
|
@ -20,7 +20,7 @@ log = { version = "0.4", optional = true }
|
|||||||
embassy-util = { path = "../../embassy-util" }
|
embassy-util = { path = "../../embassy-util" }
|
||||||
embassy-stm32 = { path = "../../embassy-stm32", default-features = false, features = ["nightly"] }
|
embassy-stm32 = { path = "../../embassy-stm32", default-features = false, features = ["nightly"] }
|
||||||
embassy-boot = { path = "../boot", default-features = false }
|
embassy-boot = { path = "../boot", default-features = false }
|
||||||
cortex-m = { version = "0.7" }
|
cortex-m = { version = "0.7.6" }
|
||||||
cortex-m-rt = { version = "0.7" }
|
cortex-m-rt = { version = "0.7" }
|
||||||
embedded-storage = "0.3.0"
|
embedded-storage = "0.3.0"
|
||||||
embedded-storage-async = "0.3.0"
|
embedded-storage-async = "0.3.0"
|
||||||
|
@ -39,8 +39,8 @@ embassy-util = { version = "0.1.0", path = "../embassy-util" }
|
|||||||
embassy-executor = { version = "0.1.0", path = "../embassy-executor"}
|
embassy-executor = { version = "0.1.0", path = "../embassy-executor"}
|
||||||
embassy-macros = { version = "0.1.0", path = "../embassy-macros"}
|
embassy-macros = { version = "0.1.0", path = "../embassy-macros"}
|
||||||
embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common"}
|
embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common"}
|
||||||
atomic-polyfill = "0.1.5"
|
atomic-polyfill = "1.0.1"
|
||||||
critical-section = "0.2.5"
|
critical-section = "1.1"
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
cortex-m = "0.7.3"
|
cortex-m = "0.7.6"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! Executor specific to cortex-m devices.
|
//! Executor specific to cortex-m devices.
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
pub use embassy_executor::executor::*;
|
pub use embassy_executor::*;
|
||||||
|
|
||||||
use crate::interrupt::{Interrupt, InterruptExt};
|
use crate::interrupt::{Interrupt, InterruptExt};
|
||||||
|
|
||||||
@ -60,11 +60,11 @@ impl<I: Interrupt> InterruptExecutor<I> {
|
|||||||
/// The executor keeps running in the background through the interrupt.
|
/// The executor keeps running in the background through the interrupt.
|
||||||
///
|
///
|
||||||
/// This returns a [`SendSpawner`] you can use to spawn tasks on it. A [`SendSpawner`]
|
/// This returns a [`SendSpawner`] you can use to spawn tasks on it. A [`SendSpawner`]
|
||||||
/// is returned instead of a [`Spawner`](embassy_executor::executor::Spawner) because the executor effectively runs in a
|
/// is returned instead of a [`Spawner`](embassy_executor::Spawner) because the executor effectively runs in a
|
||||||
/// different "thread" (the interrupt), so spawning tasks on it is effectively
|
/// different "thread" (the interrupt), so spawning tasks on it is effectively
|
||||||
/// sending them.
|
/// sending them.
|
||||||
///
|
///
|
||||||
/// To obtain a [`Spawner`](embassy_executor::executor::Spawner) for this executor, use [`Spawner::for_current_executor()`](embassy_executor::executor::Spawner::for_current_executor()) from
|
/// To obtain a [`Spawner`](embassy_executor::Spawner) for this executor, use [`Spawner::for_current_executor()`](embassy_executor::Spawner::for_current_executor()) from
|
||||||
/// a task running in it.
|
/// a task running in it.
|
||||||
///
|
///
|
||||||
/// This function requires `&'static mut self`. This means you have to store the
|
/// This function requires `&'static mut self`. This means you have to store the
|
||||||
|
@ -6,10 +6,11 @@ use cortex_m::peripheral::NVIC;
|
|||||||
use embassy_hal_common::Peripheral;
|
use embassy_hal_common::Peripheral;
|
||||||
pub use embassy_macros::cortex_m_interrupt_take as take;
|
pub use embassy_macros::cortex_m_interrupt_take as take;
|
||||||
|
|
||||||
/// Do not use. Used for macros only. Not covered by semver guarantees.
|
/// Do not use. Used for macros and HALs only. Not covered by semver guarantees.
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub mod _export {
|
pub mod _export {
|
||||||
pub use atomic_polyfill as atomic;
|
pub use atomic_polyfill as atomic;
|
||||||
|
pub use embassy_macros::{cortex_m_interrupt as interrupt, cortex_m_interrupt_declare as declare};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implementation detail, do not use outside embassy crates.
|
/// Implementation detail, do not use outside embassy crates.
|
||||||
|
@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
[package.metadata.embassy_docs]
|
[package.metadata.embassy_docs]
|
||||||
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-executor-v$VERSION/embassy-executor/src/"
|
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-executor-v$VERSION/embassy-executor/src/"
|
||||||
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-executor/src/"
|
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-executor/src/"
|
||||||
features = ["nightly", "defmt", "unstable-traits", "time", "time-tick-1mhz"]
|
features = ["nightly", "defmt", "unstable-traits"]
|
||||||
flavors = [
|
flavors = [
|
||||||
{ name = "std", target = "x86_64-unknown-linux-gnu", features = ["std"] },
|
{ name = "std", target = "x86_64-unknown-linux-gnu", features = ["std"] },
|
||||||
{ name = "wasm", target = "wasm32-unknown-unknown", features = ["wasm"] },
|
{ name = "wasm", target = "wasm32-unknown-unknown", features = ["wasm"] },
|
||||||
@ -22,49 +22,25 @@ flavors = [
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
std = ["time", "time-tick-1mhz", "embassy-macros/std"]
|
std = ["embassy-macros/std"]
|
||||||
wasm = ["wasm-bindgen", "js-sys", "embassy-macros/wasm", "wasm-timer", "time", "time-tick-1mhz"]
|
wasm = ["dep:wasm-bindgen", "dep:js-sys", "embassy-macros/wasm"]
|
||||||
|
|
||||||
# Enable nightly-only features
|
# Enable nightly-only features
|
||||||
nightly = ["embedded-hal-async"]
|
nightly = []
|
||||||
|
|
||||||
# Implement embedded-hal 1.0 alpha and embedded-hal-async traits.
|
integrated-timers = ["dep:embassy-time"]
|
||||||
# Implement embedded-hal-async traits if `nightly` is set as well.
|
|
||||||
unstable-traits = ["embedded-hal-1"]
|
|
||||||
|
|
||||||
# Display a timestamp of the number of seconds since startup next to defmt log messages
|
|
||||||
# To use this you must have a time driver provided.
|
|
||||||
defmt-timestamp-uptime = ["defmt"]
|
|
||||||
|
|
||||||
# Enable `embassy_executor::time` module.
|
|
||||||
# NOTE: This feature is only intended to be enabled by crates providing the time driver implementation.
|
|
||||||
# Enabling it directly without supplying a time driver will fail to link.
|
|
||||||
time = []
|
|
||||||
|
|
||||||
# Set the `embassy_executor::time` tick rate.
|
|
||||||
# NOTE: This feature is only intended to be enabled by crates providing the time driver implementation.
|
|
||||||
# If you're not writing your own driver, check the driver documentation to customize the tick rate.
|
|
||||||
# If you're writing a driver and your tick rate is not listed here, please add it and send a PR!
|
|
||||||
time-tick-32768hz = ["time"]
|
|
||||||
time-tick-1000hz = ["time"]
|
|
||||||
time-tick-1mhz = ["time"]
|
|
||||||
time-tick-16mhz = ["time"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
defmt = { version = "0.3", optional = true }
|
defmt = { version = "0.3", optional = true }
|
||||||
log = { version = "0.4.14", optional = true }
|
log = { version = "0.4.14", optional = true }
|
||||||
|
|
||||||
embedded-hal-02 = { package = "embedded-hal", version = "0.2.6" }
|
|
||||||
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true}
|
|
||||||
embedded-hal-async = { version = "0.1.0-alpha.1", optional = true}
|
|
||||||
|
|
||||||
futures-util = { version = "0.3.17", default-features = false }
|
futures-util = { version = "0.3.17", default-features = false }
|
||||||
embassy-macros = { version = "0.1.0", path = "../embassy-macros"}
|
embassy-macros = { version = "0.1.0", path = "../embassy-macros"}
|
||||||
atomic-polyfill = "0.1.5"
|
embassy-time = { version = "0.1.0", path = "../embassy-time", optional = true}
|
||||||
critical-section = "0.2.5"
|
atomic-polyfill = "1.0.1"
|
||||||
|
critical-section = "1.1"
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
|
|
||||||
# WASM dependencies
|
# WASM dependencies
|
||||||
wasm-bindgen = { version = "0.2.76", features = ["nightly"], optional = true }
|
wasm-bindgen = { version = "0.2.76", features = ["nightly"], optional = true }
|
||||||
js-sys = { version = "0.3", optional = true }
|
js-sys = { version = "0.3", optional = true }
|
||||||
wasm-timer = { version = "0.2.5", optional = true }
|
|
11
embassy-executor/README.md
Normal file
11
embassy-executor/README.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# embassy-executor
|
||||||
|
|
||||||
|
An async/await executor designed for embedded usage.
|
||||||
|
|
||||||
|
- No `alloc`, no heap needed. Task futures are statically allocated.
|
||||||
|
- No "fixed capacity" data structures, executor works with 1 or 1000 tasks without needing config/tuning.
|
||||||
|
- Integrated timer queue: sleeping is easy, just do `Timer::after(Duration::from_secs(1)).await;`.
|
||||||
|
- No busy-loop polling: CPU sleeps when there's no work to do, using interrupts or `WFE/SEV`.
|
||||||
|
- Efficient polling: a wake will only poll the woken task, not all of them.
|
||||||
|
- 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.
|
||||||
|
- Creating multiple executor instances is supported, to run tasks with multiple priority levels. This allows higher-priority tasks to preempt lower-priority tasks.
|
@ -1,44 +0,0 @@
|
|||||||
//! Async task executor.
|
|
||||||
//!
|
|
||||||
//! This module provides an async/await executor designed for embedded usage.
|
|
||||||
//!
|
|
||||||
//! - No `alloc`, no heap needed. Task futures are statically allocated.
|
|
||||||
//! - No "fixed capacity" data structures, executor works with 1 or 1000 tasks without needing config/tuning.
|
|
||||||
//! - Integrated timer queue: sleeping is easy, just do `Timer::after(Duration::from_secs(1)).await;`.
|
|
||||||
//! - No busy-loop polling: CPU sleeps when there's no work to do, using interrupts or `WFE/SEV`.
|
|
||||||
//! - Efficient polling: a wake will only poll the woken task, not all of them.
|
|
||||||
//! - 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.
|
|
||||||
//! - Creating multiple executor instances is supported, to run tasks with multiple priority levels. This allows higher-priority tasks to preempt lower-priority tasks.
|
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
|
||||||
if #[cfg(cortex_m)] {
|
|
||||||
#[path="arch/cortex_m.rs"]
|
|
||||||
mod arch;
|
|
||||||
pub use arch::*;
|
|
||||||
}
|
|
||||||
else if #[cfg(target_arch="riscv32")] {
|
|
||||||
#[path="arch/riscv32.rs"]
|
|
||||||
mod arch;
|
|
||||||
pub use arch::*;
|
|
||||||
}
|
|
||||||
else if #[cfg(all(target_arch="xtensa", feature = "nightly"))] {
|
|
||||||
#[path="arch/xtensa.rs"]
|
|
||||||
mod arch;
|
|
||||||
pub use arch::*;
|
|
||||||
}
|
|
||||||
else if #[cfg(feature="wasm")] {
|
|
||||||
#[path="arch/wasm.rs"]
|
|
||||||
mod arch;
|
|
||||||
pub use arch::*;
|
|
||||||
}
|
|
||||||
else if #[cfg(feature="std")] {
|
|
||||||
#[path="arch/std.rs"]
|
|
||||||
mod arch;
|
|
||||||
pub use arch::*;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub mod raw;
|
|
||||||
|
|
||||||
mod spawner;
|
|
||||||
pub use spawner::*;
|
|
@ -195,9 +195,6 @@ macro_rules! unwrap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "defmt-timestamp-uptime")]
|
|
||||||
defmt::timestamp! {"{=u64:us}", crate::time::Instant::now().as_micros() }
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||||
pub struct NoneError;
|
pub struct NoneError;
|
||||||
|
|
||||||
|
@ -1,22 +1,44 @@
|
|||||||
#![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)]
|
#![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)]
|
||||||
#![cfg_attr(feature = "nightly", feature(generic_associated_types, type_alias_impl_trait))]
|
|
||||||
#![cfg_attr(all(feature = "nightly", target_arch = "xtensa"), feature(asm_experimental_arch))]
|
#![cfg_attr(all(feature = "nightly", target_arch = "xtensa"), feature(asm_experimental_arch))]
|
||||||
#![allow(clippy::new_without_default)]
|
#![allow(clippy::new_without_default)]
|
||||||
#![doc = include_str!("../../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
// This mod MUST go first, so that the others see its macros.
|
// This mod MUST go first, so that the others see its macros.
|
||||||
pub(crate) mod fmt;
|
pub(crate) mod fmt;
|
||||||
|
|
||||||
pub mod executor;
|
|
||||||
#[cfg(feature = "time")]
|
|
||||||
pub mod time;
|
|
||||||
|
|
||||||
#[cfg(feature = "nightly")]
|
#[cfg(feature = "nightly")]
|
||||||
pub use embassy_macros::{main, task};
|
pub use embassy_macros::{main, task};
|
||||||
|
|
||||||
#[doc(hidden)]
|
cfg_if::cfg_if! {
|
||||||
/// Implementation details for embassy macros. DO NOT USE.
|
if #[cfg(cortex_m)] {
|
||||||
pub mod export {
|
#[path="arch/cortex_m.rs"]
|
||||||
pub use atomic_polyfill as atomic;
|
mod arch;
|
||||||
|
pub use arch::*;
|
||||||
|
}
|
||||||
|
else if #[cfg(target_arch="riscv32")] {
|
||||||
|
#[path="arch/riscv32.rs"]
|
||||||
|
mod arch;
|
||||||
|
pub use arch::*;
|
||||||
|
}
|
||||||
|
else if #[cfg(all(target_arch="xtensa", feature = "nightly"))] {
|
||||||
|
#[path="arch/xtensa.rs"]
|
||||||
|
mod arch;
|
||||||
|
pub use arch::*;
|
||||||
|
}
|
||||||
|
else if #[cfg(feature="wasm")] {
|
||||||
|
#[path="arch/wasm.rs"]
|
||||||
|
mod arch;
|
||||||
|
pub use arch::*;
|
||||||
|
}
|
||||||
|
else if #[cfg(feature="std")] {
|
||||||
|
#[path="arch/std.rs"]
|
||||||
|
mod arch;
|
||||||
|
pub use arch::*;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod raw;
|
||||||
|
|
||||||
|
mod spawner;
|
||||||
|
pub use spawner::*;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
//! executor wrappers in [`executor`](crate::executor) and the [`embassy_executor::task`](embassy_macros::task) macro, which are fully safe.
|
//! executor wrappers in [`executor`](crate::executor) and the [`embassy_executor::task`](embassy_macros::task) macro, which are fully safe.
|
||||||
|
|
||||||
mod run_queue;
|
mod run_queue;
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
mod timer_queue;
|
mod timer_queue;
|
||||||
pub(crate) mod util;
|
pub(crate) mod util;
|
||||||
mod waker;
|
mod waker;
|
||||||
@ -22,22 +22,22 @@ use core::{mem, ptr};
|
|||||||
|
|
||||||
use atomic_polyfill::{AtomicU32, Ordering};
|
use atomic_polyfill::{AtomicU32, Ordering};
|
||||||
use critical_section::CriticalSection;
|
use critical_section::CriticalSection;
|
||||||
|
#[cfg(feature = "integrated-timers")]
|
||||||
|
use embassy_time::driver::{self, AlarmHandle};
|
||||||
|
#[cfg(feature = "integrated-timers")]
|
||||||
|
use embassy_time::Instant;
|
||||||
|
|
||||||
use self::run_queue::{RunQueue, RunQueueItem};
|
use self::run_queue::{RunQueue, RunQueueItem};
|
||||||
use self::util::UninitCell;
|
use self::util::UninitCell;
|
||||||
pub use self::waker::task_from_waker;
|
pub use self::waker::task_from_waker;
|
||||||
use super::SpawnToken;
|
use super::SpawnToken;
|
||||||
#[cfg(feature = "time")]
|
|
||||||
use crate::time::driver::{self, AlarmHandle};
|
|
||||||
#[cfg(feature = "time")]
|
|
||||||
use crate::time::Instant;
|
|
||||||
|
|
||||||
/// Task is spawned (has a future)
|
/// Task is spawned (has a future)
|
||||||
pub(crate) const STATE_SPAWNED: u32 = 1 << 0;
|
pub(crate) const STATE_SPAWNED: u32 = 1 << 0;
|
||||||
/// Task is in the executor run queue
|
/// Task is in the executor run queue
|
||||||
pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1;
|
pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1;
|
||||||
/// Task is in the executor timer queue
|
/// Task is in the executor timer queue
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 2;
|
pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 2;
|
||||||
|
|
||||||
/// Raw task header for use in task pointers.
|
/// Raw task header for use in task pointers.
|
||||||
@ -50,9 +50,9 @@ pub struct TaskHeader {
|
|||||||
pub(crate) executor: Cell<*const Executor>, // Valid if state != 0
|
pub(crate) executor: Cell<*const Executor>, // Valid if state != 0
|
||||||
pub(crate) poll_fn: UninitCell<unsafe fn(NonNull<TaskHeader>)>, // Valid if STATE_SPAWNED
|
pub(crate) poll_fn: UninitCell<unsafe fn(NonNull<TaskHeader>)>, // Valid if STATE_SPAWNED
|
||||||
|
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
pub(crate) expires_at: Cell<Instant>,
|
pub(crate) expires_at: Cell<Instant>,
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
pub(crate) timer_queue_item: timer_queue::TimerQueueItem,
|
pub(crate) timer_queue_item: timer_queue::TimerQueueItem,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,9 +64,9 @@ impl TaskHeader {
|
|||||||
executor: Cell::new(ptr::null()),
|
executor: Cell::new(ptr::null()),
|
||||||
poll_fn: UninitCell::uninit(),
|
poll_fn: UninitCell::uninit(),
|
||||||
|
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
expires_at: Cell::new(Instant::from_ticks(0)),
|
expires_at: Cell::new(Instant::from_ticks(0)),
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
timer_queue_item: timer_queue::TimerQueueItem::new(),
|
timer_queue_item: timer_queue::TimerQueueItem::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,9 +267,9 @@ pub struct Executor {
|
|||||||
signal_fn: fn(*mut ()),
|
signal_fn: fn(*mut ()),
|
||||||
signal_ctx: *mut (),
|
signal_ctx: *mut (),
|
||||||
|
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
pub(crate) timer_queue: timer_queue::TimerQueue,
|
pub(crate) timer_queue: timer_queue::TimerQueue,
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
alarm: AlarmHandle,
|
alarm: AlarmHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,9 +281,9 @@ impl Executor {
|
|||||||
///
|
///
|
||||||
/// See [`Executor`] docs for details on `signal_fn`.
|
/// See [`Executor`] docs for details on `signal_fn`.
|
||||||
pub fn new(signal_fn: fn(*mut ()), signal_ctx: *mut ()) -> Self {
|
pub fn new(signal_fn: fn(*mut ()), signal_ctx: *mut ()) -> Self {
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
let alarm = unsafe { unwrap!(driver::allocate_alarm()) };
|
let alarm = unsafe { unwrap!(driver::allocate_alarm()) };
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
driver::set_alarm_callback(alarm, signal_fn, signal_ctx);
|
driver::set_alarm_callback(alarm, signal_fn, signal_ctx);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
@ -291,9 +291,9 @@ impl Executor {
|
|||||||
signal_fn,
|
signal_fn,
|
||||||
signal_ctx,
|
signal_ctx,
|
||||||
|
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
timer_queue: timer_queue::TimerQueue::new(),
|
timer_queue: timer_queue::TimerQueue::new(),
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
alarm,
|
alarm,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -346,13 +346,13 @@ impl Executor {
|
|||||||
/// somehow schedule for `poll()` to be called later, at a time you know for sure there's
|
/// somehow schedule for `poll()` to be called later, at a time you know for sure there's
|
||||||
/// no `poll()` already running.
|
/// no `poll()` already running.
|
||||||
pub unsafe fn poll(&'static self) {
|
pub unsafe fn poll(&'static self) {
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
self.timer_queue.dequeue_expired(Instant::now(), |task| wake_task(task));
|
self.timer_queue.dequeue_expired(Instant::now(), |task| wake_task(task));
|
||||||
|
|
||||||
self.run_queue.dequeue_all(|p| {
|
self.run_queue.dequeue_all(|p| {
|
||||||
let task = p.as_ref();
|
let task = p.as_ref();
|
||||||
|
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
task.expires_at.set(Instant::MAX);
|
task.expires_at.set(Instant::MAX);
|
||||||
|
|
||||||
let state = task.state.fetch_and(!STATE_RUN_QUEUED, Ordering::AcqRel);
|
let state = task.state.fetch_and(!STATE_RUN_QUEUED, Ordering::AcqRel);
|
||||||
@ -369,11 +369,11 @@ impl Executor {
|
|||||||
task.poll_fn.read()(p as _);
|
task.poll_fn.read()(p as _);
|
||||||
|
|
||||||
// Enqueue or update into timer_queue
|
// Enqueue or update into timer_queue
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
self.timer_queue.update(p);
|
self.timer_queue.update(p);
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
{
|
{
|
||||||
// If this is already in the past, set_alarm will immediately trigger the alarm.
|
// If this is already in the past, set_alarm will immediately trigger the alarm.
|
||||||
// This will cause `signal_fn` to be called, which will cause `poll()` to be called again,
|
// 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>) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "integrated-timers")]
|
||||||
pub(crate) unsafe fn register_timer(at: Instant, waker: &core::task::Waker) {
|
#[no_mangle]
|
||||||
|
unsafe fn _embassy_time_schedule_wake(at: Instant, waker: &core::task::Waker) {
|
||||||
let task = waker::task_from_waker(waker);
|
let task = waker::task_from_waker(waker);
|
||||||
let task = task.as_ref();
|
let task = task.as_ref();
|
||||||
let expires_at = task.expires_at.get();
|
let expires_at = task.expires_at.get();
|
@ -4,9 +4,9 @@ use core::ptr;
|
|||||||
use core::ptr::NonNull;
|
use core::ptr::NonNull;
|
||||||
|
|
||||||
use atomic_polyfill::Ordering;
|
use atomic_polyfill::Ordering;
|
||||||
|
use embassy_time::Instant;
|
||||||
|
|
||||||
use super::{TaskHeader, STATE_TIMER_QUEUED};
|
use super::{TaskHeader, STATE_TIMER_QUEUED};
|
||||||
use crate::time::Instant;
|
|
||||||
|
|
||||||
pub(crate) struct TimerQueueItem {
|
pub(crate) struct TimerQueueItem {
|
||||||
next: Cell<*mut TaskHeader>,
|
next: Cell<*mut TaskHeader>,
|
@ -40,7 +40,7 @@ pub fn task_from_waker(waker: &Waker) -> NonNull<TaskHeader> {
|
|||||||
// TODO use waker_getters when stable. https://github.com/rust-lang/rust/issues/96992
|
// TODO use waker_getters when stable. https://github.com/rust-lang/rust/issues/96992
|
||||||
let hack: &WakerHack = unsafe { mem::transmute(waker) };
|
let hack: &WakerHack = unsafe { mem::transmute(waker) };
|
||||||
if hack.vtable != &VTABLE {
|
if hack.vtable != &VTABLE {
|
||||||
panic!("Found waker not created by the Embassy executor. `embassy_executor::time::Timer` only works with the Embassy executor.")
|
panic!("Found waker not created by the Embassy executor. `embassy_time::Timer` only works with the Embassy executor.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// safety: we never create a waker with a null data pointer.
|
// safety: we never create a waker with a null data pointer.
|
@ -9,5 +9,4 @@ edition = "2021"
|
|||||||
defmt = { version = "0.3", optional = true }
|
defmt = { version = "0.3", optional = true }
|
||||||
log = { version = "0.4.14", optional = true }
|
log = { version = "0.4.14", optional = true }
|
||||||
|
|
||||||
embassy-util = { version = "0.1.0", path = "../embassy-util" }
|
|
||||||
num-traits = { version = "0.2.14", default-features = false }
|
num-traits = { version = "0.2.14", default-features = false }
|
||||||
|
@ -8,8 +8,8 @@ src_base = "https://github.com/embassy-rs/embassy/blob/embassy-lora-v$VERSION/em
|
|||||||
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-lora/src/"
|
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-lora/src/"
|
||||||
features = ["time", "defmt"]
|
features = ["time", "defmt"]
|
||||||
flavors = [
|
flavors = [
|
||||||
{ name = "sx127x", target = "thumbv7em-none-eabihf", features = ["sx127x", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy-executor/time-tick-32768hz"] },
|
{ name = "sx127x", target = "thumbv7em-none-eabihf", features = ["sx127x", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy-time/tick-32768hz"] },
|
||||||
{ name = "stm32wl", target = "thumbv7em-none-eabihf", features = ["stm32wl", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy-executor/time-tick-32768hz"] },
|
{ name = "stm32wl", target = "thumbv7em-none-eabihf", features = ["stm32wl", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy-time/tick-32768hz"] },
|
||||||
]
|
]
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
@ -24,7 +24,7 @@ time = []
|
|||||||
defmt = { version = "0.3", optional = true }
|
defmt = { version = "0.3", optional = true }
|
||||||
log = { version = "0.4.14", optional = true }
|
log = { version = "0.4.14", optional = true }
|
||||||
|
|
||||||
embassy-executor = { version = "0.1.0", path = "../embassy-executor" }
|
embassy-time = { version = "0.1.0", path = "../embassy-time" }
|
||||||
embassy-util = { version = "0.1.0", path = "../embassy-util" }
|
embassy-util = { version = "0.1.0", path = "../embassy-util" }
|
||||||
embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true }
|
embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true }
|
||||||
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" }
|
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" }
|
||||||
|
@ -18,6 +18,6 @@ pub struct LoraTimer;
|
|||||||
impl lorawan_device::async_device::radio::Timer for LoraTimer {
|
impl lorawan_device::async_device::radio::Timer for LoraTimer {
|
||||||
type DelayFuture<'m> = impl core::future::Future<Output = ()> + 'm;
|
type DelayFuture<'m> = impl core::future::Future<Output = ()> + 'm;
|
||||||
fn delay_ms<'m>(&'m mut self, millis: u64) -> Self::DelayFuture<'m> {
|
fn delay_ms<'m>(&'m mut self, millis: u64) -> Self::DelayFuture<'m> {
|
||||||
embassy_executor::time::Timer::after(embassy_executor::time::Duration::from_millis(millis))
|
embassy_time::Timer::after(embassy_time::Duration::from_millis(millis))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use bit_field::BitField;
|
use bit_field::BitField;
|
||||||
use embassy_executor::time::{Duration, Timer};
|
use embassy_time::{Duration, Timer};
|
||||||
use embedded_hal::digital::v2::OutputPin;
|
use embedded_hal::digital::v2::OutputPin;
|
||||||
use embedded_hal_async::spi::SpiBus;
|
use embedded_hal_async::spi::SpiBus;
|
||||||
|
|
||||||
|
@ -13,8 +13,5 @@ proc-macro2 = "1.0.29"
|
|||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
nrf = []
|
|
||||||
stm32 = []
|
|
||||||
rp = []
|
|
||||||
std = []
|
std = []
|
||||||
wasm = []
|
wasm = []
|
||||||
|
@ -5,11 +5,7 @@ use quote::quote;
|
|||||||
use crate::util::ctxt::Ctxt;
|
use crate::util::ctxt::Ctxt;
|
||||||
|
|
||||||
#[derive(Debug, FromMeta)]
|
#[derive(Debug, FromMeta)]
|
||||||
struct Args {
|
struct Args {}
|
||||||
#[allow(unused)]
|
|
||||||
#[darling(default)]
|
|
||||||
config: Option<syn::LitStr>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, TokenStream> {
|
pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, TokenStream> {
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
@ -20,26 +16,14 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke
|
|||||||
let ctxt = Ctxt::new();
|
let ctxt = Ctxt::new();
|
||||||
|
|
||||||
if f.sig.asyncness.is_none() {
|
if f.sig.asyncness.is_none() {
|
||||||
ctxt.error_spanned_by(&f.sig, "task functions must be async");
|
ctxt.error_spanned_by(&f.sig, "main function must be async");
|
||||||
}
|
}
|
||||||
if !f.sig.generics.params.is_empty() {
|
if !f.sig.generics.params.is_empty() {
|
||||||
ctxt.error_spanned_by(&f.sig, "task functions must not be generic");
|
ctxt.error_spanned_by(&f.sig, "main function must not be generic");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "stm32")]
|
if fargs.len() != 1 {
|
||||||
let hal = Some(quote!(::embassy_stm32));
|
ctxt.error_spanned_by(&f.sig, "main function must have 1 argument: the spawner.");
|
||||||
#[cfg(feature = "nrf")]
|
|
||||||
let hal = Some(quote!(::embassy_nrf));
|
|
||||||
#[cfg(feature = "rp")]
|
|
||||||
let hal = Some(quote!(::embassy_rp));
|
|
||||||
#[cfg(not(any(feature = "stm32", feature = "nrf", feature = "rp")))]
|
|
||||||
let hal: Option<TokenStream> = None;
|
|
||||||
|
|
||||||
if hal.is_some() && fargs.len() != 2 {
|
|
||||||
ctxt.error_spanned_by(&f.sig, "main function must have 2 arguments");
|
|
||||||
}
|
|
||||||
if hal.is_none() && fargs.len() != 1 {
|
|
||||||
ctxt.error_spanned_by(&f.sig, "main function must have 1 argument");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctxt.check()?;
|
ctxt.check()?;
|
||||||
@ -50,8 +34,8 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke
|
|||||||
let main = quote! {
|
let main = quote! {
|
||||||
#[wasm_bindgen::prelude::wasm_bindgen(start)]
|
#[wasm_bindgen::prelude::wasm_bindgen(start)]
|
||||||
pub fn main() -> Result<(), wasm_bindgen::JsValue> {
|
pub fn main() -> Result<(), wasm_bindgen::JsValue> {
|
||||||
static EXECUTOR: ::embassy_util::Forever<::embassy_executor::executor::Executor> = ::embassy_util::Forever::new();
|
static EXECUTOR: ::embassy_util::Forever<::embassy_executor::Executor> = ::embassy_util::Forever::new();
|
||||||
let executor = EXECUTOR.put(::embassy_executor::executor::Executor::new());
|
let executor = EXECUTOR.put(::embassy_executor::Executor::new());
|
||||||
|
|
||||||
executor.start(|spawner| {
|
executor.start(|spawner| {
|
||||||
spawner.spawn(__embassy_main(spawner)).unwrap();
|
spawner.spawn(__embassy_main(spawner)).unwrap();
|
||||||
@ -64,7 +48,7 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke
|
|||||||
#[cfg(all(feature = "std", not(feature = "wasm")))]
|
#[cfg(all(feature = "std", not(feature = "wasm")))]
|
||||||
let main = quote! {
|
let main = quote! {
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
let mut executor = ::embassy_executor::executor::Executor::new();
|
let mut executor = ::embassy_executor::Executor::new();
|
||||||
let executor = unsafe { __make_static(&mut executor) };
|
let executor = unsafe { __make_static(&mut executor) };
|
||||||
|
|
||||||
executor.run(|spawner| {
|
executor.run(|spawner| {
|
||||||
@ -74,36 +58,16 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(all(not(feature = "std"), not(feature = "wasm")))]
|
#[cfg(all(not(feature = "std"), not(feature = "wasm")))]
|
||||||
let main = {
|
let main = quote! {
|
||||||
let config = args.config.map(|s| s.parse::<syn::Expr>().unwrap()).unwrap_or_else(|| {
|
|
||||||
syn::Expr::Verbatim(quote! {
|
|
||||||
Default::default()
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
let (hal_setup, peris_arg) = match hal {
|
|
||||||
Some(hal) => (
|
|
||||||
quote!(
|
|
||||||
let p = #hal::init(#config);
|
|
||||||
),
|
|
||||||
quote!(p),
|
|
||||||
),
|
|
||||||
None => (quote!(), quote!()),
|
|
||||||
};
|
|
||||||
|
|
||||||
quote! {
|
|
||||||
#[cortex_m_rt::entry]
|
#[cortex_m_rt::entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
#hal_setup
|
let mut executor = ::embassy_executor::Executor::new();
|
||||||
|
|
||||||
let mut executor = ::embassy_executor::executor::Executor::new();
|
|
||||||
let executor = unsafe { __make_static(&mut executor) };
|
let executor = unsafe { __make_static(&mut executor) };
|
||||||
|
|
||||||
executor.run(|spawner| {
|
executor.run(|spawner| {
|
||||||
spawner.must_spawn(__embassy_main(spawner, #peris_arg));
|
spawner.must_spawn(__embassy_main(spawner));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = quote! {
|
let result = quote! {
|
||||||
|
@ -64,9 +64,9 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke
|
|||||||
// in the user's code.
|
// in the user's code.
|
||||||
#task_inner
|
#task_inner
|
||||||
|
|
||||||
#visibility fn #task_ident(#fargs) -> ::embassy_executor::executor::SpawnToken<impl Sized> {
|
#visibility fn #task_ident(#fargs) -> ::embassy_executor::SpawnToken<impl Sized> {
|
||||||
type Fut = impl ::core::future::Future + 'static;
|
type Fut = impl ::core::future::Future + 'static;
|
||||||
static POOL: ::embassy_executor::executor::raw::TaskPool<Fut, #pool_size> = ::embassy_executor::executor::raw::TaskPool::new();
|
static POOL: ::embassy_executor::raw::TaskPool<Fut, #pool_size> = ::embassy_executor::raw::TaskPool::new();
|
||||||
unsafe { POOL._spawn_async_fn(move || #task_inner_ident(#(#arg_names,)*)) }
|
unsafe { POOL._spawn_async_fn(move || #task_inner_ident(#(#arg_names,)*)) }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
[package.metadata.embassy_docs]
|
[package.metadata.embassy_docs]
|
||||||
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-net-v$VERSION/embassy-net/src/"
|
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-net-v$VERSION/embassy-net/src/"
|
||||||
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-net/src/"
|
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-net/src/"
|
||||||
features = [ "pool-4", "defmt", "tcp", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "embassy-executor/time", "embassy-executor/time-tick-1mhz"]
|
features = [ "pool-4", "defmt", "tcp", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "embassy-time/tick-1mhz"]
|
||||||
target = "thumbv7em-none-eabi"
|
target = "thumbv7em-none-eabi"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
@ -37,7 +37,7 @@ unstable-traits = []
|
|||||||
defmt = { version = "0.3", optional = true }
|
defmt = { version = "0.3", optional = true }
|
||||||
log = { version = "0.4.14", optional = true }
|
log = { version = "0.4.14", optional = true }
|
||||||
|
|
||||||
embassy-executor = { version = "0.1.0", path = "../embassy-executor" }
|
embassy-time = { version = "0.1.0", path = "../embassy-time" }
|
||||||
embassy-util = { version = "0.1.0", path = "../embassy-util" }
|
embassy-util = { version = "0.1.0", path = "../embassy-util" }
|
||||||
embedded-io = { version = "0.3.0", features = [ "async" ] }
|
embedded-io = { version = "0.3.0", features = [ "async" ] }
|
||||||
|
|
||||||
@ -47,8 +47,8 @@ as-slice = "0.2.1"
|
|||||||
generic-array = { version = "0.14.4", default-features = false }
|
generic-array = { version = "0.14.4", default-features = false }
|
||||||
stable_deref_trait = { version = "1.2.0", default-features = false }
|
stable_deref_trait = { version = "1.2.0", default-features = false }
|
||||||
futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] }
|
futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] }
|
||||||
atomic-pool = "0.2.1"
|
atomic-pool = "1.0"
|
||||||
atomic-polyfill = "0.1.5"
|
atomic-polyfill = "1.0.1"
|
||||||
embedded-nal-async = "0.2.0"
|
embedded-nal-async = "0.2.0"
|
||||||
|
|
||||||
[dependencies.smoltcp]
|
[dependencies.smoltcp]
|
||||||
|
@ -2,7 +2,7 @@ use core::cell::UnsafeCell;
|
|||||||
use core::future::Future;
|
use core::future::Future;
|
||||||
use core::task::{Context, Poll};
|
use core::task::{Context, Poll};
|
||||||
|
|
||||||
use embassy_executor::time::{Instant, Timer};
|
use embassy_time::{Instant, Timer};
|
||||||
use embassy_util::waitqueue::WakerRegistration;
|
use embassy_util::waitqueue::WakerRegistration;
|
||||||
use futures::future::poll_fn;
|
use futures::future::poll_fn;
|
||||||
use futures::pin_mut;
|
use futures::pin_mut;
|
||||||
|
@ -16,7 +16,7 @@ flavors = [
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
||||||
time = ["embassy-executor/time"]
|
time = ["dep:embassy-time"]
|
||||||
|
|
||||||
defmt = ["dep:defmt", "embassy-executor/defmt", "embassy-util/defmt", "embassy-usb?/defmt", "embedded-io?/defmt", "embassy-embedded-hal/defmt"]
|
defmt = ["dep:defmt", "embassy-executor/defmt", "embassy-util/defmt", "embassy-usb?/defmt", "embedded-io?/defmt", "embassy-embedded-hal/defmt"]
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ _nrf5340-net = ["_nrf5340", "nrf5340-net-pac"]
|
|||||||
_nrf5340 = ["_gpio-p1", "_dppi"]
|
_nrf5340 = ["_gpio-p1", "_dppi"]
|
||||||
_nrf9160 = ["nrf9160-pac", "_dppi"]
|
_nrf9160 = ["nrf9160-pac", "_dppi"]
|
||||||
|
|
||||||
_time-driver = ["embassy-executor/time-tick-32768hz", "time"]
|
_time-driver = ["dep:embassy-time", "embassy-time?/tick-32768hz"]
|
||||||
|
|
||||||
_ppi = []
|
_ppi = []
|
||||||
_dppi = []
|
_dppi = []
|
||||||
@ -65,9 +65,9 @@ _gpio-p1 = []
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embassy-executor = { version = "0.1.0", path = "../embassy-executor", optional = true }
|
embassy-executor = { version = "0.1.0", path = "../embassy-executor", optional = true }
|
||||||
|
embassy-time = { version = "0.1.0", path = "../embassy-time", optional = true }
|
||||||
embassy-util = { version = "0.1.0", path = "../embassy-util" }
|
embassy-util = { version = "0.1.0", path = "../embassy-util" }
|
||||||
embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]}
|
embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]}
|
||||||
embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["nrf"]}
|
|
||||||
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
|
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
|
||||||
embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" }
|
embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" }
|
||||||
embassy-usb = {version = "0.1.0", path = "../embassy-usb", optional=true }
|
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 }
|
|||||||
defmt = { version = "0.3", optional = true }
|
defmt = { version = "0.3", optional = true }
|
||||||
log = { version = "0.4.14", optional = true }
|
log = { version = "0.4.14", optional = true }
|
||||||
cortex-m-rt = ">=0.6.15,<0.8"
|
cortex-m-rt = ">=0.6.15,<0.8"
|
||||||
cortex-m = "0.7.3"
|
cortex-m = "0.7.6"
|
||||||
futures = { version = "0.3.17", default-features = false }
|
futures = { version = "0.3.17", default-features = false }
|
||||||
critical-section = "0.2.5"
|
critical-section = "1.1"
|
||||||
rand_core = "0.6.3"
|
rand_core = "0.6.3"
|
||||||
fixed = "1.10.0"
|
fixed = "1.10.0"
|
||||||
embedded-storage = "0.3.0"
|
embedded-storage = "0.3.0"
|
||||||
|
@ -197,7 +197,7 @@ impl_saadc_input!(P0_04, ANALOGINPUT2);
|
|||||||
impl_saadc_input!(P0_05, ANALOGINPUT3);
|
impl_saadc_input!(P0_05, ANALOGINPUT3);
|
||||||
|
|
||||||
pub mod irqs {
|
pub mod irqs {
|
||||||
use embassy_macros::cortex_m_interrupt_declare as declare;
|
use embassy_cortex_m::interrupt::_export::declare;
|
||||||
|
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6);
|
|||||||
impl_saadc_input!(P0_31, ANALOGINPUT7);
|
impl_saadc_input!(P0_31, ANALOGINPUT7);
|
||||||
|
|
||||||
pub mod irqs {
|
pub mod irqs {
|
||||||
use embassy_macros::cortex_m_interrupt_declare as declare;
|
use embassy_cortex_m::interrupt::_export::declare;
|
||||||
|
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6);
|
|||||||
impl_saadc_input!(P0_31, ANALOGINPUT7);
|
impl_saadc_input!(P0_31, ANALOGINPUT7);
|
||||||
|
|
||||||
pub mod irqs {
|
pub mod irqs {
|
||||||
use embassy_macros::cortex_m_interrupt_declare as declare;
|
use embassy_cortex_m::interrupt::_export::declare;
|
||||||
|
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ impl_ppi_channel!(PPI_CH30, 30 => static);
|
|||||||
impl_ppi_channel!(PPI_CH31, 31 => static);
|
impl_ppi_channel!(PPI_CH31, 31 => static);
|
||||||
|
|
||||||
pub mod irqs {
|
pub mod irqs {
|
||||||
use embassy_macros::cortex_m_interrupt_declare as declare;
|
use embassy_cortex_m::interrupt::_export::declare;
|
||||||
|
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6);
|
|||||||
impl_saadc_input!(P0_31, ANALOGINPUT7);
|
impl_saadc_input!(P0_31, ANALOGINPUT7);
|
||||||
|
|
||||||
pub mod irqs {
|
pub mod irqs {
|
||||||
use embassy_macros::cortex_m_interrupt_declare as declare;
|
use embassy_cortex_m::interrupt::_export::declare;
|
||||||
|
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6);
|
|||||||
impl_saadc_input!(P0_31, ANALOGINPUT7);
|
impl_saadc_input!(P0_31, ANALOGINPUT7);
|
||||||
|
|
||||||
pub mod irqs {
|
pub mod irqs {
|
||||||
use embassy_macros::cortex_m_interrupt_declare as declare;
|
use embassy_cortex_m::interrupt::_export::declare;
|
||||||
|
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6);
|
|||||||
impl_saadc_input!(P0_31, ANALOGINPUT7);
|
impl_saadc_input!(P0_31, ANALOGINPUT7);
|
||||||
|
|
||||||
pub mod irqs {
|
pub mod irqs {
|
||||||
use embassy_macros::cortex_m_interrupt_declare as declare;
|
use embassy_cortex_m::interrupt::_export::declare;
|
||||||
|
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ impl_saadc_input!(P0_19, ANALOGINPUT6);
|
|||||||
impl_saadc_input!(P0_20, ANALOGINPUT7);
|
impl_saadc_input!(P0_20, ANALOGINPUT7);
|
||||||
|
|
||||||
pub mod irqs {
|
pub mod irqs {
|
||||||
use embassy_macros::cortex_m_interrupt_declare as declare;
|
use embassy_cortex_m::interrupt::_export::declare;
|
||||||
|
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ impl_ppi_channel!(PPI_CH30, 30 => configurable);
|
|||||||
impl_ppi_channel!(PPI_CH31, 31 => configurable);
|
impl_ppi_channel!(PPI_CH31, 31 => configurable);
|
||||||
|
|
||||||
pub mod irqs {
|
pub mod irqs {
|
||||||
use embassy_macros::cortex_m_interrupt_declare as declare;
|
use embassy_cortex_m::interrupt::_export::declare;
|
||||||
|
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ impl_saadc_input!(P0_19, ANALOGINPUT6);
|
|||||||
impl_saadc_input!(P0_20, ANALOGINPUT7);
|
impl_saadc_input!(P0_20, ANALOGINPUT7);
|
||||||
|
|
||||||
pub mod irqs {
|
pub mod irqs {
|
||||||
use embassy_macros::cortex_m_interrupt_declare as declare;
|
use embassy_cortex_m::interrupt::_export::declare;
|
||||||
|
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
|
|
||||||
|
@ -135,8 +135,8 @@ pub use chip::pac;
|
|||||||
pub(crate) use chip::pac;
|
pub(crate) use chip::pac;
|
||||||
pub use chip::{peripherals, Peripherals};
|
pub use chip::{peripherals, Peripherals};
|
||||||
pub use embassy_cortex_m::executor;
|
pub use embassy_cortex_m::executor;
|
||||||
|
pub use embassy_cortex_m::interrupt::_export::interrupt;
|
||||||
pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
|
pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
|
||||||
pub use embassy_macros::cortex_m_interrupt as interrupt;
|
|
||||||
|
|
||||||
pub mod config {
|
pub mod config {
|
||||||
//! Configuration options used when initializing the HAL.
|
//! Configuration options used when initializing the HAL.
|
||||||
|
@ -3,7 +3,7 @@ use core::sync::atomic::{compiler_fence, AtomicU32, AtomicU8, Ordering};
|
|||||||
use core::{mem, ptr};
|
use core::{mem, ptr};
|
||||||
|
|
||||||
use critical_section::CriticalSection;
|
use critical_section::CriticalSection;
|
||||||
use embassy_executor::time::driver::{AlarmHandle, Driver};
|
use embassy_time::driver::{AlarmHandle, Driver};
|
||||||
use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex;
|
use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||||
use embassy_util::blocking_mutex::CriticalSectionMutex as Mutex;
|
use embassy_util::blocking_mutex::CriticalSectionMutex as Mutex;
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ struct RtcDriver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ALARM_STATE_NEW: AlarmState = AlarmState::new();
|
const ALARM_STATE_NEW: AlarmState = AlarmState::new();
|
||||||
embassy_executor::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver {
|
embassy_time::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver {
|
||||||
period: AtomicU32::new(0),
|
period: AtomicU32::new(0),
|
||||||
alarm_count: AtomicU8::new(0),
|
alarm_count: AtomicU8::new(0),
|
||||||
alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [ALARM_STATE_NEW; ALARM_COUNT]),
|
alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [ALARM_STATE_NEW; ALARM_COUNT]),
|
||||||
|
@ -12,9 +12,9 @@ use core::sync::atomic::Ordering::SeqCst;
|
|||||||
use core::task::Poll;
|
use core::task::Poll;
|
||||||
|
|
||||||
use embassy_embedded_hal::SetConfig;
|
use embassy_embedded_hal::SetConfig;
|
||||||
#[cfg(feature = "time")]
|
|
||||||
use embassy_executor::time::{Duration, Instant};
|
|
||||||
use embassy_hal_common::{into_ref, PeripheralRef};
|
use embassy_hal_common::{into_ref, PeripheralRef};
|
||||||
|
#[cfg(feature = "time")]
|
||||||
|
use embassy_time::{Duration, Instant};
|
||||||
use embassy_util::waitqueue::AtomicWaker;
|
use embassy_util::waitqueue::AtomicWaker;
|
||||||
use futures::future::poll_fn;
|
use futures::future::poll_fn;
|
||||||
|
|
||||||
|
@ -28,19 +28,19 @@ unstable-traits = ["embedded-hal-1"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embassy-util = { version = "0.1.0", path = "../embassy-util" }
|
embassy-util = { version = "0.1.0", path = "../embassy-util" }
|
||||||
embassy-executor = { version = "0.1.0", path = "../embassy-executor", features = [ "time-tick-1mhz" ] }
|
embassy-executor = { version = "0.1.0", path = "../embassy-executor" }
|
||||||
|
embassy-time = { version = "0.1.0", path = "../embassy-time", features = [ "tick-1mhz" ] }
|
||||||
embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]}
|
embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]}
|
||||||
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
|
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
|
||||||
embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" }
|
embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" }
|
||||||
embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["rp"]}
|
atomic-polyfill = "1.0.1"
|
||||||
atomic-polyfill = "0.1.5"
|
|
||||||
defmt = { version = "0.3", optional = true }
|
defmt = { version = "0.3", optional = true }
|
||||||
log = { version = "0.4.14", optional = true }
|
log = { version = "0.4.14", optional = true }
|
||||||
nb = "1.0.0"
|
nb = "1.0.0"
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
cortex-m-rt = ">=0.6.15,<0.8"
|
cortex-m-rt = ">=0.6.15,<0.8"
|
||||||
cortex-m = "0.7.3"
|
cortex-m = "0.7.6"
|
||||||
critical-section = "0.2.5"
|
critical-section = "1.1"
|
||||||
futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
|
futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
|
||||||
|
|
||||||
rp2040-pac2 = { git = "https://github.com/embassy-rs/rp2040-pac2", rev="9ad7223a48a065e612bc7dc7be5bf5bd0b41cfc4", features = ["rt"] }
|
rp2040-pac2 = { git = "https://github.com/embassy-rs/rp2040-pac2", rev="9ad7223a48a065e612bc7dc7be5bf5bd0b41cfc4", features = ["rt"] }
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
//! nrf_softdevice::interrupt. Intended for switching between the two at compile-time.
|
//! nrf_softdevice::interrupt. Intended for switching between the two at compile-time.
|
||||||
|
|
||||||
// Re-exports
|
// Re-exports
|
||||||
|
use embassy_cortex_m::interrupt::_export::declare;
|
||||||
pub use embassy_cortex_m::interrupt::*;
|
pub use embassy_cortex_m::interrupt::*;
|
||||||
use embassy_macros::cortex_m_interrupt_declare as declare;
|
|
||||||
|
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
declare!(TIMER_IRQ_0);
|
declare!(TIMER_IRQ_0);
|
||||||
|
@ -17,8 +17,8 @@ mod reset;
|
|||||||
// Reexports
|
// Reexports
|
||||||
|
|
||||||
pub use embassy_cortex_m::executor;
|
pub use embassy_cortex_m::executor;
|
||||||
|
pub use embassy_cortex_m::interrupt::_export::interrupt;
|
||||||
pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
|
pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
|
||||||
pub use embassy_macros::cortex_m_interrupt as interrupt;
|
|
||||||
#[cfg(feature = "unstable-pac")]
|
#[cfg(feature = "unstable-pac")]
|
||||||
pub use rp2040_pac2 as pac;
|
pub use rp2040_pac2 as pac;
|
||||||
#[cfg(not(feature = "unstable-pac"))]
|
#[cfg(not(feature = "unstable-pac"))]
|
||||||
|
@ -2,7 +2,7 @@ use core::cell::Cell;
|
|||||||
|
|
||||||
use atomic_polyfill::{AtomicU8, Ordering};
|
use atomic_polyfill::{AtomicU8, Ordering};
|
||||||
use critical_section::CriticalSection;
|
use critical_section::CriticalSection;
|
||||||
use embassy_executor::time::driver::{AlarmHandle, Driver};
|
use embassy_time::driver::{AlarmHandle, Driver};
|
||||||
use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex;
|
use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||||
use embassy_util::blocking_mutex::Mutex;
|
use embassy_util::blocking_mutex::Mutex;
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ struct TimerDriver {
|
|||||||
next_alarm: AtomicU8,
|
next_alarm: AtomicU8,
|
||||||
}
|
}
|
||||||
|
|
||||||
embassy_executor::time_driver_impl!(static DRIVER: TimerDriver = TimerDriver{
|
embassy_time::time_driver_impl!(static DRIVER: TimerDriver = TimerDriver{
|
||||||
alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [DUMMY_ALARM; ALARM_COUNT]),
|
alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [DUMMY_ALARM; ALARM_COUNT]),
|
||||||
next_alarm: AtomicU8::new(0),
|
next_alarm: AtomicU8::new(0),
|
||||||
});
|
});
|
||||||
|
@ -10,7 +10,7 @@ src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-stm32
|
|||||||
# TODO: sdmmc
|
# TODO: sdmmc
|
||||||
# TODO: net
|
# TODO: net
|
||||||
# TODO: subghz
|
# TODO: subghz
|
||||||
features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "embassy-executor/time-tick-32768hz"]
|
features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "embassy-time/tick-32768hz"]
|
||||||
flavors = [
|
flavors = [
|
||||||
{ regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" },
|
{ regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" },
|
||||||
{ regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" },
|
{ regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" },
|
||||||
@ -33,8 +33,8 @@ flavors = [
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
embassy-util = { version = "0.1.0", path = "../embassy-util" }
|
embassy-util = { version = "0.1.0", path = "../embassy-util" }
|
||||||
embassy-executor = { version = "0.1.0", path = "../embassy-executor" }
|
embassy-executor = { version = "0.1.0", path = "../embassy-executor" }
|
||||||
|
embassy-time = { version = "0.1.0", path = "../embassy-time", optional = true }
|
||||||
embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-4"]}
|
embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-4"]}
|
||||||
embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["stm32"] }
|
|
||||||
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
|
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
|
||||||
embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" }
|
embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" }
|
||||||
embassy-net = { version = "0.1.0", path = "../embassy-net", optional = true }
|
embassy-net = { version = "0.1.0", path = "../embassy-net", optional = true }
|
||||||
@ -50,14 +50,13 @@ embedded-storage-async = { version = "0.3.0", optional = true }
|
|||||||
defmt = { version = "0.3", optional = true }
|
defmt = { version = "0.3", optional = true }
|
||||||
log = { version = "0.4.14", optional = true }
|
log = { version = "0.4.14", optional = true }
|
||||||
cortex-m-rt = ">=0.6.15,<0.8"
|
cortex-m-rt = ">=0.6.15,<0.8"
|
||||||
cortex-m = "0.7.3"
|
cortex-m = "0.7.6"
|
||||||
futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
|
futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
|
||||||
rand_core = "0.6.3"
|
rand_core = "0.6.3"
|
||||||
sdio-host = "0.5.0"
|
sdio-host = "0.5.0"
|
||||||
embedded-sdmmc = { git = "https://github.com/thalesfragoso/embedded-sdmmc-rs", branch = "async", optional = true }
|
embedded-sdmmc = { git = "https://github.com/thalesfragoso/embedded-sdmmc-rs", branch = "async", optional = true }
|
||||||
critical-section = "0.2.5"
|
critical-section = "1.1"
|
||||||
bare-metal = "1.0.0"
|
atomic-polyfill = "1.0.1"
|
||||||
atomic-polyfill = "0.1.5"
|
|
||||||
stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", features = ["rt"] }
|
stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", features = ["rt"] }
|
||||||
vcell = "0.1.3"
|
vcell = "0.1.3"
|
||||||
bxcan = "0.7.0"
|
bxcan = "0.7.0"
|
||||||
@ -82,7 +81,7 @@ exti = []
|
|||||||
|
|
||||||
# Features starting with `_` are for internal use only. They're not intended
|
# Features starting with `_` are for internal use only. They're not intended
|
||||||
# to be enabled by other crates, and are not covered by semver guarantees.
|
# to be enabled by other crates, and are not covered by semver guarantees.
|
||||||
_time-driver = ["embassy-executor/time"]
|
_time-driver = ["dep:embassy-time"]
|
||||||
time-driver-any = ["_time-driver"]
|
time-driver-any = ["_time-driver"]
|
||||||
time-driver-tim2 = ["_time-driver"]
|
time-driver-tim2 = ["_time-driver"]
|
||||||
time-driver-tim3 = ["_time-driver"]
|
time-driver-tim3 = ["_time-driver"]
|
||||||
|
@ -96,7 +96,7 @@ fn main() {
|
|||||||
g.extend(quote! {
|
g.extend(quote! {
|
||||||
pub mod interrupt {
|
pub mod interrupt {
|
||||||
use crate::pac::Interrupt as InterruptEnum;
|
use crate::pac::Interrupt as InterruptEnum;
|
||||||
use embassy_macros::cortex_m_interrupt_declare as declare;
|
use embassy_cortex_m::interrupt::_export::declare;
|
||||||
#(
|
#(
|
||||||
declare!(#irqs);
|
declare!(#irqs);
|
||||||
)*
|
)*
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
pub use bare_metal::Mutex;
|
pub use critical_section::{CriticalSection, Mutex};
|
||||||
pub use critical_section::CriticalSection;
|
|
||||||
pub use embassy_cortex_m::interrupt::*;
|
pub use embassy_cortex_m::interrupt::*;
|
||||||
|
|
||||||
pub use crate::_generated::interrupt::*;
|
pub use crate::_generated::interrupt::*;
|
||||||
|
@ -75,8 +75,8 @@ pub(crate) mod _generated {
|
|||||||
// Reexports
|
// Reexports
|
||||||
pub use _generated::{peripherals, Peripherals};
|
pub use _generated::{peripherals, Peripherals};
|
||||||
pub use embassy_cortex_m::executor;
|
pub use embassy_cortex_m::executor;
|
||||||
|
pub use embassy_cortex_m::interrupt::_export::interrupt;
|
||||||
pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
|
pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
|
||||||
pub use embassy_macros::cortex_m_interrupt as interrupt;
|
|
||||||
#[cfg(feature = "unstable-pac")]
|
#[cfg(feature = "unstable-pac")]
|
||||||
pub use stm32_metapac as pac;
|
pub use stm32_metapac as pac;
|
||||||
#[cfg(not(feature = "unstable-pac"))]
|
#[cfg(not(feature = "unstable-pac"))]
|
||||||
|
@ -504,7 +504,7 @@ impl<'d> SubGhz<'d, NoDma, NoDma> {
|
|||||||
///
|
///
|
||||||
/// sg.set_standby(StandbyClk::Rc)?;
|
/// sg.set_standby(StandbyClk::Rc)?;
|
||||||
/// unsafe { sg.set_sleep(SleepCfg::default())? };
|
/// unsafe { sg.set_sleep(SleepCfg::default())? };
|
||||||
/// embassy_executor::time::Timer::after(embassy_executor::time::Duration::from_micros(500)).await;
|
/// embassy_time::Timer::after(embassy_time::Duration::from_micros(500)).await;
|
||||||
/// unsafe { wakeup() };
|
/// unsafe { wakeup() };
|
||||||
/// # Ok::<(), embassy_stm32::subghz::Error>(())
|
/// # Ok::<(), embassy_stm32::subghz::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -439,9 +439,9 @@ impl From<Timeout> for [u8; 3] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Timeout> for embassy_executor::time::Duration {
|
impl From<Timeout> for embassy_time::Duration {
|
||||||
fn from(to: Timeout) -> Self {
|
fn from(to: Timeout) -> Self {
|
||||||
embassy_executor::time::Duration::from_micros(to.as_micros().into())
|
embassy_time::Duration::from_micros(to.as_micros().into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,17 +44,17 @@ impl From<RampTime> for core::time::Duration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<RampTime> for embassy_executor::time::Duration {
|
impl From<RampTime> for embassy_time::Duration {
|
||||||
fn from(rt: RampTime) -> Self {
|
fn from(rt: RampTime) -> Self {
|
||||||
match rt {
|
match rt {
|
||||||
RampTime::Micros10 => embassy_executor::time::Duration::from_micros(10),
|
RampTime::Micros10 => embassy_time::Duration::from_micros(10),
|
||||||
RampTime::Micros20 => embassy_executor::time::Duration::from_micros(20),
|
RampTime::Micros20 => embassy_time::Duration::from_micros(20),
|
||||||
RampTime::Micros40 => embassy_executor::time::Duration::from_micros(40),
|
RampTime::Micros40 => embassy_time::Duration::from_micros(40),
|
||||||
RampTime::Micros80 => embassy_executor::time::Duration::from_micros(80),
|
RampTime::Micros80 => embassy_time::Duration::from_micros(80),
|
||||||
RampTime::Micros200 => embassy_executor::time::Duration::from_micros(200),
|
RampTime::Micros200 => embassy_time::Duration::from_micros(200),
|
||||||
RampTime::Micros800 => embassy_executor::time::Duration::from_micros(800),
|
RampTime::Micros800 => embassy_time::Duration::from_micros(800),
|
||||||
RampTime::Micros1700 => embassy_executor::time::Duration::from_micros(1700),
|
RampTime::Micros1700 => embassy_time::Duration::from_micros(1700),
|
||||||
RampTime::Micros3400 => embassy_executor::time::Duration::from_micros(3400),
|
RampTime::Micros3400 => embassy_time::Duration::from_micros(3400),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ use core::sync::atomic::{compiler_fence, Ordering};
|
|||||||
use core::{mem, ptr};
|
use core::{mem, ptr};
|
||||||
|
|
||||||
use atomic_polyfill::{AtomicU32, AtomicU8};
|
use atomic_polyfill::{AtomicU32, AtomicU8};
|
||||||
use embassy_executor::time::driver::{AlarmHandle, Driver};
|
use embassy_time::driver::{AlarmHandle, Driver};
|
||||||
use embassy_executor::time::TICKS_PER_SECOND;
|
use embassy_time::TICKS_PER_SECOND;
|
||||||
use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex;
|
use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||||
use embassy_util::blocking_mutex::Mutex;
|
use embassy_util::blocking_mutex::Mutex;
|
||||||
use stm32_metapac::timer::regs;
|
use stm32_metapac::timer::regs;
|
||||||
@ -133,7 +133,7 @@ struct RtcDriver {
|
|||||||
|
|
||||||
const ALARM_STATE_NEW: AlarmState = AlarmState::new();
|
const ALARM_STATE_NEW: AlarmState = AlarmState::new();
|
||||||
|
|
||||||
embassy_executor::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver {
|
embassy_time::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver {
|
||||||
period: AtomicU32::new(0),
|
period: AtomicU32::new(0),
|
||||||
alarm_count: AtomicU8::new(0),
|
alarm_count: AtomicU8::new(0),
|
||||||
alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [ALARM_STATE_NEW; ALARM_COUNT]),
|
alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [ALARM_STATE_NEW; ALARM_COUNT]),
|
||||||
|
@ -5,8 +5,8 @@ use core::sync::atomic::Ordering;
|
|||||||
use core::task::Poll;
|
use core::task::Poll;
|
||||||
|
|
||||||
use atomic_polyfill::{AtomicBool, AtomicU8};
|
use atomic_polyfill::{AtomicBool, AtomicU8};
|
||||||
use embassy_executor::time::{block_for, Duration};
|
|
||||||
use embassy_hal_common::into_ref;
|
use embassy_hal_common::into_ref;
|
||||||
|
use embassy_time::{block_for, Duration};
|
||||||
use embassy_usb::driver::{self, EndpointAllocError, EndpointError, Event, Unsupported};
|
use embassy_usb::driver::{self, EndpointAllocError, EndpointError, Event, Unsupported};
|
||||||
use embassy_usb::types::{EndpointAddress, EndpointInfo, EndpointType, UsbDirection};
|
use embassy_usb::types::{EndpointAddress, EndpointInfo, EndpointType, UsbDirection};
|
||||||
use embassy_util::waitqueue::AtomicWaker;
|
use embassy_util::waitqueue::AtomicWaker;
|
||||||
|
54
embassy-time/Cargo.toml
Normal file
54
embassy-time/Cargo.toml
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
[package]
|
||||||
|
name = "embassy-time"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
|
||||||
|
[package.metadata.embassy_docs]
|
||||||
|
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-time-v$VERSION/embassy-time/src/"
|
||||||
|
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-time/src/"
|
||||||
|
features = ["nightly", "defmt", "unstable-traits", "std"]
|
||||||
|
target = "x86_64-unknown-linux-gnu"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
std = ["tick-1mhz"]
|
||||||
|
wasm = ["dep:wasm-bindgen", "dep:js-sys", "dep:wasm-timer", "tick-1mhz"]
|
||||||
|
|
||||||
|
# Enable nightly-only features
|
||||||
|
nightly = ["embedded-hal-async"]
|
||||||
|
|
||||||
|
# Implement embedded-hal 1.0 alpha and embedded-hal-async traits.
|
||||||
|
# Implement embedded-hal-async traits if `nightly` is set as well.
|
||||||
|
unstable-traits = ["embedded-hal-1"]
|
||||||
|
|
||||||
|
# Display a timestamp of the number of seconds since startup next to defmt log messages
|
||||||
|
# To use this you must have a time driver provided.
|
||||||
|
defmt-timestamp-uptime = ["defmt"]
|
||||||
|
|
||||||
|
# Set the `embassy_time` tick rate.
|
||||||
|
# NOTE: This feature is only intended to be enabled by crates providing the time driver implementation.
|
||||||
|
# If you're not writing your own driver, check the driver documentation to customize the tick rate.
|
||||||
|
# If you're writing a driver and your tick rate is not listed here, please add it and send a PR!
|
||||||
|
tick-32768hz = []
|
||||||
|
tick-1000hz = []
|
||||||
|
tick-1mhz = []
|
||||||
|
tick-16mhz = []
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
defmt = { version = "0.3", optional = true }
|
||||||
|
log = { version = "0.4.14", optional = true }
|
||||||
|
|
||||||
|
embedded-hal-02 = { package = "embedded-hal", version = "0.2.6" }
|
||||||
|
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true}
|
||||||
|
embedded-hal-async = { version = "0.1.0-alpha.1", optional = true}
|
||||||
|
|
||||||
|
futures-util = { version = "0.3.17", default-features = false }
|
||||||
|
embassy-macros = { version = "0.1.0", path = "../embassy-macros"}
|
||||||
|
atomic-polyfill = "1.0.1"
|
||||||
|
critical-section = "1.1"
|
||||||
|
cfg-if = "1.0.0"
|
||||||
|
|
||||||
|
# WASM dependencies
|
||||||
|
wasm-bindgen = { version = "0.2.76", features = ["nightly"], optional = true }
|
||||||
|
js-sys = { version = "0.3", optional = true }
|
||||||
|
wasm-timer = { version = "0.2.5", optional = true }
|
@ -33,7 +33,7 @@ mod eh1 {
|
|||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] {
|
if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] {
|
||||||
use crate::time::Timer;
|
use crate::Timer;
|
||||||
use core::future::Future;
|
use core::future::Future;
|
||||||
use futures_util::FutureExt;
|
use futures_util::FutureExt;
|
||||||
|
|
@ -1,17 +1,17 @@
|
|||||||
//! Time driver interface
|
//! Time driver interface
|
||||||
//!
|
//!
|
||||||
//! This module defines the interface a driver needs to implement to power the `embassy_executor::time` module.
|
//! This module defines the interface a driver needs to implement to power the `embassy_time` module.
|
||||||
//!
|
//!
|
||||||
//! # Implementing a driver
|
//! # Implementing a driver
|
||||||
//!
|
//!
|
||||||
//! - Define a struct `MyDriver`
|
//! - Define a struct `MyDriver`
|
||||||
//! - Implement [`Driver`] for it
|
//! - Implement [`Driver`] for it
|
||||||
//! - Register it as the global driver with [`time_driver_impl`].
|
//! - Register it as the global driver with [`time_driver_impl`].
|
||||||
//! - Enable the Cargo features `embassy-executor/time` and one of `embassy-executor/time-tick-*` corresponding to the
|
//! - Enable the Cargo features `embassy-executor/time` and one of `embassy-time/tick-*` corresponding to the
|
||||||
//! tick rate of your driver.
|
//! tick rate of your driver.
|
||||||
//!
|
//!
|
||||||
//! If you wish to make the tick rate configurable by the end user, you should do so by exposing your own
|
//! If you wish to make the tick rate configurable by the end user, you should do so by exposing your own
|
||||||
//! Cargo features and having each enable the corresponding `embassy-executor/time-tick-*`.
|
//! Cargo features and having each enable the corresponding `embassy-time/tick-*`.
|
||||||
//!
|
//!
|
||||||
//! # Linkage details
|
//! # Linkage details
|
||||||
//!
|
//!
|
||||||
@ -34,10 +34,10 @@
|
|||||||
//! # Example
|
//! # Example
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use embassy_executor::time::driver::{Driver, AlarmHandle};
|
//! use embassy_time::driver::{Driver, AlarmHandle};
|
||||||
//!
|
//!
|
||||||
//! struct MyDriver{}; // not public!
|
//! struct MyDriver{}; // not public!
|
||||||
//! embassy_executor::time_driver_impl!(static DRIVER: MyDriver = MyDriver{});
|
//! embassy_time::time_driver_impl!(static DRIVER: MyDriver = MyDriver{});
|
||||||
//!
|
//!
|
||||||
//! impl Driver for MyDriver {
|
//! impl Driver for MyDriver {
|
||||||
//! fn now(&self) -> u64 {
|
//! fn now(&self) -> u64 {
|
||||||
@ -121,17 +121,25 @@ extern "Rust" {
|
|||||||
fn _embassy_time_set_alarm(alarm: AlarmHandle, timestamp: u64);
|
fn _embassy_time_set_alarm(alarm: AlarmHandle, timestamp: u64);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn now() -> u64 {
|
/// See [`Driver::now`]
|
||||||
|
pub fn now() -> u64 {
|
||||||
unsafe { _embassy_time_now() }
|
unsafe { _embassy_time_now() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// See [`Driver::allocate_alarm`]
|
||||||
|
///
|
||||||
/// Safety: it is UB to make the alarm fire before setting a callback.
|
/// Safety: it is UB to make the alarm fire before setting a callback.
|
||||||
pub(crate) unsafe fn allocate_alarm() -> Option<AlarmHandle> {
|
pub unsafe fn allocate_alarm() -> Option<AlarmHandle> {
|
||||||
_embassy_time_allocate_alarm()
|
_embassy_time_allocate_alarm()
|
||||||
}
|
}
|
||||||
pub(crate) fn set_alarm_callback(alarm: AlarmHandle, callback: fn(*mut ()), ctx: *mut ()) {
|
|
||||||
|
/// See [`Driver::set_alarm_callback`]
|
||||||
|
pub fn set_alarm_callback(alarm: AlarmHandle, callback: fn(*mut ()), ctx: *mut ()) {
|
||||||
unsafe { _embassy_time_set_alarm_callback(alarm, callback, ctx) }
|
unsafe { _embassy_time_set_alarm_callback(alarm, callback, ctx) }
|
||||||
}
|
}
|
||||||
pub(crate) fn set_alarm(alarm: AlarmHandle, timestamp: u64) {
|
|
||||||
|
/// See [`Driver::set_alarm`]
|
||||||
|
pub fn set_alarm(alarm: AlarmHandle, timestamp: u64) {
|
||||||
unsafe { _embassy_time_set_alarm(alarm, timestamp) }
|
unsafe { _embassy_time_set_alarm(alarm, timestamp) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,26 +153,22 @@ macro_rules! time_driver_impl {
|
|||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
fn _embassy_time_now() -> u64 {
|
fn _embassy_time_now() -> u64 {
|
||||||
<$t as $crate::time::driver::Driver>::now(&$name)
|
<$t as $crate::driver::Driver>::now(&$name)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
unsafe fn _embassy_time_allocate_alarm() -> Option<$crate::time::driver::AlarmHandle> {
|
unsafe fn _embassy_time_allocate_alarm() -> Option<$crate::driver::AlarmHandle> {
|
||||||
<$t as $crate::time::driver::Driver>::allocate_alarm(&$name)
|
<$t as $crate::driver::Driver>::allocate_alarm(&$name)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
fn _embassy_time_set_alarm_callback(
|
fn _embassy_time_set_alarm_callback(alarm: $crate::driver::AlarmHandle, callback: fn(*mut ()), ctx: *mut ()) {
|
||||||
alarm: $crate::time::driver::AlarmHandle,
|
<$t as $crate::driver::Driver>::set_alarm_callback(&$name, alarm, callback, ctx)
|
||||||
callback: fn(*mut ()),
|
|
||||||
ctx: *mut (),
|
|
||||||
) {
|
|
||||||
<$t as $crate::time::driver::Driver>::set_alarm_callback(&$name, alarm, callback, ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
fn _embassy_time_set_alarm(alarm: $crate::time::driver::AlarmHandle, timestamp: u64) {
|
fn _embassy_time_set_alarm(alarm: $crate::driver::AlarmHandle, timestamp: u64) {
|
||||||
<$t as $crate::time::driver::Driver>::set_alarm(&$name, alarm, timestamp)
|
<$t as $crate::driver::Driver>::set_alarm(&$name, alarm, timestamp)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ use std::{mem, ptr, thread};
|
|||||||
|
|
||||||
use atomic_polyfill::{AtomicU8, Ordering};
|
use atomic_polyfill::{AtomicU8, Ordering};
|
||||||
|
|
||||||
use crate::time::driver::{AlarmHandle, Driver};
|
use crate::driver::{AlarmHandle, Driver};
|
||||||
|
|
||||||
const ALARM_COUNT: usize = 4;
|
const ALARM_COUNT: usize = 4;
|
||||||
|
|
@ -7,7 +7,7 @@ use atomic_polyfill::{AtomicU8, Ordering};
|
|||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
use wasm_timer::Instant as StdInstant;
|
use wasm_timer::Instant as StdInstant;
|
||||||
|
|
||||||
use crate::time::driver::{AlarmHandle, Driver};
|
use crate::driver::{AlarmHandle, Driver};
|
||||||
|
|
||||||
const ALARM_COUNT: usize = 4;
|
const ALARM_COUNT: usize = 4;
|
||||||
|
|
225
embassy-time/src/fmt.rs
Normal file
225
embassy-time/src/fmt.rs
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
#![macro_use]
|
||||||
|
#![allow(unused_macros)]
|
||||||
|
|
||||||
|
#[cfg(all(feature = "defmt", feature = "log"))]
|
||||||
|
compile_error!("You may not enable both `defmt` and `log` features.");
|
||||||
|
|
||||||
|
macro_rules! assert {
|
||||||
|
($($x:tt)*) => {
|
||||||
|
{
|
||||||
|
#[cfg(not(feature = "defmt"))]
|
||||||
|
::core::assert!($($x)*);
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
::defmt::assert!($($x)*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! assert_eq {
|
||||||
|
($($x:tt)*) => {
|
||||||
|
{
|
||||||
|
#[cfg(not(feature = "defmt"))]
|
||||||
|
::core::assert_eq!($($x)*);
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
::defmt::assert_eq!($($x)*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! assert_ne {
|
||||||
|
($($x:tt)*) => {
|
||||||
|
{
|
||||||
|
#[cfg(not(feature = "defmt"))]
|
||||||
|
::core::assert_ne!($($x)*);
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
::defmt::assert_ne!($($x)*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! debug_assert {
|
||||||
|
($($x:tt)*) => {
|
||||||
|
{
|
||||||
|
#[cfg(not(feature = "defmt"))]
|
||||||
|
::core::debug_assert!($($x)*);
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
::defmt::debug_assert!($($x)*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! debug_assert_eq {
|
||||||
|
($($x:tt)*) => {
|
||||||
|
{
|
||||||
|
#[cfg(not(feature = "defmt"))]
|
||||||
|
::core::debug_assert_eq!($($x)*);
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
::defmt::debug_assert_eq!($($x)*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! debug_assert_ne {
|
||||||
|
($($x:tt)*) => {
|
||||||
|
{
|
||||||
|
#[cfg(not(feature = "defmt"))]
|
||||||
|
::core::debug_assert_ne!($($x)*);
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
::defmt::debug_assert_ne!($($x)*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! todo {
|
||||||
|
($($x:tt)*) => {
|
||||||
|
{
|
||||||
|
#[cfg(not(feature = "defmt"))]
|
||||||
|
::core::todo!($($x)*);
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
::defmt::todo!($($x)*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! unreachable {
|
||||||
|
($($x:tt)*) => {
|
||||||
|
{
|
||||||
|
#[cfg(not(feature = "defmt"))]
|
||||||
|
::core::unreachable!($($x)*);
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
::defmt::unreachable!($($x)*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! panic {
|
||||||
|
($($x:tt)*) => {
|
||||||
|
{
|
||||||
|
#[cfg(not(feature = "defmt"))]
|
||||||
|
::core::panic!($($x)*);
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
::defmt::panic!($($x)*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! trace {
|
||||||
|
($s:literal $(, $x:expr)* $(,)?) => {
|
||||||
|
{
|
||||||
|
#[cfg(feature = "log")]
|
||||||
|
::log::trace!($s $(, $x)*);
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
::defmt::trace!($s $(, $x)*);
|
||||||
|
#[cfg(not(any(feature = "log", feature="defmt")))]
|
||||||
|
let _ = ($( & $x ),*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! debug {
|
||||||
|
($s:literal $(, $x:expr)* $(,)?) => {
|
||||||
|
{
|
||||||
|
#[cfg(feature = "log")]
|
||||||
|
::log::debug!($s $(, $x)*);
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
::defmt::debug!($s $(, $x)*);
|
||||||
|
#[cfg(not(any(feature = "log", feature="defmt")))]
|
||||||
|
let _ = ($( & $x ),*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! info {
|
||||||
|
($s:literal $(, $x:expr)* $(,)?) => {
|
||||||
|
{
|
||||||
|
#[cfg(feature = "log")]
|
||||||
|
::log::info!($s $(, $x)*);
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
::defmt::info!($s $(, $x)*);
|
||||||
|
#[cfg(not(any(feature = "log", feature="defmt")))]
|
||||||
|
let _ = ($( & $x ),*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! warn {
|
||||||
|
($s:literal $(, $x:expr)* $(,)?) => {
|
||||||
|
{
|
||||||
|
#[cfg(feature = "log")]
|
||||||
|
::log::warn!($s $(, $x)*);
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
::defmt::warn!($s $(, $x)*);
|
||||||
|
#[cfg(not(any(feature = "log", feature="defmt")))]
|
||||||
|
let _ = ($( & $x ),*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! error {
|
||||||
|
($s:literal $(, $x:expr)* $(,)?) => {
|
||||||
|
{
|
||||||
|
#[cfg(feature = "log")]
|
||||||
|
::log::error!($s $(, $x)*);
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
::defmt::error!($s $(, $x)*);
|
||||||
|
#[cfg(not(any(feature = "log", feature="defmt")))]
|
||||||
|
let _ = ($( & $x ),*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
macro_rules! unwrap {
|
||||||
|
($($x:tt)*) => {
|
||||||
|
::defmt::unwrap!($($x)*)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "defmt"))]
|
||||||
|
macro_rules! unwrap {
|
||||||
|
($arg:expr) => {
|
||||||
|
match $crate::fmt::Try::into_result($arg) {
|
||||||
|
::core::result::Result::Ok(t) => t,
|
||||||
|
::core::result::Result::Err(e) => {
|
||||||
|
::core::panic!("unwrap of `{}` failed: {:?}", ::core::stringify!($arg), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
($arg:expr, $($msg:expr),+ $(,)? ) => {
|
||||||
|
match $crate::fmt::Try::into_result($arg) {
|
||||||
|
::core::result::Result::Ok(t) => t,
|
||||||
|
::core::result::Result::Err(e) => {
|
||||||
|
::core::panic!("unwrap of `{}` failed: {}: {:?}", ::core::stringify!($arg), ::core::format_args!($($msg,)*), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||||
|
pub struct NoneError;
|
||||||
|
|
||||||
|
pub trait Try {
|
||||||
|
type Ok;
|
||||||
|
type Error;
|
||||||
|
fn into_result(self) -> Result<Self::Ok, Self::Error>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Try for Option<T> {
|
||||||
|
type Ok = T;
|
||||||
|
type Error = NoneError;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn into_result(self) -> Result<T, NoneError> {
|
||||||
|
self.ok_or(NoneError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T, E> Try for Result<T, E> {
|
||||||
|
type Ok = T;
|
||||||
|
type Error = E;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn into_result(self) -> Self {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,8 @@
|
|||||||
|
#![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)]
|
||||||
|
#![cfg_attr(feature = "nightly", feature(generic_associated_types, type_alias_impl_trait))]
|
||||||
|
#![allow(clippy::new_without_default)]
|
||||||
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
//! Timekeeping, delays and timeouts.
|
//! Timekeeping, delays and timeouts.
|
||||||
//!
|
//!
|
||||||
//! Timekeeping is done with elapsed time since system boot. Time is represented in
|
//! Timekeeping is done with elapsed time since system boot. Time is represented in
|
||||||
@ -26,7 +31,7 @@
|
|||||||
//! like `2021-08-24 13:33:21`).
|
//! like `2021-08-24 13:33:21`).
|
||||||
//!
|
//!
|
||||||
//! If persistence across reboots is not needed, support can be built on top of
|
//! If persistence across reboots is not needed, support can be built on top of
|
||||||
//! `embassy_executor::time` by storing the offset between "seconds elapsed since boot"
|
//! `embassy_time` by storing the offset between "seconds elapsed since boot"
|
||||||
//! and "seconds since unix epoch".
|
//! and "seconds since unix epoch".
|
||||||
//!
|
//!
|
||||||
//! # Time driver
|
//! # Time driver
|
||||||
@ -35,12 +40,13 @@
|
|||||||
//! Only one driver can be active in a program.
|
//! Only one driver can be active in a program.
|
||||||
//!
|
//!
|
||||||
//! All methods and structs transparently call into the active driver. This makes it
|
//! All methods and structs transparently call into the active driver. This makes it
|
||||||
//! possible for libraries to use `embassy_executor::time` in a driver-agnostic way without
|
//! possible for libraries to use `embassy_time` in a driver-agnostic way without
|
||||||
//! requiring generic parameters.
|
//! requiring generic parameters.
|
||||||
//!
|
//!
|
||||||
//! For more details, check the [`driver`] module.
|
//! For more details, check the [`driver`] module.
|
||||||
|
|
||||||
#![deny(missing_docs)]
|
// This mod MUST go first, so that the others see its macros.
|
||||||
|
pub(crate) mod fmt;
|
||||||
|
|
||||||
mod delay;
|
mod delay;
|
||||||
pub mod driver;
|
pub mod driver;
|
||||||
@ -50,7 +56,6 @@ mod timer;
|
|||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
mod driver_std;
|
mod driver_std;
|
||||||
|
|
||||||
#[cfg(feature = "wasm")]
|
#[cfg(feature = "wasm")]
|
||||||
mod driver_wasm;
|
mod driver_wasm;
|
||||||
|
|
||||||
@ -59,24 +64,24 @@ pub use duration::Duration;
|
|||||||
pub use instant::Instant;
|
pub use instant::Instant;
|
||||||
pub use timer::{with_timeout, Ticker, TimeoutError, Timer};
|
pub use timer::{with_timeout, Ticker, TimeoutError, Timer};
|
||||||
|
|
||||||
#[cfg(feature = "time-tick-1000hz")]
|
#[cfg(feature = "tick-1000hz")]
|
||||||
const TPS: u64 = 1_000;
|
const TPS: u64 = 1_000;
|
||||||
|
|
||||||
#[cfg(feature = "time-tick-32768hz")]
|
#[cfg(feature = "tick-32768hz")]
|
||||||
const TPS: u64 = 32_768;
|
const TPS: u64 = 32_768;
|
||||||
|
|
||||||
#[cfg(feature = "time-tick-1mhz")]
|
#[cfg(feature = "tick-1mhz")]
|
||||||
const TPS: u64 = 1_000_000;
|
const TPS: u64 = 1_000_000;
|
||||||
|
|
||||||
#[cfg(feature = "time-tick-16mhz")]
|
#[cfg(feature = "tick-16mhz")]
|
||||||
const TPS: u64 = 16_000_000;
|
const TPS: u64 = 16_000_000;
|
||||||
|
|
||||||
/// Ticks per second of the global timebase.
|
/// Ticks per second of the global timebase.
|
||||||
///
|
///
|
||||||
/// This value is specified by the `time-tick-*` Cargo features, which
|
/// This value is specified by the `tick-*` Cargo features, which
|
||||||
/// should be set by the time driver. Some drivers support a fixed tick rate, others
|
/// should be set by the time driver. Some drivers support a fixed tick rate, others
|
||||||
/// allow you to choose a tick rate with Cargo features of their own. You should not
|
/// allow you to choose a tick rate with Cargo features of their own. You should not
|
||||||
/// set the `time-tick-*` features for embassy yourself as an end user.
|
/// set the `tick-*` features for embassy yourself as an end user.
|
||||||
pub const TICKS_PER_SECOND: u64 = TPS;
|
pub const TICKS_PER_SECOND: u64 = TPS;
|
||||||
|
|
||||||
const fn gcd(a: u64, b: u64) -> u64 {
|
const fn gcd(a: u64, b: u64) -> u64 {
|
||||||
@ -89,3 +94,6 @@ const fn gcd(a: u64, b: u64) -> u64 {
|
|||||||
|
|
||||||
pub(crate) const GCD_1K: u64 = gcd(TICKS_PER_SECOND, 1_000);
|
pub(crate) const GCD_1K: u64 = gcd(TICKS_PER_SECOND, 1_000);
|
||||||
pub(crate) const GCD_1M: u64 = gcd(TICKS_PER_SECOND, 1_000_000);
|
pub(crate) const GCD_1M: u64 = gcd(TICKS_PER_SECOND, 1_000_000);
|
||||||
|
|
||||||
|
#[cfg(feature = "defmt-timestamp-uptime")]
|
||||||
|
defmt::timestamp! {"{=u64:us}", Instant::now().as_micros() }
|
@ -1,12 +1,11 @@
|
|||||||
use core::future::Future;
|
use core::future::Future;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use core::task::{Context, Poll};
|
use core::task::{Context, Poll, Waker};
|
||||||
|
|
||||||
use futures_util::future::{select, Either};
|
use futures_util::future::{select, Either};
|
||||||
use futures_util::{pin_mut, Stream};
|
use futures_util::{pin_mut, Stream};
|
||||||
|
|
||||||
use crate::executor::raw;
|
use crate::{Duration, Instant};
|
||||||
use crate::time::{Duration, Instant};
|
|
||||||
|
|
||||||
/// Error returned by [`with_timeout`] on timeout.
|
/// Error returned by [`with_timeout`] on timeout.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
@ -49,7 +48,7 @@ impl Timer {
|
|||||||
/// # #![feature(type_alias_impl_trait)]
|
/// # #![feature(type_alias_impl_trait)]
|
||||||
/// #
|
/// #
|
||||||
/// # fn foo() {}
|
/// # fn foo() {}
|
||||||
/// use embassy_executor::time::{Duration, Timer};
|
/// use embassy_time::{Duration, Timer};
|
||||||
///
|
///
|
||||||
/// #[embassy_executor::task]
|
/// #[embassy_executor::task]
|
||||||
/// async fn demo_sleep_seconds() {
|
/// async fn demo_sleep_seconds() {
|
||||||
@ -73,7 +72,7 @@ impl Future for Timer {
|
|||||||
if self.yielded_once && self.expires_at <= Instant::now() {
|
if self.yielded_once && self.expires_at <= Instant::now() {
|
||||||
Poll::Ready(())
|
Poll::Ready(())
|
||||||
} else {
|
} else {
|
||||||
unsafe { raw::register_timer(self.expires_at, cx.waker()) };
|
schedule_wake(self.expires_at, cx.waker());
|
||||||
self.yielded_once = true;
|
self.yielded_once = true;
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
}
|
}
|
||||||
@ -88,7 +87,7 @@ impl Future for Timer {
|
|||||||
/// ``` no_run
|
/// ``` no_run
|
||||||
/// # #![feature(type_alias_impl_trait)]
|
/// # #![feature(type_alias_impl_trait)]
|
||||||
/// #
|
/// #
|
||||||
/// use embassy_executor::time::{Duration, Timer};
|
/// use embassy_time::{Duration, Timer};
|
||||||
/// # fn foo() {}
|
/// # fn foo() {}
|
||||||
///
|
///
|
||||||
/// #[embassy_executor::task]
|
/// #[embassy_executor::task]
|
||||||
@ -108,7 +107,7 @@ impl Future for Timer {
|
|||||||
/// ``` no_run
|
/// ``` no_run
|
||||||
/// # #![feature(type_alias_impl_trait)]
|
/// # #![feature(type_alias_impl_trait)]
|
||||||
/// #
|
/// #
|
||||||
/// use embassy_executor::time::{Duration, Ticker};
|
/// use embassy_time::{Duration, Ticker};
|
||||||
/// use futures::StreamExt;
|
/// use futures::StreamExt;
|
||||||
/// # fn foo(){}
|
/// # fn foo(){}
|
||||||
///
|
///
|
||||||
@ -144,8 +143,16 @@ impl Stream for Ticker {
|
|||||||
self.expires_at += dur;
|
self.expires_at += dur;
|
||||||
Poll::Ready(Some(()))
|
Poll::Ready(Some(()))
|
||||||
} else {
|
} else {
|
||||||
unsafe { raw::register_timer(self.expires_at, cx.waker()) };
|
schedule_wake(self.expires_at, cx.waker());
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "Rust" {
|
||||||
|
fn _embassy_time_schedule_wake(at: Instant, waker: &Waker);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn schedule_wake(at: Instant, waker: &Waker) {
|
||||||
|
unsafe { _embassy_time_schedule_wake(at, waker) }
|
||||||
|
}
|
@ -17,8 +17,8 @@ defmt = { version = "0.3", optional = true }
|
|||||||
log = { version = "0.4.14", optional = true }
|
log = { version = "0.4.14", optional = true }
|
||||||
|
|
||||||
futures-util = { version = "0.3.17", default-features = false }
|
futures-util = { version = "0.3.17", default-features = false }
|
||||||
atomic-polyfill = "0.1.5"
|
atomic-polyfill = "1.0.1"
|
||||||
critical-section = "0.2.5"
|
critical-section = "1.1"
|
||||||
heapless = "0.7.5"
|
heapless = "0.7.5"
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
embedded-io = "0.3.0"
|
embedded-io = "0.3.0"
|
||||||
@ -28,3 +28,6 @@ futures-executor = { version = "0.3.17", features = [ "thread-pool" ] }
|
|||||||
futures-test = "0.3.17"
|
futures-test = "0.3.17"
|
||||||
futures-timer = "3.0.2"
|
futures-timer = "3.0.2"
|
||||||
futures-util = { version = "0.3.17", features = [ "channel" ] }
|
futures-util = { version = "0.3.17", features = [ "channel" ] }
|
||||||
|
|
||||||
|
# Enable critical-section implementation for std, for tests
|
||||||
|
critical-section = { version = "1.1", features = ["std"] }
|
||||||
|
@ -5,7 +5,8 @@ version = "0.1.0"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embassy-util = { version = "0.1.0", path = "../../../../embassy-util" }
|
embassy-util = { version = "0.1.0", path = "../../../../embassy-util" }
|
||||||
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly"] }
|
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
|
||||||
|
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly"] }
|
||||||
embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly", "nrf52840"] }
|
embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly", "nrf52840"] }
|
||||||
embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf" }
|
embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf" }
|
||||||
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
||||||
@ -15,5 +16,5 @@ defmt-rtt = { version = "0.3", optional = true }
|
|||||||
panic-reset = { version = "0.1.1" }
|
panic-reset = { version = "0.1.1" }
|
||||||
embedded-hal = { version = "0.2.6" }
|
embedded-hal = { version = "0.2.6" }
|
||||||
|
|
||||||
cortex-m = "0.7.3"
|
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
cortex-m-rt = "0.7.0"
|
cortex-m-rt = "0.7.0"
|
||||||
|
@ -6,15 +6,16 @@
|
|||||||
|
|
||||||
use embassy_boot_nrf::FirmwareUpdater;
|
use embassy_boot_nrf::FirmwareUpdater;
|
||||||
use embassy_embedded_hal::adapter::BlockingAsync;
|
use embassy_embedded_hal::adapter::BlockingAsync;
|
||||||
|
use embassy_executor::Spawner;
|
||||||
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
|
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
|
||||||
use embassy_nrf::nvmc::Nvmc;
|
use embassy_nrf::nvmc::Nvmc;
|
||||||
use embassy_nrf::Peripherals;
|
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_nrf::init(Default::default());
|
||||||
let mut button = Input::new(p.P0_11, Pull::Up);
|
let mut button = Input::new(p.P0_11, Pull::Up);
|
||||||
let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
|
let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
|
||||||
//let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard);
|
//let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard);
|
||||||
|
@ -4,13 +4,14 @@
|
|||||||
#![feature(generic_associated_types)]
|
#![feature(generic_associated_types)]
|
||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
use embassy_executor::time::{Duration, Timer};
|
use embassy_executor::Spawner;
|
||||||
use embassy_nrf::gpio::{Level, Output, OutputDrive};
|
use embassy_nrf::gpio::{Level, Output, OutputDrive};
|
||||||
use embassy_nrf::Peripherals;
|
use embassy_time::{Duration, Timer};
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_nrf::init(Default::default());
|
||||||
let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
|
let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
|
||||||
//let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard);
|
//let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard);
|
||||||
|
|
||||||
|
@ -5,7 +5,8 @@ version = "0.1.0"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
|
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
|
||||||
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] }
|
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
|
||||||
|
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] }
|
||||||
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] }
|
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] }
|
||||||
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
|
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
|
||||||
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
||||||
@ -15,7 +16,7 @@ defmt-rtt = { version = "0.3", optional = true }
|
|||||||
panic-reset = { version = "0.1.1" }
|
panic-reset = { version = "0.1.1" }
|
||||||
embedded-hal = { version = "0.2.6" }
|
embedded-hal = { version = "0.2.6" }
|
||||||
|
|
||||||
cortex-m = "0.7.3"
|
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
cortex-m-rt = "0.7.0"
|
cortex-m-rt = "0.7.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -6,16 +6,17 @@
|
|||||||
use defmt_rtt::*;
|
use defmt_rtt::*;
|
||||||
use embassy_boot_stm32::FirmwareUpdater;
|
use embassy_boot_stm32::FirmwareUpdater;
|
||||||
use embassy_embedded_hal::adapter::BlockingAsync;
|
use embassy_embedded_hal::adapter::BlockingAsync;
|
||||||
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::flash::Flash;
|
use embassy_stm32::flash::Flash;
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
let flash = Flash::unlock(p.FLASH);
|
let flash = Flash::unlock(p.FLASH);
|
||||||
let mut flash = BlockingAsync::new(flash);
|
let mut flash = BlockingAsync::new(flash);
|
||||||
|
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
#[cfg(feature = "defmt-rtt")]
|
#[cfg(feature = "defmt-rtt")]
|
||||||
use defmt_rtt::*;
|
use defmt_rtt::*;
|
||||||
use embassy_executor::executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_executor::time::{Duration, Timer};
|
|
||||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
use embassy_time::{Duration, Timer};
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
let mut led = Output::new(p.PA5, Level::High, Speed::Low);
|
let mut led = Output::new(p.PA5, Level::High, Speed::Low);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -5,7 +5,8 @@ version = "0.1.0"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
|
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
|
||||||
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] }
|
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
|
||||||
|
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] }
|
||||||
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] }
|
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] }
|
||||||
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
|
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
|
||||||
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
||||||
@ -15,7 +16,7 @@ defmt-rtt = { version = "0.3", optional = true }
|
|||||||
panic-reset = { version = "0.1.1" }
|
panic-reset = { version = "0.1.1" }
|
||||||
embedded-hal = { version = "0.2.6" }
|
embedded-hal = { version = "0.2.6" }
|
||||||
|
|
||||||
cortex-m = "0.7.3"
|
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
cortex-m-rt = "0.7.0"
|
cortex-m-rt = "0.7.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -6,16 +6,17 @@
|
|||||||
use defmt_rtt::*;
|
use defmt_rtt::*;
|
||||||
use embassy_boot_stm32::FirmwareUpdater;
|
use embassy_boot_stm32::FirmwareUpdater;
|
||||||
use embassy_embedded_hal::adapter::BlockingAsync;
|
use embassy_embedded_hal::adapter::BlockingAsync;
|
||||||
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::flash::Flash;
|
use embassy_stm32::flash::Flash;
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
let flash = Flash::unlock(p.FLASH);
|
let flash = Flash::unlock(p.FLASH);
|
||||||
let mut flash = BlockingAsync::new(flash);
|
let mut flash = BlockingAsync::new(flash);
|
||||||
|
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
#[cfg(feature = "defmt-rtt")]
|
#[cfg(feature = "defmt-rtt")]
|
||||||
use defmt_rtt::*;
|
use defmt_rtt::*;
|
||||||
use embassy_executor::executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_executor::time::{Duration, Timer};
|
|
||||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
use embassy_time::{Duration, Timer};
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
Timer::after(Duration::from_millis(300)).await;
|
Timer::after(Duration::from_millis(300)).await;
|
||||||
let mut led = Output::new(p.PB7, Level::High, Speed::Low);
|
let mut led = Output::new(p.PB7, Level::High, Speed::Low);
|
||||||
led.set_high();
|
led.set_high();
|
||||||
|
@ -5,7 +5,8 @@ version = "0.1.0"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
|
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
|
||||||
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] }
|
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
|
||||||
|
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] }
|
||||||
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] }
|
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] }
|
||||||
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
|
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
|
||||||
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
||||||
@ -15,7 +16,7 @@ defmt-rtt = { version = "0.3", optional = true }
|
|||||||
panic-reset = { version = "0.1.1" }
|
panic-reset = { version = "0.1.1" }
|
||||||
embedded-hal = { version = "0.2.6" }
|
embedded-hal = { version = "0.2.6" }
|
||||||
|
|
||||||
cortex-m = "0.7.3"
|
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
cortex-m-rt = "0.7.0"
|
cortex-m-rt = "0.7.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -6,16 +6,17 @@
|
|||||||
use defmt_rtt::*;
|
use defmt_rtt::*;
|
||||||
use embassy_boot_stm32::FirmwareUpdater;
|
use embassy_boot_stm32::FirmwareUpdater;
|
||||||
use embassy_embedded_hal::adapter::BlockingAsync;
|
use embassy_embedded_hal::adapter::BlockingAsync;
|
||||||
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::flash::Flash;
|
use embassy_stm32::flash::Flash;
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
let flash = Flash::unlock(p.FLASH);
|
let flash = Flash::unlock(p.FLASH);
|
||||||
let mut flash = BlockingAsync::new(flash);
|
let mut flash = BlockingAsync::new(flash);
|
||||||
|
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
#[cfg(feature = "defmt-rtt")]
|
#[cfg(feature = "defmt-rtt")]
|
||||||
use defmt_rtt::*;
|
use defmt_rtt::*;
|
||||||
use embassy_executor::executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_executor::time::{Duration, Timer};
|
|
||||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
use embassy_time::{Duration, Timer};
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
Timer::after(Duration::from_millis(300)).await;
|
Timer::after(Duration::from_millis(300)).await;
|
||||||
let mut led = Output::new(p.PB14, Level::High, Speed::Low);
|
let mut led = Output::new(p.PB14, Level::High, Speed::Low);
|
||||||
led.set_high();
|
led.set_high();
|
||||||
|
@ -5,7 +5,8 @@ version = "0.1.0"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
|
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
|
||||||
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] }
|
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
|
||||||
|
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] }
|
||||||
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] }
|
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] }
|
||||||
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
|
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
|
||||||
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
||||||
@ -15,7 +16,7 @@ defmt-rtt = { version = "0.3", optional = true }
|
|||||||
panic-reset = { version = "0.1.1" }
|
panic-reset = { version = "0.1.1" }
|
||||||
embedded-hal = { version = "0.2.6" }
|
embedded-hal = { version = "0.2.6" }
|
||||||
|
|
||||||
cortex-m = "0.7.3"
|
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
cortex-m-rt = "0.7.0"
|
cortex-m-rt = "0.7.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -6,17 +6,18 @@
|
|||||||
use defmt_rtt::*;
|
use defmt_rtt::*;
|
||||||
use embassy_boot_stm32::FirmwareUpdater;
|
use embassy_boot_stm32::FirmwareUpdater;
|
||||||
use embassy_embedded_hal::adapter::BlockingAsync;
|
use embassy_embedded_hal::adapter::BlockingAsync;
|
||||||
use embassy_executor::time::{Duration, Timer};
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::flash::Flash;
|
use embassy_stm32::flash::Flash;
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
use embassy_time::{Duration, Timer};
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
let flash = Flash::unlock(p.FLASH);
|
let flash = Flash::unlock(p.FLASH);
|
||||||
let mut flash = BlockingAsync::new(flash);
|
let mut flash = BlockingAsync::new(flash);
|
||||||
|
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
#[cfg(feature = "defmt-rtt")]
|
#[cfg(feature = "defmt-rtt")]
|
||||||
use defmt_rtt::*;
|
use defmt_rtt::*;
|
||||||
use embassy_executor::executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_executor::time::{Duration, Timer};
|
|
||||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
use embassy_time::{Duration, Timer};
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
let mut led = Output::new(p.PB6, Level::High, Speed::Low);
|
let mut led = Output::new(p.PB6, Level::High, Speed::Low);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -5,7 +5,8 @@ version = "0.1.0"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
|
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
|
||||||
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] }
|
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
|
||||||
|
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] }
|
||||||
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] }
|
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] }
|
||||||
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
|
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
|
||||||
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
||||||
@ -15,7 +16,7 @@ defmt-rtt = { version = "0.3", optional = true }
|
|||||||
panic-reset = { version = "0.1.1" }
|
panic-reset = { version = "0.1.1" }
|
||||||
embedded-hal = { version = "0.2.6" }
|
embedded-hal = { version = "0.2.6" }
|
||||||
|
|
||||||
cortex-m = "0.7.3"
|
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
cortex-m-rt = "0.7.0"
|
cortex-m-rt = "0.7.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -6,17 +6,18 @@
|
|||||||
use defmt_rtt::*;
|
use defmt_rtt::*;
|
||||||
use embassy_boot_stm32::FirmwareUpdater;
|
use embassy_boot_stm32::FirmwareUpdater;
|
||||||
use embassy_embedded_hal::adapter::BlockingAsync;
|
use embassy_embedded_hal::adapter::BlockingAsync;
|
||||||
use embassy_executor::time::{Duration, Timer};
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::flash::Flash;
|
use embassy_stm32::flash::Flash;
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
use embassy_time::{Duration, Timer};
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
let flash = Flash::unlock(p.FLASH);
|
let flash = Flash::unlock(p.FLASH);
|
||||||
let mut flash = BlockingAsync::new(flash);
|
let mut flash = BlockingAsync::new(flash);
|
||||||
|
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
#[cfg(feature = "defmt-rtt")]
|
#[cfg(feature = "defmt-rtt")]
|
||||||
use defmt_rtt::*;
|
use defmt_rtt::*;
|
||||||
use embassy_executor::executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_executor::time::{Duration, Timer};
|
|
||||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
use embassy_time::{Duration, Timer};
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
let mut led = Output::new(p.PB6, Level::High, Speed::Low);
|
let mut led = Output::new(p.PB6, Level::High, Speed::Low);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -5,7 +5,8 @@ version = "0.1.0"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
|
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
|
||||||
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] }
|
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
|
||||||
|
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] }
|
||||||
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] }
|
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] }
|
||||||
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
|
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
|
||||||
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
||||||
@ -15,7 +16,7 @@ defmt-rtt = { version = "0.3", optional = true }
|
|||||||
panic-reset = { version = "0.1.1" }
|
panic-reset = { version = "0.1.1" }
|
||||||
embedded-hal = { version = "0.2.6" }
|
embedded-hal = { version = "0.2.6" }
|
||||||
|
|
||||||
cortex-m = "0.7.3"
|
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
cortex-m-rt = "0.7.0"
|
cortex-m-rt = "0.7.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -6,16 +6,17 @@
|
|||||||
use defmt_rtt::*;
|
use defmt_rtt::*;
|
||||||
use embassy_boot_stm32::FirmwareUpdater;
|
use embassy_boot_stm32::FirmwareUpdater;
|
||||||
use embassy_embedded_hal::adapter::BlockingAsync;
|
use embassy_embedded_hal::adapter::BlockingAsync;
|
||||||
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::flash::Flash;
|
use embassy_stm32::flash::Flash;
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
let flash = Flash::unlock(p.FLASH);
|
let flash = Flash::unlock(p.FLASH);
|
||||||
let mut flash = BlockingAsync::new(flash);
|
let mut flash = BlockingAsync::new(flash);
|
||||||
|
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
#[cfg(feature = "defmt-rtt")]
|
#[cfg(feature = "defmt-rtt")]
|
||||||
use defmt_rtt::*;
|
use defmt_rtt::*;
|
||||||
use embassy_executor::executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_executor::time::{Duration, Timer};
|
|
||||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
use embassy_time::{Duration, Timer};
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
let mut led = Output::new(p.PA5, Level::High, Speed::Low);
|
let mut led = Output::new(p.PA5, Level::High, Speed::Low);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -5,7 +5,8 @@ version = "0.1.0"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
|
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
|
||||||
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] }
|
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
|
||||||
|
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] }
|
||||||
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] }
|
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] }
|
||||||
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
|
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
|
||||||
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
|
||||||
@ -15,7 +16,7 @@ defmt-rtt = { version = "0.3", optional = true }
|
|||||||
panic-reset = { version = "0.1.1" }
|
panic-reset = { version = "0.1.1" }
|
||||||
embedded-hal = { version = "0.2.6" }
|
embedded-hal = { version = "0.2.6" }
|
||||||
|
|
||||||
cortex-m = "0.7.3"
|
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
cortex-m-rt = "0.7.0"
|
cortex-m-rt = "0.7.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -6,16 +6,17 @@
|
|||||||
use defmt_rtt::*;
|
use defmt_rtt::*;
|
||||||
use embassy_boot_stm32::FirmwareUpdater;
|
use embassy_boot_stm32::FirmwareUpdater;
|
||||||
use embassy_embedded_hal::adapter::BlockingAsync;
|
use embassy_embedded_hal::adapter::BlockingAsync;
|
||||||
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::exti::ExtiInput;
|
use embassy_stm32::exti::ExtiInput;
|
||||||
use embassy_stm32::flash::Flash;
|
use embassy_stm32::flash::Flash;
|
||||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
static APP_B: &[u8] = include_bytes!("../../b.bin");
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
let flash = Flash::unlock(p.FLASH);
|
let flash = Flash::unlock(p.FLASH);
|
||||||
let mut flash = BlockingAsync::new(flash);
|
let mut flash = BlockingAsync::new(flash);
|
||||||
|
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
#[cfg(feature = "defmt-rtt")]
|
#[cfg(feature = "defmt-rtt")]
|
||||||
use defmt_rtt::*;
|
use defmt_rtt::*;
|
||||||
use embassy_executor::executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_executor::time::{Duration, Timer};
|
|
||||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||||
use embassy_stm32::Peripherals;
|
use embassy_time::{Duration, Timer};
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner) {
|
||||||
|
let p = embassy_stm32::init(Default::default());
|
||||||
let mut led = Output::new(p.PB15, Level::High, Speed::Low);
|
let mut led = Output::new(p.PB15, Level::High, Speed::Low);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -10,7 +10,7 @@ defmt-rtt = { version = "0.3", optional = true }
|
|||||||
|
|
||||||
embassy-nrf = { path = "../../../../embassy-nrf", default-features = false, features = ["nightly"] }
|
embassy-nrf = { path = "../../../../embassy-nrf", default-features = false, features = ["nightly"] }
|
||||||
embassy-boot-nrf = { path = "../../../../embassy-boot/nrf", default-features = false }
|
embassy-boot-nrf = { path = "../../../../embassy-boot/nrf", default-features = false }
|
||||||
cortex-m = { version = "0.7" }
|
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
cortex-m-rt = { version = "0.7" }
|
cortex-m-rt = { version = "0.7" }
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ defmt-rtt = { version = "0.3", optional = true }
|
|||||||
|
|
||||||
embassy-stm32 = { path = "../../../../embassy-stm32", default-features = false, features = ["nightly"] }
|
embassy-stm32 = { path = "../../../../embassy-stm32", default-features = false, features = ["nightly"] }
|
||||||
embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32", default-features = false }
|
embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32", default-features = false }
|
||||||
cortex-m = { version = "0.7" }
|
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
cortex-m-rt = { version = "0.7" }
|
cortex-m-rt = { version = "0.7" }
|
||||||
embedded-storage = "0.3.0"
|
embedded-storage = "0.3.0"
|
||||||
embedded-storage-async = "0.3.0"
|
embedded-storage-async = "0.3.0"
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user