nrf/gpio: add toggle.
This commit is contained in:
parent
eebfee189a
commit
7fa954c027
1 changed files with 34 additions and 0 deletions
|
@ -152,6 +152,12 @@ impl<'d, T: Pin> Output<'d, T> {
|
||||||
self.pin.set_low()
|
self.pin.set_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Toggle the output level.
|
||||||
|
#[inline]
|
||||||
|
pub fn toggle(&mut self) {
|
||||||
|
self.pin.toggle()
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the output level.
|
/// Set the output level.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_level(&mut self, level: Level) {
|
pub fn set_level(&mut self, level: Level) {
|
||||||
|
@ -310,6 +316,16 @@ impl<'d, T: Pin> Flex<'d, T> {
|
||||||
self.pin.set_low()
|
self.pin.set_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Toggle the output level.
|
||||||
|
#[inline]
|
||||||
|
pub fn toggle(&mut self) {
|
||||||
|
if self.is_set_low() {
|
||||||
|
self.set_high()
|
||||||
|
} else {
|
||||||
|
self.set_low()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the output level.
|
/// Set the output level.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_level(&mut self, level: Level) {
|
pub fn set_level(&mut self, level: Level) {
|
||||||
|
@ -538,6 +554,15 @@ mod eh02 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d, T> {
|
||||||
|
type Error = Infallible;
|
||||||
|
#[inline]
|
||||||
|
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||||
|
self.toggle();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Implement [`embedded_hal_02::digital::v2::InputPin`] for [`Flex`];
|
/// Implement [`embedded_hal_02::digital::v2::InputPin`] for [`Flex`];
|
||||||
///
|
///
|
||||||
/// If the pin is not in input mode the result is unspecified.
|
/// If the pin is not in input mode the result is unspecified.
|
||||||
|
@ -574,6 +599,15 @@ mod eh02 {
|
||||||
Ok(self.ref_is_set_low())
|
Ok(self.ref_is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, T> {
|
||||||
|
type Error = Infallible;
|
||||||
|
#[inline]
|
||||||
|
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||||
|
self.toggle();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> {
|
||||||
|
|
Loading…
Reference in a new issue