From 9a863f07fe97f59c3e6a1d5aa125ed3b4094156f Mon Sep 17 00:00:00 2001 From: Caleb Jamison Date: Sat, 10 Aug 2024 17:36:28 -0400 Subject: [PATCH] Handle pad isolation everywhere and in the same way. --- embassy-rp/src/adc.rs | 2 ++ embassy-rp/src/gpio.rs | 7 ++----- embassy-rp/src/i2c.rs | 2 ++ embassy-rp/src/pwm.rs | 2 ++ embassy-rp/src/uart/mod.rs | 24 ++++++++++++++++++++---- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/embassy-rp/src/adc.rs b/embassy-rp/src/adc.rs index 12d08d06b..9768f480d 100644 --- a/embassy-rp/src/adc.rs +++ b/embassy-rp/src/adc.rs @@ -35,6 +35,8 @@ impl<'p> Channel<'p> { pub fn new_pin(pin: impl Peripheral

+ 'p, pull: Pull) -> Self { into_ref!(pin); pin.pad_ctrl().modify(|w| { + #[cfg(feature = "rp235x")] + w.set_iso(false); // manual says: // // > When using an ADC input shared with a GPIO pin, the pin’s diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index 8d6a8f2bd..24208b82e 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs @@ -581,6 +581,8 @@ impl<'d> Flex<'d> { into_ref!(pin); pin.pad_ctrl().write(|w| { + #[cfg(feature = "rp235x")] + w.set_iso(false); w.set_ie(true); }); @@ -591,11 +593,6 @@ impl<'d> Flex<'d> { w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::SIOB_PROC_0 as _); }); - #[cfg(feature = "rp235x")] - pin.pad_ctrl().modify(|w| { - w.set_iso(false); - }); - Self { pin: pin.map_into() } } diff --git a/embassy-rp/src/i2c.rs b/embassy-rp/src/i2c.rs index d95b17ff1..82189d29a 100644 --- a/embassy-rp/src/i2c.rs +++ b/embassy-rp/src/i2c.rs @@ -363,6 +363,8 @@ where { pin.gpio().ctrl().write(|w| w.set_funcsel(3)); pin.pad_ctrl().write(|w| { + #[cfg(feature = "rp235x")] + w.set_iso(false); w.set_schmitt(true); w.set_slewfast(false); w.set_ie(true); diff --git a/embassy-rp/src/pwm.rs b/embassy-rp/src/pwm.rs index 3f96a3f05..b50337ad1 100644 --- a/embassy-rp/src/pwm.rs +++ b/embassy-rp/src/pwm.rs @@ -110,6 +110,8 @@ impl<'d> Pwm<'d> { if let Some(pin) = &b { pin.gpio().ctrl().write(|w| w.set_funcsel(4)); pin.pad_ctrl().modify(|w| { + #[cfg(feature = "rp235x")] + w.set_iso(false); w.set_pue(b_pull == Pull::Up); w.set_pde(b_pull == Pull::Down); }); diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs index 058cfcbee..9fc2ad89f 100644 --- a/embassy-rp/src/uart/mod.rs +++ b/embassy-rp/src/uart/mod.rs @@ -851,7 +851,11 @@ impl<'d, T: Instance + 'd, M: Mode> Uart<'d, T, M> { Outover::NORMAL }); }); - pin.pad_ctrl().write(|w| w.set_ie(true)); + pin.pad_ctrl().write(|w| { + #[cfg(feature = "rp235x")] + w.set_iso(false); + w.set_ie(true); + }); } if let Some(pin) = &rx { let funcsel = { @@ -870,7 +874,11 @@ impl<'d, T: Instance + 'd, M: Mode> Uart<'d, T, M> { Inover::NORMAL }); }); - pin.pad_ctrl().write(|w| w.set_ie(true)); + pin.pad_ctrl().write(|w| { + #[cfg(feature = "rp235x")] + w.set_iso(false); + w.set_ie(true); + }); } if let Some(pin) = &cts { pin.gpio().ctrl().write(|w| { @@ -881,7 +889,11 @@ impl<'d, T: Instance + 'd, M: Mode> Uart<'d, T, M> { Inover::NORMAL }); }); - pin.pad_ctrl().write(|w| w.set_ie(true)); + pin.pad_ctrl().write(|w| { + #[cfg(feature = "rp235x")] + w.set_iso(false); + w.set_ie(true); + }); } if let Some(pin) = &rts { pin.gpio().ctrl().write(|w| { @@ -892,7 +904,11 @@ impl<'d, T: Instance + 'd, M: Mode> Uart<'d, T, M> { Outover::NORMAL }); }); - pin.pad_ctrl().write(|w| w.set_ie(true)); + pin.pad_ctrl().write(|w| { + #[cfg(feature = "rp235x")] + w.set_iso(false); + w.set_ie(true); + }); } Self::set_baudrate_inner(config.baudrate);