Enable input mode for PWM pins on RP235x and disable it on drop

This commit is contained in:
1-rafael-1 2025-04-14 22:41:28 +02:00
parent dd787c3727
commit dbd7ce4d38

View File

@ -157,6 +157,11 @@ impl<'d> Pwm<'d> {
pin.pad_ctrl().modify(|w| { pin.pad_ctrl().modify(|w| {
#[cfg(feature = "_rp235x")] #[cfg(feature = "_rp235x")]
w.set_iso(false); w.set_iso(false);
#[cfg(feature = "_rp235x")]
if divmode != Divmode::DIV {
// Is in input mode and so must enable input mode for the pin
w.set_ie(true);
}
w.set_pue(b_pull == Pull::Up); w.set_pue(b_pull == Pull::Up);
w.set_pde(b_pull == Pull::Down); w.set_pde(b_pull == Pull::Down);
}); });
@ -462,6 +467,11 @@ impl<'d> Drop for Pwm<'d> {
} }
if let Some(pin) = &self.pin_b { if let Some(pin) = &self.pin_b {
pin.gpio().ctrl().write(|w| w.set_funcsel(31)); pin.gpio().ctrl().write(|w| w.set_funcsel(31));
#[cfg(feature = "_rp235x")]
// Disable input mode. Only pin_b can be input, so not needed for pin_a
pin.pad_ctrl().modify(|w| {
w.set_ie(false);
});
} }
} }
} }