aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf/src/bin/pubsub.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/nrf/src/bin/pubsub.rs')
-rw-r--r--examples/nrf/src/bin/pubsub.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/nrf/src/bin/pubsub.rs b/examples/nrf/src/bin/pubsub.rs
index 2c3a355c2..5f33f3e0b 100644
--- a/examples/nrf/src/bin/pubsub.rs
+++ b/examples/nrf/src/bin/pubsub.rs
@@ -3,10 +3,10 @@
3#![feature(type_alias_impl_trait)] 3#![feature(type_alias_impl_trait)]
4 4
5use defmt::unwrap; 5use defmt::unwrap;
6use embassy::blocking_mutex::raw::ThreadModeRawMutex; 6use embassy_executor::executor::Spawner;
7use embassy::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; 7use embassy_executor::time::{Duration, Timer};
8use embassy::executor::Spawner; 8use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
9use embassy::time::{Duration, Timer}; 9use embassy_util::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber};
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
12/// Create the message bus. It has a queue of 4, supports 3 subscribers and 1 publisher 12/// Create the message bus. It has a queue of 4, supports 3 subscribers and 1 publisher
@@ -19,7 +19,7 @@ enum Message {
19 C, 19 C,
20} 20}
21 21
22#[embassy::main] 22#[embassy_executor::main]
23async fn main(spawner: Spawner, _p: embassy_nrf::Peripherals) { 23async fn main(spawner: Spawner, _p: embassy_nrf::Peripherals) {
24 defmt::info!("Hello World!"); 24 defmt::info!("Hello World!");
25 25
@@ -64,7 +64,7 @@ async fn main(spawner: Spawner, _p: embassy_nrf::Peripherals) {
64/// A logger task that just awaits the messages it receives 64/// A logger task that just awaits the messages it receives
65/// 65///
66/// This takes the generic `Subscriber`. This is most performant, but requires you to write down all of the generics 66/// This takes the generic `Subscriber`. This is most performant, but requires you to write down all of the generics
67#[embassy::task] 67#[embassy_executor::task]
68async fn fast_logger(mut messages: Subscriber<'static, ThreadModeRawMutex, Message, 4, 3, 1>) { 68async fn fast_logger(mut messages: Subscriber<'static, ThreadModeRawMutex, Message, 4, 3, 1>) {
69 loop { 69 loop {
70 let message = messages.next_message().await; 70 let message = messages.next_message().await;
@@ -76,7 +76,7 @@ async fn fast_logger(mut messages: Subscriber<'static, ThreadModeRawMutex, Messa
76/// Because of this, depeding on how the messages were published, the subscriber might miss some messages 76/// Because of this, depeding on how the messages were published, the subscriber might miss some messages
77/// 77///
78/// This takes the dynamic `DynSubscriber`. This is not as performant as the generic version, but let's you ignore some of the generics 78/// This takes the dynamic `DynSubscriber`. This is not as performant as the generic version, but let's you ignore some of the generics
79#[embassy::task] 79#[embassy_executor::task]
80async fn slow_logger(mut messages: DynSubscriber<'static, Message>) { 80async fn slow_logger(mut messages: DynSubscriber<'static, Message>) {
81 loop { 81 loop {
82 // Do some work 82 // Do some work
@@ -93,7 +93,7 @@ async fn slow_logger(mut messages: DynSubscriber<'static, Message>) {
93} 93}
94 94
95/// Same as `slow_logger` but it ignores lag results 95/// Same as `slow_logger` but it ignores lag results
96#[embassy::task] 96#[embassy_executor::task]
97async fn slow_logger_pure(mut messages: DynSubscriber<'static, Message>) { 97async fn slow_logger_pure(mut messages: DynSubscriber<'static, Message>) {
98 loop { 98 loop {
99 // Do some work 99 // Do some work