diff options
| author | Badr Bouslikhin <[email protected]> | 2024-09-06 18:35:23 +0200 |
|---|---|---|
| committer | Badr Bouslikhin <[email protected]> | 2024-09-06 18:55:33 +0200 |
| commit | ee25f14b20fc2aabf428fbc7b2bd684ece66a2a1 (patch) | |
| tree | db7003a1af776ecc30e9e26ff57ef55dec10ea6d /embassy-stm32/src | |
| parent | f0a86070512ad739641cee7d9fa39d63f5c8a9f6 (diff) | |
fix(stm32): reorder dma and idle futures
Diffstat (limited to 'embassy-stm32/src')
| -rw-r--r-- | embassy-stm32/src/usart/ringbuffered.rs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/embassy-stm32/src/usart/ringbuffered.rs b/embassy-stm32/src/usart/ringbuffered.rs index 8cf75933a..b0652046c 100644 --- a/embassy-stm32/src/usart/ringbuffered.rs +++ b/embassy-stm32/src/usart/ringbuffered.rs | |||
| @@ -184,20 +184,6 @@ impl<'d> RingBufferedUartRx<'d> { | |||
| 184 | async fn wait_for_data_or_idle(&mut self) -> Result<(), Error> { | 184 | async fn wait_for_data_or_idle(&mut self) -> Result<(), Error> { |
| 185 | compiler_fence(Ordering::SeqCst); | 185 | compiler_fence(Ordering::SeqCst); |
| 186 | 186 | ||
| 187 | let mut dma_init = false; | ||
| 188 | // Future which completes when there is dma is half full or full | ||
| 189 | let dma = poll_fn(|cx| { | ||
| 190 | self.ring_buf.set_waker(cx.waker()); | ||
| 191 | |||
| 192 | let status = match dma_init { | ||
| 193 | false => Poll::Pending, | ||
| 194 | true => Poll::Ready(()), | ||
| 195 | }; | ||
| 196 | |||
| 197 | dma_init = true; | ||
| 198 | status | ||
| 199 | }); | ||
| 200 | |||
| 201 | // Future which completes when idle line is detected | 187 | // Future which completes when idle line is detected |
| 202 | let s = self.state; | 188 | let s = self.state; |
| 203 | let uart = poll_fn(|cx| { | 189 | let uart = poll_fn(|cx| { |
| @@ -219,9 +205,23 @@ impl<'d> RingBufferedUartRx<'d> { | |||
| 219 | } | 205 | } |
| 220 | }); | 206 | }); |
| 221 | 207 | ||
| 222 | match select(dma, uart).await { | 208 | let mut dma_init = false; |
| 223 | Either::Left(((), _)) => Ok(()), | 209 | // Future which completes when there is dma is half full or full |
| 224 | Either::Right((result, _)) => result, | 210 | let dma = poll_fn(|cx| { |
| 211 | self.ring_buf.set_waker(cx.waker()); | ||
| 212 | |||
| 213 | let status = match dma_init { | ||
| 214 | false => Poll::Pending, | ||
| 215 | true => Poll::Ready(()), | ||
| 216 | }; | ||
| 217 | |||
| 218 | dma_init = true; | ||
| 219 | status | ||
| 220 | }); | ||
| 221 | |||
| 222 | match select(uart, dma).await { | ||
| 223 | Either::Left((result, _)) => result, | ||
| 224 | Either::Right(((), _)) => Ok(()), | ||
| 225 | } | 225 | } |
| 226 | } | 226 | } |
| 227 | } | 227 | } |
