aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelagil <[email protected]>2024-11-28 17:45:00 +0100
committerelagil <[email protected]>2024-11-28 17:45:00 +0100
commit5d2b38c979b045d69fee1e2b1bb7f209043ceece (patch)
treee4e097a2fb83bab677f5679557c94d4841bb3ae7
parent152d8ee0d9526a9b5d41350385ee2b2102c0c43f (diff)
doc: improve comment
-rw-r--r--embassy-stm32/src/dma/ringbuffer/mod.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/embassy-stm32/src/dma/ringbuffer/mod.rs b/embassy-stm32/src/dma/ringbuffer/mod.rs
index 4dc1b51a9..44ea497fe 100644
--- a/embassy-stm32/src/dma/ringbuffer/mod.rs
+++ b/embassy-stm32/src/dma/ringbuffer/mod.rs
@@ -253,10 +253,17 @@ impl<'a, W: Word> WritableDmaRingBuffer<'a, W> {
253 253
254 /// Write elements directly to the buffer. 254 /// Write elements directly to the buffer.
255 /// 255 ///
256 /// Subsequent writes will overwrite the content of the buffer, so it is not useful to call this more than once.
256 /// Data is aligned towards the end of the buffer. 257 /// Data is aligned towards the end of the buffer.
258 ///
259 /// In case of success, returns the written length, and the empty space in front of the written block.
260 /// Fails if the data to write exceeds the buffer capacity.
257 pub fn write_immediate(&mut self, buf: &[W]) -> Result<(usize, usize), Error> { 261 pub fn write_immediate(&mut self, buf: &[W]) -> Result<(usize, usize), Error> {
258 let start = self.cap() - buf.len(); 262 if buf.len() > self.cap() {
263 return Err(Error::Overrun);
264 }
259 265
266 let start = self.cap() - buf.len();
260 for (i, data) in buf.iter().enumerate() { 267 for (i, data) in buf.iter().enumerate() {
261 self.write_buf(start + i, *data) 268 self.write_buf(start + i, *data)
262 } 269 }