aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-rp/src/gpio.rs4
-rw-r--r--embassy-rp/src/pio/mod.rs9
2 files changed, 6 insertions, 7 deletions
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs
index 31397172c..520043b07 100644
--- a/embassy-rp/src/gpio.rs
+++ b/embassy-rp/src/gpio.rs
@@ -16,9 +16,9 @@ use crate::{interrupt, pac, peripherals, Peripheral, RegExt};
16const NEW_AW: AtomicWaker = AtomicWaker::new(); 16const NEW_AW: AtomicWaker = AtomicWaker::new();
17 17
18#[cfg(any(feature = "rp2040", feature = "rp235xa"))] 18#[cfg(any(feature = "rp2040", feature = "rp235xa"))]
19const BANK0_PIN_COUNT: usize = 30; 19pub(crate) const BANK0_PIN_COUNT: usize = 30;
20#[cfg(feature = "rp235xb")] 20#[cfg(feature = "rp235xb")]
21const BANK0_PIN_COUNT: usize = 48; 21pub(crate) const BANK0_PIN_COUNT: usize = 48;
22 22
23static BANK0_WAKERS: [AtomicWaker; BANK0_PIN_COUNT] = [NEW_AW; BANK0_PIN_COUNT]; 23static BANK0_WAKERS: [AtomicWaker; BANK0_PIN_COUNT] = [NEW_AW; BANK0_PIN_COUNT];
24#[cfg(feature = "qspi-as-gpio")] 24#[cfg(feature = "qspi-as-gpio")]
diff --git a/embassy-rp/src/pio/mod.rs b/embassy-rp/src/pio/mod.rs
index e8e411a25..fc940b045 100644
--- a/embassy-rp/src/pio/mod.rs
+++ b/embassy-rp/src/pio/mod.rs
@@ -5,7 +5,7 @@ use core::pin::Pin as FuturePin;
5use core::sync::atomic::{compiler_fence, Ordering}; 5use core::sync::atomic::{compiler_fence, Ordering};
6use core::task::{Context, Poll}; 6use core::task::{Context, Poll};
7 7
8use atomic_polyfill::{AtomicU32, AtomicU8}; 8use atomic_polyfill::{AtomicU64, AtomicU8};
9use embassy_hal_internal::{into_ref, Peripheral, PeripheralRef}; 9use embassy_hal_internal::{into_ref, Peripheral, PeripheralRef};
10use embassy_sync::waitqueue::AtomicWaker; 10use embassy_sync::waitqueue::AtomicWaker;
11use fixed::types::extra::U8; 11use fixed::types::extra::U8;
@@ -1305,7 +1305,7 @@ impl<'d, PIO: Instance> Pio<'d, PIO> {
1305// other way. 1305// other way.
1306pub struct State { 1306pub struct State {
1307 users: AtomicU8, 1307 users: AtomicU8,
1308 used_pins: AtomicU32, 1308 used_pins: AtomicU64,
1309} 1309}
1310 1310
1311fn on_pio_drop<PIO: Instance>() { 1311fn on_pio_drop<PIO: Instance>() {
@@ -1313,8 +1313,7 @@ fn on_pio_drop<PIO: Instance>() {
1313 if state.users.fetch_sub(1, Ordering::AcqRel) == 1 { 1313 if state.users.fetch_sub(1, Ordering::AcqRel) == 1 {
1314 let used_pins = state.used_pins.load(Ordering::Relaxed); 1314 let used_pins = state.used_pins.load(Ordering::Relaxed);
1315 let null = pac::io::vals::Gpio0ctrlFuncsel::NULL as _; 1315 let null = pac::io::vals::Gpio0ctrlFuncsel::NULL as _;
1316 // we only have 30 pins. don't test the other two since gpio() asserts. 1316 for i in 0..crate::gpio::BANK0_PIN_COUNT {
1317 for i in 0..30 {
1318 if used_pins & (1 << i) != 0 { 1317 if used_pins & (1 << i) != 0 {
1319 pac::IO_BANK0.gpio(i).ctrl().write(|w| w.set_funcsel(null)); 1318 pac::IO_BANK0.gpio(i).ctrl().write(|w| w.set_funcsel(null));
1320 } 1319 }
@@ -1339,7 +1338,7 @@ trait SealedInstance {
1339 fn state() -> &'static State { 1338 fn state() -> &'static State {
1340 static STATE: State = State { 1339 static STATE: State = State {
1341 users: AtomicU8::new(0), 1340 users: AtomicU8::new(0),
1342 used_pins: AtomicU32::new(0), 1341 used_pins: AtomicU64::new(0),
1343 }; 1342 };
1344 1343
1345 &STATE 1344 &STATE