Skip to content

Commit 3413c51

Browse files
committed
uart: enable auto-retriggering for ping-pong DMA
- remove redundant error checking in `read_buffered()`
1 parent b5f7c51 commit 3413c51

File tree

3 files changed

+2
-14
lines changed

3 files changed

+2
-14
lines changed

src/dma/channel.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ impl<'d> Channel<'d> {
202202
// SAFETY: unsafe due to .bits usage
203203
self.info.regs.channel(channel).xfercfg().write(|w| unsafe {
204204
w.cfgvalid().set_bit();
205-
// Descriptor is exhausted and we need to manually hit SWTRIG to trigger the next one.
206-
w.clrtrig().set_bit();
205+
// Auto-retrigger on completion for ping-pong operation
206+
w.clrtrig().clear_bit();
207207
// Set reload to enable continuous ping-pong operation
208208
w.reload().set_bit();
209209
w.setinta().set_bit();

src/dma/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@ fn dma0_irq_handler<const N: usize>(wakers: &[AtomicWaker; N]) {
170170
if ping_pong_status.buffer_b_status == BufferStatus::Granted {
171171
ping_pong_status.overrun_error = true;
172172
error!("DMA Ping-Pong buffer overrun on channel {}!", channel);
173-
} else {
174-
reg.channel(channel as usize)
175-
.xfercfg()
176-
.modify(|_, w| w.swtrig().set_bit());
177173
}
178174
} else {
179175
// Just finished Buffer B, switching to Buffer A
@@ -183,10 +179,6 @@ fn dma0_irq_handler<const N: usize>(wakers: &[AtomicWaker; N]) {
183179
if ping_pong_status.buffer_a_status == BufferStatus::Granted {
184180
ping_pong_status.overrun_error = true;
185181
error!("DMA Ping-Pong buffer overrun on channel {}!", channel);
186-
} else {
187-
reg.channel(channel as usize)
188-
.xfercfg()
189-
.modify(|_, w| w.swtrig().set_bit());
190182
}
191183
}
192184
}

src/uart.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,6 @@ impl<'a> UartRx<'a, Async> {
814814
async fn read_buffered(&mut self, buf: &mut [u8]) -> Result<usize> {
815815
let rx_dma = self._rx_dma.as_ref().ok_or(Error::Fail)?;
816816
let buffer_config = self._buffer_config.as_mut().ok_or(Error::Fail)?;
817-
// Check for ping-pong buffer overrun error from DMA
818-
if rx_dma.check_and_clear_overrun_error() {
819-
return Err(Error::Overrun);
820-
}
821817

822818
let half_size = buffer_config.buffer_a.len();
823819

0 commit comments

Comments
 (0)