Skip to content

Commit

Permalink
refactor(arch): split the dummy arch into multiple submodule files
Browse files Browse the repository at this point in the history
Split the `dummy` arch to make it more manageable when it keeps growing.
  • Loading branch information
ROMemories committed Apr 22, 2024
1 parent bead939 commit c16dd7c
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 207 deletions.
206 changes: 0 additions & 206 deletions src/riot-rs-embassy/src/arch/dummy.rs

This file was deleted.

32 changes: 32 additions & 0 deletions src/riot-rs-embassy/src/arch/dummy/executor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use embassy_executor::SpawnToken;

use crate::arch;

pub struct Executor;

impl Executor {
#[allow(clippy::new_without_default)]
pub const fn new() -> Self {
// Actually return a value instead of marking it unimplemented like other dummy
// functions, because this function is const and is thus run during compilation
Self {}
}

pub fn start(&self, _: arch::SWI) {
unimplemented!();
}

pub fn spawner(&self) -> Spawner {
unimplemented!();
}
}

pub struct Spawner;

impl Spawner {
#[allow(clippy::result_unit_err)]
pub fn spawn<S>(&self, _token: SpawnToken<S>) -> Result<(), ()> {
unimplemented!();
}
pub fn must_spawn<S>(&self, _token: SpawnToken<S>) {}
}
5 changes: 5 additions & 0 deletions src/riot-rs-embassy/src/arch/dummy/hwrng.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use crate::arch;

pub fn construct_rng(_peripherals: &mut arch::OptionalPeripherals) {
unimplemented!();
}
34 changes: 34 additions & 0 deletions src/riot-rs-embassy/src/arch/dummy/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//! Dummy module used to satisfy platform-independent tooling.

mod executor;

#[cfg(feature = "hwrng")]
pub mod hwrng;

#[cfg(feature = "usb")]
pub mod usb;

pub use executor::{Executor, Spawner};

/// Dummy type.
///
/// See the `OptionalPeripherals` type of your Embassy architecture crate instead.
pub struct OptionalPeripherals;

/// Dummy type.
pub struct Peripherals;

impl From<Peripherals> for OptionalPeripherals {
fn from(_peripherals: Peripherals) -> Self {
Self {}
}
}

#[derive(Default)]
pub struct Config;

pub fn init(_config: Config) -> OptionalPeripherals {
unimplemented!();
}

pub struct SWI;
Loading

0 comments on commit c16dd7c

Please sign in to comment.