diff options
Diffstat (limited to 'examples/nrf5340/src/bin/uart_split.rs')
| -rw-r--r-- | examples/nrf5340/src/bin/uart_split.rs | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/examples/nrf5340/src/bin/uart_split.rs b/examples/nrf5340/src/bin/uart_split.rs deleted file mode 100644 index 0bbbfeaa5..000000000 --- a/examples/nrf5340/src/bin/uart_split.rs +++ /dev/null | |||
| @@ -1,60 +0,0 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_nrf::peripherals::UARTETWISPI0; | ||
| 8 | use embassy_nrf::uarte::UarteRx; | ||
| 9 | use embassy_nrf::{interrupt, uarte}; | ||
| 10 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | ||
| 11 | use embassy_sync::channel::Channel; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | ||
| 13 | |||
| 14 | static CHANNEL: Channel<ThreadModeRawMutex, [u8; 8], 1> = Channel::new(); | ||
| 15 | |||
| 16 | #[embassy_executor::main] | ||
| 17 | async fn main(spawner: Spawner) { | ||
| 18 | let p = embassy_nrf::init(Default::default()); | ||
| 19 | let mut config = uarte::Config::default(); | ||
| 20 | config.parity = uarte::Parity::EXCLUDED; | ||
| 21 | config.baudrate = uarte::Baudrate::BAUD115200; | ||
| 22 | |||
| 23 | let irq = interrupt::take!(SERIAL0); | ||
| 24 | let uart = uarte::Uarte::new(p.UARTETWISPI0, irq, p.P1_00, p.P1_01, config); | ||
| 25 | let (mut tx, rx) = uart.split(); | ||
| 26 | |||
| 27 | info!("uarte initialized!"); | ||
| 28 | |||
| 29 | // Spawn a task responsible purely for reading | ||
| 30 | |||
| 31 | unwrap!(spawner.spawn(reader(rx))); | ||
| 32 | |||
| 33 | // Message must be in SRAM | ||
| 34 | { | ||
| 35 | let mut buf = [0; 23]; | ||
| 36 | buf.copy_from_slice(b"Type 8 chars to echo!\r\n"); | ||
| 37 | |||
| 38 | unwrap!(tx.write(&buf).await); | ||
| 39 | info!("wrote hello in uart!"); | ||
| 40 | } | ||
| 41 | |||
| 42 | // Continue reading in this main task and write | ||
| 43 | // back out the buffer we receive from the read | ||
| 44 | // task. | ||
| 45 | loop { | ||
| 46 | let buf = CHANNEL.recv().await; | ||
| 47 | info!("writing..."); | ||
| 48 | unwrap!(tx.write(&buf).await); | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | #[embassy_executor::task] | ||
| 53 | async fn reader(mut rx: UarteRx<'static, UARTETWISPI0>) { | ||
| 54 | let mut buf = [0; 8]; | ||
| 55 | loop { | ||
| 56 | info!("reading..."); | ||
| 57 | unwrap!(rx.read(&mut buf).await); | ||
| 58 | CHANNEL.send(buf).await; | ||
| 59 | } | ||
| 60 | } | ||
