2021-05-10 23:04:37 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
2022-04-02 04:35:06 +02:00
|
|
|
use defmt::*;
|
2021-05-10 23:04:37 +02:00
|
|
|
use embassy::executor::Spawner;
|
|
|
|
use embassy_nrf::{interrupt, uarte, Peripherals};
|
|
|
|
|
2022-04-02 04:35:06 +02:00
|
|
|
use defmt_rtt as _; // global logger
|
|
|
|
use panic_probe as _;
|
|
|
|
|
2021-05-10 23:04:37 +02:00
|
|
|
#[embassy::main]
|
2021-05-17 11:48:58 +02:00
|
|
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
2021-05-10 23:04:37 +02:00
|
|
|
let mut config = uarte::Config::default();
|
|
|
|
config.parity = uarte::Parity::EXCLUDED;
|
|
|
|
config.baudrate = uarte::Baudrate::BAUD115200;
|
|
|
|
|
|
|
|
let irq = interrupt::take!(UARTE0_UART0);
|
2022-01-13 22:24:13 +01:00
|
|
|
let mut uart = uarte::UarteWithIdle::new(
|
2022-02-12 01:04:01 +01:00
|
|
|
p.UARTE0, p.TIMER0, p.PPI_CH0, p.PPI_CH1, irq, p.P0_08, p.P0_06, config,
|
2022-01-13 22:24:13 +01:00
|
|
|
);
|
2021-05-10 23:04:37 +02: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...");
|
|
|
|
let n = unwrap!(uart.read_until_idle(&mut buf).await);
|
|
|
|
info!("got {} bytes", n);
|
|
|
|
}
|
|
|
|
}
|