diff options
| author | Mathias <[email protected]> | 2022-08-23 13:24:52 +0200 |
|---|---|---|
| committer | Mathias <[email protected]> | 2022-08-23 13:24:52 +0200 |
| commit | 36cf719a1899202caeae39a8a6d5443a4acbdcfe (patch) | |
| tree | 4b58c2773f577dd7bb739358e48052841fff1432 /examples | |
| parent | 7e3ce2c90befe19ea30c6a784710f6cebf5a48f2 (diff) | |
| parent | cb9f0ef5b800ce4a22cde1805e0eb88425f1e07b (diff) | |
Merge branch 'master' of https://github.com/embassy-rs/embassy into embassy-rp/dma
Diffstat (limited to 'examples')
61 files changed, 314 insertions, 149 deletions
diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml index ef9346639..b9ff92578 100644 --- a/examples/boot/application/nrf/Cargo.toml +++ b/examples/boot/application/nrf/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-boot-nrf-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util" } | 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly"] } | 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly"] } |
| 10 | embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly", "nrf52840"] } | 10 | embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly", "nrf52840"] } |
diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml index 27eafa653..f143d1e8d 100644 --- a/examples/boot/application/stm32f3/Cargo.toml +++ b/examples/boot/application/stm32f3/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-boot-stm32f3-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] } |
diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml index 7de0b82d7..29c87eee1 100644 --- a/examples/boot/application/stm32f7/Cargo.toml +++ b/examples/boot/application/stm32f7/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-boot-stm32f7-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] } |
diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml index 65d34c70b..5669527fe 100644 --- a/examples/boot/application/stm32h7/Cargo.toml +++ b/examples/boot/application/stm32h7/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-boot-stm32h7-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] } |
diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml index 8f37869e3..48624d5ec 100644 --- a/examples/boot/application/stm32l0/Cargo.toml +++ b/examples/boot/application/stm32l0/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-boot-stm32l0-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } |
diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml index 6abf1986d..00b638ca5 100644 --- a/examples/boot/application/stm32l1/Cargo.toml +++ b/examples/boot/application/stm32l1/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-boot-stm32l1-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] } |
diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml index 6f2d12ff1..51ba730d5 100644 --- a/examples/boot/application/stm32l4/Cargo.toml +++ b/examples/boot/application/stm32l4/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-boot-stm32l4-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] } |
diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml index be97d4ebb..182acf694 100644 --- a/examples/boot/application/stm32wl/Cargo.toml +++ b/examples/boot/application/stm32wl/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-boot-stm32wl-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] } |
diff --git a/examples/nrf-rtos-trace/.cargo/config.toml b/examples/nrf-rtos-trace/.cargo/config.toml new file mode 100644 index 000000000..8ca28df39 --- /dev/null +++ b/examples/nrf-rtos-trace/.cargo/config.toml | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | ||
| 2 | # replace nRF82840_xxAA with your chip as listed in `probe-run --list-chips` | ||
| 3 | runner = "probe-run --chip nRF52840_xxAA" | ||
| 4 | |||
| 5 | [build] | ||
| 6 | target = "thumbv7em-none-eabi" | ||
| 7 | |||
| 8 | [env] | ||
| 9 | DEFMT_LOG = "trace" | ||
diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml new file mode 100644 index 000000000..87c9f33f5 --- /dev/null +++ b/examples/nrf-rtos-trace/Cargo.toml | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | [package] | ||
| 2 | edition = "2021" | ||
| 3 | name = "embassy-nrf-rtos-trace-examples" | ||
| 4 | version = "0.1.0" | ||
| 5 | |||
| 6 | [features] | ||
| 7 | default = ["log", "nightly"] | ||
| 8 | nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unstable-traits"] | ||
| 9 | log = [ | ||
| 10 | "dep:log", | ||
| 11 | "embassy-sync/log", | ||
| 12 | "embassy-executor/log", | ||
| 13 | "embassy-time/log", | ||
| 14 | "embassy-nrf/log", | ||
| 15 | ] | ||
| 16 | |||
| 17 | [dependencies] | ||
| 18 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync" } | ||
| 19 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features=["rtos-trace", "rtos-trace-interrupt", "integrated-timers"] } | ||
| 20 | embassy-time = { version = "0.1.0", path = "../../embassy-time" } | ||
| 21 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } | ||
| 22 | |||
| 23 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } | ||
| 24 | cortex-m-rt = "0.7.0" | ||
| 25 | panic-probe = { version = "0.3" } | ||
| 26 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | ||
| 27 | rand = { version = "0.8.4", default-features = false } | ||
| 28 | serde = { version = "1.0.136", default-features = false } | ||
| 29 | rtos-trace = "0.1.3" | ||
| 30 | systemview-target = { version = "0.1.2", features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] } | ||
| 31 | log = { version = "0.4.17", optional = true } | ||
| 32 | |||
| 33 | [[bin]] | ||
| 34 | name = "rtos_trace" | ||
| 35 | required-features = ["nightly"] | ||
diff --git a/examples/nrf-rtos-trace/build.rs b/examples/nrf-rtos-trace/build.rs new file mode 100644 index 000000000..36cdb65a8 --- /dev/null +++ b/examples/nrf-rtos-trace/build.rs | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | //! This build script copies the `memory.x` file from the crate root into | ||
| 2 | //! a directory where the linker can always find it at build time. | ||
| 3 | //! For many projects this is optional, as the linker always searches the | ||
| 4 | //! project root directory -- wherever `Cargo.toml` is. However, if you | ||
| 5 | //! are using a workspace or have a more complicated build setup, this | ||
| 6 | //! build script becomes required. Additionally, by requesting that | ||
| 7 | //! Cargo re-run the build script whenever `memory.x` is changed, | ||
| 8 | //! updating `memory.x` ensures a rebuild of the application with the | ||
| 9 | //! new memory settings. | ||
| 10 | |||
| 11 | use std::env; | ||
| 12 | use std::fs::File; | ||
| 13 | use std::io::Write; | ||
| 14 | use std::path::PathBuf; | ||
| 15 | |||
| 16 | fn main() { | ||
| 17 | // Put `memory.x` in our output directory and ensure it's | ||
| 18 | // on the linker search path. | ||
| 19 | let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); | ||
| 20 | File::create(out.join("memory.x")) | ||
| 21 | .unwrap() | ||
| 22 | .write_all(include_bytes!("memory.x")) | ||
| 23 | .unwrap(); | ||
| 24 | println!("cargo:rustc-link-search={}", out.display()); | ||
| 25 | |||
| 26 | // By default, Cargo will re-run a build script whenever | ||
| 27 | // any file in the project changes. By specifying `memory.x` | ||
| 28 | // here, we ensure the build script is only re-run when | ||
| 29 | // `memory.x` is changed. | ||
| 30 | println!("cargo:rerun-if-changed=memory.x"); | ||
| 31 | |||
| 32 | println!("cargo:rustc-link-arg-bins=--nmagic"); | ||
| 33 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); | ||
| 34 | #[cfg(feature = "defmt")] | ||
| 35 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); | ||
| 36 | } | ||
diff --git a/examples/nrf-rtos-trace/memory.x b/examples/nrf-rtos-trace/memory.x new file mode 100644 index 000000000..9b04edec0 --- /dev/null +++ b/examples/nrf-rtos-trace/memory.x | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | MEMORY | ||
| 2 | { | ||
| 3 | /* NOTE 1 K = 1 KiBi = 1024 bytes */ | ||
| 4 | /* These values correspond to the NRF52840 with Softdevices S140 7.0.1 */ | ||
| 5 | FLASH : ORIGIN = 0x00000000, LENGTH = 1024K | ||
| 6 | RAM : ORIGIN = 0x20000000, LENGTH = 256K | ||
| 7 | } | ||
diff --git a/examples/nrf-rtos-trace/src/bin/rtos_trace.rs b/examples/nrf-rtos-trace/src/bin/rtos_trace.rs new file mode 100644 index 000000000..7d1ad87c8 --- /dev/null +++ b/examples/nrf-rtos-trace/src/bin/rtos_trace.rs | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use core::task::Poll; | ||
| 6 | |||
| 7 | use embassy_executor::Spawner; | ||
| 8 | use embassy_time::{Duration, Instant, Timer}; | ||
| 9 | #[cfg(feature = "log")] | ||
| 10 | use log::*; | ||
| 11 | use panic_probe as _; | ||
| 12 | // N.B. systemview_target cannot be used at the same time as defmt_rtt. | ||
| 13 | use rtos_trace; | ||
| 14 | use systemview_target::SystemView; | ||
| 15 | |||
| 16 | static LOGGER: systemview_target::SystemView = systemview_target::SystemView::new(); | ||
| 17 | rtos_trace::global_trace! {SystemView} | ||
| 18 | |||
| 19 | struct TraceInfo(); | ||
| 20 | |||
| 21 | impl rtos_trace::RtosTraceApplicationCallbacks for TraceInfo { | ||
| 22 | fn system_description() {} | ||
| 23 | fn sysclock() -> u32 { | ||
| 24 | 64000000 | ||
| 25 | } | ||
| 26 | } | ||
| 27 | rtos_trace::global_application_callbacks! {TraceInfo} | ||
| 28 | |||
| 29 | #[embassy_executor::task] | ||
| 30 | async fn run1() { | ||
| 31 | loop { | ||
| 32 | #[cfg(feature = "log")] | ||
| 33 | info!("DING DONG"); | ||
| 34 | #[cfg(not(feature = "log"))] | ||
| 35 | rtos_trace::trace::marker(13); | ||
| 36 | Timer::after(Duration::from_ticks(16000)).await; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | #[embassy_executor::task] | ||
| 41 | async fn run2() { | ||
| 42 | loop { | ||
| 43 | Timer::at(Instant::from_ticks(0)).await; | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | #[embassy_executor::task] | ||
| 48 | async fn run3() { | ||
| 49 | futures::future::poll_fn(|cx| { | ||
| 50 | cx.waker().wake_by_ref(); | ||
| 51 | Poll::<()>::Pending | ||
| 52 | }) | ||
| 53 | .await; | ||
| 54 | } | ||
| 55 | |||
| 56 | #[embassy_executor::main] | ||
| 57 | async fn main(spawner: Spawner) { | ||
| 58 | let _p = embassy_nrf::init(Default::default()); | ||
| 59 | LOGGER.init(); | ||
| 60 | #[cfg(feature = "log")] | ||
| 61 | { | ||
| 62 | ::log::set_logger(&LOGGER).ok(); | ||
| 63 | ::log::set_max_level(::log::LevelFilter::Trace); | ||
| 64 | } | ||
| 65 | |||
| 66 | spawner.spawn(run1()).unwrap(); | ||
| 67 | spawner.spawn(run2()).unwrap(); | ||
| 68 | spawner.spawn(run3()).unwrap(); | ||
| 69 | } | ||
diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index 2fcc31221..b0af0c86e 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml | |||
| @@ -8,7 +8,8 @@ default = ["nightly"] | |||
| 8 | nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unstable-traits", "embassy-usb", "embassy-usb-serial", "embassy-usb-hid", "embassy-usb-ncm", "embedded-io/async", "embassy-net"] | 8 | nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unstable-traits", "embassy-usb", "embassy-usb-serial", "embassy-usb-hid", "embassy-usb-ncm", "embedded-io/async", "embassy-net"] |
| 9 | 9 | ||
| 10 | [dependencies] | 10 | [dependencies] |
| 11 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 11 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } |
| 12 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } | ||
| 12 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 13 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 13 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | 14 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } |
| 14 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } | 15 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } |
| @@ -22,6 +23,7 @@ embedded-io = "0.3.0" | |||
| 22 | defmt = "0.3" | 23 | defmt = "0.3" |
| 23 | defmt-rtt = "0.3" | 24 | defmt-rtt = "0.3" |
| 24 | 25 | ||
| 26 | static_cell = "1.0" | ||
| 25 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } | 27 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 26 | cortex-m-rt = "0.7.0" | 28 | cortex-m-rt = "0.7.0" |
| 27 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 29 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
diff --git a/examples/nrf/src/bin/channel.rs b/examples/nrf/src/bin/channel.rs index 195200988..d782a79e7 100644 --- a/examples/nrf/src/bin/channel.rs +++ b/examples/nrf/src/bin/channel.rs | |||
| @@ -5,9 +5,9 @@ | |||
| 5 | use defmt::unwrap; | 5 | use defmt::unwrap; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 7 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 8 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | ||
| 9 | use embassy_sync::channel::Channel; | ||
| 8 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::{Duration, Timer}; |
| 9 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | ||
| 10 | use embassy_util::channel::mpmc::Channel; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | enum LedState { | 13 | enum LedState { |
diff --git a/examples/nrf/src/bin/channel_sender_receiver.rs b/examples/nrf/src/bin/channel_sender_receiver.rs index c9c458aec..fcccdaed5 100644 --- a/examples/nrf/src/bin/channel_sender_receiver.rs +++ b/examples/nrf/src/bin/channel_sender_receiver.rs | |||
| @@ -5,10 +5,10 @@ | |||
| 5 | use defmt::unwrap; | 5 | use defmt::unwrap; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; | 7 | use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; |
| 8 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 9 | use embassy_sync::channel::{Channel, Receiver, Sender}; | ||
| 8 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::{Duration, Timer}; |
| 9 | use embassy_util::blocking_mutex::raw::NoopRawMutex; | 11 | use static_cell::StaticCell; |
| 10 | use embassy_util::channel::mpmc::{Channel, Receiver, Sender}; | ||
| 11 | use embassy_util::Forever; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | enum LedState { | 14 | enum LedState { |
| @@ -16,7 +16,7 @@ enum LedState { | |||
| 16 | Off, | 16 | Off, |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | static CHANNEL: Forever<Channel<NoopRawMutex, LedState, 1>> = Forever::new(); | 19 | static CHANNEL: StaticCell<Channel<NoopRawMutex, LedState, 1>> = StaticCell::new(); |
| 20 | 20 | ||
| 21 | #[embassy_executor::task] | 21 | #[embassy_executor::task] |
| 22 | async fn send_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) { | 22 | async fn send_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) { |
| @@ -43,7 +43,7 @@ async fn recv_task(led: AnyPin, receiver: Receiver<'static, NoopRawMutex, LedSta | |||
| 43 | #[embassy_executor::main] | 43 | #[embassy_executor::main] |
| 44 | async fn main(spawner: Spawner) { | 44 | async fn main(spawner: Spawner) { |
| 45 | let p = embassy_nrf::init(Default::default()); | 45 | let p = embassy_nrf::init(Default::default()); |
| 46 | let channel = CHANNEL.put(Channel::new()); | 46 | let channel = CHANNEL.init(Channel::new()); |
| 47 | 47 | ||
| 48 | unwrap!(spawner.spawn(send_task(channel.sender()))); | 48 | unwrap!(spawner.spawn(send_task(channel.sender()))); |
| 49 | unwrap!(spawner.spawn(recv_task(p.P0_13.degrade(), channel.receiver()))); | 49 | unwrap!(spawner.spawn(recv_task(p.P0_13.degrade(), channel.receiver()))); |
diff --git a/examples/nrf/src/bin/multiprio.rs b/examples/nrf/src/bin/multiprio.rs index b653689a7..25806ae48 100644 --- a/examples/nrf/src/bin/multiprio.rs +++ b/examples/nrf/src/bin/multiprio.rs | |||
| @@ -63,7 +63,7 @@ use embassy_nrf::executor::{Executor, InterruptExecutor}; | |||
| 63 | use embassy_nrf::interrupt; | 63 | use embassy_nrf::interrupt; |
| 64 | use embassy_nrf::interrupt::InterruptExt; | 64 | use embassy_nrf::interrupt::InterruptExt; |
| 65 | use embassy_time::{Duration, Instant, Timer}; | 65 | use embassy_time::{Duration, Instant, Timer}; |
| 66 | use embassy_util::Forever; | 66 | use static_cell::StaticCell; |
| 67 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| 68 | 68 | ||
| 69 | #[embassy_executor::task] | 69 | #[embassy_executor::task] |
| @@ -108,9 +108,9 @@ async fn run_low() { | |||
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | static EXECUTOR_HIGH: Forever<InterruptExecutor<interrupt::SWI1_EGU1>> = Forever::new(); | 111 | static EXECUTOR_HIGH: StaticCell<InterruptExecutor<interrupt::SWI1_EGU1>> = StaticCell::new(); |
| 112 | static EXECUTOR_MED: Forever<InterruptExecutor<interrupt::SWI0_EGU0>> = Forever::new(); | 112 | static EXECUTOR_MED: StaticCell<InterruptExecutor<interrupt::SWI0_EGU0>> = StaticCell::new(); |
| 113 | static EXECUTOR_LOW: Forever<Executor> = Forever::new(); | 113 | static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new(); |
| 114 | 114 | ||
| 115 | #[entry] | 115 | #[entry] |
| 116 | fn main() -> ! { | 116 | fn main() -> ! { |
| @@ -121,19 +121,19 @@ fn main() -> ! { | |||
| 121 | // High-priority executor: SWI1_EGU1, priority level 6 | 121 | // High-priority executor: SWI1_EGU1, priority level 6 |
| 122 | let irq = interrupt::take!(SWI1_EGU1); | 122 | let irq = interrupt::take!(SWI1_EGU1); |
| 123 | irq.set_priority(interrupt::Priority::P6); | 123 | irq.set_priority(interrupt::Priority::P6); |
| 124 | let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq)); | 124 | let executor = EXECUTOR_HIGH.init(InterruptExecutor::new(irq)); |
| 125 | let spawner = executor.start(); | 125 | let spawner = executor.start(); |
| 126 | unwrap!(spawner.spawn(run_high())); | 126 | unwrap!(spawner.spawn(run_high())); |
| 127 | 127 | ||
| 128 | // Medium-priority executor: SWI0_EGU0, priority level 7 | 128 | // Medium-priority executor: SWI0_EGU0, priority level 7 |
| 129 | let irq = interrupt::take!(SWI0_EGU0); | 129 | let irq = interrupt::take!(SWI0_EGU0); |
| 130 | irq.set_priority(interrupt::Priority::P7); | 130 | irq.set_priority(interrupt::Priority::P7); |
| 131 | let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq)); | 131 | let executor = EXECUTOR_MED.init(InterruptExecutor::new(irq)); |
| 132 | let spawner = executor.start(); | 132 | let spawner = executor.start(); |
| 133 | unwrap!(spawner.spawn(run_med())); | 133 | unwrap!(spawner.spawn(run_med())); |
| 134 | 134 | ||
| 135 | // Low priority executor: runs in thread mode, using WFE/SEV | 135 | // Low priority executor: runs in thread mode, using WFE/SEV |
| 136 | let executor = EXECUTOR_LOW.put(Executor::new()); | 136 | let executor = EXECUTOR_LOW.init(Executor::new()); |
| 137 | executor.run(|spawner| { | 137 | executor.run(|spawner| { |
| 138 | unwrap!(spawner.spawn(run_low())); | 138 | unwrap!(spawner.spawn(run_low())); |
| 139 | }); | 139 | }); |
diff --git a/examples/nrf/src/bin/mutex.rs b/examples/nrf/src/bin/mutex.rs index 876297883..c402c6ba1 100644 --- a/examples/nrf/src/bin/mutex.rs +++ b/examples/nrf/src/bin/mutex.rs | |||
| @@ -4,9 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | ||
| 8 | use embassy_sync::mutex::Mutex; | ||
| 7 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::{Duration, Timer}; |
| 8 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | ||
| 9 | use embassy_util::mutex::Mutex; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | static MUTEX: Mutex<ThreadModeRawMutex, u32> = Mutex::new(0); | 12 | static MUTEX: Mutex<ThreadModeRawMutex, u32> = Mutex::new(0); |
diff --git a/examples/nrf/src/bin/pubsub.rs b/examples/nrf/src/bin/pubsub.rs index 1d90217f2..688e6d075 100644 --- a/examples/nrf/src/bin/pubsub.rs +++ b/examples/nrf/src/bin/pubsub.rs | |||
| @@ -4,9 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::unwrap; | 5 | use defmt::unwrap; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | ||
| 8 | use embassy_sync::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; | ||
| 7 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::{Duration, Timer}; |
| 8 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | ||
| 9 | use embassy_util::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | /// Create the message bus. It has a queue of 4, supports 3 subscribers and 1 publisher | 12 | /// Create the message bus. It has a queue of 4, supports 3 subscribers and 1 publisher |
diff --git a/examples/nrf/src/bin/raw_spawn.rs b/examples/nrf/src/bin/raw_spawn.rs index 415579be7..1b067f5e4 100644 --- a/examples/nrf/src/bin/raw_spawn.rs +++ b/examples/nrf/src/bin/raw_spawn.rs | |||
| @@ -8,7 +8,7 @@ use defmt::{info, unwrap}; | |||
| 8 | use embassy_executor::raw::TaskStorage; | 8 | use embassy_executor::raw::TaskStorage; |
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::{Duration, Timer}; |
| 11 | use embassy_util::Forever; | 11 | use static_cell::StaticCell; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | async fn run1() { | 14 | async fn run1() { |
| @@ -25,14 +25,14 @@ async fn run2() { | |||
| 25 | } | 25 | } |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | static EXECUTOR: Forever<Executor> = Forever::new(); | 28 | static EXECUTOR: StaticCell<Executor> = StaticCell::new(); |
| 29 | 29 | ||
| 30 | #[entry] | 30 | #[entry] |
| 31 | fn main() -> ! { | 31 | fn main() -> ! { |
| 32 | info!("Hello World!"); | 32 | info!("Hello World!"); |
| 33 | 33 | ||
| 34 | let _p = embassy_nrf::init(Default::default()); | 34 | let _p = embassy_nrf::init(Default::default()); |
| 35 | let executor = EXECUTOR.put(Executor::new()); | 35 | let executor = EXECUTOR.init(Executor::new()); |
| 36 | 36 | ||
| 37 | let run1_task = TaskStorage::new(); | 37 | let run1_task = TaskStorage::new(); |
| 38 | let run2_task = TaskStorage::new(); | 38 | let run2_task = TaskStorage::new(); |
diff --git a/examples/nrf/src/bin/uart_split.rs b/examples/nrf/src/bin/uart_split.rs index dab8e475d..1adaf53fd 100644 --- a/examples/nrf/src/bin/uart_split.rs +++ b/examples/nrf/src/bin/uart_split.rs | |||
| @@ -7,8 +7,8 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_nrf::peripherals::UARTE0; | 7 | use embassy_nrf::peripherals::UARTE0; |
| 8 | use embassy_nrf::uarte::UarteRx; | 8 | use embassy_nrf::uarte::UarteRx; |
| 9 | use embassy_nrf::{interrupt, uarte}; | 9 | use embassy_nrf::{interrupt, uarte}; |
| 10 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | 10 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; |
| 11 | use embassy_util::channel::mpmc::Channel; | 11 | use embassy_sync::channel::Channel; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | static CHANNEL: Channel<ThreadModeRawMutex, [u8; 8], 1> = Channel::new(); | 14 | static CHANNEL: Channel<ThreadModeRawMutex, [u8; 8], 1> = Channel::new(); |
diff --git a/examples/nrf/src/bin/usb_ethernet.rs b/examples/nrf/src/bin/usb_ethernet.rs index f0a870317..ca6c7e0d1 100644 --- a/examples/nrf/src/bin/usb_ethernet.rs +++ b/examples/nrf/src/bin/usb_ethernet.rs | |||
| @@ -14,21 +14,21 @@ use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources}; | |||
| 14 | use embassy_nrf::rng::Rng; | 14 | use embassy_nrf::rng::Rng; |
| 15 | use embassy_nrf::usb::{Driver, PowerUsb}; | 15 | use embassy_nrf::usb::{Driver, PowerUsb}; |
| 16 | use embassy_nrf::{interrupt, pac, peripherals}; | 16 | use embassy_nrf::{interrupt, pac, peripherals}; |
| 17 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | ||
| 18 | use embassy_sync::channel::Channel; | ||
| 17 | use embassy_usb::{Builder, Config, UsbDevice}; | 19 | use embassy_usb::{Builder, Config, UsbDevice}; |
| 18 | use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; | 20 | use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; |
| 19 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | ||
| 20 | use embassy_util::channel::mpmc::Channel; | ||
| 21 | use embassy_util::Forever; | ||
| 22 | use embedded_io::asynch::{Read, Write}; | 21 | use embedded_io::asynch::{Read, Write}; |
| 22 | use static_cell::StaticCell; | ||
| 23 | use {defmt_rtt as _, panic_probe as _}; | 23 | use {defmt_rtt as _, panic_probe as _}; |
| 24 | 24 | ||
| 25 | type MyDriver = Driver<'static, peripherals::USBD, PowerUsb>; | 25 | type MyDriver = Driver<'static, peripherals::USBD, PowerUsb>; |
| 26 | 26 | ||
| 27 | macro_rules! forever { | 27 | macro_rules! singleton { |
| 28 | ($val:expr) => {{ | 28 | ($val:expr) => {{ |
| 29 | type T = impl Sized; | 29 | type T = impl Sized; |
| 30 | static FOREVER: Forever<T> = Forever::new(); | 30 | static STATIC_CELL: StaticCell<T> = StaticCell::new(); |
| 31 | FOREVER.put_with(move || $val) | 31 | STATIC_CELL.init_with(move || $val) |
| 32 | }}; | 32 | }}; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| @@ -116,7 +116,7 @@ async fn main(spawner: Spawner) { | |||
| 116 | control_buf: [u8; 128], | 116 | control_buf: [u8; 128], |
| 117 | serial_state: State<'static>, | 117 | serial_state: State<'static>, |
| 118 | } | 118 | } |
| 119 | let res: &mut Resources = forever!(Resources { | 119 | let res: &mut Resources = singleton!(Resources { |
| 120 | device_descriptor: [0; 256], | 120 | device_descriptor: [0; 256], |
| 121 | config_descriptor: [0; 256], | 121 | config_descriptor: [0; 256], |
| 122 | bos_descriptor: [0; 256], | 122 | bos_descriptor: [0; 256], |
| @@ -174,10 +174,10 @@ async fn main(spawner: Spawner) { | |||
| 174 | 174 | ||
| 175 | // Init network stack | 175 | // Init network stack |
| 176 | let device = Device { mac_addr: our_mac_addr }; | 176 | let device = Device { mac_addr: our_mac_addr }; |
| 177 | let stack = &*forever!(Stack::new( | 177 | let stack = &*singleton!(Stack::new( |
| 178 | device, | 178 | device, |
| 179 | config, | 179 | config, |
| 180 | forever!(StackResources::<1, 2, 8>::new()), | 180 | singleton!(StackResources::<1, 2, 8>::new()), |
| 181 | seed | 181 | seed |
| 182 | )); | 182 | )); |
| 183 | 183 | ||
diff --git a/examples/nrf/src/bin/usb_hid_keyboard.rs b/examples/nrf/src/bin/usb_hid_keyboard.rs index cf0078eec..ba2159c72 100644 --- a/examples/nrf/src/bin/usb_hid_keyboard.rs +++ b/examples/nrf/src/bin/usb_hid_keyboard.rs | |||
| @@ -8,14 +8,14 @@ use core::sync::atomic::{AtomicBool, Ordering}; | |||
| 8 | 8 | ||
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_futures::{select, Either}; | ||
| 11 | use embassy_nrf::gpio::{Input, Pin, Pull}; | 12 | use embassy_nrf::gpio::{Input, Pin, Pull}; |
| 12 | use embassy_nrf::usb::{Driver, PowerUsb}; | 13 | use embassy_nrf::usb::{Driver, PowerUsb}; |
| 13 | use embassy_nrf::{interrupt, pac}; | 14 | use embassy_nrf::{interrupt, pac}; |
| 15 | use embassy_sync::signal::Signal; | ||
| 14 | use embassy_usb::control::OutResponse; | 16 | use embassy_usb::control::OutResponse; |
| 15 | use embassy_usb::{Builder, Config, DeviceStateHandler}; | 17 | use embassy_usb::{Builder, Config, DeviceStateHandler}; |
| 16 | use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State}; | 18 | use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State}; |
| 17 | use embassy_util::channel::signal::Signal; | ||
| 18 | use embassy_util::{select, Either}; | ||
| 19 | use futures::future::join; | 19 | use futures::future::join; |
| 20 | use usbd_hid::descriptor::{KeyboardReport, SerializedDescriptor}; | 20 | use usbd_hid::descriptor::{KeyboardReport, SerializedDescriptor}; |
| 21 | use {defmt_rtt as _, panic_probe as _}; | 21 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/nrf/src/bin/usb_serial_multitask.rs b/examples/nrf/src/bin/usb_serial_multitask.rs index 4c1a93087..d62d7e520 100644 --- a/examples/nrf/src/bin/usb_serial_multitask.rs +++ b/examples/nrf/src/bin/usb_serial_multitask.rs | |||
| @@ -12,7 +12,7 @@ use embassy_nrf::{interrupt, pac, peripherals}; | |||
| 12 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 13 | use embassy_usb::{Builder, Config, UsbDevice}; | 13 | use embassy_usb::{Builder, Config, UsbDevice}; |
| 14 | use embassy_usb_serial::{CdcAcmClass, State}; | 14 | use embassy_usb_serial::{CdcAcmClass, State}; |
| 15 | use embassy_util::Forever; | 15 | use static_cell::StaticCell; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 17 | ||
| 18 | type MyDriver = Driver<'static, peripherals::USBD, PowerUsb>; | 18 | type MyDriver = Driver<'static, peripherals::USBD, PowerUsb>; |
| @@ -67,8 +67,8 @@ async fn main(spawner: Spawner) { | |||
| 67 | control_buf: [u8; 64], | 67 | control_buf: [u8; 64], |
| 68 | serial_state: State<'static>, | 68 | serial_state: State<'static>, |
| 69 | } | 69 | } |
| 70 | static RESOURCES: Forever<Resources> = Forever::new(); | 70 | static RESOURCES: StaticCell<Resources> = StaticCell::new(); |
| 71 | let res = RESOURCES.put(Resources { | 71 | let res = RESOURCES.init(Resources { |
| 72 | device_descriptor: [0; 256], | 72 | device_descriptor: [0; 256], |
| 73 | config_descriptor: [0; 256], | 73 | config_descriptor: [0; 256], |
| 74 | bos_descriptor: [0; 256], | 74 | bos_descriptor: [0; 256], |
diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index c2dcf429a..d804a660b 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml | |||
| @@ -5,7 +5,7 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } |
| 11 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac"] } | 11 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac"] } |
diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index b7009017c..c7cec6b19 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-std-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["log"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "std", "nightly", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "std", "nightly", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["log", "std", "nightly"] } | 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["log", "std", "nightly"] } |
| 10 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "log", "medium-ethernet", "tcp", "udp", "dhcpv4", "pool-16"] } | 10 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "log", "medium-ethernet", "tcp", "udp", "dhcpv4", "pool-16"] } |
| @@ -20,3 +20,4 @@ libc = "0.2.101" | |||
| 20 | clap = { version = "3.0.0-beta.5", features = ["derive"] } | 20 | clap = { version = "3.0.0-beta.5", features = ["derive"] } |
| 21 | rand_core = { version = "0.6.3", features = ["std"] } | 21 | rand_core = { version = "0.6.3", features = ["std"] } |
| 22 | heapless = { version = "0.7.5", default-features = false } | 22 | heapless = { version = "0.7.5", default-features = false } |
| 23 | static_cell = "1.0" | ||
diff --git a/examples/std/src/bin/net.rs b/examples/std/src/bin/net.rs index 528609260..9b1450b72 100644 --- a/examples/std/src/bin/net.rs +++ b/examples/std/src/bin/net.rs | |||
| @@ -4,22 +4,22 @@ use clap::Parser; | |||
| 4 | use embassy_executor::{Executor, Spawner}; | 4 | use embassy_executor::{Executor, Spawner}; |
| 5 | use embassy_net::tcp::TcpSocket; | 5 | use embassy_net::tcp::TcpSocket; |
| 6 | use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, Stack, StackResources}; | 6 | use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, Stack, StackResources}; |
| 7 | use embassy_util::Forever; | ||
| 8 | use embedded_io::asynch::Write; | 7 | use embedded_io::asynch::Write; |
| 9 | use heapless::Vec; | 8 | use heapless::Vec; |
| 10 | use log::*; | 9 | use log::*; |
| 11 | use rand_core::{OsRng, RngCore}; | 10 | use rand_core::{OsRng, RngCore}; |
| 11 | use static_cell::StaticCell; | ||
| 12 | 12 | ||
| 13 | #[path = "../tuntap.rs"] | 13 | #[path = "../tuntap.rs"] |
| 14 | mod tuntap; | 14 | mod tuntap; |
| 15 | 15 | ||
| 16 | use crate::tuntap::TunTapDevice; | 16 | use crate::tuntap::TunTapDevice; |
| 17 | 17 | ||
| 18 | macro_rules! forever { | 18 | macro_rules! singleton { |
| 19 | ($val:expr) => {{ | 19 | ($val:expr) => {{ |
| 20 | type T = impl Sized; | 20 | type T = impl Sized; |
| 21 | static FOREVER: Forever<T> = Forever::new(); | 21 | static STATIC_CELL: StaticCell<T> = StaticCell::new(); |
| 22 | FOREVER.put_with(move || $val) | 22 | STATIC_CELL.init_with(move || $val) |
| 23 | }}; | 23 | }}; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| @@ -63,10 +63,10 @@ async fn main_task(spawner: Spawner) { | |||
| 63 | let seed = u64::from_le_bytes(seed); | 63 | let seed = u64::from_le_bytes(seed); |
| 64 | 64 | ||
| 65 | // Init network stack | 65 | // Init network stack |
| 66 | let stack = &*forever!(Stack::new( | 66 | let stack = &*singleton!(Stack::new( |
| 67 | device, | 67 | device, |
| 68 | config, | 68 | config, |
| 69 | forever!(StackResources::<1, 2, 8>::new()), | 69 | singleton!(StackResources::<1, 2, 8>::new()), |
| 70 | seed | 70 | seed |
| 71 | )); | 71 | )); |
| 72 | 72 | ||
| @@ -97,7 +97,7 @@ async fn main_task(spawner: Spawner) { | |||
| 97 | } | 97 | } |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | static EXECUTOR: Forever<Executor> = Forever::new(); | 100 | static EXECUTOR: StaticCell<Executor> = StaticCell::new(); |
| 101 | 101 | ||
| 102 | fn main() { | 102 | fn main() { |
| 103 | env_logger::builder() | 103 | env_logger::builder() |
| @@ -106,7 +106,7 @@ fn main() { | |||
| 106 | .format_timestamp_nanos() | 106 | .format_timestamp_nanos() |
| 107 | .init(); | 107 | .init(); |
| 108 | 108 | ||
| 109 | let executor = EXECUTOR.put(Executor::new()); | 109 | let executor = EXECUTOR.init(Executor::new()); |
| 110 | executor.run(|spawner| { | 110 | executor.run(|spawner| { |
| 111 | spawner.spawn(main_task(spawner)).unwrap(); | 111 | spawner.spawn(main_task(spawner)).unwrap(); |
| 112 | }); | 112 | }); |
diff --git a/examples/std/src/bin/net_udp.rs b/examples/std/src/bin/net_udp.rs index 07e11c385..392a97f0d 100644 --- a/examples/std/src/bin/net_udp.rs +++ b/examples/std/src/bin/net_udp.rs | |||
| @@ -4,21 +4,21 @@ use clap::Parser; | |||
| 4 | use embassy_executor::{Executor, Spawner}; | 4 | use embassy_executor::{Executor, Spawner}; |
| 5 | use embassy_net::udp::UdpSocket; | 5 | use embassy_net::udp::UdpSocket; |
| 6 | use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, PacketMetadata, Stack, StackResources}; | 6 | use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, PacketMetadata, Stack, StackResources}; |
| 7 | use embassy_util::Forever; | ||
| 8 | use heapless::Vec; | 7 | use heapless::Vec; |
| 9 | use log::*; | 8 | use log::*; |
| 10 | use rand_core::{OsRng, RngCore}; | 9 | use rand_core::{OsRng, RngCore}; |
| 10 | use static_cell::StaticCell; | ||
| 11 | 11 | ||
| 12 | #[path = "../tuntap.rs"] | 12 | #[path = "../tuntap.rs"] |
| 13 | mod tuntap; | 13 | mod tuntap; |
| 14 | 14 | ||
| 15 | use crate::tuntap::TunTapDevice; | 15 | use crate::tuntap::TunTapDevice; |
| 16 | 16 | ||
| 17 | macro_rules! forever { | 17 | macro_rules! singleton { |
| 18 | ($val:expr) => {{ | 18 | ($val:expr) => {{ |
| 19 | type T = impl Sized; | 19 | type T = impl Sized; |
| 20 | static FOREVER: Forever<T> = Forever::new(); | 20 | static STATIC_CELL: StaticCell<T> = StaticCell::new(); |
| 21 | FOREVER.put_with(move || $val) | 21 | STATIC_CELL.init_with(move || $val) |
| 22 | }}; | 22 | }}; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| @@ -62,10 +62,10 @@ async fn main_task(spawner: Spawner) { | |||
| 62 | let seed = u64::from_le_bytes(seed); | 62 | let seed = u64::from_le_bytes(seed); |
| 63 | 63 | ||
| 64 | // Init network stack | 64 | // Init network stack |
| 65 | let stack = &*forever!(Stack::new( | 65 | let stack = &*singleton!(Stack::new( |
| 66 | device, | 66 | device, |
| 67 | config, | 67 | config, |
| 68 | forever!(StackResources::<1, 2, 8>::new()), | 68 | singleton!(StackResources::<1, 2, 8>::new()), |
| 69 | seed | 69 | seed |
| 70 | )); | 70 | )); |
| 71 | 71 | ||
| @@ -93,7 +93,7 @@ async fn main_task(spawner: Spawner) { | |||
| 93 | } | 93 | } |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | static EXECUTOR: Forever<Executor> = Forever::new(); | 96 | static EXECUTOR: StaticCell<Executor> = StaticCell::new(); |
| 97 | 97 | ||
| 98 | fn main() { | 98 | fn main() { |
| 99 | env_logger::builder() | 99 | env_logger::builder() |
| @@ -102,7 +102,7 @@ fn main() { | |||
| 102 | .format_timestamp_nanos() | 102 | .format_timestamp_nanos() |
| 103 | .init(); | 103 | .init(); |
| 104 | 104 | ||
| 105 | let executor = EXECUTOR.put(Executor::new()); | 105 | let executor = EXECUTOR.init(Executor::new()); |
| 106 | executor.run(|spawner| { | 106 | executor.run(|spawner| { |
| 107 | spawner.spawn(main_task(spawner)).unwrap(); | 107 | spawner.spawn(main_task(spawner)).unwrap(); |
| 108 | }); | 108 | }); |
diff --git a/examples/std/src/bin/serial.rs b/examples/std/src/bin/serial.rs index 35cba4cee..85ee54f70 100644 --- a/examples/std/src/bin/serial.rs +++ b/examples/std/src/bin/serial.rs | |||
| @@ -5,10 +5,10 @@ mod serial_port; | |||
| 5 | 5 | ||
| 6 | use async_io::Async; | 6 | use async_io::Async; |
| 7 | use embassy_executor::Executor; | 7 | use embassy_executor::Executor; |
| 8 | use embassy_util::Forever; | ||
| 9 | use embedded_io::asynch::Read; | 8 | use embedded_io::asynch::Read; |
| 10 | use log::*; | 9 | use log::*; |
| 11 | use nix::sys::termios; | 10 | use nix::sys::termios; |
| 11 | use static_cell::StaticCell; | ||
| 12 | 12 | ||
| 13 | use self::serial_port::SerialPort; | 13 | use self::serial_port::SerialPort; |
| 14 | 14 | ||
| @@ -40,7 +40,7 @@ async fn run() { | |||
| 40 | } | 40 | } |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | static EXECUTOR: Forever<Executor> = Forever::new(); | 43 | static EXECUTOR: StaticCell<Executor> = StaticCell::new(); |
| 44 | 44 | ||
| 45 | fn main() { | 45 | fn main() { |
| 46 | env_logger::builder() | 46 | env_logger::builder() |
| @@ -49,7 +49,7 @@ fn main() { | |||
| 49 | .format_timestamp_nanos() | 49 | .format_timestamp_nanos() |
| 50 | .init(); | 50 | .init(); |
| 51 | 51 | ||
| 52 | let executor = EXECUTOR.put(Executor::new()); | 52 | let executor = EXECUTOR.init(Executor::new()); |
| 53 | executor.run(|spawner| { | 53 | executor.run(|spawner| { |
| 54 | spawner.spawn(run()).unwrap(); | 54 | spawner.spawn(run()).unwrap(); |
| 55 | }); | 55 | }); |
diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index 8476200d4..cd2995d2c 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml | |||
| @@ -11,7 +11,7 @@ cortex-m-rt = "0.7.0" | |||
| 11 | defmt = "0.3" | 11 | defmt = "0.3" |
| 12 | defmt-rtt = "0.3" | 12 | defmt-rtt = "0.3" |
| 13 | panic-probe = "0.3" | 13 | panic-probe = "0.3" |
| 14 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 14 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 15 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 15 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 16 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | 16 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } |
| 17 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "memory-x", "stm32f030f4", "time-driver-any"] } | 17 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "memory-x", "stm32f030f4", "time-driver-any"] } |
diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml index fbc96400c..8660e743d 100644 --- a/examples/stm32f1/Cargo.toml +++ b/examples/stm32f1/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-stm32f1-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any"] } |
diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml index 27894df50..b4bff4d85 100644 --- a/examples/stm32f2/Cargo.toml +++ b/examples/stm32f2/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-stm32f2-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } |
diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index b5ea28bb6..d152b145f 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-stm32f3-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } |
| @@ -23,3 +23,4 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa | |||
| 23 | heapless = { version = "0.7.5", default-features = false } | 23 | heapless = { version = "0.7.5", default-features = false } |
| 24 | nb = "1.0.0" | 24 | nb = "1.0.0" |
| 25 | embedded-storage = "0.3.0" | 25 | embedded-storage = "0.3.0" |
| 26 | static_cell = "1.0" | ||
diff --git a/examples/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs index 61fc6dcab..02c475f66 100644 --- a/examples/stm32f3/src/bin/button_events.rs +++ b/examples/stm32f3/src/bin/button_events.rs | |||
| @@ -15,9 +15,9 @@ use embassy_executor::Spawner; | |||
| 15 | use embassy_stm32::exti::ExtiInput; | 15 | use embassy_stm32::exti::ExtiInput; |
| 16 | use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; | 16 | use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; |
| 17 | use embassy_stm32::peripherals::PA0; | 17 | use embassy_stm32::peripherals::PA0; |
| 18 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | ||
| 19 | use embassy_sync::channel::Channel; | ||
| 18 | use embassy_time::{with_timeout, Duration, Timer}; | 20 | use embassy_time::{with_timeout, Duration, Timer}; |
| 19 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | ||
| 20 | use embassy_util::channel::mpmc::Channel; | ||
| 21 | use {defmt_rtt as _, panic_probe as _}; | 21 | use {defmt_rtt as _, panic_probe as _}; |
| 22 | 22 | ||
| 23 | struct Leds<'a> { | 23 | struct Leds<'a> { |
diff --git a/examples/stm32f3/src/bin/multiprio.rs b/examples/stm32f3/src/bin/multiprio.rs index e96c31249..9e8228a4b 100644 --- a/examples/stm32f3/src/bin/multiprio.rs +++ b/examples/stm32f3/src/bin/multiprio.rs | |||
| @@ -63,7 +63,7 @@ use embassy_stm32::executor::{Executor, InterruptExecutor}; | |||
| 63 | use embassy_stm32::interrupt; | 63 | use embassy_stm32::interrupt; |
| 64 | use embassy_stm32::interrupt::InterruptExt; | 64 | use embassy_stm32::interrupt::InterruptExt; |
| 65 | use embassy_time::{Duration, Instant, Timer}; | 65 | use embassy_time::{Duration, Instant, Timer}; |
| 66 | use embassy_util::Forever; | 66 | use static_cell::StaticCell; |
| 67 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| 68 | 68 | ||
| 69 | #[embassy_executor::task] | 69 | #[embassy_executor::task] |
| @@ -108,9 +108,9 @@ async fn run_low() { | |||
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | static EXECUTOR_HIGH: Forever<InterruptExecutor<interrupt::UART4>> = Forever::new(); | 111 | static EXECUTOR_HIGH: StaticCell<InterruptExecutor<interrupt::UART4>> = StaticCell::new(); |
| 112 | static EXECUTOR_MED: Forever<InterruptExecutor<interrupt::UART5>> = Forever::new(); | 112 | static EXECUTOR_MED: StaticCell<InterruptExecutor<interrupt::UART5>> = StaticCell::new(); |
| 113 | static EXECUTOR_LOW: Forever<Executor> = Forever::new(); | 113 | static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new(); |
| 114 | 114 | ||
| 115 | #[entry] | 115 | #[entry] |
| 116 | fn main() -> ! { | 116 | fn main() -> ! { |
| @@ -121,19 +121,19 @@ fn main() -> ! { | |||
| 121 | // High-priority executor: SWI1_EGU1, priority level 6 | 121 | // High-priority executor: SWI1_EGU1, priority level 6 |
| 122 | let irq = interrupt::take!(UART4); | 122 | let irq = interrupt::take!(UART4); |
| 123 | irq.set_priority(interrupt::Priority::P6); | 123 | irq.set_priority(interrupt::Priority::P6); |
| 124 | let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq)); | 124 | let executor = EXECUTOR_HIGH.init(InterruptExecutor::new(irq)); |
| 125 | let spawner = executor.start(); | 125 | let spawner = executor.start(); |
| 126 | unwrap!(spawner.spawn(run_high())); | 126 | unwrap!(spawner.spawn(run_high())); |
| 127 | 127 | ||
| 128 | // Medium-priority executor: SWI0_EGU0, priority level 7 | 128 | // Medium-priority executor: SWI0_EGU0, priority level 7 |
| 129 | let irq = interrupt::take!(UART5); | 129 | let irq = interrupt::take!(UART5); |
| 130 | irq.set_priority(interrupt::Priority::P7); | 130 | irq.set_priority(interrupt::Priority::P7); |
| 131 | let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq)); | 131 | let executor = EXECUTOR_MED.init(InterruptExecutor::new(irq)); |
| 132 | let spawner = executor.start(); | 132 | let spawner = executor.start(); |
| 133 | unwrap!(spawner.spawn(run_med())); | 133 | unwrap!(spawner.spawn(run_med())); |
| 134 | 134 | ||
| 135 | // Low priority executor: runs in thread mode, using WFE/SEV | 135 | // Low priority executor: runs in thread mode, using WFE/SEV |
| 136 | let executor = EXECUTOR_LOW.put(Executor::new()); | 136 | let executor = EXECUTOR_LOW.init(Executor::new()); |
| 137 | executor.run(|spawner| { | 137 | executor.run(|spawner| { |
| 138 | unwrap!(spawner.spawn(run_low())); | 138 | unwrap!(spawner.spawn(run_low())); |
| 139 | }); | 139 | }); |
diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index 04a217aff..9bfdda92d 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml | |||
| @@ -5,7 +5,7 @@ version = "0.1.0" | |||
| 5 | 5 | ||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-32768hz"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-32768hz"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti"] } |
| @@ -23,6 +23,7 @@ heapless = { version = "0.7.5", default-features = false } | |||
| 23 | nb = "1.0.0" | 23 | nb = "1.0.0" |
| 24 | embedded-storage = "0.3.0" | 24 | embedded-storage = "0.3.0" |
| 25 | micromath = "2.0.0" | 25 | micromath = "2.0.0" |
| 26 | static_cell = "1.0" | ||
| 26 | 27 | ||
| 27 | usb-device = "0.2" | 28 | usb-device = "0.2" |
| 28 | usbd-serial = "0.1.1" | 29 | usbd-serial = "0.1.1" |
diff --git a/examples/stm32f4/src/bin/multiprio.rs b/examples/stm32f4/src/bin/multiprio.rs index e96c31249..9e8228a4b 100644 --- a/examples/stm32f4/src/bin/multiprio.rs +++ b/examples/stm32f4/src/bin/multiprio.rs | |||
| @@ -63,7 +63,7 @@ use embassy_stm32::executor::{Executor, InterruptExecutor}; | |||
| 63 | use embassy_stm32::interrupt; | 63 | use embassy_stm32::interrupt; |
| 64 | use embassy_stm32::interrupt::InterruptExt; | 64 | use embassy_stm32::interrupt::InterruptExt; |
| 65 | use embassy_time::{Duration, Instant, Timer}; | 65 | use embassy_time::{Duration, Instant, Timer}; |
| 66 | use embassy_util::Forever; | 66 | use static_cell::StaticCell; |
| 67 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| 68 | 68 | ||
| 69 | #[embassy_executor::task] | 69 | #[embassy_executor::task] |
| @@ -108,9 +108,9 @@ async fn run_low() { | |||
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | static EXECUTOR_HIGH: Forever<InterruptExecutor<interrupt::UART4>> = Forever::new(); | 111 | static EXECUTOR_HIGH: StaticCell<InterruptExecutor<interrupt::UART4>> = StaticCell::new(); |
| 112 | static EXECUTOR_MED: Forever<InterruptExecutor<interrupt::UART5>> = Forever::new(); | 112 | static EXECUTOR_MED: StaticCell<InterruptExecutor<interrupt::UART5>> = StaticCell::new(); |
| 113 | static EXECUTOR_LOW: Forever<Executor> = Forever::new(); | 113 | static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new(); |
| 114 | 114 | ||
| 115 | #[entry] | 115 | #[entry] |
| 116 | fn main() -> ! { | 116 | fn main() -> ! { |
| @@ -121,19 +121,19 @@ fn main() -> ! { | |||
| 121 | // High-priority executor: SWI1_EGU1, priority level 6 | 121 | // High-priority executor: SWI1_EGU1, priority level 6 |
| 122 | let irq = interrupt::take!(UART4); | 122 | let irq = interrupt::take!(UART4); |
| 123 | irq.set_priority(interrupt::Priority::P6); | 123 | irq.set_priority(interrupt::Priority::P6); |
| 124 | let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq)); | 124 | let executor = EXECUTOR_HIGH.init(InterruptExecutor::new(irq)); |
| 125 | let spawner = executor.start(); | 125 | let spawner = executor.start(); |
| 126 | unwrap!(spawner.spawn(run_high())); | 126 | unwrap!(spawner.spawn(run_high())); |
| 127 | 127 | ||
| 128 | // Medium-priority executor: SWI0_EGU0, priority level 7 | 128 | // Medium-priority executor: SWI0_EGU0, priority level 7 |
| 129 | let irq = interrupt::take!(UART5); | 129 | let irq = interrupt::take!(UART5); |
| 130 | irq.set_priority(interrupt::Priority::P7); | 130 | irq.set_priority(interrupt::Priority::P7); |
| 131 | let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq)); | 131 | let executor = EXECUTOR_MED.init(InterruptExecutor::new(irq)); |
| 132 | let spawner = executor.start(); | 132 | let spawner = executor.start(); |
| 133 | unwrap!(spawner.spawn(run_med())); | 133 | unwrap!(spawner.spawn(run_med())); |
| 134 | 134 | ||
| 135 | // Low priority executor: runs in thread mode, using WFE/SEV | 135 | // Low priority executor: runs in thread mode, using WFE/SEV |
| 136 | let executor = EXECUTOR_LOW.put(Executor::new()); | 136 | let executor = EXECUTOR_LOW.init(Executor::new()); |
| 137 | executor.run(|spawner| { | 137 | executor.run(|spawner| { |
| 138 | unwrap!(spawner.spawn(run_low())); | 138 | unwrap!(spawner.spawn(run_low())); |
| 139 | }); | 139 | }); |
diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 29d6da4d8..a446fe3fb 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-stm32f7-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "net", "stm32f767zi", "unstable-pac", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "net", "stm32f767zi", "unstable-pac", "time-driver-any", "exti"] } |
| @@ -24,3 +24,4 @@ nb = "1.0.0" | |||
| 24 | rand_core = "0.6.3" | 24 | rand_core = "0.6.3" |
| 25 | critical-section = "1.1" | 25 | critical-section = "1.1" |
| 26 | embedded-storage = "0.3.0" | 26 | embedded-storage = "0.3.0" |
| 27 | static_cell = "1.0" | ||
diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index bdffabcb3..5202edf62 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs | |||
| @@ -13,16 +13,16 @@ use embassy_stm32::rng::Rng; | |||
| 13 | use embassy_stm32::time::mhz; | 13 | use embassy_stm32::time::mhz; |
| 14 | use embassy_stm32::{interrupt, Config}; | 14 | use embassy_stm32::{interrupt, Config}; |
| 15 | use embassy_time::{Duration, Timer}; | 15 | use embassy_time::{Duration, Timer}; |
| 16 | use embassy_util::Forever; | ||
| 17 | use embedded_io::asynch::Write; | 16 | use embedded_io::asynch::Write; |
| 18 | use rand_core::RngCore; | 17 | use rand_core::RngCore; |
| 18 | use static_cell::StaticCell; | ||
| 19 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 20 | ||
| 21 | macro_rules! forever { | 21 | macro_rules! singleton { |
| 22 | ($val:expr) => {{ | 22 | ($val:expr) => {{ |
| 23 | type T = impl Sized; | 23 | type T = impl Sized; |
| 24 | static FOREVER: Forever<T> = Forever::new(); | 24 | static STATIC_CELL: StaticCell<T> = StaticCell::new(); |
| 25 | FOREVER.put_with(move || $val) | 25 | STATIC_CELL.init_with(move || $val) |
| 26 | }}; | 26 | }}; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| @@ -52,7 +52,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 52 | 52 | ||
| 53 | let device = unsafe { | 53 | let device = unsafe { |
| 54 | Ethernet::new( | 54 | Ethernet::new( |
| 55 | forever!(State::new()), | 55 | singleton!(State::new()), |
| 56 | p.ETH, | 56 | p.ETH, |
| 57 | eth_int, | 57 | eth_int, |
| 58 | p.PA1, | 58 | p.PA1, |
| @@ -78,10 +78,10 @@ async fn main(spawner: Spawner) -> ! { | |||
| 78 | //}); | 78 | //}); |
| 79 | 79 | ||
| 80 | // Init network stack | 80 | // Init network stack |
| 81 | let stack = &*forever!(Stack::new( | 81 | let stack = &*singleton!(Stack::new( |
| 82 | device, | 82 | device, |
| 83 | config, | 83 | config, |
| 84 | forever!(StackResources::<1, 2, 8>::new()), | 84 | singleton!(StackResources::<1, 2, 8>::new()), |
| 85 | seed | 85 | seed |
| 86 | )); | 86 | )); |
| 87 | 87 | ||
diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml index 5c80d43eb..30f2b86f8 100644 --- a/examples/stm32g0/Cargo.toml +++ b/examples/stm32g0/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-stm32g0-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } |
diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml index 74c645cf5..f81df0b70 100644 --- a/examples/stm32g4/Cargo.toml +++ b/examples/stm32g4/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-stm32g4-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } |
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index a416796ea..0f76f3226 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-stm32h7-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "net", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "net", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } |
| @@ -28,6 +28,7 @@ critical-section = "1.1" | |||
| 28 | micromath = "2.0.0" | 28 | micromath = "2.0.0" |
| 29 | stm32-fmc = "0.2.4" | 29 | stm32-fmc = "0.2.4" |
| 30 | embedded-storage = "0.3.0" | 30 | embedded-storage = "0.3.0" |
| 31 | static_cell = "1.0" | ||
| 31 | 32 | ||
| 32 | # cargo build/run | 33 | # cargo build/run |
| 33 | [profile.dev] | 34 | [profile.dev] |
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 83210bcb5..4ccc0b5ef 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs | |||
| @@ -13,16 +13,16 @@ use embassy_stm32::rng::Rng; | |||
| 13 | use embassy_stm32::time::mhz; | 13 | use embassy_stm32::time::mhz; |
| 14 | use embassy_stm32::{interrupt, Config}; | 14 | use embassy_stm32::{interrupt, Config}; |
| 15 | use embassy_time::{Duration, Timer}; | 15 | use embassy_time::{Duration, Timer}; |
| 16 | use embassy_util::Forever; | ||
| 17 | use embedded_io::asynch::Write; | 16 | use embedded_io::asynch::Write; |
| 18 | use rand_core::RngCore; | 17 | use rand_core::RngCore; |
| 18 | use static_cell::StaticCell; | ||
| 19 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 20 | ||
| 21 | macro_rules! forever { | 21 | macro_rules! singleton { |
| 22 | ($val:expr) => {{ | 22 | ($val:expr) => {{ |
| 23 | type T = impl Sized; | 23 | type T = impl Sized; |
| 24 | static FOREVER: Forever<T> = Forever::new(); | 24 | static STATIC_CELL: StaticCell<T> = StaticCell::new(); |
| 25 | FOREVER.put_with(move || $val) | 25 | STATIC_CELL.init_with(move || $val) |
| 26 | }}; | 26 | }}; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| @@ -53,7 +53,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 53 | 53 | ||
| 54 | let device = unsafe { | 54 | let device = unsafe { |
| 55 | Ethernet::new( | 55 | Ethernet::new( |
| 56 | forever!(State::new()), | 56 | singleton!(State::new()), |
| 57 | p.ETH, | 57 | p.ETH, |
| 58 | eth_int, | 58 | eth_int, |
| 59 | p.PA1, | 59 | p.PA1, |
| @@ -79,10 +79,10 @@ async fn main(spawner: Spawner) -> ! { | |||
| 79 | //}); | 79 | //}); |
| 80 | 80 | ||
| 81 | // Init network stack | 81 | // Init network stack |
| 82 | let stack = &*forever!(Stack::new( | 82 | let stack = &*singleton!(Stack::new( |
| 83 | device, | 83 | device, |
| 84 | config, | 84 | config, |
| 85 | forever!(StackResources::<1, 2, 8>::new()), | 85 | singleton!(StackResources::<1, 2, 8>::new()), |
| 86 | seed | 86 | seed |
| 87 | )); | 87 | )); |
| 88 | 88 | ||
diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index 99946f504..64fd84141 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs | |||
| @@ -13,17 +13,17 @@ use embassy_stm32::rng::Rng; | |||
| 13 | use embassy_stm32::time::mhz; | 13 | use embassy_stm32::time::mhz; |
| 14 | use embassy_stm32::{interrupt, Config}; | 14 | use embassy_stm32::{interrupt, Config}; |
| 15 | use embassy_time::{Duration, Timer}; | 15 | use embassy_time::{Duration, Timer}; |
| 16 | use embassy_util::Forever; | ||
| 17 | use embedded_io::asynch::Write; | 16 | use embedded_io::asynch::Write; |
| 18 | use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; | 17 | use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; |
| 19 | use rand_core::RngCore; | 18 | use rand_core::RngCore; |
| 19 | use static_cell::StaticCell; | ||
| 20 | use {defmt_rtt as _, panic_probe as _}; | 20 | use {defmt_rtt as _, panic_probe as _}; |
| 21 | 21 | ||
| 22 | macro_rules! forever { | 22 | macro_rules! singleton { |
| 23 | ($val:expr) => {{ | 23 | ($val:expr) => {{ |
| 24 | type T = impl Sized; | 24 | type T = impl Sized; |
| 25 | static FOREVER: Forever<T> = Forever::new(); | 25 | static STATIC_CELL: StaticCell<T> = StaticCell::new(); |
| 26 | FOREVER.put_with(move || $val) | 26 | STATIC_CELL.init_with(move || $val) |
| 27 | }}; | 27 | }}; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| @@ -54,7 +54,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 54 | 54 | ||
| 55 | let device = unsafe { | 55 | let device = unsafe { |
| 56 | Ethernet::new( | 56 | Ethernet::new( |
| 57 | forever!(State::new()), | 57 | singleton!(State::new()), |
| 58 | p.ETH, | 58 | p.ETH, |
| 59 | eth_int, | 59 | eth_int, |
| 60 | p.PA1, | 60 | p.PA1, |
| @@ -80,10 +80,10 @@ async fn main(spawner: Spawner) -> ! { | |||
| 80 | //}); | 80 | //}); |
| 81 | 81 | ||
| 82 | // Init network stack | 82 | // Init network stack |
| 83 | let stack = &*forever!(Stack::new( | 83 | let stack = &*singleton!(Stack::new( |
| 84 | device, | 84 | device, |
| 85 | config, | 85 | config, |
| 86 | forever!(StackResources::<1, 2, 8>::new()), | 86 | singleton!(StackResources::<1, 2, 8>::new()), |
| 87 | seed | 87 | seed |
| 88 | )); | 88 | )); |
| 89 | 89 | ||
diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs index be2ac268e..cc3e4e3ca 100644 --- a/examples/stm32h7/src/bin/signal.rs +++ b/examples/stm32h7/src/bin/signal.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_sync::signal::Signal; | ||
| 7 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::{Duration, Timer}; |
| 8 | use embassy_util::channel::signal::Signal; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | static SIGNAL: Signal<u32> = Signal::new(); | 11 | static SIGNAL: Signal<u32> = Signal::new(); |
diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index c28f937a8..1f407f002 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs | |||
| @@ -12,8 +12,8 @@ use embassy_stm32::dma::NoDma; | |||
| 12 | use embassy_stm32::peripherals::SPI3; | 12 | use embassy_stm32::peripherals::SPI3; |
| 13 | use embassy_stm32::time::mhz; | 13 | use embassy_stm32::time::mhz; |
| 14 | use embassy_stm32::{spi, Config}; | 14 | use embassy_stm32::{spi, Config}; |
| 15 | use embassy_util::Forever; | ||
| 16 | use heapless::String; | 15 | use heapless::String; |
| 16 | use static_cell::StaticCell; | ||
| 17 | use {defmt_rtt as _, panic_probe as _}; | 17 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | 18 | ||
| 19 | #[embassy_executor::task] | 19 | #[embassy_executor::task] |
| @@ -31,7 +31,7 @@ async fn main_task(mut spi: spi::Spi<'static, SPI3, NoDma, NoDma>) { | |||
| 31 | } | 31 | } |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | static EXECUTOR: Forever<Executor> = Forever::new(); | 34 | static EXECUTOR: StaticCell<Executor> = StaticCell::new(); |
| 35 | 35 | ||
| 36 | #[entry] | 36 | #[entry] |
| 37 | fn main() -> ! { | 37 | fn main() -> ! { |
| @@ -54,7 +54,7 @@ fn main() -> ! { | |||
| 54 | spi::Config::default(), | 54 | spi::Config::default(), |
| 55 | ); | 55 | ); |
| 56 | 56 | ||
| 57 | let executor = EXECUTOR.put(Executor::new()); | 57 | let executor = EXECUTOR.init(Executor::new()); |
| 58 | 58 | ||
| 59 | executor.run(|spawner| { | 59 | executor.run(|spawner| { |
| 60 | unwrap!(spawner.spawn(main_task(spi))); | 60 | unwrap!(spawner.spawn(main_task(spi))); |
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index 6c78c194f..53004fc9b 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs | |||
| @@ -11,8 +11,8 @@ use embassy_executor::Executor; | |||
| 11 | use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; | 11 | use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; |
| 12 | use embassy_stm32::time::mhz; | 12 | use embassy_stm32::time::mhz; |
| 13 | use embassy_stm32::{spi, Config}; | 13 | use embassy_stm32::{spi, Config}; |
| 14 | use embassy_util::Forever; | ||
| 15 | use heapless::String; | 14 | use heapless::String; |
| 15 | use static_cell::StaticCell; | ||
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 17 | ||
| 18 | #[embassy_executor::task] | 18 | #[embassy_executor::task] |
| @@ -27,7 +27,7 @@ async fn main_task(mut spi: spi::Spi<'static, SPI3, DMA1_CH3, DMA1_CH4>) { | |||
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | static EXECUTOR: Forever<Executor> = Forever::new(); | 30 | static EXECUTOR: StaticCell<Executor> = StaticCell::new(); |
| 31 | 31 | ||
| 32 | #[entry] | 32 | #[entry] |
| 33 | fn main() -> ! { | 33 | fn main() -> ! { |
| @@ -50,7 +50,7 @@ fn main() -> ! { | |||
| 50 | spi::Config::default(), | 50 | spi::Config::default(), |
| 51 | ); | 51 | ); |
| 52 | 52 | ||
| 53 | let executor = EXECUTOR.put(Executor::new()); | 53 | let executor = EXECUTOR.init(Executor::new()); |
| 54 | 54 | ||
| 55 | executor.run(|spawner| { | 55 | executor.run(|spawner| { |
| 56 | unwrap!(spawner.spawn(main_task(spi))); | 56 | unwrap!(spawner.spawn(main_task(spi))); |
diff --git a/examples/stm32h7/src/bin/usart.rs b/examples/stm32h7/src/bin/usart.rs index 1384d54c6..87c2b1253 100644 --- a/examples/stm32h7/src/bin/usart.rs +++ b/examples/stm32h7/src/bin/usart.rs | |||
| @@ -7,7 +7,7 @@ use defmt::*; | |||
| 7 | use embassy_executor::Executor; | 7 | use embassy_executor::Executor; |
| 8 | use embassy_stm32::dma::NoDma; | 8 | use embassy_stm32::dma::NoDma; |
| 9 | use embassy_stm32::usart::{Config, Uart}; | 9 | use embassy_stm32::usart::{Config, Uart}; |
| 10 | use embassy_util::Forever; | 10 | use static_cell::StaticCell; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[embassy_executor::task] | 13 | #[embassy_executor::task] |
| @@ -27,13 +27,13 @@ async fn main_task() { | |||
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | static EXECUTOR: Forever<Executor> = Forever::new(); | 30 | static EXECUTOR: StaticCell<Executor> = StaticCell::new(); |
| 31 | 31 | ||
| 32 | #[entry] | 32 | #[entry] |
| 33 | fn main() -> ! { | 33 | fn main() -> ! { |
| 34 | info!("Hello World!"); | 34 | info!("Hello World!"); |
| 35 | 35 | ||
| 36 | let executor = EXECUTOR.put(Executor::new()); | 36 | let executor = EXECUTOR.init(Executor::new()); |
| 37 | 37 | ||
| 38 | executor.run(|spawner| { | 38 | executor.run(|spawner| { |
| 39 | unwrap!(spawner.spawn(main_task())); | 39 | unwrap!(spawner.spawn(main_task())); |
diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs index f8d58bb84..3adffcbeb 100644 --- a/examples/stm32h7/src/bin/usart_dma.rs +++ b/examples/stm32h7/src/bin/usart_dma.rs | |||
| @@ -9,8 +9,8 @@ use defmt::*; | |||
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_stm32::dma::NoDma; | 10 | use embassy_stm32::dma::NoDma; |
| 11 | use embassy_stm32::usart::{Config, Uart}; | 11 | use embassy_stm32::usart::{Config, Uart}; |
| 12 | use embassy_util::Forever; | ||
| 13 | use heapless::String; | 12 | use heapless::String; |
| 13 | use static_cell::StaticCell; | ||
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
| 16 | #[embassy_executor::task] | 16 | #[embassy_executor::task] |
| @@ -30,13 +30,13 @@ async fn main_task() { | |||
| 30 | } | 30 | } |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | static EXECUTOR: Forever<Executor> = Forever::new(); | 33 | static EXECUTOR: StaticCell<Executor> = StaticCell::new(); |
| 34 | 34 | ||
| 35 | #[entry] | 35 | #[entry] |
| 36 | fn main() -> ! { | 36 | fn main() -> ! { |
| 37 | info!("Hello World!"); | 37 | info!("Hello World!"); |
| 38 | 38 | ||
| 39 | let executor = EXECUTOR.put(Executor::new()); | 39 | let executor = EXECUTOR.init(Executor::new()); |
| 40 | 40 | ||
| 41 | executor.run(|spawner| { | 41 | executor.run(|spawner| { |
| 42 | unwrap!(spawner.spawn(main_task())); | 42 | unwrap!(spawner.spawn(main_task())); |
diff --git a/examples/stm32h7/src/bin/usart_split.rs b/examples/stm32h7/src/bin/usart_split.rs index 64080ec45..df2b600f8 100644 --- a/examples/stm32h7/src/bin/usart_split.rs +++ b/examples/stm32h7/src/bin/usart_split.rs | |||
| @@ -7,8 +7,8 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_stm32::dma::NoDma; | 7 | use embassy_stm32::dma::NoDma; |
| 8 | use embassy_stm32::peripherals::{DMA1_CH1, UART7}; | 8 | use embassy_stm32::peripherals::{DMA1_CH1, UART7}; |
| 9 | use embassy_stm32::usart::{Config, Uart, UartRx}; | 9 | use embassy_stm32::usart::{Config, Uart, UartRx}; |
| 10 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | 10 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; |
| 11 | use embassy_util::channel::mpmc::Channel; | 11 | use embassy_sync::channel::Channel; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | #[embassy_executor::task] | 14 | #[embassy_executor::task] |
diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index fdb716d15..11751a21d 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml | |||
| @@ -8,7 +8,7 @@ default = ["nightly"] | |||
| 8 | nightly = ["embassy-stm32/nightly", "embassy-lora", "lorawan-device", "lorawan", "embedded-io/async"] | 8 | nightly = ["embassy-stm32/nightly", "embassy-lora", "lorawan-device", "lorawan", "embedded-io/async"] |
| 9 | 9 | ||
| 10 | [dependencies] | 10 | [dependencies] |
| 11 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 11 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 12 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 12 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 13 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | 13 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } |
| 14 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } | 14 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } |
| @@ -29,3 +29,4 @@ panic-probe = { version = "0.3", features = ["print-defmt"] } | |||
| 29 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 29 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 30 | heapless = { version = "0.7.5", default-features = false } | 30 | heapless = { version = "0.7.5", default-features = false } |
| 31 | embedded-hal = "0.2.6" | 31 | embedded-hal = "0.2.6" |
| 32 | static_cell = "1.0" | ||
diff --git a/examples/stm32l0/src/bin/raw_spawn.rs b/examples/stm32l0/src/bin/raw_spawn.rs index bd87e62a4..edc17304a 100644 --- a/examples/stm32l0/src/bin/raw_spawn.rs +++ b/examples/stm32l0/src/bin/raw_spawn.rs | |||
| @@ -8,7 +8,7 @@ use defmt::*; | |||
| 8 | use embassy_executor::raw::TaskStorage; | 8 | use embassy_executor::raw::TaskStorage; |
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::{Duration, Timer}; |
| 11 | use embassy_util::Forever; | 11 | use static_cell::StaticCell; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | async fn run1() { | 14 | async fn run1() { |
| @@ -25,14 +25,14 @@ async fn run2() { | |||
| 25 | } | 25 | } |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | static EXECUTOR: Forever<Executor> = Forever::new(); | 28 | static EXECUTOR: StaticCell<Executor> = StaticCell::new(); |
| 29 | 29 | ||
| 30 | #[entry] | 30 | #[entry] |
| 31 | fn main() -> ! { | 31 | fn main() -> ! { |
| 32 | info!("Hello World!"); | 32 | info!("Hello World!"); |
| 33 | 33 | ||
| 34 | let _p = embassy_stm32::init(Default::default()); | 34 | let _p = embassy_stm32::init(Default::default()); |
| 35 | let executor = EXECUTOR.put(Executor::new()); | 35 | let executor = EXECUTOR.init(Executor::new()); |
| 36 | 36 | ||
| 37 | let run1_task = TaskStorage::new(); | 37 | let run1_task = TaskStorage::new(); |
| 38 | let run2_task = TaskStorage::new(); | 38 | let run2_task = TaskStorage::new(); |
diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml index 43f844b67..18b35b305 100644 --- a/examples/stm32l1/Cargo.toml +++ b/examples/stm32l1/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-stm32l1-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } |
diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index eaffa253e..cb7238e4c 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml | |||
| @@ -6,7 +6,7 @@ version = "0.1.0" | |||
| 6 | [features] | 6 | [features] |
| 7 | 7 | ||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 9 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 10 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 10 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 11 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | 11 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } |
| 12 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } | 12 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } |
diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index 4d96d31fc..624c73c26 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml | |||
| @@ -6,7 +6,7 @@ version = "0.1.0" | |||
| 6 | [features] | 6 | [features] |
| 7 | 7 | ||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 9 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 10 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 10 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 11 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | 11 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } |
| 12 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "unstable-traits", "memory-x"] } | 12 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "unstable-traits", "memory-x"] } |
| @@ -28,3 +28,4 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa | |||
| 28 | heapless = { version = "0.7.5", default-features = false } | 28 | heapless = { version = "0.7.5", default-features = false } |
| 29 | rand_core = { version = "0.6.3", default-features = false } | 29 | rand_core = { version = "0.6.3", default-features = false } |
| 30 | embedded-io = { version = "0.3.0", features = ["async"] } | 30 | embedded-io = { version = "0.3.0", features = ["async"] } |
| 31 | static_cell = "1.0" | ||
diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index 7c53d03cc..3286f5c4d 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs | |||
| @@ -15,22 +15,22 @@ use embassy_stm32::rng::Rng; | |||
| 15 | use embassy_stm32::time::Hertz; | 15 | use embassy_stm32::time::Hertz; |
| 16 | use embassy_stm32::usb::Driver; | 16 | use embassy_stm32::usb::Driver; |
| 17 | use embassy_stm32::{interrupt, Config}; | 17 | use embassy_stm32::{interrupt, Config}; |
| 18 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | ||
| 19 | use embassy_sync::channel::Channel; | ||
| 18 | use embassy_usb::{Builder, UsbDevice}; | 20 | use embassy_usb::{Builder, UsbDevice}; |
| 19 | use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; | 21 | use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; |
| 20 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | ||
| 21 | use embassy_util::channel::mpmc::Channel; | ||
| 22 | use embassy_util::Forever; | ||
| 23 | use embedded_io::asynch::{Read, Write}; | 22 | use embedded_io::asynch::{Read, Write}; |
| 24 | use rand_core::RngCore; | 23 | use rand_core::RngCore; |
| 24 | use static_cell::StaticCell; | ||
| 25 | use {defmt_rtt as _, panic_probe as _}; | 25 | use {defmt_rtt as _, panic_probe as _}; |
| 26 | 26 | ||
| 27 | type MyDriver = Driver<'static, embassy_stm32::peripherals::USB>; | 27 | type MyDriver = Driver<'static, embassy_stm32::peripherals::USB>; |
| 28 | 28 | ||
| 29 | macro_rules! forever { | 29 | macro_rules! singleton { |
| 30 | ($val:expr) => {{ | 30 | ($val:expr) => {{ |
| 31 | type T = impl Sized; | 31 | type T = impl Sized; |
| 32 | static FOREVER: Forever<T> = Forever::new(); | 32 | static STATIC_CELL: StaticCell<T> = StaticCell::new(); |
| 33 | FOREVER.put_with(move || $val) | 33 | STATIC_CELL.init_with(move || $val) |
| 34 | }}; | 34 | }}; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -115,7 +115,7 @@ async fn main(spawner: Spawner) { | |||
| 115 | control_buf: [u8; 128], | 115 | control_buf: [u8; 128], |
| 116 | serial_state: State<'static>, | 116 | serial_state: State<'static>, |
| 117 | } | 117 | } |
| 118 | let res: &mut Resources = forever!(Resources { | 118 | let res: &mut Resources = singleton!(Resources { |
| 119 | device_descriptor: [0; 256], | 119 | device_descriptor: [0; 256], |
| 120 | config_descriptor: [0; 256], | 120 | config_descriptor: [0; 256], |
| 121 | bos_descriptor: [0; 256], | 121 | bos_descriptor: [0; 256], |
| @@ -171,10 +171,10 @@ async fn main(spawner: Spawner) { | |||
| 171 | 171 | ||
| 172 | // Init network stack | 172 | // Init network stack |
| 173 | let device = Device { mac_addr: our_mac_addr }; | 173 | let device = Device { mac_addr: our_mac_addr }; |
| 174 | let stack = &*forever!(Stack::new( | 174 | let stack = &*singleton!(Stack::new( |
| 175 | device, | 175 | device, |
| 176 | config, | 176 | config, |
| 177 | forever!(StackResources::<1, 2, 8>::new()), | 177 | singleton!(StackResources::<1, 2, 8>::new()), |
| 178 | seed | 178 | seed |
| 179 | )); | 179 | )); |
| 180 | 180 | ||
diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml index 48833664a..ff0ec9f42 100644 --- a/examples/stm32u5/Cargo.toml +++ b/examples/stm32u5/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-stm32u5-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } |
diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index b46300764..3b10da0ad 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-stm32wb-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55cc", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55cc", "time-driver-any", "exti"] } |
diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index ae33478af..5f6679f4b 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml | |||
| @@ -4,7 +4,7 @@ name = "embassy-stm32wl-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } | 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 8 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } | 9 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "subghz", "unstable-pac", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "subghz", "unstable-pac", "exti"] } |
diff --git a/examples/stm32wl/src/bin/subghz.rs b/examples/stm32wl/src/bin/subghz.rs index d16e3f5e4..c5e9bb597 100644 --- a/examples/stm32wl/src/bin/subghz.rs +++ b/examples/stm32wl/src/bin/subghz.rs | |||
| @@ -13,7 +13,7 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | |||
| 13 | use embassy_stm32::interrupt; | 13 | use embassy_stm32::interrupt; |
| 14 | use embassy_stm32::interrupt::{Interrupt, InterruptExt}; | 14 | use embassy_stm32::interrupt::{Interrupt, InterruptExt}; |
| 15 | use embassy_stm32::subghz::*; | 15 | use embassy_stm32::subghz::*; |
| 16 | use embassy_util::channel::signal::Signal; | 16 | use embassy_sync::signal::Signal; |
| 17 | use {defmt_rtt as _, panic_probe as _}; | 17 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | 18 | ||
| 19 | const PING_DATA: &str = "PING"; | 19 | const PING_DATA: &str = "PING"; |
diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml index c7f980366..194e8f4b8 100644 --- a/examples/wasm/Cargo.toml +++ b/examples/wasm/Cargo.toml | |||
| @@ -7,7 +7,7 @@ version = "0.1.0" | |||
| 7 | crate-type = ["cdylib"] | 7 | crate-type = ["cdylib"] |
| 8 | 8 | ||
| 9 | [dependencies] | 9 | [dependencies] |
| 10 | embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] } | 10 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["log"] } |
| 11 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "wasm", "nightly", "integrated-timers"] } | 11 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "wasm", "nightly", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["log", "wasm", "nightly"] } | 12 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["log", "wasm", "nightly"] } |
| 13 | 13 | ||
