Don't use embedded_dma in nrf uarte.
This commit is contained in:
@ -28,6 +28,7 @@ async fn run(mut uart: uarte::Uarte<pac::UARTE0>) {
|
||||
info!("wrote hello in uart!");
|
||||
|
||||
loop {
|
||||
let buf_len = buf.len();
|
||||
info!("reading...");
|
||||
|
||||
// `receive()` doesn't return until the buffer has been completely filled with
|
||||
@ -37,19 +38,17 @@ async fn run(mut uart: uarte::Uarte<pac::UARTE0>) {
|
||||
// 1 second timer, effectively adding a timeout to the receive operation.
|
||||
let recv_fut = uart.receive(&mut buf);
|
||||
let timer_fut = Timer::after(Duration::from_millis(1000));
|
||||
let received = match select(recv_fut, timer_fut).await {
|
||||
let received_len = match select(recv_fut, timer_fut).await {
|
||||
// recv_fut completed first, so we've received `buf_len` bytes.
|
||||
Either::Left((buf, _)) => buf,
|
||||
Either::Left(_) => buf_len,
|
||||
// timer_fut completed first. `select` gives us back the future that didn't complete, which
|
||||
// is `recv_fut` in this case, so we can do further stuff with it.
|
||||
//
|
||||
// The recv_fut would stop the uart read automatically when dropped. However, we want to know how
|
||||
// many bytes have been received, so we have to "gracefully stop" it with `.stop()`.
|
||||
Either::Right((_, recv_fut)) => {
|
||||
let (buf, n) = recv_fut.stop().await;
|
||||
&buf[..n]
|
||||
}
|
||||
Either::Right((_, recv_fut)) => recv_fut.stop().await,
|
||||
};
|
||||
let received = &mut buf[..received_len];
|
||||
|
||||
if received.len() > 0 {
|
||||
info!("read done, got {:[u8]}", received);
|
||||
|
Reference in New Issue
Block a user