mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 06:42:32 +00:00
Change GPIO inherent methods back to &self
.
With the embedded-hal rc3 update I changed them to require `&mut self`, but in retrospect I think `&self` is better, for extra flexibility. This PR reverts the changes from the rc3 update to inherent methods.
This commit is contained in:
parent
67ed134479
commit
495b8b739a
@ -9,7 +9,7 @@ use {defmt_rtt as _, panic_probe as _};
|
|||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
let mut led = Output::new(p.PB14, Level::High, Speed::VeryHigh);
|
let mut led = Output::new(p.PB14, Level::High, Speed::VeryHigh);
|
||||||
let mut button = Input::new(p.PC13, Pull::Up);
|
let button = Input::new(p.PC13, Pull::Up);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if button.is_low() {
|
if button.is_low() {
|
||||||
|
@ -52,19 +52,19 @@ impl<'d, T: Pin> Input<'d, T> {
|
|||||||
|
|
||||||
/// Get whether the pin input level is high.
|
/// Get whether the pin input level is high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_high(&mut self) -> bool {
|
pub fn is_high(&self) -> bool {
|
||||||
self.pin.is_high()
|
self.pin.is_high()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the pin input level is low.
|
/// Get whether the pin input level is low.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_low(&mut self) -> bool {
|
pub fn is_low(&self) -> bool {
|
||||||
self.pin.is_low()
|
self.pin.is_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the pin input level.
|
/// Get the pin input level.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_level(&mut self) -> Level {
|
pub fn get_level(&self) -> Level {
|
||||||
self.pin.get_level()
|
self.pin.get_level()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,19 +166,19 @@ impl<'d, T: Pin> Output<'d, T> {
|
|||||||
|
|
||||||
/// Get whether the output level is set to high.
|
/// Get whether the output level is set to high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_high(&mut self) -> bool {
|
pub fn is_set_high(&self) -> bool {
|
||||||
self.pin.is_set_high()
|
self.pin.is_set_high()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the output level is set to low.
|
/// Get whether the output level is set to low.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_low(&mut self) -> bool {
|
pub fn is_set_low(&self) -> bool {
|
||||||
self.pin.is_set_low()
|
self.pin.is_set_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current output level.
|
/// Get the current output level.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_output_level(&mut self) -> Level {
|
pub fn get_output_level(&self) -> Level {
|
||||||
self.pin.get_output_level()
|
self.pin.get_output_level()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,24 +283,19 @@ impl<'d, T: Pin> Flex<'d, T> {
|
|||||||
|
|
||||||
/// Get whether the pin input level is high.
|
/// Get whether the pin input level is high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_high(&mut self) -> bool {
|
pub fn is_high(&self) -> bool {
|
||||||
!self.is_low()
|
!self.is_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the pin input level is low.
|
/// Get whether the pin input level is low.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_low(&mut self) -> bool {
|
pub fn is_low(&self) -> bool {
|
||||||
self.ref_is_low()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub(crate) fn ref_is_low(&self) -> bool {
|
|
||||||
self.pin.block().in_.read().bits() & (1 << self.pin.pin()) == 0
|
self.pin.block().in_.read().bits() & (1 << self.pin.pin()) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the pin input level.
|
/// Get the pin input level.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_level(&mut self) -> Level {
|
pub fn get_level(&self) -> Level {
|
||||||
self.is_high().into()
|
self.is_high().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,24 +332,19 @@ impl<'d, T: Pin> Flex<'d, T> {
|
|||||||
|
|
||||||
/// Get whether the output level is set to high.
|
/// Get whether the output level is set to high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_high(&mut self) -> bool {
|
pub fn is_set_high(&self) -> bool {
|
||||||
!self.is_set_low()
|
!self.is_set_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the output level is set to low.
|
/// Get whether the output level is set to low.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_low(&mut self) -> bool {
|
pub fn is_set_low(&self) -> bool {
|
||||||
self.ref_is_set_low()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub(crate) fn ref_is_set_low(&self) -> bool {
|
|
||||||
self.pin.block().out.read().bits() & (1 << self.pin.pin()) == 0
|
self.pin.block().out.read().bits() & (1 << self.pin.pin()) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current output level.
|
/// Get the current output level.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_output_level(&mut self) -> Level {
|
pub fn get_output_level(&self) -> Level {
|
||||||
self.is_set_high().into()
|
self.is_set_high().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -524,11 +514,11 @@ mod eh02 {
|
|||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.pin.ref_is_low())
|
Ok(self.is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_low(&self) -> Result<bool, Self::Error> {
|
fn is_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.pin.ref_is_low())
|
Ok(self.is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,11 +536,11 @@ mod eh02 {
|
|||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> {
|
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> {
|
||||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.pin.ref_is_set_low())
|
Ok(self.is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.pin.ref_is_set_low())
|
Ok(self.is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,11 +560,11 @@ mod eh02 {
|
|||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.ref_is_low())
|
Ok(self.is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_low(&self) -> Result<bool, Self::Error> {
|
fn is_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.ref_is_low())
|
Ok(self.is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,11 +582,11 @@ mod eh02 {
|
|||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> {
|
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> {
|
||||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.ref_is_set_low())
|
Ok(self.is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.ref_is_set_low())
|
Ok(self.is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,11 +606,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> {
|
|||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
|
||||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_high())
|
Ok((*self).is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_low())
|
Ok((*self).is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,11 +630,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
|
|||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
|
||||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_high())
|
Ok((*self).is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_low())
|
Ok((*self).is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,11 +647,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> {
|
|||||||
/// If the pin is not in input mode the result is unspecified.
|
/// If the pin is not in input mode the result is unspecified.
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
|
||||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_high())
|
Ok((*self).is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_low())
|
Ok((*self).is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -677,10 +667,10 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
|
|||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
|
||||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_high())
|
Ok((*self).is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_low())
|
Ok((*self).is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> {
|
|||||||
|
|
||||||
impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> {
|
impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> {
|
||||||
/// Create a new GPIOTE output channel driver.
|
/// Create a new GPIOTE output channel driver.
|
||||||
pub fn new(ch: impl Peripheral<P = C> + 'd, mut pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self {
|
pub fn new(ch: impl Peripheral<P = C> + 'd, pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self {
|
||||||
into_ref!(ch);
|
into_ref!(ch);
|
||||||
let g = regs();
|
let g = regs();
|
||||||
let num = ch.number();
|
let num = ch.number();
|
||||||
@ -481,11 +481,11 @@ mod eh02 {
|
|||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.pin.pin.ref_is_low())
|
Ok(self.pin.is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_low(&self) -> Result<bool, Self::Error> {
|
fn is_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.pin.pin.ref_is_low())
|
Ok(self.pin.is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,19 +127,19 @@ impl<'d, T: Pin> Input<'d, T> {
|
|||||||
|
|
||||||
/// Get whether the pin input level is high.
|
/// Get whether the pin input level is high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_high(&mut self) -> bool {
|
pub fn is_high(&self) -> bool {
|
||||||
self.pin.is_high()
|
self.pin.is_high()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the pin input level is low.
|
/// Get whether the pin input level is low.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_low(&mut self) -> bool {
|
pub fn is_low(&self) -> bool {
|
||||||
self.pin.is_low()
|
self.pin.is_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns current pin level
|
/// Returns current pin level
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_level(&mut self) -> Level {
|
pub fn get_level(&self) -> Level {
|
||||||
self.pin.get_level()
|
self.pin.get_level()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,19 +394,19 @@ impl<'d, T: Pin> Output<'d, T> {
|
|||||||
|
|
||||||
/// Is the output pin set as high?
|
/// Is the output pin set as high?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_high(&mut self) -> bool {
|
pub fn is_set_high(&self) -> bool {
|
||||||
self.pin.is_set_high()
|
self.pin.is_set_high()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the output pin set as low?
|
/// Is the output pin set as low?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_low(&mut self) -> bool {
|
pub fn is_set_low(&self) -> bool {
|
||||||
self.pin.is_set_low()
|
self.pin.is_set_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// What level output is set to
|
/// What level output is set to
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_output_level(&mut self) -> Level {
|
pub fn get_output_level(&self) -> Level {
|
||||||
self.pin.get_output_level()
|
self.pin.get_output_level()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,19 +472,19 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> {
|
|||||||
|
|
||||||
/// Is the output level high?
|
/// Is the output level high?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_high(&mut self) -> bool {
|
pub fn is_set_high(&self) -> bool {
|
||||||
!self.is_set_low()
|
!self.is_set_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the output level low?
|
/// Is the output level low?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_low(&mut self) -> bool {
|
pub fn is_set_low(&self) -> bool {
|
||||||
self.pin.is_set_as_output()
|
self.pin.is_set_as_output()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// What level output is set to
|
/// What level output is set to
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_output_level(&mut self) -> Level {
|
pub fn get_output_level(&self) -> Level {
|
||||||
self.is_set_high().into()
|
self.is_set_high().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,19 +496,19 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> {
|
|||||||
|
|
||||||
/// Get whether the pin input level is high.
|
/// Get whether the pin input level is high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_high(&mut self) -> bool {
|
pub fn is_high(&self) -> bool {
|
||||||
self.pin.is_high()
|
self.pin.is_high()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the pin input level is low.
|
/// Get whether the pin input level is low.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_low(&mut self) -> bool {
|
pub fn is_low(&self) -> bool {
|
||||||
self.pin.is_low()
|
self.pin.is_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns current pin level
|
/// Returns current pin level
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_level(&mut self) -> Level {
|
pub fn get_level(&self) -> Level {
|
||||||
self.is_high().into()
|
self.is_high().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,12 +640,7 @@ impl<'d, T: Pin> Flex<'d, T> {
|
|||||||
|
|
||||||
/// Set as output pin.
|
/// Set as output pin.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_as_output(&mut self) -> bool {
|
fn is_set_as_output(&self) -> bool {
|
||||||
self.ref_is_set_as_output()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub(crate) fn ref_is_set_as_output(&self) -> bool {
|
|
||||||
(self.pin.sio_oe().value().read() & self.bit()) != 0
|
(self.pin.sio_oe().value().read() & self.bit()) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,24 +652,19 @@ impl<'d, T: Pin> Flex<'d, T> {
|
|||||||
|
|
||||||
/// Get whether the pin input level is high.
|
/// Get whether the pin input level is high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_high(&mut self) -> bool {
|
pub fn is_high(&self) -> bool {
|
||||||
!self.is_low()
|
!self.is_low()
|
||||||
}
|
}
|
||||||
/// Get whether the pin input level is low.
|
/// Get whether the pin input level is low.
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_low(&mut self) -> bool {
|
pub fn is_low(&self) -> bool {
|
||||||
self.ref_is_low()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub(crate) fn ref_is_low(&self) -> bool {
|
|
||||||
self.pin.sio_in().read() & self.bit() == 0
|
self.pin.sio_in().read() & self.bit() == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns current pin level
|
/// Returns current pin level
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_level(&mut self) -> Level {
|
pub fn get_level(&self) -> Level {
|
||||||
self.is_high().into()
|
self.is_high().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,24 +691,19 @@ impl<'d, T: Pin> Flex<'d, T> {
|
|||||||
|
|
||||||
/// Is the output level high?
|
/// Is the output level high?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_high(&mut self) -> bool {
|
pub fn is_set_high(&self) -> bool {
|
||||||
!self.is_set_low()
|
!self.is_set_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the output level low?
|
/// Is the output level low?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_low(&mut self) -> bool {
|
pub fn is_set_low(&self) -> bool {
|
||||||
self.ref_is_set_low()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub(crate) fn ref_is_set_low(&self) -> bool {
|
|
||||||
(self.pin.sio_out().value().read() & self.bit()) == 0
|
(self.pin.sio_out().value().read() & self.bit()) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// What level output is set to
|
/// What level output is set to
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_output_level(&mut self) -> Level {
|
pub fn get_output_level(&self) -> Level {
|
||||||
self.is_set_high().into()
|
self.is_set_high().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -989,11 +974,11 @@ mod eh02 {
|
|||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.pin.ref_is_low())
|
Ok(self.is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_low(&self) -> Result<bool, Self::Error> {
|
fn is_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.pin.ref_is_low())
|
Ok(self.is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1011,11 +996,11 @@ mod eh02 {
|
|||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> {
|
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> {
|
||||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.pin.ref_is_set_low())
|
Ok(self.is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.pin.ref_is_set_low())
|
Ok(self.is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1031,11 +1016,11 @@ mod eh02 {
|
|||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.pin.ref_is_low())
|
Ok(self.is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_low(&self) -> Result<bool, Self::Error> {
|
fn is_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.pin.ref_is_low())
|
Ok(self.is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1055,11 +1040,11 @@ mod eh02 {
|
|||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> {
|
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> {
|
||||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.pin.ref_is_set_as_output())
|
Ok(self.is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.pin.ref_is_set_as_output())
|
Ok(self.is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1075,11 +1060,11 @@ mod eh02 {
|
|||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.ref_is_low())
|
Ok(self.is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_low(&self) -> Result<bool, Self::Error> {
|
fn is_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.ref_is_low())
|
Ok(self.is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1097,11 +1082,11 @@ mod eh02 {
|
|||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> {
|
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> {
|
||||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.ref_is_set_low())
|
Ok(self.is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.ref_is_set_low())
|
Ok(self.is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1120,11 +1105,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> {
|
|||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
|
||||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_high())
|
Ok((*self).is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_low())
|
Ok((*self).is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1144,11 +1129,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
|
|||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
|
||||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_high())
|
Ok((*self).is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_low())
|
Ok((*self).is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1168,21 +1153,21 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> {
|
|||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> {
|
||||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_high())
|
Ok((*self).is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_low())
|
Ok((*self).is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> {
|
||||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_high())
|
Ok((*self).is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_low())
|
Ok((*self).is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1192,11 +1177,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> {
|
|||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
|
||||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_high())
|
Ok((*self).is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_low())
|
Ok((*self).is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1212,11 +1197,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
|
|||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
|
||||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_high())
|
Ok((*self).is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_low())
|
Ok((*self).is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,17 +106,17 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the pin is high.
|
/// Get whether the pin is high.
|
||||||
pub fn is_high(&mut self) -> bool {
|
pub fn is_high(&self) -> bool {
|
||||||
self.pin.is_high()
|
self.pin.is_high()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the pin is low.
|
/// Get whether the pin is low.
|
||||||
pub fn is_low(&mut self) -> bool {
|
pub fn is_low(&self) -> bool {
|
||||||
self.pin.is_low()
|
self.pin.is_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the pin level.
|
/// Get the pin level.
|
||||||
pub fn get_level(&mut self) -> Level {
|
pub fn get_level(&self) -> Level {
|
||||||
self.pin.get_level()
|
self.pin.get_level()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,11 +166,11 @@ impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T>
|
|||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.pin.pin.ref_is_low())
|
Ok(self.is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_low(&self) -> Result<bool, Self::Error> {
|
fn is_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.pin.pin.ref_is_low())
|
Ok(self.is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,11 +180,11 @@ impl<'d, T: GpioPin> embedded_hal_1::digital::ErrorType for ExtiInput<'d, T> {
|
|||||||
|
|
||||||
impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> {
|
impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> {
|
||||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_high())
|
Ok((*self).is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_low())
|
Ok((*self).is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,49 +150,39 @@ impl<'d, T: Pin> Flex<'d, T> {
|
|||||||
|
|
||||||
/// Get whether the pin input level is high.
|
/// Get whether the pin input level is high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_high(&mut self) -> bool {
|
pub fn is_high(&self) -> bool {
|
||||||
!self.ref_is_low()
|
!self.is_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the pin input level is low.
|
/// Get whether the pin input level is low.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_low(&mut self) -> bool {
|
pub fn is_low(&self) -> bool {
|
||||||
self.ref_is_low()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub(crate) fn ref_is_low(&self) -> bool {
|
|
||||||
let state = self.pin.block().idr().read().idr(self.pin.pin() as _);
|
let state = self.pin.block().idr().read().idr(self.pin.pin() as _);
|
||||||
state == vals::Idr::LOW
|
state == vals::Idr::LOW
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current pin input level.
|
/// Get the current pin input level.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_level(&mut self) -> Level {
|
pub fn get_level(&self) -> Level {
|
||||||
self.is_high().into()
|
self.is_high().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the output level is set to high.
|
/// Get whether the output level is set to high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_high(&mut self) -> bool {
|
pub fn is_set_high(&self) -> bool {
|
||||||
!self.ref_is_set_low()
|
!self.is_set_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the output level is set to low.
|
/// Get whether the output level is set to low.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_low(&mut self) -> bool {
|
pub fn is_set_low(&self) -> bool {
|
||||||
self.ref_is_set_low()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub(crate) fn ref_is_set_low(&self) -> bool {
|
|
||||||
let state = self.pin.block().odr().read().odr(self.pin.pin() as _);
|
let state = self.pin.block().odr().read().odr(self.pin.pin() as _);
|
||||||
state == vals::Odr::LOW
|
state == vals::Odr::LOW
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current output level.
|
/// Get the current output level.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_output_level(&mut self) -> Level {
|
pub fn get_output_level(&self) -> Level {
|
||||||
self.is_set_high().into()
|
self.is_set_high().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,19 +336,19 @@ impl<'d, T: Pin> Input<'d, T> {
|
|||||||
|
|
||||||
/// Get whether the pin input level is high.
|
/// Get whether the pin input level is high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_high(&mut self) -> bool {
|
pub fn is_high(&self) -> bool {
|
||||||
self.pin.is_high()
|
self.pin.is_high()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the pin input level is low.
|
/// Get whether the pin input level is low.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_low(&mut self) -> bool {
|
pub fn is_low(&self) -> bool {
|
||||||
self.pin.is_low()
|
self.pin.is_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current pin input level.
|
/// Get the current pin input level.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_level(&mut self) -> Level {
|
pub fn get_level(&self) -> Level {
|
||||||
self.pin.get_level()
|
self.pin.get_level()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -445,19 +435,19 @@ impl<'d, T: Pin> Output<'d, T> {
|
|||||||
|
|
||||||
/// Is the output pin set as high?
|
/// Is the output pin set as high?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_high(&mut self) -> bool {
|
pub fn is_set_high(&self) -> bool {
|
||||||
self.pin.is_set_high()
|
self.pin.is_set_high()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the output pin set as low?
|
/// Is the output pin set as low?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_low(&mut self) -> bool {
|
pub fn is_set_low(&self) -> bool {
|
||||||
self.pin.is_set_low()
|
self.pin.is_set_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// What level output is set to
|
/// What level output is set to
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_output_level(&mut self) -> Level {
|
pub fn get_output_level(&self) -> Level {
|
||||||
self.pin.get_output_level()
|
self.pin.get_output_level()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,19 +496,19 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> {
|
|||||||
|
|
||||||
/// Get whether the pin input level is high.
|
/// Get whether the pin input level is high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_high(&mut self) -> bool {
|
pub fn is_high(&self) -> bool {
|
||||||
!self.pin.is_low()
|
!self.pin.is_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the pin input level is low.
|
/// Get whether the pin input level is low.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_low(&mut self) -> bool {
|
pub fn is_low(&self) -> bool {
|
||||||
self.pin.is_low()
|
self.pin.is_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current pin input level.
|
/// Get the current pin input level.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_level(&mut self) -> Level {
|
pub fn get_level(&self) -> Level {
|
||||||
self.pin.get_level()
|
self.pin.get_level()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,19 +532,19 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> {
|
|||||||
|
|
||||||
/// Get whether the output level is set to high.
|
/// Get whether the output level is set to high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_high(&mut self) -> bool {
|
pub fn is_set_high(&self) -> bool {
|
||||||
self.pin.is_set_high()
|
self.pin.is_set_high()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get whether the output level is set to low.
|
/// Get whether the output level is set to low.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_set_low(&mut self) -> bool {
|
pub fn is_set_low(&self) -> bool {
|
||||||
self.pin.is_set_low()
|
self.pin.is_set_low()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current output level.
|
/// Get the current output level.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_output_level(&mut self) -> Level {
|
pub fn get_output_level(&self) -> Level {
|
||||||
self.pin.get_output_level()
|
self.pin.get_output_level()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -851,12 +841,12 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.pin.ref_is_low())
|
Ok(self.is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_low(&self) -> Result<bool, Self::Error> {
|
fn is_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.pin.ref_is_low())
|
Ok(self.is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -879,13 +869,13 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> {
|
|||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> {
|
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.pin.ref_is_set_low())
|
Ok(self.is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the output pin set as low?
|
/// Is the output pin set as low?
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.pin.ref_is_set_low())
|
Ok(self.is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -917,13 +907,13 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d,
|
|||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> {
|
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.pin.ref_is_set_low())
|
Ok(self.is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the output pin set as low?
|
/// Is the output pin set as low?
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.pin.ref_is_set_low())
|
Ok(self.is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -941,12 +931,12 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.ref_is_low())
|
Ok(self.is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_low(&self) -> Result<bool, Self::Error> {
|
fn is_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.ref_is_low())
|
Ok(self.is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -969,13 +959,13 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> {
|
|||||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> {
|
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(!self.ref_is_set_low())
|
Ok(self.is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the output pin set as low?
|
/// Is the output pin set as low?
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
fn is_set_low(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.ref_is_set_low())
|
Ok(self.is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -995,12 +985,12 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> {
|
|||||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_high())
|
Ok((*self).is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_low())
|
Ok((*self).is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1023,13 +1013,13 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
|
|||||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_high())
|
Ok((*self).is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the output pin set as low?
|
/// Is the output pin set as low?
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_low())
|
Ok((*self).is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1040,12 +1030,12 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d, T> {
|
|||||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_high())
|
Ok((*self).is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_low())
|
Ok((*self).is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1064,25 +1054,25 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> {
|
|||||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_high())
|
Ok((*self).is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the output pin set as low?
|
/// Is the output pin set as low?
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_low())
|
Ok((*self).is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_high())
|
Ok((*self).is_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_low())
|
Ok((*self).is_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1105,13 +1095,13 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> {
|
|||||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
|
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_high())
|
Ok((*self).is_set_high())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the output pin set as low?
|
/// Is the output pin set as low?
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_low())
|
Ok((*self).is_set_low())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## 0.1.3 - 2023-08-28
|
## 0.1.3 - 2023-08-28
|
||||||
|
|
||||||
- Update `embedded-hal-async` to `1.0.0-rc.3`
|
- Update `embedded-hal-async` to `1.0.0-rc.2`
|
||||||
- Update `embedded-hal v1` to `1.0.0-rc.3`
|
- Update `embedded-hal v1` to `1.0.0-rc.2`
|
||||||
|
|
||||||
## 0.1.2 - 2023-07-05
|
## 0.1.2 - 2023-07-05
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
// Use PIN_28, Pin34 on J0 for RP Pico, as a input.
|
// Use PIN_28, Pin34 on J0 for RP Pico, as a input.
|
||||||
// You need to add your own button.
|
// You need to add your own button.
|
||||||
let mut button = Input::new(p.PIN_28, Pull::Up);
|
let button = Input::new(p.PIN_28, Pull::Up);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if button.is_high() {
|
if button.is_high() {
|
||||||
|
@ -12,7 +12,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
|
|
||||||
let mut button = Input::new(p.PC13, Pull::Up);
|
let button = Input::new(p.PC13, Pull::Up);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if button.is_high() {
|
if button.is_high() {
|
||||||
|
@ -12,7 +12,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
|
|
||||||
let mut button = Input::new(p.PA0, Pull::Down);
|
let button = Input::new(p.PA0, Pull::Down);
|
||||||
let mut led1 = Output::new(p.PE9, Level::High, Speed::Low);
|
let mut led1 = Output::new(p.PE9, Level::High, Speed::Low);
|
||||||
let mut led2 = Output::new(p.PE15, Level::High, Speed::Low);
|
let mut led2 = Output::new(p.PE15, Level::High, Speed::Low);
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
|
|
||||||
let mut button = Input::new(p.PC13, Pull::Down);
|
let button = Input::new(p.PC13, Pull::Down);
|
||||||
let mut led1 = Output::new(p.PB0, Level::High, Speed::Low);
|
let mut led1 = Output::new(p.PB0, Level::High, Speed::Low);
|
||||||
let _led2 = Output::new(p.PB7, Level::High, Speed::Low);
|
let _led2 = Output::new(p.PB7, Level::High, Speed::Low);
|
||||||
let mut led3 = Output::new(p.PB14, Level::High, Speed::Low);
|
let mut led3 = Output::new(p.PB14, Level::High, Speed::Low);
|
||||||
|
@ -12,7 +12,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
|
|
||||||
let mut button = Input::new(p.PC13, Pull::Down);
|
let button = Input::new(p.PC13, Pull::Down);
|
||||||
let mut led1 = Output::new(p.PB0, Level::High, Speed::Low);
|
let mut led1 = Output::new(p.PB0, Level::High, Speed::Low);
|
||||||
let _led2 = Output::new(p.PB7, Level::High, Speed::Low);
|
let _led2 = Output::new(p.PB7, Level::High, Speed::Low);
|
||||||
let mut led3 = Output::new(p.PB14, Level::High, Speed::Low);
|
let mut led3 = Output::new(p.PB14, Level::High, Speed::Low);
|
||||||
|
@ -12,7 +12,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
|
|
||||||
let mut button = Input::new(p.PC13, Pull::Up);
|
let button = Input::new(p.PC13, Pull::Up);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if button.is_high() {
|
if button.is_high() {
|
||||||
|
@ -12,7 +12,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
|
|
||||||
let mut button = Input::new(p.PC13, Pull::Down);
|
let button = Input::new(p.PC13, Pull::Down);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if button.is_high() {
|
if button.is_high() {
|
||||||
|
@ -11,7 +11,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let mut button = Input::new(p.PB2, Pull::Up);
|
let button = Input::new(p.PB2, Pull::Up);
|
||||||
let mut led1 = Output::new(p.PA5, Level::High, Speed::Low);
|
let mut led1 = Output::new(p.PA5, Level::High, Speed::Low);
|
||||||
let mut led2 = Output::new(p.PB5, Level::High, Speed::Low);
|
let mut led2 = Output::new(p.PB5, Level::High, Speed::Low);
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
|
|
||||||
let mut button = Input::new(p.PC13, Pull::Up);
|
let button = Input::new(p.PC13, Pull::Up);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if button.is_high() {
|
if button.is_high() {
|
||||||
|
@ -111,8 +111,8 @@ async fn main(spawner: Spawner) {
|
|||||||
let led_uc4_blue = Output::new(dp.PG15, Level::High, Speed::Low);
|
let led_uc4_blue = Output::new(dp.PG15, Level::High, Speed::Low);
|
||||||
|
|
||||||
// Read the uc_cfg switches
|
// Read the uc_cfg switches
|
||||||
let mut uc_cfg0 = Input::new(dp.PB2, Pull::None);
|
let uc_cfg0 = Input::new(dp.PB2, Pull::None);
|
||||||
let mut uc_cfg1 = Input::new(dp.PF11, Pull::None);
|
let uc_cfg1 = Input::new(dp.PF11, Pull::None);
|
||||||
let _uc_cfg2 = Input::new(dp.PG6, Pull::None);
|
let _uc_cfg2 = Input::new(dp.PG6, Pull::None);
|
||||||
let _uc_cfg3 = Input::new(dp.PG11, Pull::None);
|
let _uc_cfg3 = Input::new(dp.PG11, Pull::None);
|
||||||
|
|
||||||
@ -130,8 +130,8 @@ async fn main(spawner: Spawner) {
|
|||||||
|
|
||||||
// Setup IO and SPI for the SPE chip
|
// Setup IO and SPI for the SPE chip
|
||||||
let spe_reset_n = Output::new(dp.PC7, Level::Low, Speed::Low);
|
let spe_reset_n = Output::new(dp.PC7, Level::Low, Speed::Low);
|
||||||
let mut spe_cfg0 = Input::new(dp.PC8, Pull::None);
|
let spe_cfg0 = Input::new(dp.PC8, Pull::None);
|
||||||
let mut spe_cfg1 = Input::new(dp.PC9, Pull::None);
|
let spe_cfg1 = Input::new(dp.PC9, Pull::None);
|
||||||
let _spe_ts_capt = Output::new(dp.PC6, Level::Low, Speed::Low);
|
let _spe_ts_capt = Output::new(dp.PC6, Level::Low, Speed::Low);
|
||||||
|
|
||||||
let spe_int = Input::new(dp.PB11, Pull::None);
|
let spe_int = Input::new(dp.PB11, Pull::None);
|
||||||
|
@ -29,7 +29,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
let _wake = Output::new(p.PB13, Level::Low, Speed::VeryHigh);
|
let _wake = Output::new(p.PB13, Level::Low, Speed::VeryHigh);
|
||||||
let mut reset = Output::new(p.PE8, Level::Low, Speed::VeryHigh);
|
let mut reset = Output::new(p.PE8, Level::Low, Speed::VeryHigh);
|
||||||
let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh);
|
let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh);
|
||||||
let mut ready = Input::new(p.PE1, Pull::Up);
|
let ready = Input::new(p.PE1, Pull::Up);
|
||||||
|
|
||||||
cortex_m::asm::delay(100_000);
|
cortex_m::asm::delay(100_000);
|
||||||
reset.set_high();
|
reset.set_high();
|
||||||
|
@ -24,7 +24,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
let _wake = Output::new(p.PB13, Level::Low, Speed::VeryHigh);
|
let _wake = Output::new(p.PB13, Level::Low, Speed::VeryHigh);
|
||||||
let mut reset = Output::new(p.PE8, Level::Low, Speed::VeryHigh);
|
let mut reset = Output::new(p.PE8, Level::Low, Speed::VeryHigh);
|
||||||
let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh);
|
let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh);
|
||||||
let mut ready = Input::new(p.PE1, Pull::Up);
|
let ready = Input::new(p.PE1, Pull::Up);
|
||||||
|
|
||||||
cortex_m::asm::delay(100_000);
|
cortex_m::asm::delay(100_000);
|
||||||
reset.set_high();
|
reset.set_high();
|
||||||
|
@ -12,7 +12,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let p = embassy_stm32::init(Default::default());
|
let p = embassy_stm32::init(Default::default());
|
||||||
|
|
||||||
let mut button = Input::new(p.PA0, Pull::Up);
|
let button = Input::new(p.PA0, Pull::Up);
|
||||||
let mut led1 = Output::new(p.PB15, Level::High, Speed::Low);
|
let mut led1 = Output::new(p.PB15, Level::High, Speed::Low);
|
||||||
let mut led2 = Output::new(p.PB9, Level::High, Speed::Low);
|
let mut led2 = Output::new(p.PB9, Level::High, Speed::Low);
|
||||||
|
|
||||||
|
@ -16,10 +16,10 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
// Test initial output
|
// Test initial output
|
||||||
{
|
{
|
||||||
let mut b = Input::new(&mut b, Pull::None);
|
let b = Input::new(&mut b, Pull::None);
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut a = Output::new(&mut a, Level::Low);
|
let a = Output::new(&mut a, Level::Low);
|
||||||
delay();
|
delay();
|
||||||
assert!(b.is_low());
|
assert!(b.is_low());
|
||||||
assert!(!b.is_high());
|
assert!(!b.is_high());
|
||||||
@ -64,7 +64,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
// Test input no pull
|
// Test input no pull
|
||||||
{
|
{
|
||||||
let mut b = Input::new(&mut b, Pull::None);
|
let b = Input::new(&mut b, Pull::None);
|
||||||
// no pull, the status is undefined
|
// no pull, the status is undefined
|
||||||
|
|
||||||
let mut a = Output::new(&mut a, Level::Low);
|
let mut a = Output::new(&mut a, Level::Low);
|
||||||
@ -77,7 +77,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
// Test input pulldown
|
// Test input pulldown
|
||||||
{
|
{
|
||||||
let mut b = Input::new(&mut b, Pull::Down);
|
let b = Input::new(&mut b, Pull::Down);
|
||||||
delay();
|
delay();
|
||||||
assert!(b.is_low());
|
assert!(b.is_low());
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
// Test input pullup
|
// Test input pullup
|
||||||
{
|
{
|
||||||
let mut b = Input::new(&mut b, Pull::Up);
|
let b = Input::new(&mut b, Pull::Up);
|
||||||
delay();
|
delay();
|
||||||
assert!(b.is_high());
|
assert!(b.is_high());
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
// Test output from A
|
// Test output from A
|
||||||
{
|
{
|
||||||
let mut pin1 = Input::new(&mut p9, Pull::None);
|
let pin1 = Input::new(&mut p9, Pull::None);
|
||||||
let _pwm = Pwm::new_output_a(&mut p.PWM_CH3, &mut p6, cfg.clone());
|
let _pwm = Pwm::new_output_a(&mut p.PWM_CH3, &mut p6, cfg.clone());
|
||||||
Timer::after_millis(1).await;
|
Timer::after_millis(1).await;
|
||||||
assert_eq!(pin1.is_low(), invert_a);
|
assert_eq!(pin1.is_low(), invert_a);
|
||||||
@ -59,7 +59,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
// Test output from B
|
// Test output from B
|
||||||
{
|
{
|
||||||
let mut pin2 = Input::new(&mut p11, Pull::None);
|
let pin2 = Input::new(&mut p11, Pull::None);
|
||||||
let _pwm = Pwm::new_output_b(&mut p.PWM_CH3, &mut p7, cfg.clone());
|
let _pwm = Pwm::new_output_b(&mut p.PWM_CH3, &mut p7, cfg.clone());
|
||||||
Timer::after_millis(1).await;
|
Timer::after_millis(1).await;
|
||||||
assert_ne!(pin2.is_low(), invert_a);
|
assert_ne!(pin2.is_low(), invert_a);
|
||||||
@ -73,8 +73,8 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
// Test output from A+B
|
// Test output from A+B
|
||||||
{
|
{
|
||||||
let mut pin1 = Input::new(&mut p9, Pull::None);
|
let pin1 = Input::new(&mut p9, Pull::None);
|
||||||
let mut pin2 = Input::new(&mut p11, Pull::None);
|
let pin2 = Input::new(&mut p11, Pull::None);
|
||||||
let _pwm = Pwm::new_output_ab(&mut p.PWM_CH3, &mut p6, &mut p7, cfg.clone());
|
let _pwm = Pwm::new_output_ab(&mut p.PWM_CH3, &mut p6, &mut p7, cfg.clone());
|
||||||
Timer::after_millis(1).await;
|
Timer::after_millis(1).await;
|
||||||
assert_eq!(pin1.is_low(), invert_a);
|
assert_eq!(pin1.is_low(), invert_a);
|
||||||
|
@ -20,10 +20,10 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
// Test initial output
|
// Test initial output
|
||||||
{
|
{
|
||||||
let mut b = Input::new(&mut b, Pull::None);
|
let b = Input::new(&mut b, Pull::None);
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut a = Output::new(&mut a, Level::Low, Speed::Low);
|
let a = Output::new(&mut a, Level::Low, Speed::Low);
|
||||||
delay();
|
delay();
|
||||||
assert!(b.is_low());
|
assert!(b.is_low());
|
||||||
assert!(!b.is_high());
|
assert!(!b.is_high());
|
||||||
@ -68,7 +68,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
// Test input no pull
|
// Test input no pull
|
||||||
{
|
{
|
||||||
let mut b = Input::new(&mut b, Pull::None);
|
let b = Input::new(&mut b, Pull::None);
|
||||||
// no pull, the status is undefined
|
// no pull, the status is undefined
|
||||||
|
|
||||||
let mut a = Output::new(&mut a, Level::Low, Speed::Low);
|
let mut a = Output::new(&mut a, Level::Low, Speed::Low);
|
||||||
@ -81,7 +81,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
// Test input pulldown
|
// Test input pulldown
|
||||||
{
|
{
|
||||||
let mut b = Input::new(&mut b, Pull::Down);
|
let b = Input::new(&mut b, Pull::Down);
|
||||||
delay();
|
delay();
|
||||||
assert!(b.is_low());
|
assert!(b.is_low());
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
// Test input pullup
|
// Test input pullup
|
||||||
{
|
{
|
||||||
let mut b = Input::new(&mut b, Pull::Up);
|
let b = Input::new(&mut b, Pull::Up);
|
||||||
delay();
|
delay();
|
||||||
assert!(b.is_high());
|
assert!(b.is_high());
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
// Test output open drain
|
// Test output open drain
|
||||||
{
|
{
|
||||||
let mut b = Input::new(&mut b, Pull::Down);
|
let b = Input::new(&mut b, Pull::Down);
|
||||||
// no pull, the status is undefined
|
// no pull, the status is undefined
|
||||||
|
|
||||||
let mut a = OutputOpenDrain::new(&mut a, Level::Low, Speed::Low, Pull::None);
|
let mut a = OutputOpenDrain::new(&mut a, Level::Low, Speed::Low, Pull::None);
|
||||||
|
Loading…
Reference in New Issue
Block a user