diff options
Diffstat (limited to 'embassy-nrf/src/gpio.rs')
| -rw-r--r-- | embassy-nrf/src/gpio.rs | 107 |
1 files changed, 51 insertions, 56 deletions
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index ea2b76096..cf6225282 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs | |||
| @@ -566,82 +566,77 @@ mod eh02 { | |||
| 566 | } | 566 | } |
| 567 | } | 567 | } |
| 568 | 568 | ||
| 569 | #[cfg(feature = "unstable-traits")] | 569 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { |
| 570 | mod eh1 { | 570 | type Error = Infallible; |
| 571 | use super::*; | 571 | } |
| 572 | 572 | ||
| 573 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { | 573 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { |
| 574 | type Error = Infallible; | 574 | fn is_high(&self) -> Result<bool, Self::Error> { |
| 575 | Ok(self.is_high()) | ||
| 575 | } | 576 | } |
| 576 | 577 | ||
| 577 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { | 578 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 578 | fn is_high(&self) -> Result<bool, Self::Error> { | 579 | Ok(self.is_low()) |
| 579 | Ok(self.is_high()) | 580 | } |
| 580 | } | 581 | } |
| 581 | 582 | ||
| 582 | fn is_low(&self) -> Result<bool, Self::Error> { | 583 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { |
| 583 | Ok(self.is_low()) | 584 | type Error = Infallible; |
| 584 | } | 585 | } |
| 586 | |||
| 587 | impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { | ||
| 588 | fn set_high(&mut self) -> Result<(), Self::Error> { | ||
| 589 | Ok(self.set_high()) | ||
| 585 | } | 590 | } |
| 586 | 591 | ||
| 587 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { | 592 | fn set_low(&mut self) -> Result<(), Self::Error> { |
| 588 | type Error = Infallible; | 593 | Ok(self.set_low()) |
| 589 | } | 594 | } |
| 595 | } | ||
| 590 | 596 | ||
| 591 | impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { | 597 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { |
| 592 | fn set_high(&mut self) -> Result<(), Self::Error> { | 598 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 593 | Ok(self.set_high()) | 599 | Ok(self.is_set_high()) |
| 594 | } | 600 | } |
| 595 | 601 | ||
| 596 | fn set_low(&mut self) -> Result<(), Self::Error> { | 602 | fn is_set_low(&self) -> Result<bool, Self::Error> { |
| 597 | Ok(self.set_low()) | 603 | Ok(self.is_set_low()) |
| 598 | } | ||
| 599 | } | 604 | } |
| 605 | } | ||
| 600 | 606 | ||
| 601 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { | 607 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { |
| 602 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 608 | type Error = Infallible; |
| 603 | Ok(self.is_set_high()) | 609 | } |
| 604 | } | ||
| 605 | 610 | ||
| 606 | fn is_set_low(&self) -> Result<bool, Self::Error> { | 611 | /// Implement [`InputPin`] for [`Flex`]; |
| 607 | Ok(self.is_set_low()) | 612 | /// |
| 608 | } | 613 | /// If the pin is not in input mode the result is unspecified. |
| 614 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { | ||
| 615 | fn is_high(&self) -> Result<bool, Self::Error> { | ||
| 616 | Ok(self.is_high()) | ||
| 609 | } | 617 | } |
| 610 | 618 | ||
| 611 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { | 619 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 612 | type Error = Infallible; | 620 | Ok(self.is_low()) |
| 613 | } | 621 | } |
| 622 | } | ||
| 614 | 623 | ||
| 615 | /// Implement [`InputPin`] for [`Flex`]; | 624 | impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { |
| 616 | /// | 625 | fn set_high(&mut self) -> Result<(), Self::Error> { |
| 617 | /// If the pin is not in input mode the result is unspecified. | 626 | Ok(self.set_high()) |
| 618 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { | ||
| 619 | fn is_high(&self) -> Result<bool, Self::Error> { | ||
| 620 | Ok(self.is_high()) | ||
| 621 | } | ||
| 622 | |||
| 623 | fn is_low(&self) -> Result<bool, Self::Error> { | ||
| 624 | Ok(self.is_low()) | ||
| 625 | } | ||
| 626 | } | 627 | } |
| 627 | 628 | ||
| 628 | impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { | 629 | fn set_low(&mut self) -> Result<(), Self::Error> { |
| 629 | fn set_high(&mut self) -> Result<(), Self::Error> { | 630 | Ok(self.set_low()) |
| 630 | Ok(self.set_high()) | ||
| 631 | } | ||
| 632 | |||
| 633 | fn set_low(&mut self) -> Result<(), Self::Error> { | ||
| 634 | Ok(self.set_low()) | ||
| 635 | } | ||
| 636 | } | 631 | } |
| 632 | } | ||
| 637 | 633 | ||
| 638 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { | 634 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { |
| 639 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 635 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 640 | Ok(self.is_set_high()) | 636 | Ok(self.is_set_high()) |
| 641 | } | 637 | } |
| 642 | 638 | ||
| 643 | fn is_set_low(&self) -> Result<bool, Self::Error> { | 639 | fn is_set_low(&self) -> Result<bool, Self::Error> { |
| 644 | Ok(self.is_set_low()) | 640 | Ok(self.is_set_low()) |
| 645 | } | ||
| 646 | } | 641 | } |
| 647 | } | 642 | } |
