de016e8456
trait_alias seems unused. no idea why it's there.
40 lines
1 KiB
Rust
40 lines
1 KiB
Rust
#![no_std]
|
|
#![no_main]
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
#[path = "../example_common.rs"]
|
|
mod example_common;
|
|
use example_common::*;
|
|
|
|
use defmt::panic;
|
|
use embassy::executor::Spawner;
|
|
use embassy::traits::uart::{Read, Write};
|
|
use embassy_nrf::gpio::NoPin;
|
|
use embassy_nrf::{interrupt, uarte, Peripherals};
|
|
|
|
#[embassy::main]
|
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
|
let mut config = uarte::Config::default();
|
|
config.parity = uarte::Parity::EXCLUDED;
|
|
config.baudrate = uarte::Baudrate::BAUD115200;
|
|
|
|
let irq = interrupt::take!(UARTE0_UART0);
|
|
let mut uart =
|
|
unsafe { uarte::Uarte::new(p.UARTE0, irq, p.P0_08, p.P0_06, NoPin, NoPin, config) };
|
|
|
|
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);
|
|
}
|
|
}
|