aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-02-11 23:25:30 +0100
committerDario Nieuwenhuis <[email protected]>2022-02-12 01:16:31 +0100
commit6c925b2342708266f24d58020e89786811531d47 (patch)
treee46a871fe4d2845d2bfb29f24c8e688165a17738 /examples
parent5ae4e20f8654bdc129d152b5364b6864457c2e02 (diff)
blocking_mutex: refactor to work on stable. No GATs, and can be constructed in const.
Diffstat (limited to 'examples')
-rw-r--r--examples/nrf/src/bin/mpsc.rs6
-rw-r--r--examples/nrf/src/bin/uart_split.rs6
-rw-r--r--examples/stm32f3/src/bin/button_events.rs11
3 files changed, 13 insertions, 10 deletions
diff --git a/examples/nrf/src/bin/mpsc.rs b/examples/nrf/src/bin/mpsc.rs
index 454fb9541..d50736d82 100644
--- a/examples/nrf/src/bin/mpsc.rs
+++ b/examples/nrf/src/bin/mpsc.rs
@@ -6,7 +6,7 @@
6mod example_common; 6mod example_common;
7 7
8use defmt::unwrap; 8use defmt::unwrap;
9use embassy::blocking_mutex::kind::Noop; 9use embassy::blocking_mutex::raw::NoopRawMutex;
10use embassy::channel::mpsc::{self, Channel, Sender, TryRecvError}; 10use embassy::channel::mpsc::{self, Channel, Sender, TryRecvError};
11use embassy::executor::Spawner; 11use embassy::executor::Spawner;
12use embassy::time::{Duration, Timer}; 12use embassy::time::{Duration, Timer};
@@ -19,10 +19,10 @@ enum LedState {
19 Off, 19 Off,
20} 20}
21 21
22static CHANNEL: Forever<Channel<Noop, LedState, 1>> = Forever::new(); 22static CHANNEL: Forever<Channel<NoopRawMutex, LedState, 1>> = Forever::new();
23 23
24#[embassy::task(pool_size = 1)] 24#[embassy::task(pool_size = 1)]
25async fn my_task(sender: Sender<'static, Noop, LedState, 1>) { 25async fn my_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) {
26 loop { 26 loop {
27 let _ = sender.send(LedState::On).await; 27 let _ = sender.send(LedState::On).await;
28 Timer::after(Duration::from_secs(1)).await; 28 Timer::after(Duration::from_secs(1)).await;
diff --git a/examples/nrf/src/bin/uart_split.rs b/examples/nrf/src/bin/uart_split.rs
index a9c02e796..9a9bad3e9 100644
--- a/examples/nrf/src/bin/uart_split.rs
+++ b/examples/nrf/src/bin/uart_split.rs
@@ -6,7 +6,7 @@
6mod example_common; 6mod example_common;
7use example_common::*; 7use example_common::*;
8 8
9use embassy::blocking_mutex::kind::Noop; 9use embassy::blocking_mutex::raw::NoopRawMutex;
10use embassy::channel::mpsc::{self, Channel, Sender}; 10use embassy::channel::mpsc::{self, Channel, Sender};
11use embassy::executor::Spawner; 11use embassy::executor::Spawner;
12use embassy::util::Forever; 12use embassy::util::Forever;
@@ -15,7 +15,7 @@ use embassy_nrf::peripherals::UARTE0;
15use embassy_nrf::uarte::UarteRx; 15use embassy_nrf::uarte::UarteRx;
16use embassy_nrf::{interrupt, uarte, Peripherals}; 16use embassy_nrf::{interrupt, uarte, Peripherals};
17 17
18static CHANNEL: Forever<Channel<Noop, [u8; 8], 1>> = Forever::new(); 18static CHANNEL: Forever<Channel<NoopRawMutex, [u8; 8], 1>> = Forever::new();
19 19
20#[embassy::main] 20#[embassy::main]
21async fn main(spawner: Spawner, p: Peripherals) { 21async fn main(spawner: Spawner, p: Peripherals) {
@@ -57,7 +57,7 @@ async fn main(spawner: Spawner, p: Peripherals) {
57} 57}
58 58
59#[embassy::task] 59#[embassy::task]
60async fn reader(mut rx: UarteRx<'static, UARTE0>, s: Sender<'static, Noop, [u8; 8], 1>) { 60async fn reader(mut rx: UarteRx<'static, UARTE0>, s: Sender<'static, NoopRawMutex, [u8; 8], 1>) {
61 let mut buf = [0; 8]; 61 let mut buf = [0; 8];
62 loop { 62 loop {
63 info!("reading..."); 63 info!("reading...");
diff --git a/examples/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs
index 720ed9d11..1218edd2b 100644
--- a/examples/stm32f3/src/bin/button_events.rs
+++ b/examples/stm32f3/src/bin/button_events.rs
@@ -12,7 +12,7 @@
12 12
13#[path = "../example_common.rs"] 13#[path = "../example_common.rs"]
14mod example_common; 14mod example_common;
15use embassy::blocking_mutex::kind::Noop; 15use embassy::blocking_mutex::raw::NoopRawMutex;
16use embassy::channel::mpsc::{self, Channel, Receiver, Sender}; 16use embassy::channel::mpsc::{self, Channel, Receiver, Sender};
17use embassy::executor::Spawner; 17use embassy::executor::Spawner;
18use embassy::time::{with_timeout, Duration, Timer}; 18use embassy::time::{with_timeout, Duration, Timer};
@@ -77,7 +77,7 @@ enum ButtonEvent {
77 Hold, 77 Hold,
78} 78}
79 79
80static BUTTON_EVENTS_QUEUE: Forever<Channel<Noop, ButtonEvent, 4>> = Forever::new(); 80static BUTTON_EVENTS_QUEUE: Forever<Channel<NoopRawMutex, ButtonEvent, 4>> = Forever::new();
81 81
82#[embassy::main] 82#[embassy::main]
83async fn main(spawner: Spawner, p: Peripherals) { 83async fn main(spawner: Spawner, p: Peripherals) {
@@ -103,7 +103,10 @@ async fn main(spawner: Spawner, p: Peripherals) {
103} 103}
104 104
105#[embassy::task] 105#[embassy::task]
106async fn led_blinker(mut leds: Leds<'static>, queue: Receiver<'static, Noop, ButtonEvent, 4>) { 106async fn led_blinker(
107 mut leds: Leds<'static>,
108 queue: Receiver<'static, NoopRawMutex, ButtonEvent, 4>,
109) {
107 loop { 110 loop {
108 leds.blink().await; 111 leds.blink().await;
109 match queue.try_recv() { 112 match queue.try_recv() {
@@ -121,7 +124,7 @@ async fn led_blinker(mut leds: Leds<'static>, queue: Receiver<'static, Noop, But
121#[embassy::task] 124#[embassy::task]
122async fn button_waiter( 125async fn button_waiter(
123 mut button: ExtiInput<'static, PA0>, 126 mut button: ExtiInput<'static, PA0>,
124 queue: Sender<'static, Noop, ButtonEvent, 4>, 127 queue: Sender<'static, NoopRawMutex, ButtonEvent, 4>,
125) { 128) {
126 const DOUBLE_CLICK_DELAY: u64 = 250; 129 const DOUBLE_CLICK_DELAY: u64 = 250;
127 const HOLD_DELAY: u64 = 1000; 130 const HOLD_DELAY: u64 = 1000;