Skip to content

Commit

Permalink
fix: add a dummy arch module to make rustdoc happy
Browse files Browse the repository at this point in the history
  • Loading branch information
ROMemories committed Jan 30, 2024
1 parent 074c51b commit a681508
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/riot-rs-embassy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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]
Expand Down
39 changes: 39 additions & 0 deletions src/riot-rs-embassy/src/arch/dummy.rs
Original file line number Diff line number Diff line change
@@ -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<S>(&self, token: SpawnToken<S>) -> Result<(), ()> {
Ok(())
}
}
}
pub use executor::{Executor, Spawner};

pub fn init(_: ()) -> OptionalPeripherals {
OptionalPeripherals {}
}

pub struct SWI;
1 change: 1 addition & 0 deletions src/riot-rs-embassy/src/arch/nrf52.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
1 change: 1 addition & 0 deletions src/riot-rs-embassy/src/arch/rp2040.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
13 changes: 7 additions & 6 deletions src/riot-rs-embassy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions src/riot-rs-rt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ 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]
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"]
Expand Down

0 comments on commit a681508

Please sign in to comment.