diff options
| author | huntc <[email protected]> | 2021-07-09 12:04:22 +1000 |
|---|---|---|
| committer | huntc <[email protected]> | 2021-07-15 12:31:52 +1000 |
| commit | 5f87c7808c9d896a2a2d5e064a58ed2ac23a4348 (patch) | |
| tree | 4e3eec5de3d804bb6b90684cca912936195b1ea2 /examples | |
| parent | 56b3e927fe2c779c4bc6d556ff9fc836d2a4f2d4 (diff) | |
Remove the cell and trait
At the expense of exposing the channel types again. We do this as we want to avoid using dyn traits given their overhead for embedded environments.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/nrf/src/bin/mpsc.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/nrf/src/bin/mpsc.rs b/examples/nrf/src/bin/mpsc.rs index eafa29e60..6a0f8f471 100644 --- a/examples/nrf/src/bin/mpsc.rs +++ b/examples/nrf/src/bin/mpsc.rs | |||
| @@ -11,7 +11,7 @@ mod example_common; | |||
| 11 | use defmt::panic; | 11 | use defmt::panic; |
| 12 | use embassy::executor::Spawner; | 12 | use embassy::executor::Spawner; |
| 13 | use embassy::time::{Duration, Timer}; | 13 | use embassy::time::{Duration, Timer}; |
| 14 | use embassy::util::mpsc::{ChannelCell, TryRecvError}; | 14 | use embassy::util::mpsc::TryRecvError; |
| 15 | use embassy::util::{mpsc, Forever}; | 15 | use embassy::util::{mpsc, Forever}; |
| 16 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 16 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 17 | use embassy_nrf::Peripherals; | 17 | use embassy_nrf::Peripherals; |
| @@ -23,10 +23,10 @@ enum LedState { | |||
| 23 | Off, | 23 | Off, |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | static CHANNEL: Forever<ChannelCell<Channel<WithThreadModeOnly, LedState, 1>>> = Forever::new(); | 26 | static CHANNEL: Forever<Channel<WithThreadModeOnly, LedState, 1>> = Forever::new(); |
| 27 | 27 | ||
| 28 | #[embassy::task(pool_size = 1)] | 28 | #[embassy::task(pool_size = 1)] |
| 29 | async fn my_task(sender: Sender<'static, LedState>) { | 29 | async fn my_task(sender: Sender<'static, WithThreadModeOnly, LedState, 1>) { |
| 30 | loop { | 30 | loop { |
| 31 | let _ = sender.send(LedState::On).await; | 31 | let _ = sender.send(LedState::On).await; |
| 32 | Timer::after(Duration::from_secs(1)).await; | 32 | Timer::after(Duration::from_secs(1)).await; |
| @@ -39,7 +39,7 @@ async fn my_task(sender: Sender<'static, LedState>) { | |||
| 39 | async fn main(spawner: Spawner, p: Peripherals) { | 39 | async fn main(spawner: Spawner, p: Peripherals) { |
| 40 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | 40 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); |
| 41 | 41 | ||
| 42 | let channel = CHANNEL.put(ChannelCell::new(Channel::with_thread_mode_only())); | 42 | let channel = CHANNEL.put(Channel::with_thread_mode_only()); |
| 43 | let (sender, mut receiver) = mpsc::split(channel); | 43 | let (sender, mut receiver) = mpsc::split(channel); |
| 44 | 44 | ||
| 45 | spawner.spawn(my_task(sender)).unwrap(); | 45 | spawner.spawn(my_task(sender)).unwrap(); |
