2023-01-08 15:36:35 +01:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
|
|
|
use defmt::*;
|
|
|
|
use embassy_executor::Spawner;
|
2023-03-05 20:17:52 +01:00
|
|
|
use embassy_nrf::peripherals::SERIAL0;
|
|
|
|
use embassy_nrf::{bind_interrupts, uarte};
|
2023-01-08 15:36:35 +01:00
|
|
|
use {defmt_rtt as _, panic_probe as _};
|
|
|
|
|
2023-03-05 20:17:52 +01:00
|
|
|
bind_interrupts!(struct Irqs {
|
|
|
|
SERIAL0 => uarte::InterruptHandler<SERIAL0>;
|
|
|
|
});
|
|
|
|
|
2023-01-08 15:36:35 +01:00
|
|
|
#[embassy_executor::main]
|
|
|
|
async fn main(_spawner: Spawner) {
|
|
|
|
let p = embassy_nrf::init(Default::default());
|
|
|
|
let mut config = uarte::Config::default();
|
|
|
|
config.parity = uarte::Parity::EXCLUDED;
|
|
|
|
config.baudrate = uarte::Baudrate::BAUD115200;
|
|
|
|
|
2023-03-05 20:17:52 +01:00
|
|
|
let mut uart = uarte::Uarte::new(p.SERIAL0, Irqs, p.P1_00, p.P1_01, config);
|
2023-01-08 15:36:35 +01:00
|
|
|
|
|
|
|
info!("uarte initialized!");
|
|
|
|
|
|
|
|
// Message must be in SRAM
|
|
|
|
let mut buf = [0; 8];
|
|
|
|
buf.copy_from_slice(b"Hello!\r\n");
|
|
|
|
|
|
|
|
unwrap!(uart.write(&buf).await);
|
|
|
|
info!("wrote hello in uart!");
|
|
|
|
|
|
|
|
loop {
|
|
|
|
info!("reading...");
|
|
|
|
unwrap!(uart.read(&mut buf).await);
|
|
|
|
info!("writing...");
|
|
|
|
unwrap!(uart.write(&buf).await);
|
|
|
|
}
|
|
|
|
}
|