diff options
| author | elagil <[email protected]> | 2024-11-17 23:09:51 +0100 |
|---|---|---|
| committer | elagil <[email protected]> | 2024-11-17 23:10:11 +0100 |
| commit | 7ae28163414d0042c4e06cc02de900e67b62df01 (patch) | |
| tree | 4cbc9fbdf85cfcdc5f812fb208a650a366a7874f /embassy-stm32/src/sai | |
| parent | f99d733b616e748eb9c7122b77d6521297d53171 (diff) | |
feat: SAI/ringbuffer add function to wait for any write error
Diffstat (limited to 'embassy-stm32/src/sai')
| -rw-r--r-- | embassy-stm32/src/sai/mod.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/embassy-stm32/src/sai/mod.rs b/embassy-stm32/src/sai/mod.rs index 057b21980..fd61e5339 100644 --- a/embassy-stm32/src/sai/mod.rs +++ b/embassy-stm32/src/sai/mod.rs | |||
| @@ -1003,6 +1003,22 @@ impl<'d, T: Instance, W: word::Word> Sai<'d, T, W> { | |||
| 1003 | } | 1003 | } |
| 1004 | } | 1004 | } |
| 1005 | 1005 | ||
| 1006 | /// Wait until any SAI write error occurs. | ||
| 1007 | /// | ||
| 1008 | /// One useful application for this is stopping playback as soon as the SAI | ||
| 1009 | /// experiences an overrun of the ring buffer. Then, instead of letting | ||
| 1010 | /// the SAI peripheral play the last written buffer over and over again, SAI | ||
| 1011 | /// can be muted or dropped instead. | ||
| 1012 | pub async fn write_error(&mut self) -> Result<(), Error> { | ||
| 1013 | match &mut self.ring_buffer { | ||
| 1014 | RingBuffer::Writable(buffer) => { | ||
| 1015 | buffer.write_error().await?; | ||
| 1016 | Ok(()) | ||
| 1017 | } | ||
| 1018 | _ => return Err(Error::NotATransmitter), | ||
| 1019 | } | ||
| 1020 | } | ||
| 1021 | |||
| 1006 | /// Write data to the SAI ringbuffer. | 1022 | /// Write data to the SAI ringbuffer. |
| 1007 | /// | 1023 | /// |
| 1008 | /// The first write starts the DMA after filling the ring buffer with the provided data. | 1024 | /// The first write starts the DMA after filling the ring buffer with the provided data. |
