diff options
| author | diogo464 <[email protected]> | 2025-12-19 20:11:10 +0000 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-12-19 20:11:10 +0000 |
| commit | 235ed74ea44c9ed9764ec5633302ea399cb633e9 (patch) | |
| tree | 4eb7a749e31f40ce5781cfdb9a847cc5e0eb30a7 /embassy-rp/src | |
| parent | 8484b3bfaf11c7b2a9adfe4091c45fc44f1af1dc (diff) | |
embassy-rp: fix set_input_sync_bypass pin offset
currently this function causes a crash in debug mode when used with pins greater than
32 (available on the rp235xb variant) because it overflows when doing
the shift. this commit applies the offset to pin value before doing the
shift. this assumes that when using a pin greater than 32 the GPIOBASE
has already been set to 16.
Diffstat (limited to 'embassy-rp/src')
| -rw-r--r-- | embassy-rp/src/pio/mod.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/embassy-rp/src/pio/mod.rs b/embassy-rp/src/pio/mod.rs index 1c370fdfc..4d20dfd81 100644 --- a/embassy-rp/src/pio/mod.rs +++ b/embassy-rp/src/pio/mod.rs | |||
| @@ -294,7 +294,12 @@ impl<'l, PIO: Instance> Pin<'l, PIO> { | |||
| 294 | 294 | ||
| 295 | /// Set the pin's input sync bypass. | 295 | /// Set the pin's input sync bypass. |
| 296 | pub fn set_input_sync_bypass(&mut self, bypass: bool) { | 296 | pub fn set_input_sync_bypass(&mut self, bypass: bool) { |
| 297 | let mask = 1 << self.pin(); | 297 | let offset = match self.pin() { |
| 298 | pin @ 0..32 => 0, | ||
| 299 | pin @ _ => 16, | ||
| 300 | }; | ||
| 301 | let mask = 1 << self.pin() - offset; | ||
| 302 | |||
| 298 | if bypass { | 303 | if bypass { |
| 299 | PIO::PIO.input_sync_bypass().write_set(|w| *w = mask); | 304 | PIO::PIO.input_sync_bypass().write_set(|w| *w = mask); |
| 300 | } else { | 305 | } else { |
