diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-03-18 02:29:03 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-03-18 18:49:10 +0100 |
| commit | b57489eb5d27075e077b955b295cc97bf2fc312f (patch) | |
| tree | 0fc17b38e80f0b2c9c1fd28ca916997a33dbca3a /embassy-nrf/src | |
| parent | 0cd19a58c3dcaa689ba57da80c02af75866f7e09 (diff) | |
peripheralmutex: separate interrupt registration to own method.
Diffstat (limited to 'embassy-nrf/src')
| -rw-r--r-- | embassy-nrf/src/buffered_uarte.rs | 12 | ||||
| -rw-r--r-- | embassy-nrf/src/spim.rs | 1 |
2 files changed, 10 insertions, 3 deletions
diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index 9b4ec6061..6cc5f1322 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs | |||
| @@ -207,7 +207,9 @@ impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi | |||
| 207 | for BufferedUarte<'a, U, T, P1, P2> | 207 | for BufferedUarte<'a, U, T, P1, P2> |
| 208 | { | 208 | { |
| 209 | fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>> { | 209 | fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>> { |
| 210 | self.inner().with(|state, _irq| { | 210 | let mut inner = self.inner(); |
| 211 | inner.as_mut().register_interrupt(); | ||
| 212 | inner.with(|state, _irq| { | ||
| 211 | // Conservative compiler fence to prevent optimizations that do not | 213 | // Conservative compiler fence to prevent optimizations that do not |
| 212 | // take in to account actions by DMA. The fence has been placed here, | 214 | // take in to account actions by DMA. The fence has been placed here, |
| 213 | // before any DMA action has started | 215 | // before any DMA action has started |
| @@ -230,7 +232,9 @@ impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi | |||
| 230 | } | 232 | } |
| 231 | 233 | ||
| 232 | fn consume(self: Pin<&mut Self>, amt: usize) { | 234 | fn consume(self: Pin<&mut Self>, amt: usize) { |
| 233 | self.inner().with(|state, irq| { | 235 | let mut inner = self.inner(); |
| 236 | inner.as_mut().register_interrupt(); | ||
| 237 | inner.with(|state, irq| { | ||
| 234 | trace!("consume {:?}", amt); | 238 | trace!("consume {:?}", amt); |
| 235 | state.rx.pop(amt); | 239 | state.rx.pop(amt); |
| 236 | irq.pend(); | 240 | irq.pend(); |
| @@ -242,7 +246,9 @@ impl<'a, U: Instance, T: TimerInstance, P1: ConfigurablePpi, P2: ConfigurablePpi | |||
| 242 | for BufferedUarte<'a, U, T, P1, P2> | 246 | for BufferedUarte<'a, U, T, P1, P2> |
| 243 | { | 247 | { |
| 244 | fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>> { | 248 | fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>> { |
| 245 | self.inner().with(|state, irq| { | 249 | let mut inner = self.inner(); |
| 250 | inner.as_mut().register_interrupt(); | ||
| 251 | inner.with(|state, irq| { | ||
| 246 | trace!("poll_write: {:?}", buf.len()); | 252 | trace!("poll_write: {:?}", buf.len()); |
| 247 | 253 | ||
| 248 | let tx_buf = state.tx.push_buf(); | 254 | let tx_buf = state.tx.push_buf(); |
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index 4a3adeb3d..ef89afbc6 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs | |||
| @@ -148,6 +148,7 @@ impl<T: Instance> FullDuplex<u8> for Spim<T> { | |||
| 148 | slice_in_ram_or(rx, Error::DMABufferNotInDataMemory)?; | 148 | slice_in_ram_or(rx, Error::DMABufferNotInDataMemory)?; |
| 149 | slice_in_ram_or(tx, Error::DMABufferNotInDataMemory)?; | 149 | slice_in_ram_or(tx, Error::DMABufferNotInDataMemory)?; |
| 150 | 150 | ||
| 151 | self.as_mut().inner().register_interrupt(); | ||
| 151 | self.as_mut().inner().with(|s, _irq| { | 152 | self.as_mut().inner().with(|s, _irq| { |
| 152 | // Conservative compiler fence to prevent optimizations that do not | 153 | // Conservative compiler fence to prevent optimizations that do not |
| 153 | // take in to account actions by DMA. The fence has been placed here, | 154 | // take in to account actions by DMA. The fence has been placed here, |
