2020-09-22 18:03:43 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
|
2022-04-02 04:35:06 +02:00
|
|
|
use defmt::*;
|
2022-08-17 23:40:16 +02:00
|
|
|
use embassy_executor::Spawner;
|
2023-03-05 20:17:52 +01:00
|
|
|
use embassy_nrf::{bind_interrupts, peripherals, uarte};
|
2022-06-12 22:15:44 +02:00
|
|
|
use {defmt_rtt as _, panic_probe as _};
|
2022-04-02 04:35:06 +02:00
|
|
|
|
2023-03-05 20:17:52 +01:00
|
|
|
bind_interrupts!(struct Irqs {
|
|
|
|
UARTE0_UART0 => uarte::InterruptHandler<peripherals::UARTE0>;
|
|
|
|
});
|
|
|
|
|
2022-07-29 21:58:35 +02:00
|
|
|
#[embassy_executor::main]
|
2022-08-17 18:49:55 +02:00
|
|
|
async fn main(_spawner: Spawner) {
|
|
|
|
let p = embassy_nrf::init(Default::default());
|
2021-03-22 01:15:44 +01:00
|
|
|
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.UARTE0, Irqs, p.P0_08, p.P0_06, config);
|
2021-02-02 05:14:52 +01:00
|
|
|
|
2020-09-22 18:03:43 +02:00
|
|
|
info!("uarte initialized!");
|
|
|
|
|
2020-12-23 16:18:29 +01:00
|
|
|
// Message must be in SRAM
|
|
|
|
let mut buf = [0; 8];
|
|
|
|
buf.copy_from_slice(b"Hello!\r\n");
|
|
|
|
|
2021-04-14 16:01:43 +02:00
|
|
|
unwrap!(uart.write(&buf).await);
|
2020-09-22 18:03:43 +02:00
|
|
|
info!("wrote hello in uart!");
|
|
|
|
|
|
|
|
loop {
|
2021-01-01 23:04:18 +01:00
|
|
|
info!("reading...");
|
2021-04-14 16:01:43 +02:00
|
|
|
unwrap!(uart.read(&mut buf).await);
|
2021-03-22 01:15:44 +01:00
|
|
|
info!("writing...");
|
2021-04-14 16:01:43 +02:00
|
|
|
unwrap!(uart.write(&buf).await);
|
2020-09-22 18:03:43 +02:00
|
|
|
}
|
|
|
|
}
|