pub mod input {
use embassy_stm32::{
gpio::{Level, Pull},
Peripheral,
};
#[doc(hidden)]
pub use embassy_stm32::gpio::{Input, Pin as InputPin};
#[cfg(feature = "external-interrupts")]
#[doc(hidden)]
pub use embassy_stm32::exti::ExtiInput as IntEnabledInput;
pub const SCHMITT_TRIGGER_CONFIGURABLE: bool = false;
#[doc(hidden)]
pub fn new(
pin: impl Peripheral<P: InputPin> + 'static,
pull: ariel_os_embassy_common::gpio::Pull,
_schmitt_trigger: bool, ) -> Result<Input<'static>, ariel_os_embassy_common::gpio::input::Error> {
let pull = from_pull(pull);
Ok(Input::new(pin, pull))
}
#[cfg(feature = "external-interrupts")]
#[doc(hidden)]
pub fn new_int_enabled<P: Peripheral<P = T> + 'static, T: InputPin>(
pin: P,
pull: ariel_os_embassy_common::gpio::Pull,
_schmitt_trigger: bool, ) -> Result<IntEnabledInput<'static>, ariel_os_embassy_common::gpio::input::Error> {
let pull = from_pull(pull);
let mut pin = pin.into_ref();
let ch = crate::extint_registry::EXTINT_REGISTRY.get_interrupt_channel_for_pin(&mut pin)?;
let pin = pin.into_ref().map_into();
Ok(IntEnabledInput::new(pin, ch, pull))
}
ariel_os_embassy_common::define_from_pull!();
ariel_os_embassy_common::define_into_level!();
}
pub mod output {
use embassy_stm32::{gpio::Level, Peripheral};
#[doc(hidden)]
pub use embassy_stm32::gpio::{Output, Pin as OutputPin};
pub const DRIVE_STRENGTH_CONFIGURABLE: bool = false;
pub const SPEED_CONFIGURABLE: bool = true;
#[doc(hidden)]
pub fn new(
pin: impl Peripheral<P: OutputPin> + 'static,
initial_level: ariel_os_embassy_common::gpio::Level,
_drive_strength: super::DriveStrength, speed: super::Speed,
) -> Output<'static> {
let initial_level = match initial_level {
ariel_os_embassy_common::gpio::Level::Low => Level::Low,
ariel_os_embassy_common::gpio::Level::High => Level::High,
};
Output::new(pin, initial_level, speed.into())
}
}
pub use ariel_os_embassy_common::gpio::UnsupportedDriveStrength as DriveStrength;
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum Speed {
Low,
Medium,
High,
VeryHigh,
}
impl From<Speed> for embassy_stm32::gpio::Speed {
fn from(speed: Speed) -> Self {
match speed {
Speed::Low => Self::Low,
Speed::Medium => Self::Medium,
Speed::High => Self::High,
Speed::VeryHigh => Self::VeryHigh,
}
}
}
impl ariel_os_embassy_common::gpio::FromSpeed for Speed {
fn from(speed: ariel_os_embassy_common::gpio::Speed<Self>) -> Self {
use ariel_os_embassy_common::gpio::Speed::*;
match speed {
Hal(speed) => speed,
Low => Self::Low,
Medium => Self::Medium,
High => Self::High,
VeryHigh => Self::VeryHigh,
}
}
}