forked from future-proof-iot/RIOT-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(arch): introduce
riot-rs-arch
dispatch crate
- Loading branch information
Showing
15 changed files
with
640 additions
and
65 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/spi", | ||
"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-nrf/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", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
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<'_> { | ||
type Error = core::convert::Infallible; | ||
} | ||
|
||
impl embedded_hal::digital::InputPin for $type<'_> { | ||
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; | ||
|
||
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> { | ||
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> { | ||
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!(); | ||
} | ||
|
||
pub mod output { | ||
use embedded_hal::digital::StatefulOutputPin; | ||
use riot_rs_embassy_common::gpio::{FromDriveStrength, FromSpeed}; | ||
|
||
use crate::arch::peripheral::Peripheral; | ||
|
||
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!(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!(); | ||
} |
Oops, something went wrong.