diff options
| author | elagil <[email protected]> | 2025-08-25 21:10:59 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-09-05 14:43:29 +0200 |
| commit | cf5b1ea9f593d1d80b718b88330f041b59d071f1 (patch) | |
| tree | 7d48e58a7549406f964f44c4659bf9c9dec5a44e /embassy-stm32/src/dma/ringbuffer | |
| parent | 3c3b43fb00355a5db64a34416dc2f19042a3fc5a (diff) | |
feat: gpdma support (wip)
Diffstat (limited to 'embassy-stm32/src/dma/ringbuffer')
| -rw-r--r-- | embassy-stm32/src/dma/ringbuffer/mod.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/embassy-stm32/src/dma/ringbuffer/mod.rs b/embassy-stm32/src/dma/ringbuffer/mod.rs index e462c71d4..99960bc74 100644 --- a/embassy-stm32/src/dma/ringbuffer/mod.rs +++ b/embassy-stm32/src/dma/ringbuffer/mod.rs | |||
| @@ -92,6 +92,16 @@ impl<'a, W: Word> ReadableDmaRingBuffer<'a, W> { | |||
| 92 | } | 92 | } |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | /// The current ring-buffer read index. | ||
| 96 | pub fn read_index(&self, offset: usize) -> usize { | ||
| 97 | self.read_index.as_index(self.cap(), offset) | ||
| 98 | } | ||
| 99 | |||
| 100 | /// The current ring-buffer write index. | ||
| 101 | pub fn write_index(&self, offset: usize) -> usize { | ||
| 102 | self.write_index.as_index(self.cap(), offset) | ||
| 103 | } | ||
| 104 | |||
| 95 | /// Reset the ring buffer to its initial state. | 105 | /// Reset the ring buffer to its initial state. |
| 96 | pub fn reset(&mut self, dma: &mut impl DmaCtrl) { | 106 | pub fn reset(&mut self, dma: &mut impl DmaCtrl) { |
| 97 | dma.reset_complete_count(); | 107 | dma.reset_complete_count(); |
| @@ -208,6 +218,16 @@ impl<'a, W: Word> WritableDmaRingBuffer<'a, W> { | |||
| 208 | } | 218 | } |
| 209 | } | 219 | } |
| 210 | 220 | ||
| 221 | /// The current ring-buffer read index. | ||
| 222 | pub fn read_index(&self, offset: usize) -> usize { | ||
| 223 | self.read_index.as_index(self.cap(), offset) | ||
| 224 | } | ||
| 225 | |||
| 226 | /// The current ring-buffer write index. | ||
| 227 | pub fn write_index(&self, offset: usize) -> usize { | ||
| 228 | self.write_index.as_index(self.cap(), offset) | ||
| 229 | } | ||
| 230 | |||
| 211 | /// Reset the ring buffer to its initial state. The buffer after the reset will be full. | 231 | /// Reset the ring buffer to its initial state. The buffer after the reset will be full. |
| 212 | pub fn reset(&mut self, dma: &mut impl DmaCtrl) { | 232 | pub fn reset(&mut self, dma: &mut impl DmaCtrl) { |
| 213 | dma.reset_complete_count(); | 233 | dma.reset_complete_count(); |
