blocking_mutex: refactor to work on stable. No GATs, and can be constructed in const.
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
mod example_common;
|
||||
|
||||
use defmt::unwrap;
|
||||
use embassy::blocking_mutex::kind::Noop;
|
||||
use embassy::blocking_mutex::raw::NoopRawMutex;
|
||||
use embassy::channel::mpsc::{self, Channel, Sender, TryRecvError};
|
||||
use embassy::executor::Spawner;
|
||||
use embassy::time::{Duration, Timer};
|
||||
@ -19,10 +19,10 @@ enum LedState {
|
||||
Off,
|
||||
}
|
||||
|
||||
static CHANNEL: Forever<Channel<Noop, LedState, 1>> = Forever::new();
|
||||
static CHANNEL: Forever<Channel<NoopRawMutex, LedState, 1>> = Forever::new();
|
||||
|
||||
#[embassy::task(pool_size = 1)]
|
||||
async fn my_task(sender: Sender<'static, Noop, LedState, 1>) {
|
||||
async fn my_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) {
|
||||
loop {
|
||||
let _ = sender.send(LedState::On).await;
|
||||
Timer::after(Duration::from_secs(1)).await;
|
||||
|
@ -6,7 +6,7 @@
|
||||
mod example_common;
|
||||
use example_common::*;
|
||||
|
||||
use embassy::blocking_mutex::kind::Noop;
|
||||
use embassy::blocking_mutex::raw::NoopRawMutex;
|
||||
use embassy::channel::mpsc::{self, Channel, Sender};
|
||||
use embassy::executor::Spawner;
|
||||
use embassy::util::Forever;
|
||||
@ -15,7 +15,7 @@ use embassy_nrf::peripherals::UARTE0;
|
||||
use embassy_nrf::uarte::UarteRx;
|
||||
use embassy_nrf::{interrupt, uarte, Peripherals};
|
||||
|
||||
static CHANNEL: Forever<Channel<Noop, [u8; 8], 1>> = Forever::new();
|
||||
static CHANNEL: Forever<Channel<NoopRawMutex, [u8; 8], 1>> = Forever::new();
|
||||
|
||||
#[embassy::main]
|
||||
async fn main(spawner: Spawner, p: Peripherals) {
|
||||
@ -57,7 +57,7 @@ async fn main(spawner: Spawner, p: Peripherals) {
|
||||
}
|
||||
|
||||
#[embassy::task]
|
||||
async fn reader(mut rx: UarteRx<'static, UARTE0>, s: Sender<'static, Noop, [u8; 8], 1>) {
|
||||
async fn reader(mut rx: UarteRx<'static, UARTE0>, s: Sender<'static, NoopRawMutex, [u8; 8], 1>) {
|
||||
let mut buf = [0; 8];
|
||||
loop {
|
||||
info!("reading...");
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
use embassy::blocking_mutex::kind::Noop;
|
||||
use embassy::blocking_mutex::raw::NoopRawMutex;
|
||||
use embassy::channel::mpsc::{self, Channel, Receiver, Sender};
|
||||
use embassy::executor::Spawner;
|
||||
use embassy::time::{with_timeout, Duration, Timer};
|
||||
@ -77,7 +77,7 @@ enum ButtonEvent {
|
||||
Hold,
|
||||
}
|
||||
|
||||
static BUTTON_EVENTS_QUEUE: Forever<Channel<Noop, ButtonEvent, 4>> = Forever::new();
|
||||
static BUTTON_EVENTS_QUEUE: Forever<Channel<NoopRawMutex, ButtonEvent, 4>> = Forever::new();
|
||||
|
||||
#[embassy::main]
|
||||
async fn main(spawner: Spawner, p: Peripherals) {
|
||||
@ -103,7 +103,10 @@ async fn main(spawner: Spawner, p: Peripherals) {
|
||||
}
|
||||
|
||||
#[embassy::task]
|
||||
async fn led_blinker(mut leds: Leds<'static>, queue: Receiver<'static, Noop, ButtonEvent, 4>) {
|
||||
async fn led_blinker(
|
||||
mut leds: Leds<'static>,
|
||||
queue: Receiver<'static, NoopRawMutex, ButtonEvent, 4>,
|
||||
) {
|
||||
loop {
|
||||
leds.blink().await;
|
||||
match queue.try_recv() {
|
||||
@ -121,7 +124,7 @@ async fn led_blinker(mut leds: Leds<'static>, queue: Receiver<'static, Noop, But
|
||||
#[embassy::task]
|
||||
async fn button_waiter(
|
||||
mut button: ExtiInput<'static, PA0>,
|
||||
queue: Sender<'static, Noop, ButtonEvent, 4>,
|
||||
queue: Sender<'static, NoopRawMutex, ButtonEvent, 4>,
|
||||
) {
|
||||
const DOUBLE_CLICK_DELAY: u64 = 250;
|
||||
const HOLD_DELAY: u64 = 1000;
|
||||
|
Reference in New Issue
Block a user