diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/nrf/src/bin/mpsc.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/nrf/src/bin/mpsc.rs b/examples/nrf/src/bin/mpsc.rs index 6a0f8f471..d692abee2 100644 --- a/examples/nrf/src/bin/mpsc.rs +++ b/examples/nrf/src/bin/mpsc.rs | |||
| @@ -8,6 +8,8 @@ | |||
| 8 | #[path = "../example_common.rs"] | 8 | #[path = "../example_common.rs"] |
| 9 | mod example_common; | 9 | mod example_common; |
| 10 | 10 | ||
| 11 | use core::cell::UnsafeCell; | ||
| 12 | |||
| 11 | use defmt::panic; | 13 | use defmt::panic; |
| 12 | use embassy::executor::Spawner; | 14 | use embassy::executor::Spawner; |
| 13 | use embassy::time::{Duration, Timer}; | 15 | use embassy::time::{Duration, Timer}; |
| @@ -23,10 +25,10 @@ enum LedState { | |||
| 23 | Off, | 25 | Off, |
| 24 | } | 26 | } |
| 25 | 27 | ||
| 26 | static CHANNEL: Forever<Channel<WithThreadModeOnly, LedState, 1>> = Forever::new(); | 28 | static CHANNEL: Forever<UnsafeCell<Channel<WithThreadModeOnly, LedState, 1>>> = Forever::new(); |
| 27 | 29 | ||
| 28 | #[embassy::task(pool_size = 1)] | 30 | #[embassy::task(pool_size = 1)] |
| 29 | async fn my_task(sender: Sender<'static, WithThreadModeOnly, LedState, 1>) { | 31 | async fn my_task(sender: Sender<'static, LedState>) { |
| 30 | loop { | 32 | loop { |
| 31 | let _ = sender.send(LedState::On).await; | 33 | let _ = sender.send(LedState::On).await; |
| 32 | Timer::after(Duration::from_secs(1)).await; | 34 | Timer::after(Duration::from_secs(1)).await; |
| @@ -39,7 +41,7 @@ async fn my_task(sender: Sender<'static, WithThreadModeOnly, LedState, 1>) { | |||
| 39 | async fn main(spawner: Spawner, p: Peripherals) { | 41 | async fn main(spawner: Spawner, p: Peripherals) { |
| 40 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | 42 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); |
| 41 | 43 | ||
| 42 | let channel = CHANNEL.put(Channel::with_thread_mode_only()); | 44 | let channel = CHANNEL.put(UnsafeCell::new(Channel::with_thread_mode_only())); |
| 43 | let (sender, mut receiver) = mpsc::split(channel); | 45 | let (sender, mut receiver) = mpsc::split(channel); |
| 44 | 46 | ||
| 45 | spawner.spawn(my_task(sender)).unwrap(); | 47 | spawner.spawn(my_task(sender)).unwrap(); |
