2020-09-22 16:03:43 +00:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
|
|
|
#[path = "../example_common.rs"]
|
|
|
|
mod example_common;
|
|
|
|
use example_common::*;
|
|
|
|
|
2021-03-29 00:47:10 +00:00
|
|
|
use embassy::executor::Spawner;
|
2021-03-28 22:42:08 +00:00
|
|
|
use embassy_nrf::gpio::NoPin;
|
2021-03-29 00:47:10 +00:00
|
|
|
use embassy_nrf::{interrupt, uarte, Peripherals};
|
2020-09-24 20:04:45 +00:00
|
|
|
|
2021-03-29 00:47:10 +00:00
|
|
|
#[embassy::main]
|
2021-05-17 09:48:58 +00:00
|
|
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
2021-03-22 00:15:44 +00:00
|
|
|
let mut config = uarte::Config::default();
|
|
|
|
config.parity = uarte::Parity::EXCLUDED;
|
|
|
|
config.baudrate = uarte::Baudrate::BAUD115200;
|
|
|
|
|
|
|
|
let irq = interrupt::take!(UARTE0_UART0);
|
2021-11-30 22:14:24 +00:00
|
|
|
let mut uart = uarte::Uarte::new(p.UARTE0, irq, p.P0_08, p.P0_06, NoPin, NoPin, config);
|
2021-02-02 04:14:52 +00:00
|
|
|
|
2020-09-22 16:03:43 +00:00
|
|
|
info!("uarte initialized!");
|
|
|
|
|
2020-12-23 15:18:29 +00:00
|
|
|
// Message must be in SRAM
|
|
|
|
let mut buf = [0; 8];
|
|
|
|
buf.copy_from_slice(b"Hello!\r\n");
|
|
|
|
|
2021-04-14 14:01:43 +00:00
|
|
|
unwrap!(uart.write(&buf).await);
|
2020-09-22 16:03:43 +00:00
|
|
|
info!("wrote hello in uart!");
|
|
|
|
|
|
|
|
loop {
|
2021-01-01 22:04:18 +00:00
|
|
|
info!("reading...");
|
2021-04-14 14:01:43 +00:00
|
|
|
unwrap!(uart.read(&mut buf).await);
|
2021-03-22 00:15:44 +00:00
|
|
|
info!("writing...");
|
2021-04-14 14:01:43 +00:00
|
|
|
unwrap!(uart.write(&buf).await);
|
2020-09-22 16:03:43 +00:00
|
|
|
}
|
|
|
|
}
|