diff options
| -rw-r--r-- | embassy-nrf/src/uarte.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 36c9e6b23..b814b9ae9 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs | |||
| @@ -288,7 +288,7 @@ impl<'d, T: Instance> Write for Uarte<'d, T> { | |||
| 288 | pub struct UarteWithIdle<'d, U: Instance, T: TimerInstance> { | 288 | pub struct UarteWithIdle<'d, U: Instance, T: TimerInstance> { |
| 289 | uarte: Uarte<'d, U>, | 289 | uarte: Uarte<'d, U>, |
| 290 | timer: T, | 290 | timer: T, |
| 291 | _ppi_ch1: Ppi<'d, AnyConfigurableChannel>, | 291 | ppi_ch1: Ppi<'d, AnyConfigurableChannel>, |
| 292 | _ppi_ch2: Ppi<'d, AnyConfigurableChannel>, | 292 | _ppi_ch2: Ppi<'d, AnyConfigurableChannel>, |
| 293 | } | 293 | } |
| 294 | 294 | ||
| @@ -355,7 +355,7 @@ impl<'d, U: Instance, T: TimerInstance> UarteWithIdle<'d, U, T> { | |||
| 355 | Self { | 355 | Self { |
| 356 | uarte, | 356 | uarte, |
| 357 | timer, | 357 | timer, |
| 358 | _ppi_ch1: ppi_ch1, | 358 | ppi_ch1: ppi_ch1, |
| 359 | _ppi_ch2: ppi_ch2, | 359 | _ppi_ch2: ppi_ch2, |
| 360 | } | 360 | } |
| 361 | } | 361 | } |
| @@ -410,11 +410,12 @@ impl<'d, U: Instance, T: TimerInstance> ReadUntilIdle for UarteWithIdle<'d, U, T | |||
| 410 | .await; | 410 | .await; |
| 411 | 411 | ||
| 412 | compiler_fence(Ordering::SeqCst); | 412 | compiler_fence(Ordering::SeqCst); |
| 413 | r.events_rxstarted.reset(); | ||
| 414 | let n = r.rxd.amount.read().amount().bits() as usize; | 413 | let n = r.rxd.amount.read().amount().bits() as usize; |
| 415 | 414 | ||
| 416 | // Stop timer | 415 | // Stop timer |
| 417 | rt.tasks_stop.write(|w| unsafe { w.bits(1) }); | 416 | rt.tasks_stop.write(|w| unsafe { w.bits(1) }); |
| 417 | r.events_rxstarted.reset(); | ||
| 418 | |||
| 418 | drop.defuse(); | 419 | drop.defuse(); |
| 419 | 420 | ||
| 420 | Ok(n) | 421 | Ok(n) |
| @@ -426,7 +427,12 @@ impl<'d, U: Instance, T: TimerInstance> Read for UarteWithIdle<'d, U, T> { | |||
| 426 | #[rustfmt::skip] | 427 | #[rustfmt::skip] |
| 427 | type ReadFuture<'a> where Self: 'a = impl Future<Output = Result<(), Error>> + 'a; | 428 | type ReadFuture<'a> where Self: 'a = impl Future<Output = Result<(), Error>> + 'a; |
| 428 | fn read<'a>(&'a mut self, rx_buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { | 429 | fn read<'a>(&'a mut self, rx_buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { |
| 429 | self.uarte.read(rx_buffer) | 430 | async move { |
| 431 | self.ppi_ch1.disable(); | ||
| 432 | let result = self.uarte.read(rx_buffer).await; | ||
| 433 | self.ppi_ch1.enable(); | ||
| 434 | result | ||
| 435 | } | ||
| 430 | } | 436 | } |
| 431 | } | 437 | } |
| 432 | 438 | ||
