From 821909ae812ece13c2f7c0deafdc0a4a5923b4e3 Mon Sep 17 00:00:00 2001 From: Wilfried Chauveau Date: Mon, 12 Feb 2024 06:42:10 +0000 Subject: [PATCH 1/2] gpio: Add getters to the various pad overrides (not type tracked) --- rp2040-hal/src/gpio/mod.rs | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/rp2040-hal/src/gpio/mod.rs b/rp2040-hal/src/gpio/mod.rs index e5b017578..34057ab40 100644 --- a/rp2040-hal/src/gpio/mod.rs +++ b/rp2040-hal/src/gpio/mod.rs @@ -522,6 +522,18 @@ impl Pin { // ======================= // IO related methods + /// Get the input override. + #[inline] + pub fn get_input_override(&self) -> InputOverride { + use pac::io_bank0::gpio::gpio_ctrl::INOVER_A; + match self.id.io_ctrl().read().inover().variant() { + INOVER_A::NORMAL => InputOverride::Normal, + INOVER_A::INVERT => InputOverride::Invert, + INOVER_A::LOW => InputOverride::AlwaysLow, + INOVER_A::HIGH => InputOverride::AlwaysHigh, + } + } + /// Set the input override. #[inline] pub fn set_input_override(&mut self, override_value: InputOverride) { @@ -535,6 +547,18 @@ impl Pin { self.id.io_ctrl().modify(|_, w| w.inover().variant(variant)); } + /// Set the output enable override. + #[inline] + pub fn get_output_enable_override(&self) -> OutputEnableOverride { + use pac::io_bank0::gpio::gpio_ctrl::OEOVER_A; + match self.id.io_ctrl().read().oeover().variant() { + OEOVER_A::NORMAL => OutputEnableOverride::Normal, + OEOVER_A::INVERT => OutputEnableOverride::Invert, + OEOVER_A::DISABLE => OutputEnableOverride::Disable, + OEOVER_A::ENABLE => OutputEnableOverride::Enable, + } + } + /// Set the output enable override. #[inline] pub fn set_output_enable_override(&mut self, override_value: OutputEnableOverride) { @@ -548,6 +572,18 @@ impl Pin { self.id.io_ctrl().modify(|_, w| w.oeover().variant(variant)); } + /// Get the output override. + #[inline] + pub fn get_output_override(&self) -> OutputOverride { + use pac::io_bank0::gpio::gpio_ctrl::OUTOVER_A; + match self.id.io_ctrl().read().outover().variant() { + OUTOVER_A::NORMAL => OutputOverride::DontInvert, + OUTOVER_A::INVERT => OutputOverride::Invert, + OUTOVER_A::LOW => OutputOverride::AlwaysLow, + OUTOVER_A::HIGH => OutputOverride::AlwaysHigh, + } + } + /// Set the output override. #[inline] pub fn set_output_override(&mut self, override_value: OutputOverride) { @@ -563,6 +599,18 @@ impl Pin { .modify(|_, w| w.outover().variant(variant)); } + /// Get the interrupt override. + #[inline] + pub fn get_interrupt_override(&self) -> InterruptOverride { + use pac::io_bank0::gpio::gpio_ctrl::IRQOVER_A; + match self.id.io_ctrl().read().irqover().variant() { + IRQOVER_A::NORMAL => InterruptOverride::Normal, + IRQOVER_A::INVERT => InterruptOverride::Invert, + IRQOVER_A::LOW => InterruptOverride::AlwaysLow, + IRQOVER_A::HIGH => InterruptOverride::AlwaysHigh, + } + } + /// Set the interrupt override. #[inline] pub fn set_interrupt_override(&mut self, override_value: InterruptOverride) { From c99bf2abd5799bb7fd54af5e6a2d8a1a17864781 Mon Sep 17 00:00:00 2001 From: Wilfried Chauveau Date: Mon, 12 Feb 2024 09:07:19 +0000 Subject: [PATCH 2/2] gpio: Missed documentation update in copy/pase Co-authored-by: 9names <60134748+9names@users.noreply.github.com> --- rp2040-hal/src/gpio/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rp2040-hal/src/gpio/mod.rs b/rp2040-hal/src/gpio/mod.rs index 34057ab40..cbf46839d 100644 --- a/rp2040-hal/src/gpio/mod.rs +++ b/rp2040-hal/src/gpio/mod.rs @@ -547,7 +547,7 @@ impl Pin { self.id.io_ctrl().modify(|_, w| w.inover().variant(variant)); } - /// Set the output enable override. + /// Get the output enable override. #[inline] pub fn get_output_enable_override(&self) -> OutputEnableOverride { use pac::io_bank0::gpio::gpio_ctrl::OEOVER_A;