diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-08-08 00:22:08 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-08-08 00:22:08 +0200 |
| commit | 6c10fa44d05d79e337cececca0215f2d4844c835 (patch) | |
| tree | 20c8deb30899b789cbd6125017d1f5344ac1d9fc | |
| parent | 89e2e25d6f40310d7d6c7aa403148bfc7e1d6aa9 (diff) | |
rp/gpio: fix wait_for_* when multiple pins are in use.
| -rw-r--r-- | embassy-rp/src/gpio.rs | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index a5df6068d..f9fa8378b 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs | |||
| @@ -152,24 +152,26 @@ unsafe fn IO_IRQ_BANK0() { | |||
| 152 | let event = (intsx.read().0 >> pin_group * 4) & 0xf as u32; | 152 | let event = (intsx.read().0 >> pin_group * 4) & 0xf as u32; |
| 153 | 153 | ||
| 154 | if let Some(trigger) = InterruptTrigger::from_u32(event) { | 154 | if let Some(trigger) = InterruptTrigger::from_u32(event) { |
| 155 | proc_intx.inte(pin / 8).write(|w| match trigger { | 155 | critical_section::with(|_| { |
| 156 | InterruptTrigger::AnyEdge => { | 156 | proc_intx.inte(pin / 8).modify(|w| match trigger { |
| 157 | w.set_edge_high(pin_group, false); | 157 | InterruptTrigger::AnyEdge => { |
| 158 | w.set_edge_low(pin_group, false); | 158 | w.set_edge_high(pin_group, false); |
| 159 | } | 159 | w.set_edge_low(pin_group, false); |
| 160 | InterruptTrigger::LevelHigh => { | 160 | } |
| 161 | debug!("IO_IRQ_BANK0 pin {} LevelHigh triggered\n", pin); | 161 | InterruptTrigger::LevelHigh => { |
| 162 | w.set_level_high(pin_group, false); | 162 | debug!("IO_IRQ_BANK0 pin {} LevelHigh triggered\n", pin); |
| 163 | } | 163 | w.set_level_high(pin_group, false); |
| 164 | InterruptTrigger::LevelLow => { | 164 | } |
| 165 | w.set_level_low(pin_group, false); | 165 | InterruptTrigger::LevelLow => { |
| 166 | } | 166 | w.set_level_low(pin_group, false); |
| 167 | InterruptTrigger::EdgeHigh => { | 167 | } |
| 168 | w.set_edge_high(pin_group, false); | 168 | InterruptTrigger::EdgeHigh => { |
| 169 | } | 169 | w.set_edge_high(pin_group, false); |
| 170 | InterruptTrigger::EdgeLow => { | 170 | } |
| 171 | w.set_edge_low(pin_group, false); | 171 | InterruptTrigger::EdgeLow => { |
| 172 | } | 172 | w.set_edge_low(pin_group, false); |
| 173 | } | ||
| 174 | }); | ||
| 173 | }); | 175 | }); |
| 174 | INTERRUPT_WAKERS[pin as usize].wake(); | 176 | INTERRUPT_WAKERS[pin as usize].wake(); |
| 175 | } | 177 | } |
| @@ -193,23 +195,25 @@ impl<'d, T: Pin> InputFuture<'d, T> { | |||
| 193 | // pin, and each group consists of LEVEL_LOW, LEVEL_HIGH, EDGE_LOW, | 195 | // pin, and each group consists of LEVEL_LOW, LEVEL_HIGH, EDGE_LOW, |
| 194 | // and EGDE_HIGH. | 196 | // and EGDE_HIGH. |
| 195 | let pin_group = (pin.pin() % 8) as usize; | 197 | let pin_group = (pin.pin() % 8) as usize; |
| 196 | pin.int_proc().inte((pin.pin() / 8) as usize).write(|w| match level { | 198 | critical_section::with(|_| { |
| 197 | InterruptTrigger::LevelHigh => { | 199 | pin.int_proc().inte((pin.pin() / 8) as usize).modify(|w| match level { |
| 198 | debug!("InputFuture::new enable LevelHigh for pin {} \n", pin.pin()); | 200 | InterruptTrigger::LevelHigh => { |
| 199 | w.set_level_high(pin_group, true); | 201 | debug!("InputFuture::new enable LevelHigh for pin {} \n", pin.pin()); |
| 200 | } | 202 | w.set_level_high(pin_group, true); |
| 201 | InterruptTrigger::LevelLow => { | 203 | } |
| 202 | w.set_level_low(pin_group, true); | 204 | InterruptTrigger::LevelLow => { |
| 203 | } | 205 | w.set_level_low(pin_group, true); |
| 204 | InterruptTrigger::EdgeHigh => { | 206 | } |
| 205 | w.set_edge_high(pin_group, true); | 207 | InterruptTrigger::EdgeHigh => { |
| 206 | } | 208 | w.set_edge_high(pin_group, true); |
| 207 | InterruptTrigger::EdgeLow => { | 209 | } |
| 208 | w.set_edge_low(pin_group, true); | 210 | InterruptTrigger::EdgeLow => { |
| 209 | } | 211 | w.set_edge_low(pin_group, true); |
| 210 | InterruptTrigger::AnyEdge => { | 212 | } |
| 211 | // noop | 213 | InterruptTrigger::AnyEdge => { |
| 212 | } | 214 | // noop |
| 215 | } | ||
| 216 | }); | ||
| 213 | }); | 217 | }); |
| 214 | 218 | ||
| 215 | irq.enable(); | 219 | irq.enable(); |
