Skip to content
Snippets Groups Projects
Commit c4932c60 authored by Benjamin Koch's avatar Benjamin Koch
Browse files

read from uart

parent 2d5c2192
No related branches found
No related tags found
No related merge requests found
......@@ -14,10 +14,21 @@ use embassy_rp::peripherals::UART0;
use embassy_rp::uart::{self, Async, UartRx, UartTx, Parity};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
async fn reader(mut rx: UartRx<'static, UART0, Async>) {
info!("Reading...");
loop {
let mut buf = [0; 1];
match rx.read(&mut buf).await {
Result::Ok(()) => info!("RX {:?}", buf),
Result::Err(e) => info!("RX error {:?}", e),
}
}
}
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
async fn main(spawner: Spawner) {
let p = embassy_rp::init(Default::default());
// pinout:
......@@ -71,6 +82,7 @@ async fn main(_spawner: Spawner) {
p.DMA_CH1,
uart_config,
);
unwrap!(spawner.spawn(reader(uart_rx)));
loop {
info!("led on!");
......@@ -81,8 +93,4 @@ async fn main(_spawner: Spawner) {
led_b.set_low();
Timer::after(Duration::from_secs(1)).await;
}
// dummy read to fix Mode paraemter of UartRx
let buf = [0; 1];
let x = uart_rx.read(&mut buf).await;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment