embassy/examples/nrf/src/bin
bors[bot] 5df16c6793
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 <huntchr@gmail.com>
2021-12-16 07:44:40 +00:00
..
awaitable_timer.rs Remove trait_alias, allow(incomplete_features). 2021-09-03 17:00:58 +02:00
blinky.rs Revert blinky changes for now 2021-12-10 12:32:20 +01:00
buffered_uart.rs Documents the nRF BufferedUarte problem 2021-12-12 17:52:17 +11:00
executor_fairness_test.rs Remove trait_alias, allow(incomplete_features). 2021-09-03 17:00:58 +02:00
gpiote_channel.rs Remove trait_alias, allow(incomplete_features). 2021-09-03 17:00:58 +02:00
gpiote_port.rs nrf/gpiote: remove PortInput, move impls to Input. 2021-12-14 13:23:40 +01:00
mpsc.rs embassy/channel: switch to use MutexKind 2021-09-13 00:08:41 +02:00
multiprio.rs Fix interrupt_take macro by specifying path to panic macro. 2021-11-23 11:00:37 +01:00
nvmc.rs nrf: add NVMC driver. 2021-10-22 02:14:33 +02:00
ppi.rs Fixed examples 2021-10-26 14:47:33 +02:00
pwm.rs fix examples for mut self set_duty 2021-11-10 12:48:15 -07:00
pwm_sequence.rs pwm_sequence show implicit and explicit stop functionality 2021-11-11 23:47:35 -07:00
pwm_sequence_ppi.rs nrf: sequencepwm add events 2021-11-13 16:24:41 -07:00
pwm_servo.rs pwm_servo example comment for clarity 2021-11-11 23:32:34 -07:00
qspi.rs Fix interrupt_take macro by specifying path to panic macro. 2021-11-23 11:00:37 +01:00
qspi_lowpower.rs Fix interrupt_take macro by specifying path to panic macro. 2021-11-23 11:00:37 +01:00
raw_spawn.rs Improve executor naming. Add docs. 2021-08-31 23:59:28 +02:00
rng.rs Fix interrupt_take macro by specifying path to panic macro. 2021-11-23 11:00:37 +01:00
saadc.rs Fix interrupt_take macro by specifying path to panic macro. 2021-11-23 11:00:37 +01:00
saadc_continuous.rs Fix interrupt_take macro by specifying path to panic macro. 2021-11-23 11:00:37 +01:00
spim.rs Fix interrupt_take macro by specifying path to panic macro. 2021-11-23 11:00:37 +01:00
temp.rs Fix interrupt_take macro by specifying path to panic macro. 2021-11-23 11:00:37 +01:00
timer.rs Remove trait_alias, allow(incomplete_features). 2021-09-03 17:00:58 +02:00
twim.rs Fix interrupt_take macro by specifying path to panic macro. 2021-11-23 11:00:37 +01:00
twim_lowpower.rs Fix interrupt_take macro by specifying path to panic macro. 2021-11-23 11:00:37 +01:00
uart.rs Removed unsafe from uarte 2021-12-01 09:14:24 +11:00
uart_idle.rs Fix interrupt_take macro by specifying path to panic macro. 2021-11-23 11:00:37 +01:00
uart_split.rs Introduces split on the nRF Uarte 2021-12-15 18:31:52 +11:00
wdt.rs nrf/gpiote: remove PortInput, move impls to Input. 2021-12-14 13:23:40 +01:00