Add embedded_hal::digital::v2::* for ExtiPin

This commit is contained in:
Michael Beaumont 2021-03-14 23:28:29 +01:00
parent 16e00669ae
commit 693177ec27
No known key found for this signature in database
GPG Key ID: 94C1243E6859F368

View File

@ -10,6 +10,7 @@ use crate::hal::gpio;
use crate::hal::gpio::{Edge, ExtiPin as HalExtiPin}; use crate::hal::gpio::{Edge, ExtiPin as HalExtiPin};
use crate::hal::syscfg::SysCfg; use crate::hal::syscfg::SysCfg;
use crate::pac::EXTI; use crate::pac::EXTI;
use embedded_hal::digital::v2 as digital;
use crate::interrupt; use crate::interrupt;
@ -42,6 +43,52 @@ pub struct ExtiPin<T: HalExtiPin + WithInterrupt> {
_mgr: &'static ExtiManager, _mgr: &'static ExtiManager,
} }
impl<T: HalExtiPin + WithInterrupt + digital::OutputPin> digital::OutputPin for ExtiPin<T> {
type Error = T::Error;
fn set_low(&mut self) -> Result<(), Self::Error> {
self.pin.set_low()
}
fn set_high(&mut self) -> Result<(), Self::Error> {
self.pin.set_high()
}
}
impl<T: HalExtiPin + WithInterrupt + digital::StatefulOutputPin> digital::StatefulOutputPin
for ExtiPin<T>
{
fn is_set_low(&self) -> Result<bool, Self::Error> {
self.pin.is_set_low()
}
fn is_set_high(&self) -> Result<bool, Self::Error> {
self.pin.is_set_high()
}
}
impl<T: HalExtiPin + WithInterrupt + digital::ToggleableOutputPin> digital::ToggleableOutputPin
for ExtiPin<T>
{
type Error = T::Error;
fn toggle(&mut self) -> Result<(), Self::Error> {
self.pin.toggle()
}
}
impl<T: HalExtiPin + WithInterrupt + digital::InputPin> digital::InputPin for ExtiPin<T> {
type Error = T::Error;
fn is_high(&self) -> Result<bool, Self::Error> {
self.pin.is_high()
}
fn is_low(&self) -> Result<bool, Self::Error> {
self.pin.is_low()
}
}
/* /*
Irq Handler Description Irq Handler Description
EXTI0_IRQn EXTI0_IRQHandler Handler for pins connected to line 0 EXTI0_IRQn EXTI0_IRQHandler Handler for pins connected to line 0