nrf/buffered_uart: take into account EASYDMA_SIZE. fixes nrf52832

This commit is contained in:
Dario Nieuwenhuis 2024-06-25 23:55:07 +02:00
parent c48547b475
commit 1ce9418bca

View File

@ -27,7 +27,7 @@ use crate::ppi::{
}; };
use crate::timer::{Instance as TimerInstance, Timer}; use crate::timer::{Instance as TimerInstance, Timer};
use crate::uarte::{configure, drop_tx_rx, Config, Instance as UarteInstance}; use crate::uarte::{configure, drop_tx_rx, Config, Instance as UarteInstance};
use crate::{interrupt, pac, Peripheral}; use crate::{interrupt, pac, Peripheral, EASY_DMA_SIZE};
pub(crate) struct State { pub(crate) struct State {
tx_buf: RingBuffer, tx_buf: RingBuffer,
@ -186,6 +186,7 @@ impl<U: UarteInstance> interrupt::typelevel::Handler<U::Interrupt> for Interrupt
// If not TXing, start. // If not TXing, start.
if s.tx_count.load(Ordering::Relaxed) == 0 { if s.tx_count.load(Ordering::Relaxed) == 0 {
let (ptr, len) = tx.pop_buf(); let (ptr, len) = tx.pop_buf();
let len = len.min(EASY_DMA_SIZE);
if len != 0 { if len != 0 {
//trace!(" irq_tx: starting {:?}", len); //trace!(" irq_tx: starting {:?}", len);
s.tx_count.store(len, Ordering::Relaxed); s.tx_count.store(len, Ordering::Relaxed);
@ -641,8 +642,8 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> {
s.rx_started_count.store(0, Ordering::Relaxed); s.rx_started_count.store(0, Ordering::Relaxed);
s.rx_ended_count.store(0, Ordering::Relaxed); s.rx_ended_count.store(0, Ordering::Relaxed);
s.rx_started.store(false, Ordering::Relaxed); s.rx_started.store(false, Ordering::Relaxed);
let len = rx_buffer.len(); let rx_len = rx_buffer.len().min(EASY_DMA_SIZE * 2);
unsafe { s.rx_buf.init(rx_buffer.as_mut_ptr(), len) }; unsafe { s.rx_buf.init(rx_buffer.as_mut_ptr(), rx_len) };
// clear errors // clear errors
let errors = r.errorsrc.read().bits(); let errors = r.errorsrc.read().bits();
@ -663,7 +664,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> {
// Configure byte counter. // Configure byte counter.
let timer = Timer::new_counter(timer); let timer = Timer::new_counter(timer);
timer.cc(1).write(rx_buffer.len() as u32 * 2); timer.cc(1).write(rx_len as u32 * 2);
timer.cc(1).short_compare_clear(); timer.cc(1).short_compare_clear();
timer.clear(); timer.clear();
timer.start(); timer.start();