aboutsummaryrefslogtreecommitdiff
path: root/rust-toolchain.toml
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-12-16 07:44:40 +0000
committerGitHub <[email protected]>2021-12-16 07:44:40 +0000
commit5df16c6793a3730535ac91af8133ff744d76fad5 (patch)
treeefe5218718aa6115d472aa00b8611c8bb5510078 /rust-toolchain.toml
parentd5a3064c2c20b4a9515e5322bb9a74724ebcf7c9 (diff)
parent0642eec01e23d9037e21186cfb0c169e56f9a161 (diff)
Merge #544
544: Introduces split on the nRF Uarte r=Dirbaio a=huntc A new `split` method is introduced such that the Uarte tx and rx can be used from separate tasks. An MPSC is used in an example to illustrate how data may be passed between these tasks. The approach taken within the `Uarte` struct is to split into tx and rx fields on calling `Uarte::new`. These fields are returned given a call to `Uarte::split`, but otherwise, if that call isn't made, then the API remains as it was before. Here's a snippet from a new example introduced: ```rust #[embassy::main] async fn main(spawner: Spawner, p: Peripherals) { // ... let uart = uarte::Uarte::new(p.UARTE0, irq, p.P0_08, p.P0_06, NoPin, NoPin, config); let (mut tx, rx) = uart.split(); // ... // Spawn a task responsible purely for reading unwrap!(spawner.spawn(reader(rx, s))); // ... // Continue reading in this main task and write // back out the buffer we receive from the read // task. loop { if let Some(buf) = r.recv().await { info!("writing..."); unwrap!(tx.write(&buf).await); } } } #[embassy::task] async fn reader(mut rx: UarteRx<'static, UARTE0>, s: Sender<'static, Noop, [u8; 8], 1>) { let mut buf = [0; 8]; loop { info!("reading..."); unwrap!(rx.read(&mut buf).await); unwrap!(s.send(buf).await); } } ``` Co-authored-by: huntc <[email protected]>
Diffstat (limited to 'rust-toolchain.toml')
0 files changed, 0 insertions, 0 deletions