diff --git a/src/riot-rs-embassy/Cargo.toml b/src/riot-rs-embassy/Cargo.toml index 204f6714f..df4083fb4 100644 --- a/src/riot-rs-embassy/Cargo.toml +++ b/src/riot-rs-embassy/Cargo.toml @@ -8,6 +8,7 @@ edition = "2021" linkme.workspace = true static_cell.workspace = true critical-section.workspace = true +embassy-executor = { workspace = true, features = ["nightly"] } embassy-sync = { workspace = true } riot-rs-core = { path = "../riot-rs-core", optional = true } riot-rs-rt = { path = "../riot-rs-rt" } @@ -29,7 +30,6 @@ cyw43-pio = { version = "0.1.0", features = ["overclock"], optional = true } embassy-executor = { workspace = true, features = [ "arch-cortex-m", "executor-interrupt", - "nightly", ] } [target.'cfg(context = "nrf52")'.dependencies] diff --git a/src/riot-rs-embassy/src/arch/dummy.rs b/src/riot-rs-embassy/src/arch/dummy.rs new file mode 100644 index 000000000..3facae027 --- /dev/null +++ b/src/riot-rs-embassy/src/arch/dummy.rs @@ -0,0 +1,39 @@ +//! Dummy module used to satisfy platform-independent tooling. + +/// Dummy type. +/// +/// See the `OptionalPeripherals` type of your Embassy architecture crate instead. +pub struct OptionalPeripherals; + +mod executor { + use embassy_executor::SpawnToken; + + pub struct Executor; + + impl Executor { + pub const fn new() -> Self { + Self {} + } + + pub fn start(&self, _: super::SWI) {} + + pub fn spawner(&self) -> Spawner { + Spawner {} + } + } + + pub struct Spawner {} + + impl Spawner { + pub fn spawn(&self, token: SpawnToken) -> Result<(), ()> { + Ok(()) + } + } +} +pub use executor::{Executor, Spawner}; + +pub fn init(_: ()) -> OptionalPeripherals { + OptionalPeripherals {} +} + +pub struct SWI; diff --git a/src/riot-rs-embassy/src/arch/nrf52.rs b/src/riot-rs-embassy/src/arch/nrf52.rs index 5c1b27b69..2e8fce774 100644 --- a/src/riot-rs-embassy/src/arch/nrf52.rs +++ b/src/riot-rs-embassy/src/arch/nrf52.rs @@ -1,3 +1,4 @@ +pub(crate) use embassy_executor::InterruptExecutor as Executor; pub use embassy_nrf::interrupt; pub use embassy_nrf::interrupt::SWI0_EGU0 as SWI; pub use embassy_nrf::{init, OptionalPeripherals}; diff --git a/src/riot-rs-embassy/src/arch/rp2040.rs b/src/riot-rs-embassy/src/arch/rp2040.rs index 1395e2467..f07fa7f49 100644 --- a/src/riot-rs-embassy/src/arch/rp2040.rs +++ b/src/riot-rs-embassy/src/arch/rp2040.rs @@ -1,3 +1,4 @@ +pub(crate) use embassy_executor::InterruptExecutor as Executor; pub use embassy_rp::interrupt; pub use embassy_rp::interrupt::SWI_IRQ_1 as SWI; pub use embassy_rp::{config::Config, peripherals, OptionalPeripherals, Peripherals}; diff --git a/src/riot-rs-embassy/src/lib.rs b/src/riot-rs-embassy/src/lib.rs index ec3c415b6..8d26bddf5 100644 --- a/src/riot-rs-embassy/src/lib.rs +++ b/src/riot-rs-embassy/src/lib.rs @@ -17,6 +17,10 @@ pub mod define_peripherals; #[cfg_attr(context = "nrf52", path = "arch/nrf52.rs")] #[cfg_attr(context = "rp2040", path = "arch/rp2040.rs")] +#[cfg_attr( + not(any(context = "nrf52", context = "rp2040")), + path = "arch/dummy.rs" +)] pub mod arch; use core::cell::OnceCell; @@ -25,7 +29,7 @@ use core::cell::OnceCell; pub use linkme::{self, distributed_slice}; pub use static_cell::make_static; -use embassy_executor::{InterruptExecutor, Spawner}; +use embassy_executor::Spawner; use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, mutex::Mutex}; use crate::define_peripherals::DefinePeripheralsError; @@ -57,13 +61,11 @@ pub struct Drivers { pub stack: &'static OnceCell<&'static NetworkStack>, } -pub static EXECUTOR: InterruptExecutor = InterruptExecutor::new(); +pub static EXECUTOR: arch::Executor = arch::Executor::new(); #[distributed_slice] pub static EMBASSY_TASKS: [Task] = [..]; -use arch::SWI; - // // usb common start #[cfg(feature = "usb")] @@ -187,8 +189,7 @@ fn network_config() -> embassy_net::Config { pub(crate) fn init() { riot_rs_rt::debug::println!("riot-rs-embassy::init()"); let p = arch::OptionalPeripherals::from(arch::init(Default::default())); - - EXECUTOR.start(SWI); + EXECUTOR.start(arch::SWI); EXECUTOR.spawner().spawn(init_task(p)).unwrap(); riot_rs_rt::debug::println!("riot-rs-embassy::init() done"); diff --git a/src/riot-rs-rt/Cargo.toml b/src/riot-rs-rt/Cargo.toml index 3dd73fa05..6e19c764d 100644 --- a/src/riot-rs-rt/Cargo.toml +++ b/src/riot-rs-rt/Cargo.toml @@ -6,6 +6,8 @@ edition = "2021" [dependencies] cfg-if = "1.0.0" +linkme.workspace = true +riot-rs-threads = { path = "../riot-rs-threads", optional = true } riot-rs-utils = { path = "../riot-rs-utils" } [target.'cfg(context = "cortex-m")'.dependencies] @@ -13,9 +15,7 @@ cortex-m = { workspace = true, features = ["critical-section-single-core"] } cortex-m-rt = { workspace = true } cortex-m-semihosting = { workspace = true, optional = true } portable-atomic = { version = "1.6.0", features = ["critical-section"] } -riot-rs-threads = { path = "../riot-rs-threads", optional = true } rtt-target = { version = "0.4.0", optional = true } -linkme.workspace = true [features] #default = ["threading"]