Compare commits

..

No commits in common. "df191603dda129317a971591e4609f113559bd02" and "3b6acbd65e5ca344a6c9e2559a4befca53fd3338" have entirely different histories.

2 changed files with 11 additions and 13 deletions

View File

@ -96,12 +96,9 @@ embassy-futures = { git = "https://github.com/embassy-rs/embassy" }
embassy-boot-rp = { git = "https://github.com/embassy-rs/embassy" } embassy-boot-rp = { git = "https://github.com/embassy-rs/embassy" }
embassy-boot = { git = "https://github.com/embassy-rs/embassy" } embassy-boot = { git = "https://github.com/embassy-rs/embassy" }
# Updated to embedded-io 0.5.0
rust-mqtt = { git = "https://git.huizinga.dev/Dreaded_X/rust-mqtt" } rust-mqtt = { git = "https://git.huizinga.dev/Dreaded_X/rust-mqtt" }
# Make mqtt:// and mqtts:// actually work
nourl = { git = "https://git.huizinga.dev/Dreaded_X/nourl" } nourl = { git = "https://git.huizinga.dev/Dreaded_X/nourl" }
# Waiting for this to get updated to embedded-io 0.5 properly
reqwless = { path = "../reqwless" } reqwless = { path = "../reqwless" }
[build-dependencies] [build-dependencies]

View File

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