From 816b78c0d9733362d8653eb2032f126e6a710030 Mon Sep 17 00:00:00 2001 From: huntc Date: Tue, 6 Jul 2021 23:20:47 +1000 Subject: Reduces the types on sender and receiver In exchange for an UnsafeCell being passed into split --- examples/nrf/src/bin/mpsc.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'examples') 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 @@ #[path = "../example_common.rs"] mod example_common; +use core::cell::UnsafeCell; + use defmt::panic; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; @@ -23,10 +25,10 @@ enum LedState { Off, } -static CHANNEL: Forever> = Forever::new(); +static CHANNEL: Forever>> = Forever::new(); #[embassy::task(pool_size = 1)] -async fn my_task(sender: Sender<'static, WithThreadModeOnly, LedState, 1>) { +async fn my_task(sender: Sender<'static, LedState>) { loop { let _ = sender.send(LedState::On).await; Timer::after(Duration::from_secs(1)).await; @@ -39,7 +41,7 @@ async fn my_task(sender: Sender<'static, WithThreadModeOnly, LedState, 1>) { async fn main(spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); - let channel = CHANNEL.put(Channel::with_thread_mode_only()); + let channel = CHANNEL.put(UnsafeCell::new(Channel::with_thread_mode_only())); let (sender, mut receiver) = mpsc::split(channel); spawner.spawn(my_task(sender)).unwrap(); -- cgit