-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
riot-rs-arch
dispatch crate
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
[package] | ||
name = "riot-rs-arch" | ||
version = "0.1.0" | ||
license.workspace = true | ||
edition = "2021" | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[dependencies] | ||
cfg-if.workspace = true | ||
|
||
[target.'cfg(context = "esp")'.dependencies] | ||
riot-rs-esp = { path = "../riot-rs-esp" } | ||
|
||
[target.'cfg(context = "nrf")'.dependencies] | ||
riot-rs-nrf = { path = "../riot-rs-nrf" } | ||
|
||
[target.'cfg(context = "rp")'.dependencies] | ||
riot-rs-rp = { path = "../riot-rs-rp" } | ||
|
||
[target.'cfg(context = "stm32")'.dependencies] | ||
riot-rs-stm32 = { workspace = true } | ||
|
||
[features] | ||
external-interrupts = [ | ||
"riot-rs-esp/external-interrupts", | ||
"riot-rs-nrf/external-interrupts", | ||
"riot-rs-rp/external-interrupts", | ||
"riot-rs-stm32/external-interrupts", | ||
] | ||
|
||
i2c = [ | ||
"riot-rs-esp/i2c", | ||
"riot-rs-nrf/i2c", | ||
"riot-rs-rp/i2c", | ||
"riot-rs-stm32/i2c", | ||
] | ||
|
||
spi = [ | ||
"riot-rs-esp/spi", | ||
"riot-rs-nrf/spi", | ||
"riot-rs-rp/spi", | ||
"riot-rs-stm32/spi", | ||
] | ||
|
||
usb = [ | ||
#"riot-rs-esp/usb", | ||
"riot-rs-nrf/usb", | ||
"riot-rs-rp/usb", | ||
"riot-rs-stm32/usb", | ||
] | ||
|
||
hwrng = [ | ||
#"riot-rs-esp/hwrng", | ||
"riot-rs-nrf/hwrng", | ||
"riot-rs-rp/hwrng", | ||
"riot-rs-stm32/hwrng", | ||
] | ||
|
||
wifi-cyw43 = ["riot-rs-rp/wifi-cyw43"] | ||
wifi-esp = ["riot-rs-esp/wifi-esp"] | ||
|
||
threading = ["riot-rs-esp/threading"] | ||
|
||
executor-single-thread = ["riot-rs-esp/executor-single-thread"] | ||
|
||
executor-interrupt = [ | ||
#"riot-rs-esp/executor-interrupt", | ||
"riot-rs-nrf/executor-interrupt", | ||
"riot-rs-rp/executor-interrupt", | ||
"riot-rs-stm32/executor-interrupt", | ||
] | ||
|
||
defmt = [ | ||
"riot-rs-esp/defmt", | ||
"riot-rs-nrf/defmt", | ||
"riot-rs-rp/defmt", | ||
"riot-rs-stm32/defmt", | ||
] |
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>) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
macro_rules! define_input_like { | ||
($type:ident) => { | ||
pub struct $type<'d> { | ||
_marker: core::marker::PhantomData<&'d ()>, | ||
} | ||
|
||
impl $type<'_> { | ||
pub fn is_high(&self) -> bool { | ||
unimplemented!(); | ||
} | ||
|
||
pub fn is_low(&self) -> bool { | ||
unimplemented!(); | ||
} | ||
|
||
pub fn get_level(&self) -> crate::arch::gpio::input::Level { | ||
Check failure on line 16 in src/riot-rs-arch/src/dummy/gpio.rs GitHub Actions / lintfailed to resolve: unresolved import
|
||
unimplemented!(); | ||
} | ||
|
||
pub async fn wait_for_high(&mut self) { | ||
unimplemented!(); | ||
} | ||
|
||
pub async fn wait_for_low(&mut self) { | ||
unimplemented!(); | ||
} | ||
|
||
pub async fn wait_for_rising_edge(&mut self) { | ||
unimplemented!(); | ||
} | ||
|
||
pub async fn wait_for_falling_edge(&mut self) { | ||
unimplemented!(); | ||
} | ||
|
||
pub async fn wait_for_any_edge(&mut self) { | ||
unimplemented!(); | ||
} | ||
} | ||
|
||
impl embedded_hal::digital::ErrorType for $type<'_> { | ||
Check failure on line 41 in src/riot-rs-arch/src/dummy/gpio.rs GitHub Actions / lintfailed to resolve: use of undeclared crate or module `embedded_hal`
|
||
type Error = core::convert::Infallible; | ||
} | ||
|
||
impl embedded_hal::digital::InputPin for $type<'_> { | ||
Check failure on line 45 in src/riot-rs-arch/src/dummy/gpio.rs GitHub Actions / lintfailed to resolve: use of undeclared crate or module `embedded_hal`
|
||
fn is_low(&mut self) -> Result<bool, Self::Error> { | ||
unimplemented!(); | ||
} | ||
|
||
fn is_high(&mut self) -> Result<bool, Self::Error> { | ||
unimplemented!(); | ||
} | ||
} | ||
|
||
impl embedded_hal_async::digital::Wait for $type<'_> { | ||
async fn wait_for_high(&mut self) -> Result<(), Self::Error> { | ||
unimplemented!(); | ||
} | ||
|
||
async fn wait_for_low(&mut self) -> Result<(), Self::Error> { | ||
unimplemented!(); | ||
} | ||
|
||
async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { | ||
unimplemented!(); | ||
} | ||
|
||
async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { | ||
unimplemented!(); | ||
} | ||
|
||
async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { | ||
unimplemented!(); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
pub mod input { | ||
use crate::arch::peripheral::Peripheral; | ||
Check failure on line 80 in src/riot-rs-arch/src/dummy/gpio.rs GitHub Actions / lintfailed to resolve: unresolved import
|
||
|
||
pub(crate) const SCHMITT_TRIGGER_CONFIGURABLE: bool = false; | ||
|
||
pub trait InputPin {} | ||
|
||
pub(crate) fn new( | ||
_pin: impl Peripheral<P: InputPin> + 'static, | ||
_pull: crate::gpio::Pull, | ||
_schmitt_trigger: bool, | ||
) -> Result<Input<'static>, riot_rs_embassy_common::gpio::input::Error> { | ||
Check failure on line 90 in src/riot-rs-arch/src/dummy/gpio.rs GitHub Actions / lintfailed to resolve: use of undeclared crate or module `riot_rs_embassy_common`
|
||
unimplemented!(); | ||
} | ||
|
||
#[cfg(feature = "external-interrupts")] | ||
pub(crate) fn new_int_enabled( | ||
_pin: impl Peripheral<P: InputPin> + 'static, | ||
_pull: crate::gpio::Pull, | ||
_schmitt_trigger: bool, | ||
) -> Result<IntEnabledInput<'static>, riot_rs_embassy_common::gpio::input::Error> { | ||
Check failure on line 99 in src/riot-rs-arch/src/dummy/gpio.rs GitHub Actions / lintfailed to resolve: use of undeclared crate or module `riot_rs_embassy_common`
|
||
unimplemented!(); | ||
} | ||
|
||
define_input_like!(Input); | ||
#[cfg(feature = "external-interrupts")] | ||
define_input_like!(IntEnabledInput); | ||
|
||
pub enum Level { | ||
Low, | ||
High, | ||
} | ||
|
||
riot_rs_embassy_common::define_into_level!(); | ||
Check failure on line 112 in src/riot-rs-arch/src/dummy/gpio.rs GitHub Actions / lintfailed to resolve: use of undeclared crate or module `riot_rs_embassy_common`
|
||
} | ||
|
||
pub mod output { | ||
use embedded_hal::digital::StatefulOutputPin; | ||
Check failure on line 116 in src/riot-rs-arch/src/dummy/gpio.rs GitHub Actions / lintfailed to resolve: use of undeclared crate or module `embedded_hal`
|
||
use riot_rs_embassy_common::gpio::{FromDriveStrength, FromSpeed}; | ||
Check failure on line 117 in src/riot-rs-arch/src/dummy/gpio.rs GitHub Actions / lintfailed to resolve: use of undeclared crate or module `riot_rs_embassy_common`
|
||
|
||
use crate::arch::peripheral::Peripheral; | ||
Check failure on line 119 in src/riot-rs-arch/src/dummy/gpio.rs GitHub Actions / lintfailed to resolve: unresolved import
|
||
|
||
pub(crate) const DRIVE_STRENGTH_CONFIGURABLE: bool = false; | ||
pub(crate) const SPEED_CONFIGURABLE: bool = false; | ||
|
||
pub trait OutputPin {} | ||
|
||
pub(crate) fn new( | ||
_pin: impl Peripheral<P: OutputPin> + 'static, | ||
_initial_level: crate::gpio::Level, | ||
_drive_strength: DriveStrength, | ||
_speed: Speed, | ||
) -> Output<'static> { | ||
unimplemented!(); | ||
} | ||
|
||
/// Actual type is architecture-specific. | ||
#[derive(Copy, Clone, PartialEq, Eq)] | ||
pub enum DriveStrength { | ||
#[doc(hidden)] | ||
Hidden, | ||
} | ||
|
||
impl FromDriveStrength for DriveStrength { | ||
fn from(_drive_strength: crate::gpio::DriveStrength<DriveStrength>) -> Self { | ||
unimplemented!(); | ||
} | ||
} | ||
|
||
/// Actual type is architecture-specific. | ||
#[derive(Copy, Clone, PartialEq, Eq)] | ||
pub enum Speed { | ||
#[doc(hidden)] | ||
Hidden, | ||
} | ||
|
||
impl FromSpeed for Speed { | ||
fn from(_speed: crate::gpio::Speed<Speed>) -> Self { | ||
unimplemented!(); | ||
} | ||
} | ||
|
||
pub struct Output<'d> { | ||
_marker: core::marker::PhantomData<&'d ()>, | ||
} | ||
|
||
impl embedded_hal::digital::ErrorType for Output<'_> { | ||
type Error = core::convert::Infallible; | ||
} | ||
|
||
impl embedded_hal::digital::OutputPin for Output<'_> { | ||
fn set_low(&mut self) -> Result<(), Self::Error> { | ||
unimplemented!(); | ||
} | ||
|
||
fn set_high(&mut self) -> Result<(), Self::Error> { | ||
unimplemented!(); | ||
} | ||
} | ||
|
||
impl StatefulOutputPin for Output<'_> { | ||
fn is_set_high(&mut self) -> Result<bool, Self::Error> { | ||
unimplemented!(); | ||
} | ||
|
||
fn is_set_low(&mut self) -> Result<bool, Self::Error> { | ||
unimplemented!(); | ||
} | ||
} | ||
} |
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!(); | ||
} |