From 77eba3071d2a0584d251bdbb3e51f3866253443a Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Fri, 8 Sep 2023 00:11:56 +0200 Subject: [PATCH] UART adjustments --- src/main.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5c86f85..42a4f86 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,9 +25,9 @@ use embassy_rp::{ clocks::RoscRng, flash::{Flash, WRITE_SIZE}, gpio::{Level, Output}, - peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0, UART0}, + peripherals::{DMA_CH1, PIN_23, PIN_25, PIO0, UART0}, pio::{self, Pio}, - uart::{self, BufferedUartRx, Parity}, + uart::{self, Async, Parity, UartRx}, }; use embassy_sync::{ blocking_mutex::{raw::NoopRawMutex, Mutex}, @@ -58,7 +58,7 @@ use defmt::{debug, error, info, warn, Debug2Format}; use {defmt_rtt as _, panic_probe as _}; bind_interrupts!(struct Irqs { - UART0_IRQ => uart::BufferedInterruptHandler; + UART0_IRQ => uart::InterruptHandler; PIO0_IRQ_0 => pio::InterruptHandler; }); @@ -102,7 +102,7 @@ async fn wifi_task( runner: cyw43::Runner< 'static, Output<'static, PIN_23>, - PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>, + PioSpi<'static, PIN_25, PIO0, 0, DMA_CH1>, >, ) -> ! { runner.run().await @@ -113,14 +113,14 @@ async fn net_task(stack: &'static Stack>) -> ! { stack.run().await } -async fn get_readout(rx: &mut BufferedUartRx<'static, UART0>) -> Readout { +async fn get_readout(rx: &mut UartRx<'static, UART0, Async>) -> Readout { let mut buffer: Vec = Vec::new(); buffer.push(b'/').unwrap(); let mut byte = [0; 1]; debug!("Waiting for next telegram..."); loop { - rx.read_exact(&mut byte).await.unwrap(); + rx.read(&mut byte).await.unwrap(); if byte[0] == b'/' { break; @@ -137,7 +137,7 @@ async fn get_readout(rx: &mut BufferedUartRx<'static, UART0>) -> Readout { debug!("Start of CRC detected"); let mut crc = [0; 4]; - rx.read_exact(&mut crc).await.unwrap(); + rx.read(&mut crc).await.unwrap(); buffer.extend_from_slice(&crc).unwrap(); @@ -155,7 +155,7 @@ async fn get_readout(rx: &mut BufferedUartRx<'static, UART0>) -> Readout { #[embassy_executor::task] async fn uart_rx_task( - mut rx: BufferedUartRx<'static, UART0>, + mut rx: UartRx<'static, UART0, Async>, sender: Sender<'static, NoopRawMutex, dsmr5::state::State, 1>, ) { info!("Wating for serial data"); @@ -213,8 +213,7 @@ async fn main(spawner: Spawner) { config.parity = Parity::ParityNone; // config.invert_rx = true; - let buf = make_static!([0u8; 2048]); - let rx = BufferedUartRx::new_with_rts(p.UART0, Irqs, p.PIN_1, p.PIN_3, buf, config); + let rx = UartRx::new(p.UART0, p.PIN_17, Irqs, p.DMA_CH0, config); spawner.spawn(uart_rx_task(rx, channel.sender())).unwrap(); @@ -229,7 +228,7 @@ async fn main(spawner: Spawner) { cs, p.PIN_24, p.PIN_29, - p.DMA_CH0, + p.DMA_CH1, ); let (fw, clm) = unsafe { get_firmware() };