mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 14:53:03 +00:00
Add embedded_hal::digital::v2::* for ExtiPin
This commit is contained in:
parent
16e00669ae
commit
693177ec27
@ -10,6 +10,7 @@ use crate::hal::gpio;
|
||||
use crate::hal::gpio::{Edge, ExtiPin as HalExtiPin};
|
||||
use crate::hal::syscfg::SysCfg;
|
||||
use crate::pac::EXTI;
|
||||
use embedded_hal::digital::v2 as digital;
|
||||
|
||||
use crate::interrupt;
|
||||
|
||||
@ -42,6 +43,52 @@ pub struct ExtiPin<T: HalExtiPin + WithInterrupt> {
|
||||
_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
|
||||
EXTI0_IRQn EXTI0_IRQHandler Handler for pins connected to line 0
|
||||
|
Loading…
Reference in New Issue
Block a user