diff options
| author | dvdsk <[email protected]> | 2024-10-26 12:38:10 +0200 |
|---|---|---|
| committer | dvdsk <[email protected]> | 2024-10-26 12:38:10 +0200 |
| commit | edac7cc6304c724c9626f73a35a22b074588c012 (patch) | |
| tree | 5db525bdc6987b7c14e31b4d52ea9e523ccf0845 | |
| parent | be50b62677f04f0d30727a9168b435b90584f06c (diff) | |
stm32/uart remove DmaUnsynced from public api
Its an internal error which should never be exposed. It should only
occur with wrong driver implementations. We log to the user and return
an Overrun error since handling DmaUnsynced as an Overrun will resolve it.
| -rw-r--r-- | embassy-stm32/src/dma/ringbuffer/mod.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/usart/mod.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/usart/ringbuffered.rs | 9 |
3 files changed, 12 insertions, 3 deletions
diff --git a/embassy-stm32/src/dma/ringbuffer/mod.rs b/embassy-stm32/src/dma/ringbuffer/mod.rs index 12d418414..0da8c374f 100644 --- a/embassy-stm32/src/dma/ringbuffer/mod.rs +++ b/embassy-stm32/src/dma/ringbuffer/mod.rs | |||
| @@ -21,6 +21,10 @@ pub trait DmaCtrl { | |||
| 21 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 21 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 22 | pub enum Error { | 22 | pub enum Error { |
| 23 | Overrun, | 23 | Overrun, |
| 24 | /// the newly read DMA positions don't make sense compared to the previous | ||
| 25 | /// ones. This can usually only occur due to wrong Driver implementation, if | ||
| 26 | /// the driver author (or the user using raw metapac code) directly resets | ||
| 27 | /// the channel for instance. | ||
| 24 | DmaUnsynced, | 28 | DmaUnsynced, |
| 25 | } | 29 | } |
| 26 | 30 | ||
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index 86c94789a..aaf7b41e6 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs | |||
| @@ -260,8 +260,6 @@ pub enum Error { | |||
| 260 | Parity, | 260 | Parity, |
| 261 | /// Buffer too large for DMA | 261 | /// Buffer too large for DMA |
| 262 | BufferTooLong, | 262 | BufferTooLong, |
| 263 | // TODO: ask what this is and document it (dvdsk) | ||
| 264 | DmaUnsynced, | ||
| 265 | } | 263 | } |
| 266 | 264 | ||
| 267 | enum ReadCompletionEvent { | 265 | enum ReadCompletionEvent { |
diff --git a/embassy-stm32/src/usart/ringbuffered.rs b/embassy-stm32/src/usart/ringbuffered.rs index f1914e1bf..a791ac2a9 100644 --- a/embassy-stm32/src/usart/ringbuffered.rs +++ b/embassy-stm32/src/usart/ringbuffered.rs | |||
| @@ -268,7 +268,14 @@ impl ReadReady for RingBufferedUartRx<'_> { | |||
| 268 | fn read_ready(&mut self) -> Result<bool, Self::Error> { | 268 | fn read_ready(&mut self) -> Result<bool, Self::Error> { |
| 269 | let len = self.ring_buf.len().map_err(|e| match e { | 269 | let len = self.ring_buf.len().map_err(|e| match e { |
| 270 | crate::dma::ringbuffer::Error::Overrun => Self::Error::Overrun, | 270 | crate::dma::ringbuffer::Error::Overrun => Self::Error::Overrun, |
| 271 | crate::dma::ringbuffer::Error::DmaUnsynced => Self::Error::DmaUnsynced, | 271 | crate::dma::ringbuffer::Error::DmaUnsynced => { |
| 272 | error!( | ||
| 273 | "Ringbuffer error: DmaUNsynced, driver implementation is | ||
| 274 | probably bugged please open an issue" | ||
| 275 | ); | ||
| 276 | // we report this as overrun since its recoverable in the same way | ||
| 277 | Self::Error::Overrun | ||
| 278 | } | ||
| 272 | })?; | 279 | })?; |
| 273 | Ok(len > 0) | 280 | Ok(len > 0) |
| 274 | } | 281 | } |
