aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp/src
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-rp/src')
-rw-r--r--embassy-rp/src/gpio.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs
index 2fb2d65c2..9b5faac15 100644
--- a/embassy-rp/src/gpio.rs
+++ b/embassy-rp/src/gpio.rs
@@ -146,6 +146,12 @@ impl<'d> Input<'d> {
146 self.pin.get_level() 146 self.pin.get_level()
147 } 147 }
148 148
149 /// Configure the input logic inversion of this pin.
150 #[inline]
151 pub fn set_inversion(&mut self, invert: bool) {
152 self.pin.set_input_inversion(invert)
153 }
154
149 /// Wait until the pin is high. If it is already high, return immediately. 155 /// Wait until the pin is high. If it is already high, return immediately.
150 #[inline] 156 #[inline]
151 pub async fn wait_for_high(&mut self) { 157 pub async fn wait_for_high(&mut self) {
@@ -382,6 +388,12 @@ impl<'d> Output<'d> {
382 self.pin.set_slew_rate(slew_rate) 388 self.pin.set_slew_rate(slew_rate)
383 } 389 }
384 390
391 /// Configure the output logic inversion of this pin.
392 #[inline]
393 pub fn set_inversion(&mut self, invert: bool) {
394 self.pin.set_output_inversion(invert)
395 }
396
385 /// Set the output as high. 397 /// Set the output as high.
386 #[inline] 398 #[inline]
387 pub fn set_high(&mut self) { 399 pub fn set_high(&mut self) {
@@ -685,6 +697,30 @@ impl<'d> Flex<'d> {
685 self.pin.sio_oe().value_xor().write_value(self.bit()) 697 self.pin.sio_oe().value_xor().write_value(self.bit())
686 } 698 }
687 699
700 /// Configure the input logic inversion of this pin.
701 #[inline]
702 pub fn set_input_inversion(&mut self, invert: bool) {
703 self.pin.gpio().ctrl().modify(|w| {
704 w.set_inover(if invert {
705 pac::io::vals::Inover::INVERT
706 } else {
707 pac::io::vals::Inover::NORMAL
708 })
709 });
710 }
711
712 /// Configure the output logic inversion of this pin.
713 #[inline]
714 pub fn set_output_inversion(&mut self, invert: bool) {
715 self.pin.gpio().ctrl().modify(|w| {
716 w.set_outover(if invert {
717 pac::io::vals::Outover::INVERT
718 } else {
719 pac::io::vals::Outover::NORMAL
720 })
721 });
722 }
723
688 /// Get whether the pin input level is high. 724 /// Get whether the pin input level is high.
689 #[inline] 725 #[inline]
690 pub fn is_high(&self) -> bool { 726 pub fn is_high(&self) -> bool {
@@ -815,6 +851,8 @@ impl<'d> Drop for Flex<'d> {
815 self.pin.pad_ctrl().write(|_| {}); 851 self.pin.pad_ctrl().write(|_| {});
816 self.pin.gpio().ctrl().write(|w| { 852 self.pin.gpio().ctrl().write(|w| {
817 w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::NULL as _); 853 w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::NULL as _);
854 w.set_inover(pac::io::vals::Inover::NORMAL);
855 w.set_outover(pac::io::vals::Outover::NORMAL);
818 }); 856 });
819 self.pin.io().int_dormant_wake().inte(idx / 8).write_clear(|w| { 857 self.pin.io().int_dormant_wake().inte(idx / 8).write_clear(|w| {
820 w.set_edge_high(idx % 8, true); 858 w.set_edge_high(idx % 8, true);