rp/pio: make sure gpio() asserts are compiled out

we'll have to touch pio one way or other if the number of gpio pins ever
increases. may as well make sure an assert never fires until that happens.
This commit is contained in:
pennae 2023-05-06 21:14:00 +02:00
parent b38d496d51
commit db9b8eb88f

View File

@ -1070,7 +1070,8 @@ fn on_pio_drop<PIO: Instance>() {
if state.users.fetch_sub(1, Ordering::AcqRel) == 1 { if state.users.fetch_sub(1, Ordering::AcqRel) == 1 {
let used_pins = state.used_pins.load(Ordering::Relaxed); let used_pins = state.used_pins.load(Ordering::Relaxed);
let null = Gpio0ctrlFuncsel::NULL.0; let null = Gpio0ctrlFuncsel::NULL.0;
for i in 0..32 { // we only have 30 pins. don't test the other two since gpio() asserts.
for i in 0..30 {
if used_pins & (1 << i) != 0 { if used_pins & (1 << i) != 0 {
unsafe { unsafe {
pac::IO_BANK0.gpio(i).ctrl().write(|w| w.set_funcsel(null)); pac::IO_BANK0.gpio(i).ctrl().write(|w| w.set_funcsel(null));