From c1d8c8cf36e3d13daf0eb93b56d8e149acf55b27 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Tue, 16 Aug 2022 01:17:28 -0400 Subject: Add example of rtos-trace / SystemView --- examples/nrf/Cargo.toml | 68 +++++++++++++++++++++++++++++++------- examples/nrf/build.rs | 1 + examples/nrf/src/bin/rtos_trace.rs | 64 +++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 12 deletions(-) create mode 100644 examples/nrf/src/bin/rtos_trace.rs (limited to 'examples') diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index 91edbd36d..2f877b6a1 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml @@ -4,28 +4,72 @@ name = "embassy-nrf-examples" version = "0.1.0" [features] -default = ["nightly"] +default = ["defmt", "nightly"] 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"] +defmt = [ + "dep:defmt", + "dep:defmt-rtt", + "embassy-util/defmt", + "embassy-executor/defmt", + "embassy-executor/defmt-timestamp-uptime", + "embassy-nrf/defmt", + "embassy-net/defmt", + "embassy-usb/defmt", + "embassy-usb-serial/defmt", + "embassy-usb-hid/defmt", + "embassy-usb-ncm/defmt", + "panic-probe/print-defmt", +] +log = [ + "dep:log", + "embassy-util/log", + "embassy-executor/log", + "embassy-nrf/log", + "embassy-net/log", + "embassy-usb-ncm/log", + # Currently broken: + # "embassy-usb/log", + # "embassy-usb-serial/log", + # "embassy-usb-hid/log", +] +rtos-trace = [ + "dep:rtos-trace", + "dep:systemview-target", + "log", + "embassy-executor/rtos-trace", + "embassy-executor/rtos-trace-interrupt", +] [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime"] } -embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } -embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true } -embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"], optional = true } -embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"], optional = true } -embassy-usb-hid = { version = "0.1.0", path = "../../embassy-usb-hid", features = ["defmt"], optional = true } -embassy-usb-ncm = { version = "0.1.0", path = "../../embassy-usb-ncm", features = ["defmt"], optional = true } +embassy-util = { version = "0.1.0", path = "../../embassy-util" } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor" } +embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } +embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true } +embassy-usb = { version = "0.1.0", path = "../../embassy-usb", optional = true } +embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", optional = true } +embassy-usb-hid = { version = "0.1.0", path = "../../embassy-usb-hid", optional = true } +embassy-usb-ncm = { version = "0.1.0", path = "../../embassy-usb-ncm", optional = true } embedded-io = "0.3.0" -defmt = "0.3" -defmt-rtt = "0.3" +defmt = { version = "0.3", optional = true } +defmt-rtt = { version = "0.3", optional = true } cortex-m = "0.7.3" cortex-m-rt = "0.7.0" -panic-probe = { version = "0.3", features = ["print-defmt"] } +panic-probe = { version = "0.3" } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } rand = { version = "0.8.4", default-features = false } embedded-storage = "0.3.0" usbd-hid = "0.5.2" serde = { version = "1.0.136", default-features = false } +rtos-trace = { version = "0.1.3", optional = true } +systemview-target = { version = "0.1.1", optional = true, features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] } +log = { version = "0.4.17", optional = true } + +[[bin]] +name = "rtos_trace" +required-features = ["nightly", "rtos-trace", "log"] + +[patch.crates-io] +rtos-trace = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" } +systemview-target = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" } diff --git a/examples/nrf/build.rs b/examples/nrf/build.rs index 30691aa97..36cdb65a8 100644 --- a/examples/nrf/build.rs +++ b/examples/nrf/build.rs @@ -31,5 +31,6 @@ fn main() { println!("cargo:rustc-link-arg-bins=--nmagic"); println!("cargo:rustc-link-arg-bins=-Tlink.x"); + #[cfg(feature = "defmt")] println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); } diff --git a/examples/nrf/src/bin/rtos_trace.rs b/examples/nrf/src/bin/rtos_trace.rs new file mode 100644 index 000000000..8b4f5b755 --- /dev/null +++ b/examples/nrf/src/bin/rtos_trace.rs @@ -0,0 +1,64 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use core::task::Poll; + +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Instant, Timer}; +use embassy_nrf::Peripherals; + +// N.B. systemview_target cannot be used at the same time as defmt_rtt. + +use rtos_trace; +use systemview_target::SystemView; +use panic_probe as _; +use log::*; + +static LOGGER: systemview_target::SystemView = systemview_target::SystemView::new(); +rtos_trace::global_trace!{SystemView} + +struct TraceInfo(); + +impl rtos_trace::RtosTraceApplicationCallbacks for TraceInfo { + fn system_description() {} + fn sysclock() -> u32 { + 64000000 + } +} +rtos_trace::global_application_callbacks!{TraceInfo} + +#[embassy_executor::task] +async fn run1() { + loop { + info!("DING DONG"); + Timer::after(Duration::from_ticks(16000)).await; + } +} + +#[embassy_executor::task] +async fn run2() { + loop { + Timer::at(Instant::from_ticks(0)).await; + } +} + +#[embassy_executor::task] +async fn run3() { + futures::future::poll_fn(|cx| { + cx.waker().wake_by_ref(); + Poll::<()>::Pending + }) + .await; +} + +#[embassy_executor::main] +async fn main(spawner: Spawner, _p: Peripherals) { + LOGGER.init(); + ::log::set_logger(&LOGGER).ok(); + ::log::set_max_level(::log::LevelFilter::Trace); + + spawner.spawn(run1()).unwrap(); + spawner.spawn(run2()).unwrap(); + spawner.spawn(run3()).unwrap(); +} -- cgit From cd561b19ef411c296c86afc6f0df4f39caa1c9e9 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Tue, 16 Aug 2022 01:20:07 -0400 Subject: Allow rtos_trace example to be used without log --- examples/nrf/Cargo.toml | 3 +-- examples/nrf/src/bin/rtos_trace.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index 2f877b6a1..8704f27c3 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml @@ -35,7 +35,6 @@ log = [ rtos-trace = [ "dep:rtos-trace", "dep:systemview-target", - "log", "embassy-executor/rtos-trace", "embassy-executor/rtos-trace-interrupt", ] @@ -68,7 +67,7 @@ log = { version = "0.4.17", optional = true } [[bin]] name = "rtos_trace" -required-features = ["nightly", "rtos-trace", "log"] +required-features = ["nightly", "rtos-trace"] [patch.crates-io] rtos-trace = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" } diff --git a/examples/nrf/src/bin/rtos_trace.rs b/examples/nrf/src/bin/rtos_trace.rs index 8b4f5b755..461e174c9 100644 --- a/examples/nrf/src/bin/rtos_trace.rs +++ b/examples/nrf/src/bin/rtos_trace.rs @@ -13,6 +13,7 @@ use embassy_nrf::Peripherals; use rtos_trace; use systemview_target::SystemView; use panic_probe as _; +#[cfg(feature = "log")] use log::*; static LOGGER: systemview_target::SystemView = systemview_target::SystemView::new(); @@ -31,7 +32,10 @@ rtos_trace::global_application_callbacks!{TraceInfo} #[embassy_executor::task] async fn run1() { loop { + #[cfg(feature = "log")] info!("DING DONG"); + #[cfg(not(feature = "log"))] + rtos_trace::trace::marker(13); Timer::after(Duration::from_ticks(16000)).await; } } @@ -55,8 +59,11 @@ async fn run3() { #[embassy_executor::main] async fn main(spawner: Spawner, _p: Peripherals) { LOGGER.init(); - ::log::set_logger(&LOGGER).ok(); - ::log::set_max_level(::log::LevelFilter::Trace); + #[cfg(feature = "log")] + { + ::log::set_logger(&LOGGER).ok(); + ::log::set_max_level(::log::LevelFilter::Trace); + } spawner.spawn(run1()).unwrap(); spawner.spawn(run2()).unwrap(); -- cgit From 7dfe119fe0c7b99d7a6d73af6ac3fc6f7cef9d12 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Tue, 16 Aug 2022 01:47:18 -0400 Subject: Run cargo fmt --- examples/nrf/src/bin/rtos_trace.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'examples') diff --git a/examples/nrf/src/bin/rtos_trace.rs b/examples/nrf/src/bin/rtos_trace.rs index 461e174c9..5699fe8e2 100644 --- a/examples/nrf/src/bin/rtos_trace.rs +++ b/examples/nrf/src/bin/rtos_trace.rs @@ -7,17 +7,15 @@ use core::task::Poll; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Instant, Timer}; use embassy_nrf::Peripherals; - +#[cfg(feature = "log")] +use log::*; +use panic_probe as _; // N.B. systemview_target cannot be used at the same time as defmt_rtt. - use rtos_trace; use systemview_target::SystemView; -use panic_probe as _; -#[cfg(feature = "log")] -use log::*; static LOGGER: systemview_target::SystemView = systemview_target::SystemView::new(); -rtos_trace::global_trace!{SystemView} +rtos_trace::global_trace! {SystemView} struct TraceInfo(); @@ -27,7 +25,7 @@ impl rtos_trace::RtosTraceApplicationCallbacks for TraceInfo { 64000000 } } -rtos_trace::global_application_callbacks!{TraceInfo} +rtos_trace::global_application_callbacks! {TraceInfo} #[embassy_executor::task] async fn run1() { -- cgit From 2edf532f8d8ce048137990bf74b07759428ed7c1 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Thu, 18 Aug 2022 01:38:58 -0400 Subject: Move rtos-trace example to a separate project to simplify Cargo.toml --- examples/nrf-rtos-trace/.cargo/config.toml | 9 ++++ examples/nrf-rtos-trace/Cargo.toml | 51 ++++++++++++++++++++ examples/nrf-rtos-trace/build.rs | 36 ++++++++++++++ examples/nrf-rtos-trace/memory.x | 7 +++ examples/nrf-rtos-trace/src/bin/rtos_trace.rs | 69 +++++++++++++++++++++++++++ examples/nrf/Cargo.toml | 67 +++++--------------------- examples/nrf/build.rs | 1 - examples/nrf/src/bin/rtos_trace.rs | 69 --------------------------- 8 files changed, 184 insertions(+), 125 deletions(-) create mode 100644 examples/nrf-rtos-trace/.cargo/config.toml create mode 100644 examples/nrf-rtos-trace/Cargo.toml create mode 100644 examples/nrf-rtos-trace/build.rs create mode 100644 examples/nrf-rtos-trace/memory.x create mode 100644 examples/nrf-rtos-trace/src/bin/rtos_trace.rs delete mode 100644 examples/nrf/src/bin/rtos_trace.rs (limited to 'examples') 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 @@ +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +# replace nRF82840_xxAA with your chip as listed in `probe-run --list-chips` +runner = "probe-run --chip nRF52840_xxAA" + +[build] +target = "thumbv7em-none-eabi" + +[env] +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..9c749a388 --- /dev/null +++ b/examples/nrf-rtos-trace/Cargo.toml @@ -0,0 +1,51 @@ +[package] +edition = "2021" +name = "embassy-nrf-examples" +version = "0.1.0" + +[features] +default = ["log", "nightly"] +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"] +log = [ + "dep:log", + "embassy-util/log", + "embassy-executor/log", + "embassy-nrf/log", + "embassy-net/log", + "embassy-usb-ncm/log", + # Currently broken: + # "embassy-usb/log", + # "embassy-usb-serial/log", + # "embassy-usb-hid/log", +] + +[dependencies] +embassy-util = { version = "0.1.0", path = "../../embassy-util" } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features=["rtos-trace", "rtos-trace-interrupt"] } +embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } +embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true } +embassy-usb = { version = "0.1.0", path = "../../embassy-usb", optional = true } +embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", optional = true } +embassy-usb-hid = { version = "0.1.0", path = "../../embassy-usb-hid", optional = true } +embassy-usb-ncm = { version = "0.1.0", path = "../../embassy-usb-ncm", optional = true } +embedded-io = "0.3.0" + +cortex-m = "0.7.3" +cortex-m-rt = "0.7.0" +panic-probe = { version = "0.3" } +futures = { version = "0.3.17", default-features = false, features = ["async-await"] } +rand = { version = "0.8.4", default-features = false } +embedded-storage = "0.3.0" +usbd-hid = "0.5.2" +serde = { version = "1.0.136", default-features = false } +rtos-trace = "0.1.3" +systemview-target = { version = "0.1.1", features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] } +log = { version = "0.4.17", optional = true } + +[[bin]] +name = "rtos_trace" +required-features = ["nightly"] + +[patch.crates-io] +rtos-trace = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" } +systemview-target = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" } 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 @@ +//! This build script copies the `memory.x` file from the crate root into +//! a directory where the linker can always find it at build time. +//! For many projects this is optional, as the linker always searches the +//! project root directory -- wherever `Cargo.toml` is. However, if you +//! are using a workspace or have a more complicated build setup, this +//! build script becomes required. Additionally, by requesting that +//! Cargo re-run the build script whenever `memory.x` is changed, +//! updating `memory.x` ensures a rebuild of the application with the +//! new memory settings. + +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::PathBuf; + +fn main() { + // Put `memory.x` in our output directory and ensure it's + // on the linker search path. + let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); + File::create(out.join("memory.x")) + .unwrap() + .write_all(include_bytes!("memory.x")) + .unwrap(); + println!("cargo:rustc-link-search={}", out.display()); + + // By default, Cargo will re-run a build script whenever + // any file in the project changes. By specifying `memory.x` + // here, we ensure the build script is only re-run when + // `memory.x` is changed. + println!("cargo:rerun-if-changed=memory.x"); + + println!("cargo:rustc-link-arg-bins=--nmagic"); + println!("cargo:rustc-link-arg-bins=-Tlink.x"); + #[cfg(feature = "defmt")] + println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); +} 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 @@ +MEMORY +{ + /* NOTE 1 K = 1 KiBi = 1024 bytes */ + /* These values correspond to the NRF52840 with Softdevices S140 7.0.1 */ + FLASH : ORIGIN = 0x00000000, LENGTH = 1024K + RAM : ORIGIN = 0x20000000, LENGTH = 256K +} 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..5699fe8e2 --- /dev/null +++ b/examples/nrf-rtos-trace/src/bin/rtos_trace.rs @@ -0,0 +1,69 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use core::task::Poll; + +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Instant, Timer}; +use embassy_nrf::Peripherals; +#[cfg(feature = "log")] +use log::*; +use panic_probe as _; +// N.B. systemview_target cannot be used at the same time as defmt_rtt. +use rtos_trace; +use systemview_target::SystemView; + +static LOGGER: systemview_target::SystemView = systemview_target::SystemView::new(); +rtos_trace::global_trace! {SystemView} + +struct TraceInfo(); + +impl rtos_trace::RtosTraceApplicationCallbacks for TraceInfo { + fn system_description() {} + fn sysclock() -> u32 { + 64000000 + } +} +rtos_trace::global_application_callbacks! {TraceInfo} + +#[embassy_executor::task] +async fn run1() { + loop { + #[cfg(feature = "log")] + info!("DING DONG"); + #[cfg(not(feature = "log"))] + rtos_trace::trace::marker(13); + Timer::after(Duration::from_ticks(16000)).await; + } +} + +#[embassy_executor::task] +async fn run2() { + loop { + Timer::at(Instant::from_ticks(0)).await; + } +} + +#[embassy_executor::task] +async fn run3() { + futures::future::poll_fn(|cx| { + cx.waker().wake_by_ref(); + Poll::<()>::Pending + }) + .await; +} + +#[embassy_executor::main] +async fn main(spawner: Spawner, _p: Peripherals) { + LOGGER.init(); + #[cfg(feature = "log")] + { + ::log::set_logger(&LOGGER).ok(); + ::log::set_max_level(::log::LevelFilter::Trace); + } + + spawner.spawn(run1()).unwrap(); + spawner.spawn(run2()).unwrap(); + spawner.spawn(run3()).unwrap(); +} diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index 8704f27c3..91edbd36d 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml @@ -4,71 +4,28 @@ name = "embassy-nrf-examples" version = "0.1.0" [features] -default = ["defmt", "nightly"] +default = ["nightly"] 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"] -defmt = [ - "dep:defmt", - "dep:defmt-rtt", - "embassy-util/defmt", - "embassy-executor/defmt", - "embassy-executor/defmt-timestamp-uptime", - "embassy-nrf/defmt", - "embassy-net/defmt", - "embassy-usb/defmt", - "embassy-usb-serial/defmt", - "embassy-usb-hid/defmt", - "embassy-usb-ncm/defmt", - "panic-probe/print-defmt", -] -log = [ - "dep:log", - "embassy-util/log", - "embassy-executor/log", - "embassy-nrf/log", - "embassy-net/log", - "embassy-usb-ncm/log", - # Currently broken: - # "embassy-usb/log", - # "embassy-usb-serial/log", - # "embassy-usb-hid/log", -] -rtos-trace = [ - "dep:rtos-trace", - "dep:systemview-target", - "embassy-executor/rtos-trace", - "embassy-executor/rtos-trace-interrupt", -] [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util" } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor" } -embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } -embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true } -embassy-usb = { version = "0.1.0", path = "../../embassy-usb", optional = true } -embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", optional = true } -embassy-usb-hid = { version = "0.1.0", path = "../../embassy-usb-hid", optional = true } -embassy-usb-ncm = { version = "0.1.0", path = "../../embassy-usb-ncm", optional = true } +embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime"] } +embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } +embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true } +embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"], optional = true } +embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"], optional = true } +embassy-usb-hid = { version = "0.1.0", path = "../../embassy-usb-hid", features = ["defmt"], optional = true } +embassy-usb-ncm = { version = "0.1.0", path = "../../embassy-usb-ncm", features = ["defmt"], optional = true } embedded-io = "0.3.0" -defmt = { version = "0.3", optional = true } -defmt-rtt = { version = "0.3", optional = true } +defmt = "0.3" +defmt-rtt = "0.3" cortex-m = "0.7.3" cortex-m-rt = "0.7.0" -panic-probe = { version = "0.3" } +panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } rand = { version = "0.8.4", default-features = false } embedded-storage = "0.3.0" usbd-hid = "0.5.2" serde = { version = "1.0.136", default-features = false } -rtos-trace = { version = "0.1.3", optional = true } -systemview-target = { version = "0.1.1", optional = true, features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] } -log = { version = "0.4.17", optional = true } - -[[bin]] -name = "rtos_trace" -required-features = ["nightly", "rtos-trace"] - -[patch.crates-io] -rtos-trace = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" } -systemview-target = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" } diff --git a/examples/nrf/build.rs b/examples/nrf/build.rs index 36cdb65a8..30691aa97 100644 --- a/examples/nrf/build.rs +++ b/examples/nrf/build.rs @@ -31,6 +31,5 @@ fn main() { println!("cargo:rustc-link-arg-bins=--nmagic"); println!("cargo:rustc-link-arg-bins=-Tlink.x"); - #[cfg(feature = "defmt")] println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); } diff --git a/examples/nrf/src/bin/rtos_trace.rs b/examples/nrf/src/bin/rtos_trace.rs deleted file mode 100644 index 5699fe8e2..000000000 --- a/examples/nrf/src/bin/rtos_trace.rs +++ /dev/null @@ -1,69 +0,0 @@ -#![no_std] -#![no_main] -#![feature(type_alias_impl_trait)] - -use core::task::Poll; - -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Instant, Timer}; -use embassy_nrf::Peripherals; -#[cfg(feature = "log")] -use log::*; -use panic_probe as _; -// N.B. systemview_target cannot be used at the same time as defmt_rtt. -use rtos_trace; -use systemview_target::SystemView; - -static LOGGER: systemview_target::SystemView = systemview_target::SystemView::new(); -rtos_trace::global_trace! {SystemView} - -struct TraceInfo(); - -impl rtos_trace::RtosTraceApplicationCallbacks for TraceInfo { - fn system_description() {} - fn sysclock() -> u32 { - 64000000 - } -} -rtos_trace::global_application_callbacks! {TraceInfo} - -#[embassy_executor::task] -async fn run1() { - loop { - #[cfg(feature = "log")] - info!("DING DONG"); - #[cfg(not(feature = "log"))] - rtos_trace::trace::marker(13); - Timer::after(Duration::from_ticks(16000)).await; - } -} - -#[embassy_executor::task] -async fn run2() { - loop { - Timer::at(Instant::from_ticks(0)).await; - } -} - -#[embassy_executor::task] -async fn run3() { - futures::future::poll_fn(|cx| { - cx.waker().wake_by_ref(); - Poll::<()>::Pending - }) - .await; -} - -#[embassy_executor::main] -async fn main(spawner: Spawner, _p: Peripherals) { - LOGGER.init(); - #[cfg(feature = "log")] - { - ::log::set_logger(&LOGGER).ok(); - ::log::set_max_level(::log::LevelFilter::Trace); - } - - spawner.spawn(run1()).unwrap(); - spawner.spawn(run2()).unwrap(); - spawner.spawn(run3()).unwrap(); -} -- cgit From 5ce18f49158e23a2a3c775343126d9670f212fc5 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Fri, 19 Aug 2022 00:54:53 -0400 Subject: Fix package name for the new nrf-rtos-trace example --- examples/nrf-rtos-trace/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml index dad74235f..bdf49f574 100644 --- a/examples/nrf-rtos-trace/Cargo.toml +++ b/examples/nrf-rtos-trace/Cargo.toml @@ -1,6 +1,6 @@ [package] edition = "2021" -name = "embassy-nrf-examples" +name = "embassy-nrf-rtos-trace-examples" version = "0.1.0" [features] -- cgit From 0c7ad547935fa684b32c6fc59ac9d911f2e021a3 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Fri, 19 Aug 2022 11:58:45 -0400 Subject: Fetch systemview-target from upstream git --- examples/nrf-rtos-trace/Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml index bdf49f574..52b4bb7ee 100644 --- a/examples/nrf-rtos-trace/Cargo.toml +++ b/examples/nrf-rtos-trace/Cargo.toml @@ -35,5 +35,4 @@ name = "rtos_trace" required-features = ["nightly"] [patch.crates-io] -rtos-trace = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" } -systemview-target = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" } +systemview-target = { git = "https://gitlab.com/bern-rtos/tools/rtos-trace.git", rev = "3f68ec60f07aa87c191628568263f57073aa3dab" } -- cgit From 614b894ff871add9f0394fcf9ef220f133c4aae4 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Sat, 20 Aug 2022 14:16:06 -0400 Subject: Switch to crates.io version of systemview-target --- examples/nrf-rtos-trace/Cargo.toml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml index 52b4bb7ee..b0907f92c 100644 --- a/examples/nrf-rtos-trace/Cargo.toml +++ b/examples/nrf-rtos-trace/Cargo.toml @@ -27,12 +27,9 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa rand = { version = "0.8.4", default-features = false } serde = { version = "1.0.136", default-features = false } rtos-trace = "0.1.3" -systemview-target = { version = "0.1.1", features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] } +systemview-target = { version = "0.1.2", features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] } log = { version = "0.4.17", optional = true } [[bin]] name = "rtos_trace" required-features = ["nightly"] - -[patch.crates-io] -systemview-target = { git = "https://gitlab.com/bern-rtos/tools/rtos-trace.git", rev = "3f68ec60f07aa87c191628568263f57073aa3dab" } -- cgit From 478f4727846f6a43c28fff3b09cb639c0b800465 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 22 Aug 2022 15:51:44 +0200 Subject: Remove Forever, switch to static_cell. --- examples/nrf/Cargo.toml | 1 + examples/nrf/src/bin/channel_sender_receiver.rs | 6 +++--- examples/nrf/src/bin/multiprio.rs | 14 +++++++------- examples/nrf/src/bin/raw_spawn.rs | 6 +++--- examples/nrf/src/bin/usb_ethernet.rs | 14 +++++++------- examples/nrf/src/bin/usb_serial_multitask.rs | 6 +++--- examples/std/Cargo.toml | 1 + examples/std/src/bin/net.rs | 16 ++++++++-------- examples/std/src/bin/net_udp.rs | 16 ++++++++-------- examples/std/src/bin/serial.rs | 6 +++--- examples/stm32f3/Cargo.toml | 1 + examples/stm32f3/src/bin/multiprio.rs | 14 +++++++------- examples/stm32f4/Cargo.toml | 1 + examples/stm32f4/src/bin/multiprio.rs | 14 +++++++------- examples/stm32f7/Cargo.toml | 1 + examples/stm32f7/src/bin/eth.rs | 14 +++++++------- examples/stm32h7/Cargo.toml | 1 + examples/stm32h7/src/bin/eth.rs | 14 +++++++------- examples/stm32h7/src/bin/eth_client.rs | 14 +++++++------- examples/stm32h7/src/bin/spi.rs | 6 +++--- examples/stm32h7/src/bin/spi_dma.rs | 6 +++--- examples/stm32h7/src/bin/usart.rs | 6 +++--- examples/stm32h7/src/bin/usart_dma.rs | 6 +++--- examples/stm32l0/Cargo.toml | 1 + examples/stm32l0/src/bin/raw_spawn.rs | 6 +++--- examples/stm32l5/Cargo.toml | 1 + examples/stm32l5/src/bin/usb_ethernet.rs | 14 +++++++------- 27 files changed, 107 insertions(+), 99 deletions(-) (limited to 'examples') diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index 2fcc31221..17f29b8fb 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml @@ -22,6 +22,7 @@ embedded-io = "0.3.0" defmt = "0.3" defmt-rtt = "0.3" +static_cell = "1.0" cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" panic-probe = { version = "0.3", features = ["print-defmt"] } diff --git a/examples/nrf/src/bin/channel_sender_receiver.rs b/examples/nrf/src/bin/channel_sender_receiver.rs index c9c458aec..d250b6a5c 100644 --- a/examples/nrf/src/bin/channel_sender_receiver.rs +++ b/examples/nrf/src/bin/channel_sender_receiver.rs @@ -8,7 +8,7 @@ use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; use embassy_time::{Duration, Timer}; use embassy_util::blocking_mutex::raw::NoopRawMutex; use embassy_util::channel::mpmc::{Channel, Receiver, Sender}; -use embassy_util::Forever; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; enum LedState { @@ -16,7 +16,7 @@ enum LedState { Off, } -static CHANNEL: Forever> = Forever::new(); +static CHANNEL: StaticCell> = StaticCell::new(); #[embassy_executor::task] 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 #[embassy_executor::main] async fn main(spawner: Spawner) { let p = embassy_nrf::init(Default::default()); - let channel = CHANNEL.put(Channel::new()); + let channel = CHANNEL.init(Channel::new()); unwrap!(spawner.spawn(send_task(channel.sender()))); 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}; use embassy_nrf::interrupt; use embassy_nrf::interrupt::InterruptExt; use embassy_time::{Duration, Instant, Timer}; -use embassy_util::Forever; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task] @@ -108,9 +108,9 @@ async fn run_low() { } } -static EXECUTOR_HIGH: Forever> = Forever::new(); -static EXECUTOR_MED: Forever> = Forever::new(); -static EXECUTOR_LOW: Forever = Forever::new(); +static EXECUTOR_HIGH: StaticCell> = StaticCell::new(); +static EXECUTOR_MED: StaticCell> = StaticCell::new(); +static EXECUTOR_LOW: StaticCell = StaticCell::new(); #[entry] fn main() -> ! { @@ -121,19 +121,19 @@ fn main() -> ! { // High-priority executor: SWI1_EGU1, priority level 6 let irq = interrupt::take!(SWI1_EGU1); irq.set_priority(interrupt::Priority::P6); - let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq)); + let executor = EXECUTOR_HIGH.init(InterruptExecutor::new(irq)); let spawner = executor.start(); unwrap!(spawner.spawn(run_high())); // Medium-priority executor: SWI0_EGU0, priority level 7 let irq = interrupt::take!(SWI0_EGU0); irq.set_priority(interrupt::Priority::P7); - let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq)); + let executor = EXECUTOR_MED.init(InterruptExecutor::new(irq)); let spawner = executor.start(); unwrap!(spawner.spawn(run_med())); // Low priority executor: runs in thread mode, using WFE/SEV - let executor = EXECUTOR_LOW.put(Executor::new()); + let executor = EXECUTOR_LOW.init(Executor::new()); executor.run(|spawner| { unwrap!(spawner.spawn(run_low())); }); 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}; use embassy_executor::raw::TaskStorage; use embassy_executor::Executor; use embassy_time::{Duration, Timer}; -use embassy_util::Forever; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; async fn run1() { @@ -25,14 +25,14 @@ async fn run2() { } } -static EXECUTOR: Forever = Forever::new(); +static EXECUTOR: StaticCell = StaticCell::new(); #[entry] fn main() -> ! { info!("Hello World!"); let _p = embassy_nrf::init(Default::default()); - let executor = EXECUTOR.put(Executor::new()); + let executor = EXECUTOR.init(Executor::new()); let run1_task = TaskStorage::new(); let run2_task = TaskStorage::new(); diff --git a/examples/nrf/src/bin/usb_ethernet.rs b/examples/nrf/src/bin/usb_ethernet.rs index f0a870317..d427f7563 100644 --- a/examples/nrf/src/bin/usb_ethernet.rs +++ b/examples/nrf/src/bin/usb_ethernet.rs @@ -18,17 +18,17 @@ use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; use embassy_util::channel::mpmc::Channel; -use embassy_util::Forever; use embedded_io::asynch::{Read, Write}; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; type MyDriver = Driver<'static, peripherals::USBD, PowerUsb>; -macro_rules! forever { +macro_rules! singleton { ($val:expr) => {{ type T = impl Sized; - static FOREVER: Forever = Forever::new(); - FOREVER.put_with(move || $val) + static STATIC_CELL: StaticCell = StaticCell::new(); + STATIC_CELL.init_with(move || $val) }}; } @@ -116,7 +116,7 @@ async fn main(spawner: Spawner) { control_buf: [u8; 128], serial_state: State<'static>, } - let res: &mut Resources = forever!(Resources { + let res: &mut Resources = singleton!(Resources { device_descriptor: [0; 256], config_descriptor: [0; 256], bos_descriptor: [0; 256], @@ -174,10 +174,10 @@ async fn main(spawner: Spawner) { // Init network stack let device = Device { mac_addr: our_mac_addr }; - let stack = &*forever!(Stack::new( + let stack = &*singleton!(Stack::new( device, config, - forever!(StackResources::<1, 2, 8>::new()), + singleton!(StackResources::<1, 2, 8>::new()), seed )); 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}; use embassy_usb::driver::EndpointError; use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb_serial::{CdcAcmClass, State}; -use embassy_util::Forever; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; type MyDriver = Driver<'static, peripherals::USBD, PowerUsb>; @@ -67,8 +67,8 @@ async fn main(spawner: Spawner) { control_buf: [u8; 64], serial_state: State<'static>, } - static RESOURCES: Forever = Forever::new(); - let res = RESOURCES.put(Resources { + static RESOURCES: StaticCell = StaticCell::new(); + let res = RESOURCES.init(Resources { device_descriptor: [0; 256], config_descriptor: [0; 256], bos_descriptor: [0; 256], diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index b7009017c..164a2b42d 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml @@ -20,3 +20,4 @@ libc = "0.2.101" clap = { version = "3.0.0-beta.5", features = ["derive"] } rand_core = { version = "0.6.3", features = ["std"] } heapless = { version = "0.7.5", default-features = false } +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; use embassy_executor::{Executor, Spawner}; use embassy_net::tcp::TcpSocket; use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, Stack, StackResources}; -use embassy_util::Forever; use embedded_io::asynch::Write; use heapless::Vec; use log::*; use rand_core::{OsRng, RngCore}; +use static_cell::StaticCell; #[path = "../tuntap.rs"] mod tuntap; use crate::tuntap::TunTapDevice; -macro_rules! forever { +macro_rules! singleton { ($val:expr) => {{ type T = impl Sized; - static FOREVER: Forever = Forever::new(); - FOREVER.put_with(move || $val) + static STATIC_CELL: StaticCell = StaticCell::new(); + STATIC_CELL.init_with(move || $val) }}; } @@ -63,10 +63,10 @@ async fn main_task(spawner: Spawner) { let seed = u64::from_le_bytes(seed); // Init network stack - let stack = &*forever!(Stack::new( + let stack = &*singleton!(Stack::new( device, config, - forever!(StackResources::<1, 2, 8>::new()), + singleton!(StackResources::<1, 2, 8>::new()), seed )); @@ -97,7 +97,7 @@ async fn main_task(spawner: Spawner) { } } -static EXECUTOR: Forever = Forever::new(); +static EXECUTOR: StaticCell = StaticCell::new(); fn main() { env_logger::builder() @@ -106,7 +106,7 @@ fn main() { .format_timestamp_nanos() .init(); - let executor = EXECUTOR.put(Executor::new()); + let executor = EXECUTOR.init(Executor::new()); executor.run(|spawner| { spawner.spawn(main_task(spawner)).unwrap(); }); 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; use embassy_executor::{Executor, Spawner}; use embassy_net::udp::UdpSocket; use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, PacketMetadata, Stack, StackResources}; -use embassy_util::Forever; use heapless::Vec; use log::*; use rand_core::{OsRng, RngCore}; +use static_cell::StaticCell; #[path = "../tuntap.rs"] mod tuntap; use crate::tuntap::TunTapDevice; -macro_rules! forever { +macro_rules! singleton { ($val:expr) => {{ type T = impl Sized; - static FOREVER: Forever = Forever::new(); - FOREVER.put_with(move || $val) + static STATIC_CELL: StaticCell = StaticCell::new(); + STATIC_CELL.init_with(move || $val) }}; } @@ -62,10 +62,10 @@ async fn main_task(spawner: Spawner) { let seed = u64::from_le_bytes(seed); // Init network stack - let stack = &*forever!(Stack::new( + let stack = &*singleton!(Stack::new( device, config, - forever!(StackResources::<1, 2, 8>::new()), + singleton!(StackResources::<1, 2, 8>::new()), seed )); @@ -93,7 +93,7 @@ async fn main_task(spawner: Spawner) { } } -static EXECUTOR: Forever = Forever::new(); +static EXECUTOR: StaticCell = StaticCell::new(); fn main() { env_logger::builder() @@ -102,7 +102,7 @@ fn main() { .format_timestamp_nanos() .init(); - let executor = EXECUTOR.put(Executor::new()); + let executor = EXECUTOR.init(Executor::new()); executor.run(|spawner| { spawner.spawn(main_task(spawner)).unwrap(); }); 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; use async_io::Async; use embassy_executor::Executor; -use embassy_util::Forever; use embedded_io::asynch::Read; use log::*; use nix::sys::termios; +use static_cell::StaticCell; use self::serial_port::SerialPort; @@ -40,7 +40,7 @@ async fn run() { } } -static EXECUTOR: Forever = Forever::new(); +static EXECUTOR: StaticCell = StaticCell::new(); fn main() { env_logger::builder() @@ -49,7 +49,7 @@ fn main() { .format_timestamp_nanos() .init(); - let executor = EXECUTOR.put(Executor::new()); + let executor = EXECUTOR.init(Executor::new()); executor.run(|spawner| { spawner.spawn(run()).unwrap(); }); diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index b5ea28bb6..4e6b0ea1e 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml @@ -23,3 +23,4 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa heapless = { version = "0.7.5", default-features = false } nb = "1.0.0" embedded-storage = "0.3.0" +static_cell = "1.0" 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}; use embassy_stm32::interrupt; use embassy_stm32::interrupt::InterruptExt; use embassy_time::{Duration, Instant, Timer}; -use embassy_util::Forever; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task] @@ -108,9 +108,9 @@ async fn run_low() { } } -static EXECUTOR_HIGH: Forever> = Forever::new(); -static EXECUTOR_MED: Forever> = Forever::new(); -static EXECUTOR_LOW: Forever = Forever::new(); +static EXECUTOR_HIGH: StaticCell> = StaticCell::new(); +static EXECUTOR_MED: StaticCell> = StaticCell::new(); +static EXECUTOR_LOW: StaticCell = StaticCell::new(); #[entry] fn main() -> ! { @@ -121,19 +121,19 @@ fn main() -> ! { // High-priority executor: SWI1_EGU1, priority level 6 let irq = interrupt::take!(UART4); irq.set_priority(interrupt::Priority::P6); - let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq)); + let executor = EXECUTOR_HIGH.init(InterruptExecutor::new(irq)); let spawner = executor.start(); unwrap!(spawner.spawn(run_high())); // Medium-priority executor: SWI0_EGU0, priority level 7 let irq = interrupt::take!(UART5); irq.set_priority(interrupt::Priority::P7); - let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq)); + let executor = EXECUTOR_MED.init(InterruptExecutor::new(irq)); let spawner = executor.start(); unwrap!(spawner.spawn(run_med())); // Low priority executor: runs in thread mode, using WFE/SEV - let executor = EXECUTOR_LOW.put(Executor::new()); + let executor = EXECUTOR_LOW.init(Executor::new()); executor.run(|spawner| { unwrap!(spawner.spawn(run_low())); }); diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index 04a217aff..f93a1d0f9 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml @@ -23,6 +23,7 @@ heapless = { version = "0.7.5", default-features = false } nb = "1.0.0" embedded-storage = "0.3.0" micromath = "2.0.0" +static_cell = "1.0" usb-device = "0.2" 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}; use embassy_stm32::interrupt; use embassy_stm32::interrupt::InterruptExt; use embassy_time::{Duration, Instant, Timer}; -use embassy_util::Forever; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task] @@ -108,9 +108,9 @@ async fn run_low() { } } -static EXECUTOR_HIGH: Forever> = Forever::new(); -static EXECUTOR_MED: Forever> = Forever::new(); -static EXECUTOR_LOW: Forever = Forever::new(); +static EXECUTOR_HIGH: StaticCell> = StaticCell::new(); +static EXECUTOR_MED: StaticCell> = StaticCell::new(); +static EXECUTOR_LOW: StaticCell = StaticCell::new(); #[entry] fn main() -> ! { @@ -121,19 +121,19 @@ fn main() -> ! { // High-priority executor: SWI1_EGU1, priority level 6 let irq = interrupt::take!(UART4); irq.set_priority(interrupt::Priority::P6); - let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq)); + let executor = EXECUTOR_HIGH.init(InterruptExecutor::new(irq)); let spawner = executor.start(); unwrap!(spawner.spawn(run_high())); // Medium-priority executor: SWI0_EGU0, priority level 7 let irq = interrupt::take!(UART5); irq.set_priority(interrupt::Priority::P7); - let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq)); + let executor = EXECUTOR_MED.init(InterruptExecutor::new(irq)); let spawner = executor.start(); unwrap!(spawner.spawn(run_med())); // Low priority executor: runs in thread mode, using WFE/SEV - let executor = EXECUTOR_LOW.put(Executor::new()); + let executor = EXECUTOR_LOW.init(Executor::new()); executor.run(|spawner| { unwrap!(spawner.spawn(run_low())); }); diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 29d6da4d8..e286d2310 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml @@ -24,3 +24,4 @@ nb = "1.0.0" rand_core = "0.6.3" critical-section = "1.1" embedded-storage = "0.3.0" +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; use embassy_stm32::time::mhz; use embassy_stm32::{interrupt, Config}; use embassy_time::{Duration, Timer}; -use embassy_util::Forever; use embedded_io::asynch::Write; use rand_core::RngCore; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; -macro_rules! forever { +macro_rules! singleton { ($val:expr) => {{ type T = impl Sized; - static FOREVER: Forever = Forever::new(); - FOREVER.put_with(move || $val) + static STATIC_CELL: StaticCell = StaticCell::new(); + STATIC_CELL.init_with(move || $val) }}; } @@ -52,7 +52,7 @@ async fn main(spawner: Spawner) -> ! { let device = unsafe { Ethernet::new( - forever!(State::new()), + singleton!(State::new()), p.ETH, eth_int, p.PA1, @@ -78,10 +78,10 @@ async fn main(spawner: Spawner) -> ! { //}); // Init network stack - let stack = &*forever!(Stack::new( + let stack = &*singleton!(Stack::new( device, config, - forever!(StackResources::<1, 2, 8>::new()), + singleton!(StackResources::<1, 2, 8>::new()), seed )); diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index a416796ea..fc5f74f99 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -28,6 +28,7 @@ critical-section = "1.1" micromath = "2.0.0" stm32-fmc = "0.2.4" embedded-storage = "0.3.0" +static_cell = "1.0" # cargo build/run [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; use embassy_stm32::time::mhz; use embassy_stm32::{interrupt, Config}; use embassy_time::{Duration, Timer}; -use embassy_util::Forever; use embedded_io::asynch::Write; use rand_core::RngCore; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; -macro_rules! forever { +macro_rules! singleton { ($val:expr) => {{ type T = impl Sized; - static FOREVER: Forever = Forever::new(); - FOREVER.put_with(move || $val) + static STATIC_CELL: StaticCell = StaticCell::new(); + STATIC_CELL.init_with(move || $val) }}; } @@ -53,7 +53,7 @@ async fn main(spawner: Spawner) -> ! { let device = unsafe { Ethernet::new( - forever!(State::new()), + singleton!(State::new()), p.ETH, eth_int, p.PA1, @@ -79,10 +79,10 @@ async fn main(spawner: Spawner) -> ! { //}); // Init network stack - let stack = &*forever!(Stack::new( + let stack = &*singleton!(Stack::new( device, config, - forever!(StackResources::<1, 2, 8>::new()), + singleton!(StackResources::<1, 2, 8>::new()), seed )); 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; use embassy_stm32::time::mhz; use embassy_stm32::{interrupt, Config}; use embassy_time::{Duration, Timer}; -use embassy_util::Forever; use embedded_io::asynch::Write; use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; use rand_core::RngCore; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; -macro_rules! forever { +macro_rules! singleton { ($val:expr) => {{ type T = impl Sized; - static FOREVER: Forever = Forever::new(); - FOREVER.put_with(move || $val) + static STATIC_CELL: StaticCell = StaticCell::new(); + STATIC_CELL.init_with(move || $val) }}; } @@ -54,7 +54,7 @@ async fn main(spawner: Spawner) -> ! { let device = unsafe { Ethernet::new( - forever!(State::new()), + singleton!(State::new()), p.ETH, eth_int, p.PA1, @@ -80,10 +80,10 @@ async fn main(spawner: Spawner) -> ! { //}); // Init network stack - let stack = &*forever!(Stack::new( + let stack = &*singleton!(Stack::new( device, config, - forever!(StackResources::<1, 2, 8>::new()), + singleton!(StackResources::<1, 2, 8>::new()), seed )); 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; use embassy_stm32::peripherals::SPI3; use embassy_stm32::time::mhz; use embassy_stm32::{spi, Config}; -use embassy_util::Forever; use heapless::String; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task] @@ -31,7 +31,7 @@ async fn main_task(mut spi: spi::Spi<'static, SPI3, NoDma, NoDma>) { } } -static EXECUTOR: Forever = Forever::new(); +static EXECUTOR: StaticCell = StaticCell::new(); #[entry] fn main() -> ! { @@ -54,7 +54,7 @@ fn main() -> ! { spi::Config::default(), ); - let executor = EXECUTOR.put(Executor::new()); + let executor = EXECUTOR.init(Executor::new()); executor.run(|spawner| { 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; use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; use embassy_stm32::time::mhz; use embassy_stm32::{spi, Config}; -use embassy_util::Forever; use heapless::String; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task] @@ -27,7 +27,7 @@ async fn main_task(mut spi: spi::Spi<'static, SPI3, DMA1_CH3, DMA1_CH4>) { } } -static EXECUTOR: Forever = Forever::new(); +static EXECUTOR: StaticCell = StaticCell::new(); #[entry] fn main() -> ! { @@ -50,7 +50,7 @@ fn main() -> ! { spi::Config::default(), ); - let executor = EXECUTOR.put(Executor::new()); + let executor = EXECUTOR.init(Executor::new()); executor.run(|spawner| { 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::*; use embassy_executor::Executor; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use embassy_util::Forever; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task] @@ -27,13 +27,13 @@ async fn main_task() { } } -static EXECUTOR: Forever = Forever::new(); +static EXECUTOR: StaticCell = StaticCell::new(); #[entry] fn main() -> ! { info!("Hello World!"); - let executor = EXECUTOR.put(Executor::new()); + let executor = EXECUTOR.init(Executor::new()); executor.run(|spawner| { 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::*; use embassy_executor::Executor; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use embassy_util::Forever; use heapless::String; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task] @@ -30,13 +30,13 @@ async fn main_task() { } } -static EXECUTOR: Forever = Forever::new(); +static EXECUTOR: StaticCell = StaticCell::new(); #[entry] fn main() -> ! { info!("Hello World!"); - let executor = EXECUTOR.put(Executor::new()); + let executor = EXECUTOR.init(Executor::new()); executor.run(|spawner| { unwrap!(spawner.spawn(main_task())); diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index fdb716d15..72365a640 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -29,3 +29,4 @@ panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.7.5", default-features = false } embedded-hal = "0.2.6" +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::*; use embassy_executor::raw::TaskStorage; use embassy_executor::Executor; use embassy_time::{Duration, Timer}; -use embassy_util::Forever; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; async fn run1() { @@ -25,14 +25,14 @@ async fn run2() { } } -static EXECUTOR: Forever = Forever::new(); +static EXECUTOR: StaticCell = StaticCell::new(); #[entry] fn main() -> ! { info!("Hello World!"); let _p = embassy_stm32::init(Default::default()); - let executor = EXECUTOR.put(Executor::new()); + let executor = EXECUTOR.init(Executor::new()); let run1_task = TaskStorage::new(); let run2_task = TaskStorage::new(); diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index 4d96d31fc..d8e78088a 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml @@ -28,3 +28,4 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa heapless = { version = "0.7.5", default-features = false } rand_core = { version = "0.6.3", default-features = false } embedded-io = { version = "0.3.0", features = ["async"] } +static_cell = "1.0" diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index 7c53d03cc..959195518 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs @@ -19,18 +19,18 @@ use embassy_usb::{Builder, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; use embassy_util::channel::mpmc::Channel; -use embassy_util::Forever; use embedded_io::asynch::{Read, Write}; use rand_core::RngCore; +use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; type MyDriver = Driver<'static, embassy_stm32::peripherals::USB>; -macro_rules! forever { +macro_rules! singleton { ($val:expr) => {{ type T = impl Sized; - static FOREVER: Forever = Forever::new(); - FOREVER.put_with(move || $val) + static STATIC_CELL: StaticCell = StaticCell::new(); + STATIC_CELL.init_with(move || $val) }}; } @@ -115,7 +115,7 @@ async fn main(spawner: Spawner) { control_buf: [u8; 128], serial_state: State<'static>, } - let res: &mut Resources = forever!(Resources { + let res: &mut Resources = singleton!(Resources { device_descriptor: [0; 256], config_descriptor: [0; 256], bos_descriptor: [0; 256], @@ -171,10 +171,10 @@ async fn main(spawner: Spawner) { // Init network stack let device = Device { mac_addr: our_mac_addr }; - let stack = &*forever!(Stack::new( + let stack = &*singleton!(Stack::new( device, config, - forever!(StackResources::<1, 2, 8>::new()), + singleton!(StackResources::<1, 2, 8>::new()), seed )); -- cgit From 21072bee48ff6ec19b79e0d9527ad8cc34a4e9e0 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 22 Aug 2022 21:46:09 +0200 Subject: split `embassy-util` into `embassy-futures`, `embassy-sync`. --- examples/boot/application/nrf/Cargo.toml | 2 +- examples/boot/application/stm32f3/Cargo.toml | 2 +- examples/boot/application/stm32f7/Cargo.toml | 2 +- examples/boot/application/stm32h7/Cargo.toml | 2 +- examples/boot/application/stm32l0/Cargo.toml | 2 +- examples/boot/application/stm32l1/Cargo.toml | 2 +- examples/boot/application/stm32l4/Cargo.toml | 2 +- examples/boot/application/stm32wl/Cargo.toml | 2 +- examples/nrf-rtos-trace/Cargo.toml | 4 ++-- examples/nrf/Cargo.toml | 3 ++- examples/nrf/src/bin/channel.rs | 4 ++-- examples/nrf/src/bin/channel_sender_receiver.rs | 4 ++-- examples/nrf/src/bin/mutex.rs | 4 ++-- examples/nrf/src/bin/pubsub.rs | 4 ++-- examples/nrf/src/bin/uart_split.rs | 4 ++-- examples/nrf/src/bin/usb_ethernet.rs | 4 ++-- examples/nrf/src/bin/usb_hid_keyboard.rs | 4 ++-- examples/rp/Cargo.toml | 2 +- examples/std/Cargo.toml | 2 +- examples/stm32f0/Cargo.toml | 2 +- examples/stm32f1/Cargo.toml | 2 +- examples/stm32f2/Cargo.toml | 2 +- examples/stm32f3/Cargo.toml | 2 +- examples/stm32f3/src/bin/button_events.rs | 4 ++-- examples/stm32f4/Cargo.toml | 2 +- examples/stm32f7/Cargo.toml | 2 +- examples/stm32g0/Cargo.toml | 2 +- examples/stm32g4/Cargo.toml | 2 +- examples/stm32h7/Cargo.toml | 2 +- examples/stm32h7/src/bin/signal.rs | 2 +- examples/stm32h7/src/bin/usart_split.rs | 4 ++-- examples/stm32l0/Cargo.toml | 2 +- examples/stm32l1/Cargo.toml | 2 +- examples/stm32l4/Cargo.toml | 2 +- examples/stm32l5/Cargo.toml | 2 +- examples/stm32l5/src/bin/usb_ethernet.rs | 4 ++-- examples/stm32u5/Cargo.toml | 2 +- examples/stm32wb/Cargo.toml | 2 +- examples/stm32wl/Cargo.toml | 2 +- examples/stm32wl/src/bin/subghz.rs | 2 +- examples/wasm/Cargo.toml | 2 +- 41 files changed, 53 insertions(+), 52 deletions(-) (limited to 'examples') 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../../../embassy-util" } +embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly"] } embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly", "nrf52840"] } 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] } 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] } 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] } 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] } 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] } 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] } diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml index b0907f92c..87c9f33f5 100644 --- a/examples/nrf-rtos-trace/Cargo.toml +++ b/examples/nrf-rtos-trace/Cargo.toml @@ -8,14 +8,14 @@ default = ["log", "nightly"] nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unstable-traits"] log = [ "dep:log", - "embassy-util/log", + "embassy-sync/log", "embassy-executor/log", "embassy-time/log", "embassy-nrf/log", ] [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util" } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync" } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features=["rtos-trace", "rtos-trace-interrupt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time" } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index 17f29b8fb..b0af0c86e 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml @@ -8,7 +8,8 @@ default = ["nightly"] 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"] [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } diff --git a/examples/nrf/src/bin/channel.rs b/examples/nrf/src/bin/channel.rs index 195200988..8371fd0af 100644 --- a/examples/nrf/src/bin/channel.rs +++ b/examples/nrf/src/bin/channel.rs @@ -5,9 +5,9 @@ use defmt::unwrap; use embassy_executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; +use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_sync::channel::mpmc::Channel; use embassy_time::{Duration, Timer}; -use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_util::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; enum LedState { diff --git a/examples/nrf/src/bin/channel_sender_receiver.rs b/examples/nrf/src/bin/channel_sender_receiver.rs index d250b6a5c..55d1fccb2 100644 --- a/examples/nrf/src/bin/channel_sender_receiver.rs +++ b/examples/nrf/src/bin/channel_sender_receiver.rs @@ -5,9 +5,9 @@ use defmt::unwrap; use embassy_executor::Spawner; use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; +use embassy_sync::blocking_mutex::raw::NoopRawMutex; +use embassy_sync::channel::mpmc::{Channel, Receiver, Sender}; use embassy_time::{Duration, Timer}; -use embassy_util::blocking_mutex::raw::NoopRawMutex; -use embassy_util::channel::mpmc::{Channel, Receiver, Sender}; use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; 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 @@ use defmt::{info, unwrap}; use embassy_executor::Spawner; +use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_sync::mutex::Mutex; use embassy_time::{Duration, Timer}; -use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_util::mutex::Mutex; use {defmt_rtt as _, panic_probe as _}; static MUTEX: Mutex = Mutex::new(0); diff --git a/examples/nrf/src/bin/pubsub.rs b/examples/nrf/src/bin/pubsub.rs index 1d90217f2..64fed641b 100644 --- a/examples/nrf/src/bin/pubsub.rs +++ b/examples/nrf/src/bin/pubsub.rs @@ -4,9 +4,9 @@ use defmt::unwrap; use embassy_executor::Spawner; +use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_sync::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; use embassy_time::{Duration, Timer}; -use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_util::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; use {defmt_rtt as _, panic_probe as _}; /// Create the message bus. It has a queue of 4, supports 3 subscribers and 1 publisher diff --git a/examples/nrf/src/bin/uart_split.rs b/examples/nrf/src/bin/uart_split.rs index dab8e475d..88b9c0a81 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; use embassy_nrf::peripherals::UARTE0; use embassy_nrf::uarte::UarteRx; use embassy_nrf::{interrupt, uarte}; -use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_util::channel::mpmc::Channel; +use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_sync::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; static CHANNEL: Channel = Channel::new(); diff --git a/examples/nrf/src/bin/usb_ethernet.rs b/examples/nrf/src/bin/usb_ethernet.rs index d427f7563..0200d8807 100644 --- a/examples/nrf/src/bin/usb_ethernet.rs +++ b/examples/nrf/src/bin/usb_ethernet.rs @@ -14,10 +14,10 @@ use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources}; use embassy_nrf::rng::Rng; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac, peripherals}; +use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_sync::channel::mpmc::Channel; use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; -use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_util::channel::mpmc::Channel; use embedded_io::asynch::{Read, Write}; use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/usb_hid_keyboard.rs b/examples/nrf/src/bin/usb_hid_keyboard.rs index cf0078eec..d7c6dafdf 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}; use defmt::*; use embassy_executor::Spawner; +use embassy_futures::{select, Either}; use embassy_nrf::gpio::{Input, Pin, Pull}; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac}; +use embassy_sync::channel::signal::Signal; use embassy_usb::control::OutResponse; use embassy_usb::{Builder, Config, DeviceStateHandler}; use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State}; -use embassy_util::channel::signal::Signal; -use embassy_util::{select, Either}; use futures::future::join; use usbd_hid::descriptor::{KeyboardReport, SerializedDescriptor}; use {defmt_rtt as _, panic_probe as _}; 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" [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 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 164a2b42d..c7cec6b19 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml @@ -4,7 +4,7 @@ name = "embassy-std-examples" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["log"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "std", "nightly", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["log", "std", "nightly"] } embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "log", "medium-ethernet", "tcp", "udp", "dhcpv4", "pool-16"] } 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" defmt = "0.3" defmt-rtt = "0.3" panic-probe = "0.3" -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } 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 4e6b0ea1e..d152b145f 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml @@ -4,7 +4,7 @@ name = "embassy-stm32f3-examples" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } diff --git a/examples/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs index 61fc6dcab..edf34b4d1 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; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; use embassy_stm32::peripherals::PA0; +use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_sync::channel::mpmc::Channel; use embassy_time::{with_timeout, Duration, Timer}; -use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_util::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; struct Leds<'a> { diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index f93a1d0f9..9bfdda92d 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti"] } diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index e286d2310..a446fe3fb 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml @@ -4,7 +4,7 @@ name = "embassy-stm32f7-examples" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "net", "stm32f767zi", "unstable-pac", "time-driver-any", "exti"] } 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } 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 fc5f74f99..0f76f3226 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -4,7 +4,7 @@ name = "embassy-stm32h7-examples" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "net", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs index be2ac268e..ae41b07a9 100644 --- a/examples/stm32h7/src/bin/signal.rs +++ b/examples/stm32h7/src/bin/signal.rs @@ -4,8 +4,8 @@ use defmt::{info, unwrap}; use embassy_executor::Spawner; +use embassy_sync::channel::signal::Signal; use embassy_time::{Duration, Timer}; -use embassy_util::channel::signal::Signal; use {defmt_rtt as _, panic_probe as _}; static SIGNAL: Signal = Signal::new(); diff --git a/examples/stm32h7/src/bin/usart_split.rs b/examples/stm32h7/src/bin/usart_split.rs index 64080ec45..55630dd39 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; use embassy_stm32::dma::NoDma; use embassy_stm32::peripherals::{DMA1_CH1, UART7}; use embassy_stm32::usart::{Config, Uart, UartRx}; -use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_util::channel::mpmc::Channel; +use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_sync::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task] diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 72365a640..11751a21d 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -8,7 +8,7 @@ default = ["nightly"] nightly = ["embassy-stm32/nightly", "embassy-lora", "lorawan-device", "lorawan", "embedded-io/async"] [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } 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" [features] [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index d8e78088a..624c73c26 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml @@ -6,7 +6,7 @@ version = "0.1.0" [features] [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "unstable-traits", "memory-x"] } diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index 959195518..b21d8629f 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs @@ -15,10 +15,10 @@ use embassy_stm32::rng::Rng; use embassy_stm32::time::Hertz; use embassy_stm32::usb::Driver; use embassy_stm32::{interrupt, Config}; +use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_sync::channel::mpmc::Channel; use embassy_usb::{Builder, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; -use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_util::channel::mpmc::Channel; use embedded_io::asynch::{Read, Write}; use rand_core::RngCore; use static_cell::StaticCell; 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } 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" version = "0.1.0" [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] } 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..6d54e8503 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}; use embassy_stm32::interrupt; use embassy_stm32::interrupt::{Interrupt, InterruptExt}; use embassy_stm32::subghz::*; -use embassy_util::channel::signal::Signal; +use embassy_sync::channel::signal::Signal; use {defmt_rtt as _, panic_probe as _}; 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" crate-type = ["cdylib"] [dependencies] -embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] } +embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["log"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "wasm", "nightly", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["log", "wasm", "nightly"] } -- cgit From 5677b13a86beca58aa57ecfd7cea0db7ceb189fa Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 22 Aug 2022 22:00:06 +0200 Subject: sync: flatten module structure. --- examples/nrf/src/bin/channel.rs | 2 +- examples/nrf/src/bin/channel_sender_receiver.rs | 2 +- examples/nrf/src/bin/pubsub.rs | 2 +- examples/nrf/src/bin/uart_split.rs | 2 +- examples/nrf/src/bin/usb_ethernet.rs | 2 +- examples/nrf/src/bin/usb_hid_keyboard.rs | 2 +- examples/stm32f3/src/bin/button_events.rs | 2 +- examples/stm32h7/src/bin/signal.rs | 2 +- examples/stm32h7/src/bin/usart_split.rs | 2 +- examples/stm32l5/src/bin/usb_ethernet.rs | 2 +- examples/stm32wl/src/bin/subghz.rs | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) (limited to 'examples') diff --git a/examples/nrf/src/bin/channel.rs b/examples/nrf/src/bin/channel.rs index 8371fd0af..d782a79e7 100644 --- a/examples/nrf/src/bin/channel.rs +++ b/examples/nrf/src/bin/channel.rs @@ -6,7 +6,7 @@ use defmt::unwrap; use embassy_executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_sync::channel::mpmc::Channel; +use embassy_sync::channel::Channel; use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/channel_sender_receiver.rs b/examples/nrf/src/bin/channel_sender_receiver.rs index 55d1fccb2..fcccdaed5 100644 --- a/examples/nrf/src/bin/channel_sender_receiver.rs +++ b/examples/nrf/src/bin/channel_sender_receiver.rs @@ -6,7 +6,7 @@ use defmt::unwrap; use embassy_executor::Spawner; use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; use embassy_sync::blocking_mutex::raw::NoopRawMutex; -use embassy_sync::channel::mpmc::{Channel, Receiver, Sender}; +use embassy_sync::channel::{Channel, Receiver, Sender}; use embassy_time::{Duration, Timer}; use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/pubsub.rs b/examples/nrf/src/bin/pubsub.rs index 64fed641b..688e6d075 100644 --- a/examples/nrf/src/bin/pubsub.rs +++ b/examples/nrf/src/bin/pubsub.rs @@ -5,7 +5,7 @@ use defmt::unwrap; use embassy_executor::Spawner; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_sync::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; +use embassy_sync::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/uart_split.rs b/examples/nrf/src/bin/uart_split.rs index 88b9c0a81..1adaf53fd 100644 --- a/examples/nrf/src/bin/uart_split.rs +++ b/examples/nrf/src/bin/uart_split.rs @@ -8,7 +8,7 @@ use embassy_nrf::peripherals::UARTE0; use embassy_nrf::uarte::UarteRx; use embassy_nrf::{interrupt, uarte}; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_sync::channel::mpmc::Channel; +use embassy_sync::channel::Channel; use {defmt_rtt as _, panic_probe as _}; static CHANNEL: Channel = Channel::new(); diff --git a/examples/nrf/src/bin/usb_ethernet.rs b/examples/nrf/src/bin/usb_ethernet.rs index 0200d8807..ca6c7e0d1 100644 --- a/examples/nrf/src/bin/usb_ethernet.rs +++ b/examples/nrf/src/bin/usb_ethernet.rs @@ -15,7 +15,7 @@ use embassy_nrf::rng::Rng; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac, peripherals}; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_sync::channel::mpmc::Channel; +use embassy_sync::channel::Channel; use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; use embedded_io::asynch::{Read, Write}; diff --git a/examples/nrf/src/bin/usb_hid_keyboard.rs b/examples/nrf/src/bin/usb_hid_keyboard.rs index d7c6dafdf..ba2159c72 100644 --- a/examples/nrf/src/bin/usb_hid_keyboard.rs +++ b/examples/nrf/src/bin/usb_hid_keyboard.rs @@ -12,7 +12,7 @@ use embassy_futures::{select, Either}; use embassy_nrf::gpio::{Input, Pin, Pull}; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac}; -use embassy_sync::channel::signal::Signal; +use embassy_sync::signal::Signal; use embassy_usb::control::OutResponse; use embassy_usb::{Builder, Config, DeviceStateHandler}; use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State}; diff --git a/examples/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs index edf34b4d1..02c475f66 100644 --- a/examples/stm32f3/src/bin/button_events.rs +++ b/examples/stm32f3/src/bin/button_events.rs @@ -16,7 +16,7 @@ use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; use embassy_stm32::peripherals::PA0; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_sync::channel::mpmc::Channel; +use embassy_sync::channel::Channel; use embassy_time::{with_timeout, Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs index ae41b07a9..cc3e4e3ca 100644 --- a/examples/stm32h7/src/bin/signal.rs +++ b/examples/stm32h7/src/bin/signal.rs @@ -4,7 +4,7 @@ use defmt::{info, unwrap}; use embassy_executor::Spawner; -use embassy_sync::channel::signal::Signal; +use embassy_sync::signal::Signal; use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32h7/src/bin/usart_split.rs b/examples/stm32h7/src/bin/usart_split.rs index 55630dd39..df2b600f8 100644 --- a/examples/stm32h7/src/bin/usart_split.rs +++ b/examples/stm32h7/src/bin/usart_split.rs @@ -8,7 +8,7 @@ use embassy_stm32::dma::NoDma; use embassy_stm32::peripherals::{DMA1_CH1, UART7}; use embassy_stm32::usart::{Config, Uart, UartRx}; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_sync::channel::mpmc::Channel; +use embassy_sync::channel::Channel; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task] diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index b21d8629f..3286f5c4d 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs @@ -16,7 +16,7 @@ use embassy_stm32::time::Hertz; use embassy_stm32::usb::Driver; use embassy_stm32::{interrupt, Config}; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; -use embassy_sync::channel::mpmc::Channel; +use embassy_sync::channel::Channel; use embassy_usb::{Builder, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; use embedded_io::asynch::{Read, Write}; diff --git a/examples/stm32wl/src/bin/subghz.rs b/examples/stm32wl/src/bin/subghz.rs index 6d54e8503..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}; use embassy_stm32::interrupt; use embassy_stm32::interrupt::{Interrupt, InterruptExt}; use embassy_stm32::subghz::*; -use embassy_sync::channel::signal::Signal; +use embassy_sync::signal::Signal; use {defmt_rtt as _, panic_probe as _}; const PING_DATA: &str = "PING"; -- cgit