diff options
author | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2022-07-29 21:58:35 +0200 |
---|---|---|
committer | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2022-07-29 23:40:36 +0200 |
commit | a0f1b0ee01d461607660d2d56b5b1bdc57e0d3fb (patch) | |
tree | e60fc8f8db8ec07e55d655c1a830b07f4db0b7d2 /examples/nrf/src | |
parent | 8745d646f0976791b7098456aa61adb983fb1c18 (diff) | |
download | embassy-a0f1b0ee01d461607660d2d56b5b1bdc57e0d3fb.zip |
Split embassy crate into embassy-executor, embassy-util.
Diffstat (limited to 'examples/nrf/src')
42 files changed, 154 insertions, 155 deletions
diff --git a/examples/nrf/src/bin/awaitable_timer.rs b/examples/nrf/src/bin/awaitable_timer.rs index 34a657cb..f2c1d9fa 100644 --- a/examples/nrf/src/bin/awaitable_timer.rs +++ b/examples/nrf/src/bin/awaitable_timer.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::timer::Timer; use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut t = Timer::new_awaitable(p.TIMER0, interrupt::take!(TIMER0)); // default frequency is 1MHz, so this triggers every second diff --git a/examples/nrf/src/bin/blinky.rs b/examples/nrf/src/bin/blinky.rs index 23d16f79..98db6546 100644 --- a/examples/nrf/src/bin/blinky.rs +++ b/examples/nrf/src/bin/blinky.rs @@ -2,13 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); diff --git a/examples/nrf/src/bin/buffered_uart.rs b/examples/nrf/src/bin/buffered_uart.rs index 18dd698b..f02b7d84 100644 --- a/examples/nrf/src/bin/buffered_uart.rs +++ b/examples/nrf/src/bin/buffered_uart.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::buffered_uarte::{BufferedUarte, State}; use embassy_nrf::{interrupt, uarte, Peripherals}; use embedded_io::asynch::{BufRead, Write}; use futures::pin_mut; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut config = uarte::Config::default(); config.parity = uarte::Parity::EXCLUDED; diff --git a/examples/nrf/src/bin/channel.rs b/examples/nrf/src/bin/channel.rs index c57b91a4..e97c6c5e 100644 --- a/examples/nrf/src/bin/channel.rs +++ b/examples/nrf/src/bin/channel.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::unwrap; -use embassy::blocking_mutex::raw::ThreadModeRawMutex; -use embassy::channel::mpmc::Channel; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::Peripherals; +use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_util::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; enum LedState { @@ -18,7 +18,7 @@ enum LedState { static CHANNEL: Channel<ThreadModeRawMutex, LedState, 1> = Channel::new(); -#[embassy::task] +#[embassy_executor::task] async fn my_task() { loop { CHANNEL.send(LedState::On).await; @@ -28,7 +28,7 @@ async fn my_task() { } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); diff --git a/examples/nrf/src/bin/channel_sender_receiver.rs b/examples/nrf/src/bin/channel_sender_receiver.rs index 847ce238..bca7bb24 100644 --- a/examples/nrf/src/bin/channel_sender_receiver.rs +++ b/examples/nrf/src/bin/channel_sender_receiver.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::unwrap; -use embassy::blocking_mutex::raw::NoopRawMutex; -use embassy::channel::mpmc::{Channel, Receiver, Sender}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; -use embassy::util::Forever; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; use embassy_nrf::Peripherals; +use embassy_util::blocking_mutex::raw::NoopRawMutex; +use embassy_util::channel::mpmc::{Channel, Receiver, Sender}; +use embassy_util::Forever; use {defmt_rtt as _, panic_probe as _}; enum LedState { @@ -19,7 +19,7 @@ enum LedState { static CHANNEL: Forever<Channel<NoopRawMutex, LedState, 1>> = Forever::new(); -#[embassy::task] +#[embassy_executor::task] async fn send_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) { loop { sender.send(LedState::On).await; @@ -29,7 +29,7 @@ async fn send_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) { } } -#[embassy::task] +#[embassy_executor::task] async fn recv_task(led: AnyPin, receiver: Receiver<'static, NoopRawMutex, LedState, 1>) { let mut led = Output::new(led, Level::Low, OutputDrive::Standard); @@ -41,7 +41,7 @@ async fn recv_task(led: AnyPin, receiver: Receiver<'static, NoopRawMutex, LedSta } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { let channel = CHANNEL.put(Channel::new()); diff --git a/examples/nrf/src/bin/executor_fairness_test.rs b/examples/nrf/src/bin/executor_fairness_test.rs index 5a422151..b9845493 100644 --- a/examples/nrf/src/bin/executor_fairness_test.rs +++ b/examples/nrf/src/bin/executor_fairness_test.rs @@ -5,12 +5,12 @@ use core::task::Poll; use defmt::{info, unwrap}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Instant, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Instant, Timer}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task] +#[embassy_executor::task] async fn run1() { loop { info!("DING DONG"); @@ -18,14 +18,14 @@ async fn run1() { } } -#[embassy::task] +#[embassy_executor::task] async fn run2() { loop { Timer::at(Instant::from_ticks(0)).await; } } -#[embassy::task] +#[embassy_executor::task] async fn run3() { futures::future::poll_fn(|cx| { cx.waker().wake_by_ref(); @@ -34,7 +34,7 @@ async fn run3() { .await; } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, _p: Peripherals) { unwrap!(spawner.spawn(run1())); unwrap!(spawner.spawn(run2())); diff --git a/examples/nrf/src/bin/gpiote_channel.rs b/examples/nrf/src/bin/gpiote_channel.rs index ad8f37c6..65c7b4df 100644 --- a/examples/nrf/src/bin/gpiote_channel.rs +++ b/examples/nrf/src/bin/gpiote_channel.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Starting!"); diff --git a/examples/nrf/src/bin/gpiote_port.rs b/examples/nrf/src/bin/gpiote_port.rs index 30b87b3a..7746a7f9 100644 --- a/examples/nrf/src/bin/gpiote_port.rs +++ b/examples/nrf/src/bin/gpiote_port.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task(pool_size = 4)] +#[embassy_executor::task(pool_size = 4)] async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) { loop { pin.wait_for_low().await; @@ -18,7 +18,7 @@ async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) { } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { info!("Starting!"); diff --git a/examples/nrf/src/bin/multiprio.rs b/examples/nrf/src/bin/multiprio.rs index 1a4598e2..7050da37 100644 --- a/examples/nrf/src/bin/multiprio.rs +++ b/examples/nrf/src/bin/multiprio.rs @@ -59,14 +59,14 @@ use cortex_m_rt::entry; use defmt::{info, unwrap}; -use embassy::time::{Duration, Instant, Timer}; -use embassy::util::Forever; +use embassy_executor::time::{Duration, Instant, Timer}; use embassy_nrf::executor::{Executor, InterruptExecutor}; use embassy_nrf::interrupt; use embassy_nrf::interrupt::InterruptExt; +use embassy_util::Forever; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task] +#[embassy_executor::task] async fn run_high() { loop { info!(" [high] tick!"); @@ -74,7 +74,7 @@ async fn run_high() { } } -#[embassy::task] +#[embassy_executor::task] async fn run_med() { loop { let start = Instant::now(); @@ -91,7 +91,7 @@ async fn run_med() { } } -#[embassy::task] +#[embassy_executor::task] async fn run_low() { loop { let start = Instant::now(); diff --git a/examples/nrf/src/bin/mutex.rs b/examples/nrf/src/bin/mutex.rs index 92e01976..5fe7eadb 100644 --- a/examples/nrf/src/bin/mutex.rs +++ b/examples/nrf/src/bin/mutex.rs @@ -3,16 +3,16 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::blocking_mutex::raw::ThreadModeRawMutex; -use embassy::executor::Spawner; -use embassy::mutex::Mutex; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::Peripherals; +use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_util::mutex::Mutex; use {defmt_rtt as _, panic_probe as _}; static MUTEX: Mutex<ThreadModeRawMutex, u32> = Mutex::new(0); -#[embassy::task] +#[embassy_executor::task] async fn my_task() { loop { { @@ -29,7 +29,7 @@ async fn my_task() { } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, _p: Peripherals) { unwrap!(spawner.spawn(my_task())); diff --git a/examples/nrf/src/bin/nvmc.rs b/examples/nrf/src/bin/nvmc.rs index b55ef1f6..1d4387de 100644 --- a/examples/nrf/src/bin/nvmc.rs +++ b/examples/nrf/src/bin/nvmc.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::nvmc::Nvmc; use embassy_nrf::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello NVMC!"); diff --git a/examples/nrf/src/bin/ppi.rs b/examples/nrf/src/bin/ppi.rs index 004a1bfa..9a60cc0a 100644 --- a/examples/nrf/src/bin/ppi.rs +++ b/examples/nrf/src/bin/ppi.rs @@ -5,7 +5,7 @@ use core::future::pending; use defmt::info; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity}; use embassy_nrf::ppi::Ppi; @@ -13,7 +13,7 @@ use embassy_nrf::Peripherals; use gpiote::{OutputChannel, OutputChannelPolarity}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Starting!"); diff --git a/examples/nrf/src/bin/pubsub.rs b/examples/nrf/src/bin/pubsub.rs index 2c3a355c..5f33f3e0 100644 --- a/examples/nrf/src/bin/pubsub.rs +++ b/examples/nrf/src/bin/pubsub.rs @@ -3,10 +3,10 @@ #![feature(type_alias_impl_trait)] use defmt::unwrap; -use embassy::blocking_mutex::raw::ThreadModeRawMutex; -use embassy::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; +use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_util::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; use {defmt_rtt as _, panic_probe as _}; /// Create the message bus. It has a queue of 4, supports 3 subscribers and 1 publisher @@ -19,7 +19,7 @@ enum Message { C, } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, _p: embassy_nrf::Peripherals) { defmt::info!("Hello World!"); @@ -64,7 +64,7 @@ async fn main(spawner: Spawner, _p: embassy_nrf::Peripherals) { /// A logger task that just awaits the messages it receives /// /// This takes the generic `Subscriber`. This is most performant, but requires you to write down all of the generics -#[embassy::task] +#[embassy_executor::task] async fn fast_logger(mut messages: Subscriber<'static, ThreadModeRawMutex, Message, 4, 3, 1>) { loop { let message = messages.next_message().await; @@ -76,7 +76,7 @@ async fn fast_logger(mut messages: Subscriber<'static, ThreadModeRawMutex, Messa /// Because of this, depeding on how the messages were published, the subscriber might miss some messages /// /// This takes the dynamic `DynSubscriber`. This is not as performant as the generic version, but let's you ignore some of the generics -#[embassy::task] +#[embassy_executor::task] async fn slow_logger(mut messages: DynSubscriber<'static, Message>) { loop { // Do some work @@ -93,7 +93,7 @@ async fn slow_logger(mut messages: DynSubscriber<'static, Message>) { } /// Same as `slow_logger` but it ignores lag results -#[embassy::task] +#[embassy_executor::task] async fn slow_logger_pure(mut messages: DynSubscriber<'static, Message>) { loop { // Do some work diff --git a/examples/nrf/src/bin/pwm.rs b/examples/nrf/src/bin/pwm.rs index aec5dd73..c8a08329 100644 --- a/examples/nrf/src/bin/pwm.rs +++ b/examples/nrf/src/bin/pwm.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{Prescaler, SimplePwm}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; @@ -70,7 +70,7 @@ static DUTY: [u16; 1024] = [ 7255, 7331, 7407, 7484, 7561, 7638, 7716, 7794, 7873, 7952, 8031, 8111, ]; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut pwm = SimplePwm::new_4ch(p.PWM0, p.P0_13, p.P0_14, p.P0_16, p.P0_15); pwm.set_prescaler(Prescaler::Div1); diff --git a/examples/nrf/src/bin/pwm_double_sequence.rs b/examples/nrf/src/bin/pwm_double_sequence.rs index facafa77..cfd8db86 100644 --- a/examples/nrf/src/bin/pwm_double_sequence.rs +++ b/examples/nrf/src/bin/pwm_double_sequence.rs @@ -3,15 +3,15 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{ Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, StartSequence, }; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let seq_words_0: [u16; 5] = [1000, 250, 100, 50, 0]; let seq_words_1: [u16; 4] = [50, 100, 250, 1000]; diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index b7cb385c..b7a04c03 100644 --- a/examples/nrf/src/bin/pwm_sequence.rs +++ b/examples/nrf/src/bin/pwm_sequence.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let seq_words: [u16; 5] = [1000, 250, 100, 50, 0]; diff --git a/examples/nrf/src/bin/pwm_sequence_ppi.rs b/examples/nrf/src/bin/pwm_sequence_ppi.rs index d98e2ca7..f5c587c3 100644 --- a/examples/nrf/src/bin/pwm_sequence_ppi.rs +++ b/examples/nrf/src/bin/pwm_sequence_ppi.rs @@ -5,7 +5,7 @@ use core::future::pending; use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; use embassy_nrf::ppi::Ppi; @@ -13,7 +13,7 @@ use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSeq use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let seq_words: [u16; 5] = [1000, 250, 100, 50, 0]; diff --git a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs index 0dee8c94..d6b3f005 100644 --- a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs +++ b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{ Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, SingleSequencer, }; @@ -26,7 +26,7 @@ const RES: u16 = 0x8000; // Provides data to a WS2812b (Neopixel) LED and makes it go blue. The data // line is assumed to be P1_05. -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut config = Config::default(); config.sequence_load = SequenceLoad::Common; diff --git a/examples/nrf/src/bin/pwm_servo.rs b/examples/nrf/src/bin/pwm_servo.rs index 71a90a94..d28a5a17 100644 --- a/examples/nrf/src/bin/pwm_servo.rs +++ b/examples/nrf/src/bin/pwm_servo.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::pwm::{Prescaler, SimplePwm}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut pwm = SimplePwm::new_1ch(p.PWM0, p.P0_05); // sg90 microervo requires 50hz or 20ms period diff --git a/examples/nrf/src/bin/qdec.rs b/examples/nrf/src/bin/qdec.rs index 9529c7bb..6bda82f7 100644 --- a/examples/nrf/src/bin/qdec.rs +++ b/examples/nrf/src/bin/qdec.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::qdec::{self, Qdec}; use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let irq = interrupt::take!(QDEC); let config = qdec::Config::default(); diff --git a/examples/nrf/src/bin/qspi.rs b/examples/nrf/src/bin/qspi.rs index 96c90f9c..57e0fdbe 100644 --- a/examples/nrf/src/bin/qspi.rs +++ b/examples/nrf/src/bin/qspi.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::{assert_eq, info, unwrap}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::{interrupt, qspi, Peripherals}; use {defmt_rtt as _, panic_probe as _}; @@ -14,7 +14,7 @@ const PAGE_SIZE: usize = 4096; #[repr(C, align(4))] struct AlignedBuf([u8; 4096]); -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { // Config for the MX25R64 present in the nRF52840 DK let mut config = qspi::Config::default(); diff --git a/examples/nrf/src/bin/qspi_lowpower.rs b/examples/nrf/src/bin/qspi_lowpower.rs index ce2e40b2..080b27a1 100644 --- a/examples/nrf/src/bin/qspi_lowpower.rs +++ b/examples/nrf/src/bin/qspi_lowpower.rs @@ -5,8 +5,8 @@ use core::mem; use defmt::{info, unwrap}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::{interrupt, qspi, Peripherals}; use {defmt_rtt as _, panic_probe as _}; @@ -15,7 +15,7 @@ use {defmt_rtt as _, panic_probe as _}; #[repr(C, align(4))] struct AlignedBuf([u8; 64]); -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, mut p: Peripherals) { let mut irq = interrupt::take!(QSPI); diff --git a/examples/nrf/src/bin/raw_spawn.rs b/examples/nrf/src/bin/raw_spawn.rs index d564b6b2..9199d3ae 100644 --- a/examples/nrf/src/bin/raw_spawn.rs +++ b/examples/nrf/src/bin/raw_spawn.rs @@ -5,10 +5,10 @@ use core::mem; use cortex_m_rt::entry; use defmt::{info, unwrap}; -use embassy::executor::raw::TaskStorage; -use embassy::executor::Executor; -use embassy::time::{Duration, Timer}; -use embassy::util::Forever; +use embassy_executor::executor::raw::TaskStorage; +use embassy_executor::executor::Executor; +use embassy_executor::time::{Duration, Timer}; +use embassy_util::Forever; use {defmt_rtt as _, panic_probe as _}; async fn run1() { diff --git a/examples/nrf/src/bin/rng.rs b/examples/nrf/src/bin/rng.rs index 08d3abe1..a4314e8b 100644 --- a/examples/nrf/src/bin/rng.rs +++ b/examples/nrf/src/bin/rng.rs @@ -2,13 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::rng::Rng; use embassy_nrf::{interrupt, Peripherals}; use rand::Rng as _; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut rng = Rng::new(p.RNG, interrupt::take!(RNG)); diff --git a/examples/nrf/src/bin/saadc.rs b/examples/nrf/src/bin/saadc.rs index cb928978..65c78d84 100644 --- a/examples/nrf/src/bin/saadc.rs +++ b/examples/nrf/src/bin/saadc.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::saadc::{ChannelConfig, Config, Saadc}; use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, mut p: Peripherals) { let config = Config::default(); let channel_config = ChannelConfig::single_ended(&mut p.P0_02); diff --git a/examples/nrf/src/bin/saadc_continuous.rs b/examples/nrf/src/bin/saadc_continuous.rs index 234294ea..d0305736 100644 --- a/examples/nrf/src/bin/saadc_continuous.rs +++ b/examples/nrf/src/bin/saadc_continuous.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; -use embassy::time::Duration; +use embassy_executor::executor::Spawner; +use embassy_executor::time::Duration; use embassy_nrf::saadc::{ChannelConfig, Config, Saadc, SamplerState}; use embassy_nrf::timer::Frequency; use embassy_nrf::{interrupt, Peripherals}; @@ -12,7 +12,7 @@ use {defmt_rtt as _, panic_probe as _}; // Demonstrates both continuous sampling and scanning multiple channels driven by a PPI linked timer -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, mut p: Peripherals) { let config = Config::default(); let channel_1_config = ChannelConfig::single_ended(&mut p.P0_02); @@ -27,7 +27,7 @@ async fn main(_spawner: Spawner, mut p: Peripherals) { // This delay demonstrates that starting the timer prior to running // the task sampler is benign given the calibration that follows. - embassy::time::Timer::after(Duration::from_millis(500)).await; + embassy_executor::time::Timer::after(Duration::from_millis(500)).await; saadc.calibrate().await; let mut bufs = [[[0; 3]; 500]; 2]; diff --git a/examples/nrf/src/bin/self_spawn.rs b/examples/nrf/src/bin/self_spawn.rs index 4b8ac04b..e0152802 100644 --- a/examples/nrf/src/bin/self_spawn.rs +++ b/examples/nrf/src/bin/self_spawn.rs @@ -3,19 +3,19 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task(pool_size = 2)] +#[embassy_executor::task(pool_size = 2)] async fn my_task(spawner: Spawner, n: u32) { Timer::after(Duration::from_secs(1)).await; info!("Spawning self! {}", n); unwrap!(spawner.spawn(my_task(spawner, n + 1))); } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, _p: Peripherals) { info!("Hello World!"); unwrap!(spawner.spawn(my_task(spawner, 0))); diff --git a/examples/nrf/src/bin/self_spawn_current_executor.rs b/examples/nrf/src/bin/self_spawn_current_executor.rs index 3c3379ce..1d8309d7 100644 --- a/examples/nrf/src/bin/self_spawn_current_executor.rs +++ b/examples/nrf/src/bin/self_spawn_current_executor.rs @@ -3,19 +3,19 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task(pool_size = 2)] +#[embassy_executor::task(pool_size = 2)] async fn my_task(n: u32) { Timer::after(Duration::from_secs(1)).await; info!("Spawning self! {}", n); unwrap!(Spawner::for_current_executor().await.spawn(my_task(n + 1))); } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, _p: Peripherals) { info!("Hello World!"); unwrap!(spawner.spawn(my_task(0))); diff --git a/examples/nrf/src/bin/spim.rs b/examples/nrf/src/bin/spim.rs index 62040168..fd741b21 100644 --- a/examples/nrf/src/bin/spim.rs +++ b/examples/nrf/src/bin/spim.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::{interrupt, spim, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("running!"); diff --git a/examples/nrf/src/bin/temp.rs b/examples/nrf/src/bin/temp.rs index 939cb39e..654098e0 100644 --- a/examples/nrf/src/bin/temp.rs +++ b/examples/nrf/src/bin/temp.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::temp::Temp; use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let irq = interrupt::take!(TEMP); let mut temp = Temp::new(p.TEMP, irq); diff --git a/examples/nrf/src/bin/timer.rs b/examples/nrf/src/bin/timer.rs index 64376dd7..61ff1d6d 100644 --- a/examples/nrf/src/bin/timer.rs +++ b/examples/nrf/src/bin/timer.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::task] +#[embassy_executor::task] async fn run1() { loop { info!("BIG INFREQUENT TICK"); @@ -16,7 +16,7 @@ async fn run1() { } } -#[embassy::task] +#[embassy_executor::task] async fn run2() { loop { info!("tick"); @@ -24,7 +24,7 @@ async fn run2() { } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, _p: Peripherals) { unwrap!(spawner.spawn(run1())); unwrap!(spawner.spawn(run2())); diff --git a/examples/nrf/src/bin/twim.rs b/examples/nrf/src/bin/twim.rs index fb8372a1..bb7ee9db 100644 --- a/examples/nrf/src/bin/twim.rs +++ b/examples/nrf/src/bin/twim.rs @@ -7,14 +7,14 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::twim::{self, Twim}; use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x50; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Initializing TWI..."); let config = twim::Config::default(); diff --git a/examples/nrf/src/bin/twim_lowpower.rs b/examples/nrf/src/bin/twim_lowpower.rs index c9c2d503..ebf3d710 100644 --- a/examples/nrf/src/bin/twim_lowpower.rs +++ b/examples/nrf/src/bin/twim_lowpower.rs @@ -11,15 +11,15 @@ use core::mem; use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::twim::{self, Twim}; use embassy_nrf::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x50; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, mut p: Peripherals) { info!("Started!"); let mut irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); diff --git a/examples/nrf/src/bin/uart.rs b/examples/nrf/src/bin/uart.rs index c8c4a67a..5f363b69 100644 --- a/examples/nrf/src/bin/uart.rs +++ b/examples/nrf/src/bin/uart.rs @@ -3,11 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::{interrupt, uarte, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut config = uarte::Config::default(); config.parity = uarte::Parity::EXCLUDED; diff --git a/examples/nrf/src/bin/uart_idle.rs b/examples/nrf/src/bin/uart_idle.rs index 6679b28d..0f455dff 100644 --- a/examples/nrf/src/bin/uart_idle.rs +++ b/examples/nrf/src/bin/uart_idle.rs @@ -3,11 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::{interrupt, uarte, Peripherals}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut config = uarte::Config::default(); config.parity = uarte::Parity::EXCLUDED; diff --git a/examples/nrf/src/bin/uart_split.rs b/examples/nrf/src/bin/uart_split.rs index 1ffb6370..2de5f90c 100644 --- a/examples/nrf/src/bin/uart_split.rs +++ b/examples/nrf/src/bin/uart_split.rs @@ -3,17 +3,17 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::blocking_mutex::raw::ThreadModeRawMutex; -use embassy::channel::mpmc::Channel; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::peripherals::UARTE0; use embassy_nrf::uarte::UarteRx; use embassy_nrf::{interrupt, uarte, Peripherals}; +use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_util::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; static CHANNEL: Channel<ThreadModeRawMutex, [u8; 8], 1> = Channel::new(); -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { let mut config = uarte::Config::default(); config.parity = uarte::Parity::EXCLUDED; @@ -48,7 +48,7 @@ async fn main(spawner: Spawner, p: Peripherals) { } } -#[embassy::task] +#[embassy_executor::task] async fn reader(mut rx: UarteRx<'static, UARTE0>) { let mut buf = [0; 8]; loop { diff --git a/examples/nrf/src/bin/usb_ethernet.rs b/examples/nrf/src/bin/usb_ethernet.rs index e57cdaf6..93cb0590 100644 --- a/examples/nrf/src/bin/usb_ethernet.rs +++ b/examples/nrf/src/bin/usb_ethernet.rs @@ -8,10 +8,7 @@ use core::sync::atomic::{AtomicBool, Ordering}; use core::task::Waker; use defmt::*; -use embassy::blocking_mutex::raw::ThreadModeRawMutex; -use embassy::channel::mpmc::Channel; -use embassy::executor::Spawner; -use embassy::util::Forever; +use embassy_executor::executor::Spawner; use embassy_net::tcp::TcpSocket; use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources}; use embassy_nrf::rng::Rng; @@ -19,6 +16,9 @@ use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac, peripherals, Peripherals}; use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; +use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; +use embassy_util::channel::mpmc::Channel; +use embassy_util::Forever; use embedded_io::asynch::{Read, Write}; use {defmt_rtt as _, panic_probe as _}; @@ -32,12 +32,12 @@ macro_rules! forever { }}; } -#[embassy::task] +#[embassy_executor::task] async fn usb_task(mut device: UsbDevice<'static, MyDriver>) -> ! { device.run().await } -#[embassy::task] +#[embassy_executor::task] async fn usb_ncm_rx_task(mut class: Receiver<'static, MyDriver>) { loop { warn!("WAITING for connection"); @@ -66,7 +66,7 @@ async fn usb_ncm_rx_task(mut class: Receiver<'static, MyDriver>) { } } -#[embassy::task] +#[embassy_executor::task] async fn usb_ncm_tx_task(mut class: Sender<'static, MyDriver>) { loop { let pkt = TX_CHANNEL.recv().await; @@ -76,12 +76,12 @@ async fn usb_ncm_tx_task(mut class: Sender<'static, MyDriver>) { } } -#[embassy::task] +#[embassy_executor::task] async fn net_task(stack: &'static Stack<Device>) -> ! { stack.run().await } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { let clock: pac::CLOCK = unsafe { mem::transmute(()) }; diff --git a/examples/nrf/src/bin/usb_hid_keyboard.rs b/examples/nrf/src/bin/usb_hid_keyboard.rs index 539ae6f1..863f3e5d 100644 --- a/examples/nrf/src/bin/usb_hid_keyboard.rs +++ b/examples/nrf/src/bin/usb_hid_keyboard.rs @@ -7,23 +7,22 @@ use core::mem; use core::sync::atomic::{AtomicBool, Ordering}; use defmt::*; -use embassy::channel::signal::Signal; -use embassy::executor::Spawner; -use embassy::time::Duration; -use embassy::util::{select, Either}; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Pin, Pull}; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac, Peripherals}; use embassy_usb::control::OutResponse; use embassy_usb::{Builder, Config, DeviceStateHandler}; use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State}; +use embassy_util::channel::signal::Signal; +use embassy_util::{select, Either}; use futures::future::join; use usbd_hid::descriptor::{KeyboardReport, SerializedDescriptor}; use {defmt_rtt as _, panic_probe as _}; static SUSPENDED: AtomicBool = AtomicBool::new(false); -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let clock: pac::CLOCK = unsafe { mem::transmute(()) }; @@ -154,11 +153,11 @@ impl RequestHandler for MyRequestHandler { OutResponse::Accepted } - fn set_idle(&self, id: Option<ReportId>, dur: Duration) { + fn set_idle_ms(&self, id: Option<ReportId>, dur: u32) { info!("Set idle rate for {:?} to {:?}", id, dur); } - fn get_idle(&self, id: Option<ReportId>) -> Option<Duration> { + fn get_idle_ms(&self, id: Option<ReportId>) -> Option<u32> { info!("Get idle rate for {:?}", id); None } diff --git a/examples/nrf/src/bin/usb_hid_mouse.rs b/examples/nrf/src/bin/usb_hid_mouse.rs index 516e7ea9..88bf87bd 100644 --- a/examples/nrf/src/bin/usb_hid_mouse.rs +++ b/examples/nrf/src/bin/usb_hid_mouse.rs @@ -6,8 +6,8 @@ use core::mem; use defmt::*; -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac, Peripherals}; use embassy_usb::control::OutResponse; @@ -17,7 +17,7 @@ use futures::future::join; use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let clock: pac::CLOCK = unsafe { mem::transmute(()) }; @@ -113,11 +113,11 @@ impl RequestHandler for MyRequestHandler { OutResponse::Accepted } - fn set_idle(&self, id: Option<ReportId>, dur: Duration) { + fn set_idle_ms(&self, id: Option<ReportId>, dur: u32) { info!("Set idle rate for {:?} to {:?}", id, dur); } - fn get_idle(&self, id: Option<ReportId>) -> Option<Duration> { + fn get_idle_ms(&self, id: Option<ReportId>) -> Option<u32> { info!("Get idle rate for {:?}", id); None } diff --git a/examples/nrf/src/bin/usb_serial.rs b/examples/nrf/src/bin/usb_serial.rs index d2200dc5..7d233d24 100644 --- a/examples/nrf/src/bin/usb_serial.rs +++ b/examples/nrf/src/bin/usb_serial.rs @@ -6,7 +6,7 @@ use core::mem; use defmt::{info, panic}; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::usb::{Driver, Instance, PowerUsb, UsbSupply}; use embassy_nrf::{interrupt, pac, Peripherals}; use embassy_usb::driver::EndpointError; @@ -15,7 +15,7 @@ use embassy_usb_serial::{CdcAcmClass, State}; use futures::future::join; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { let clock: pac::CLOCK = unsafe { mem::transmute(()) }; diff --git a/examples/nrf/src/bin/usb_serial_multitask.rs b/examples/nrf/src/bin/usb_serial_multitask.rs index 3806da5a..95631532 100644 --- a/examples/nrf/src/bin/usb_serial_multitask.rs +++ b/examples/nrf/src/bin/usb_serial_multitask.rs @@ -6,23 +6,23 @@ use core::mem; use defmt::{info, panic, unwrap}; -use embassy::executor::Spawner; -use embassy::util::Forever; +use embassy_executor::executor::Spawner; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac, peripherals, Peripherals}; use embassy_usb::driver::EndpointError; use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb_serial::{CdcAcmClass, State}; +use embassy_util::Forever; use {defmt_rtt as _, panic_probe as _}; type MyDriver = Driver<'static, peripherals::USBD, PowerUsb>; -#[embassy::task] +#[embassy_executor::task] async fn usb_task(mut device: UsbDevice<'static, MyDriver>) { device.run().await; } -#[embassy::task] +#[embassy_executor::task] async fn echo_task(mut class: CdcAcmClass<'static, MyDriver>) { loop { class.wait_connection().await; @@ -32,7 +32,7 @@ async fn echo_task(mut class: CdcAcmClass<'static, MyDriver>) { } } -#[embassy::main] +#[embassy_executor::main] async fn main(spawner: Spawner, p: Peripherals) { let clock: pac::CLOCK = unsafe { mem::transmute(()) }; diff --git a/examples/nrf/src/bin/wdt.rs b/examples/nrf/src/bin/wdt.rs index 280e23bc..560cb356 100644 --- a/examples/nrf/src/bin/wdt.rs +++ b/examples/nrf/src/bin/wdt.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy::executor::Spawner; +use embassy_executor::executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::wdt::{Config, Watchdog}; use embassy_nrf::Peripherals; use {defmt_rtt as _, panic_probe as _}; -#[embassy::main] +#[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { info!("Hello World!"); |