diff options
| author | Adam Greig <[email protected]> | 2023-10-15 00:57:25 +0100 |
|---|---|---|
| committer | Adam Greig <[email protected]> | 2023-10-15 01:30:12 +0100 |
| commit | 0621e957a0ddc7010d46b3ea3ddc8b9852bc8333 (patch) | |
| tree | f6caefe939109e55a73e9141c736d2f6c20f51e8 /examples/nrf52840/src | |
| parent | 7559f9e5834799b041d899767ef4305dcfdf0181 (diff) | |
time: Update examples, tests, and other code to use new Timer::after_x convenience methods
Diffstat (limited to 'examples/nrf52840/src')
28 files changed, 76 insertions, 77 deletions
diff --git a/examples/nrf52840/src/bin/blinky.rs b/examples/nrf52840/src/bin/blinky.rs index 513f6cd82..d3d1a7122 100644 --- a/examples/nrf52840/src/bin/blinky.rs +++ b/examples/nrf52840/src/bin/blinky.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 6 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 7 | use embassy_time::{Duration, Timer}; | 7 | use embassy_time::Timer; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -14,8 +14,8 @@ async fn main(_spawner: Spawner) { | |||
| 14 | 14 | ||
| 15 | loop { | 15 | loop { |
| 16 | led.set_high(); | 16 | led.set_high(); |
| 17 | Timer::after(Duration::from_millis(300)).await; | 17 | Timer::after_millis(300).await; |
| 18 | led.set_low(); | 18 | led.set_low(); |
| 19 | Timer::after(Duration::from_millis(300)).await; | 19 | Timer::after_millis(300).await; |
| 20 | } | 20 | } |
| 21 | } | 21 | } |
diff --git a/examples/nrf52840/src/bin/channel.rs b/examples/nrf52840/src/bin/channel.rs index bd9c909da..d3c7b47d2 100644 --- a/examples/nrf52840/src/bin/channel.rs +++ b/examples/nrf52840/src/bin/channel.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 7 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 8 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | 8 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; |
| 9 | use embassy_sync::channel::Channel; | 9 | use embassy_sync::channel::Channel; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | enum LedState { | 13 | enum LedState { |
| @@ -21,9 +21,9 @@ static CHANNEL: Channel<ThreadModeRawMutex, LedState, 1> = Channel::new(); | |||
| 21 | async fn my_task() { | 21 | async fn my_task() { |
| 22 | loop { | 22 | loop { |
| 23 | CHANNEL.send(LedState::On).await; | 23 | CHANNEL.send(LedState::On).await; |
| 24 | Timer::after(Duration::from_secs(1)).await; | 24 | Timer::after_secs(1).await; |
| 25 | CHANNEL.send(LedState::Off).await; | 25 | CHANNEL.send(LedState::Off).await; |
| 26 | Timer::after(Duration::from_secs(1)).await; | 26 | Timer::after_secs(1).await; |
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | 29 | ||
diff --git a/examples/nrf52840/src/bin/channel_sender_receiver.rs b/examples/nrf52840/src/bin/channel_sender_receiver.rs index ec4f1d800..79d2c4048 100644 --- a/examples/nrf52840/src/bin/channel_sender_receiver.rs +++ b/examples/nrf52840/src/bin/channel_sender_receiver.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; | 7 | use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; |
| 8 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | 8 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; |
| 9 | use embassy_sync::channel::{Channel, Receiver, Sender}; | 9 | use embassy_sync::channel::{Channel, Receiver, Sender}; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use static_cell::StaticCell; | 11 | use static_cell::StaticCell; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| @@ -22,9 +22,9 @@ static CHANNEL: StaticCell<Channel<NoopRawMutex, LedState, 1>> = StaticCell::new | |||
| 22 | async fn send_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) { | 22 | async fn send_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) { |
| 23 | loop { | 23 | loop { |
| 24 | sender.send(LedState::On).await; | 24 | sender.send(LedState::On).await; |
| 25 | Timer::after(Duration::from_secs(1)).await; | 25 | Timer::after_secs(1).await; |
| 26 | sender.send(LedState::Off).await; | 26 | sender.send(LedState::Off).await; |
| 27 | Timer::after(Duration::from_secs(1)).await; | 27 | Timer::after_secs(1).await; |
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
diff --git a/examples/nrf52840/src/bin/executor_fairness_test.rs b/examples/nrf52840/src/bin/executor_fairness_test.rs index 2a28f2763..f111b272e 100644 --- a/examples/nrf52840/src/bin/executor_fairness_test.rs +++ b/examples/nrf52840/src/bin/executor_fairness_test.rs | |||
| @@ -7,14 +7,14 @@ use core::task::Poll; | |||
| 7 | 7 | ||
| 8 | use defmt::{info, unwrap}; | 8 | use defmt::{info, unwrap}; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_time::{Duration, Instant, Timer}; | 10 | use embassy_time::{Instant, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[embassy_executor::task] | 13 | #[embassy_executor::task] |
| 14 | async fn run1() { | 14 | async fn run1() { |
| 15 | loop { | 15 | loop { |
| 16 | info!("DING DONG"); | 16 | info!("DING DONG"); |
| 17 | Timer::after(Duration::from_ticks(16000)).await; | 17 | Timer::after_ticks(16000).await; |
| 18 | } | 18 | } |
| 19 | } | 19 | } |
| 20 | 20 | ||
diff --git a/examples/nrf52840/src/bin/lora_cad.rs b/examples/nrf52840/src/bin/lora_cad.rs index 3a98133c9..38e6d6197 100644 --- a/examples/nrf52840/src/bin/lora_cad.rs +++ b/examples/nrf52840/src/bin/lora_cad.rs | |||
| @@ -11,7 +11,7 @@ use embassy_executor::Spawner; | |||
| 11 | use embassy_lora::iv::GenericSx126xInterfaceVariant; | 11 | use embassy_lora::iv::GenericSx126xInterfaceVariant; |
| 12 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; | 12 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; |
| 13 | use embassy_nrf::{bind_interrupts, peripherals, spim}; | 13 | use embassy_nrf::{bind_interrupts, peripherals, spim}; |
| 14 | use embassy_time::{Delay, Duration, Timer}; | 14 | use embassy_time::{Delay, Timer}; |
| 15 | use lora_phy::mod_params::*; | 15 | use lora_phy::mod_params::*; |
| 16 | use lora_phy::sx1261_2::SX1261_2; | 16 | use lora_phy::sx1261_2::SX1261_2; |
| 17 | use lora_phy::LoRa; | 17 | use lora_phy::LoRa; |
| @@ -55,7 +55,7 @@ async fn main(_spawner: Spawner) { | |||
| 55 | let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); | 55 | let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); |
| 56 | 56 | ||
| 57 | start_indicator.set_high(); | 57 | start_indicator.set_high(); |
| 58 | Timer::after(Duration::from_secs(5)).await; | 58 | Timer::after_secs(5).await; |
| 59 | start_indicator.set_low(); | 59 | start_indicator.set_low(); |
| 60 | 60 | ||
| 61 | let mdltn_params = { | 61 | let mdltn_params = { |
| @@ -89,7 +89,7 @@ async fn main(_spawner: Spawner) { | |||
| 89 | info!("cad successful without activity detected") | 89 | info!("cad successful without activity detected") |
| 90 | } | 90 | } |
| 91 | debug_indicator.set_high(); | 91 | debug_indicator.set_high(); |
| 92 | Timer::after(Duration::from_secs(5)).await; | 92 | Timer::after_secs(5).await; |
| 93 | debug_indicator.set_low(); | 93 | debug_indicator.set_low(); |
| 94 | } | 94 | } |
| 95 | Err(err) => info!("cad unsuccessful = {}", err), | 95 | Err(err) => info!("cad unsuccessful = {}", err), |
diff --git a/examples/nrf52840/src/bin/lora_p2p_receive.rs b/examples/nrf52840/src/bin/lora_p2p_receive.rs index 1d293c6bf..4f41e1245 100644 --- a/examples/nrf52840/src/bin/lora_p2p_receive.rs +++ b/examples/nrf52840/src/bin/lora_p2p_receive.rs | |||
| @@ -11,7 +11,7 @@ use embassy_executor::Spawner; | |||
| 11 | use embassy_lora::iv::GenericSx126xInterfaceVariant; | 11 | use embassy_lora::iv::GenericSx126xInterfaceVariant; |
| 12 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; | 12 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; |
| 13 | use embassy_nrf::{bind_interrupts, peripherals, spim}; | 13 | use embassy_nrf::{bind_interrupts, peripherals, spim}; |
| 14 | use embassy_time::{Delay, Duration, Timer}; | 14 | use embassy_time::{Delay, Timer}; |
| 15 | use lora_phy::mod_params::*; | 15 | use lora_phy::mod_params::*; |
| 16 | use lora_phy::sx1261_2::SX1261_2; | 16 | use lora_phy::sx1261_2::SX1261_2; |
| 17 | use lora_phy::LoRa; | 17 | use lora_phy::LoRa; |
| @@ -55,7 +55,7 @@ async fn main(_spawner: Spawner) { | |||
| 55 | let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); | 55 | let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); |
| 56 | 56 | ||
| 57 | start_indicator.set_high(); | 57 | start_indicator.set_high(); |
| 58 | Timer::after(Duration::from_secs(5)).await; | 58 | Timer::after_secs(5).await; |
| 59 | start_indicator.set_low(); | 59 | start_indicator.set_low(); |
| 60 | 60 | ||
| 61 | let mut receiving_buffer = [00u8; 100]; | 61 | let mut receiving_buffer = [00u8; 100]; |
| @@ -107,7 +107,7 @@ async fn main(_spawner: Spawner) { | |||
| 107 | { | 107 | { |
| 108 | info!("rx successful"); | 108 | info!("rx successful"); |
| 109 | debug_indicator.set_high(); | 109 | debug_indicator.set_high(); |
| 110 | Timer::after(Duration::from_secs(5)).await; | 110 | Timer::after_secs(5).await; |
| 111 | debug_indicator.set_low(); | 111 | debug_indicator.set_low(); |
| 112 | } else { | 112 | } else { |
| 113 | info!("rx unknown packet"); | 113 | info!("rx unknown packet"); |
diff --git a/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs b/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs index eee4d20e7..3d34f6aef 100644 --- a/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs +++ b/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs | |||
| @@ -11,7 +11,7 @@ use embassy_executor::Spawner; | |||
| 11 | use embassy_lora::iv::GenericSx126xInterfaceVariant; | 11 | use embassy_lora::iv::GenericSx126xInterfaceVariant; |
| 12 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; | 12 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; |
| 13 | use embassy_nrf::{bind_interrupts, peripherals, spim}; | 13 | use embassy_nrf::{bind_interrupts, peripherals, spim}; |
| 14 | use embassy_time::{Delay, Duration, Timer}; | 14 | use embassy_time::{Delay, Timer}; |
| 15 | use lora_phy::mod_params::*; | 15 | use lora_phy::mod_params::*; |
| 16 | use lora_phy::sx1261_2::SX1261_2; | 16 | use lora_phy::sx1261_2::SX1261_2; |
| 17 | use lora_phy::LoRa; | 17 | use lora_phy::LoRa; |
| @@ -55,7 +55,7 @@ async fn main(_spawner: Spawner) { | |||
| 55 | let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); | 55 | let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); |
| 56 | 56 | ||
| 57 | start_indicator.set_high(); | 57 | start_indicator.set_high(); |
| 58 | Timer::after(Duration::from_secs(5)).await; | 58 | Timer::after_secs(5).await; |
| 59 | start_indicator.set_low(); | 59 | start_indicator.set_low(); |
| 60 | 60 | ||
| 61 | let mut receiving_buffer = [00u8; 100]; | 61 | let mut receiving_buffer = [00u8; 100]; |
| @@ -116,7 +116,7 @@ async fn main(_spawner: Spawner) { | |||
| 116 | { | 116 | { |
| 117 | info!("rx successful"); | 117 | info!("rx successful"); |
| 118 | debug_indicator.set_high(); | 118 | debug_indicator.set_high(); |
| 119 | Timer::after(Duration::from_secs(5)).await; | 119 | Timer::after_secs(5).await; |
| 120 | debug_indicator.set_low(); | 120 | debug_indicator.set_low(); |
| 121 | } else { | 121 | } else { |
| 122 | info!("rx unknown packet") | 122 | info!("rx unknown packet") |
diff --git a/examples/nrf52840/src/bin/manually_create_executor.rs b/examples/nrf52840/src/bin/manually_create_executor.rs index 12ce660f9..80364d34a 100644 --- a/examples/nrf52840/src/bin/manually_create_executor.rs +++ b/examples/nrf52840/src/bin/manually_create_executor.rs | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | use cortex_m_rt::entry; | 8 | use cortex_m_rt::entry; |
| 9 | use defmt::{info, unwrap}; | 9 | use defmt::{info, unwrap}; |
| 10 | use embassy_executor::Executor; | 10 | use embassy_executor::Executor; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use static_cell::StaticCell; | 12 | use static_cell::StaticCell; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| @@ -16,7 +16,7 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 16 | async fn run1() { | 16 | async fn run1() { |
| 17 | loop { | 17 | loop { |
| 18 | info!("BIG INFREQUENT TICK"); | 18 | info!("BIG INFREQUENT TICK"); |
| 19 | Timer::after(Duration::from_ticks(64000)).await; | 19 | Timer::after_ticks(64000).await; |
| 20 | } | 20 | } |
| 21 | } | 21 | } |
| 22 | 22 | ||
| @@ -24,7 +24,7 @@ async fn run1() { | |||
| 24 | async fn run2() { | 24 | async fn run2() { |
| 25 | loop { | 25 | loop { |
| 26 | info!("tick"); | 26 | info!("tick"); |
| 27 | Timer::after(Duration::from_ticks(13000)).await; | 27 | Timer::after_ticks(13000).await; |
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
diff --git a/examples/nrf52840/src/bin/multiprio.rs b/examples/nrf52840/src/bin/multiprio.rs index aab819117..352f62bf2 100644 --- a/examples/nrf52840/src/bin/multiprio.rs +++ b/examples/nrf52840/src/bin/multiprio.rs | |||
| @@ -62,7 +62,7 @@ use defmt::{info, unwrap}; | |||
| 62 | use embassy_executor::{Executor, InterruptExecutor}; | 62 | use embassy_executor::{Executor, InterruptExecutor}; |
| 63 | use embassy_nrf::interrupt; | 63 | use embassy_nrf::interrupt; |
| 64 | use embassy_nrf::interrupt::{InterruptExt, Priority}; | 64 | use embassy_nrf::interrupt::{InterruptExt, Priority}; |
| 65 | use embassy_time::{Duration, Instant, Timer}; | 65 | use embassy_time::{Instant, Timer}; |
| 66 | use static_cell::StaticCell; | 66 | use static_cell::StaticCell; |
| 67 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| 68 | 68 | ||
| @@ -70,7 +70,7 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 70 | async fn run_high() { | 70 | async fn run_high() { |
| 71 | loop { | 71 | loop { |
| 72 | info!(" [high] tick!"); | 72 | info!(" [high] tick!"); |
| 73 | Timer::after(Duration::from_ticks(27374)).await; | 73 | Timer::after_ticks(27374).await; |
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| 76 | 76 | ||
| @@ -87,7 +87,7 @@ async fn run_med() { | |||
| 87 | let ms = end.duration_since(start).as_ticks() / 33; | 87 | let ms = end.duration_since(start).as_ticks() / 33; |
| 88 | info!(" [med] done in {} ms", ms); | 88 | info!(" [med] done in {} ms", ms); |
| 89 | 89 | ||
| 90 | Timer::after(Duration::from_ticks(23421)).await; | 90 | Timer::after_ticks(23421).await; |
| 91 | } | 91 | } |
| 92 | } | 92 | } |
| 93 | 93 | ||
| @@ -104,7 +104,7 @@ async fn run_low() { | |||
| 104 | let ms = end.duration_since(start).as_ticks() / 33; | 104 | let ms = end.duration_since(start).as_ticks() / 33; |
| 105 | info!("[low] done in {} ms", ms); | 105 | info!("[low] done in {} ms", ms); |
| 106 | 106 | ||
| 107 | Timer::after(Duration::from_ticks(32983)).await; | 107 | Timer::after_ticks(32983).await; |
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | 110 | ||
diff --git a/examples/nrf52840/src/bin/mutex.rs b/examples/nrf52840/src/bin/mutex.rs index c402c6ba1..11b47d991 100644 --- a/examples/nrf52840/src/bin/mutex.rs +++ b/examples/nrf52840/src/bin/mutex.rs | |||
| @@ -6,7 +6,7 @@ use defmt::{info, unwrap}; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | 7 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; |
| 8 | use embassy_sync::mutex::Mutex; | 8 | use embassy_sync::mutex::Mutex; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | static MUTEX: Mutex<ThreadModeRawMutex, u32> = Mutex::new(0); | 12 | static MUTEX: Mutex<ThreadModeRawMutex, u32> = Mutex::new(0); |
| @@ -20,11 +20,11 @@ async fn my_task() { | |||
| 20 | *m += 1000; | 20 | *m += 1000; |
| 21 | 21 | ||
| 22 | // Hold the mutex for a long time. | 22 | // Hold the mutex for a long time. |
| 23 | Timer::after(Duration::from_secs(1)).await; | 23 | Timer::after_secs(1).await; |
| 24 | info!("end long operation: count = {}", *m); | 24 | info!("end long operation: count = {}", *m); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | Timer::after(Duration::from_secs(1)).await; | 27 | Timer::after_secs(1).await; |
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
| @@ -34,7 +34,7 @@ async fn main(spawner: Spawner) { | |||
| 34 | unwrap!(spawner.spawn(my_task())); | 34 | unwrap!(spawner.spawn(my_task())); |
| 35 | 35 | ||
| 36 | loop { | 36 | loop { |
| 37 | Timer::after(Duration::from_millis(300)).await; | 37 | Timer::after_millis(300).await; |
| 38 | let mut m = MUTEX.lock().await; | 38 | let mut m = MUTEX.lock().await; |
| 39 | *m += 1; | 39 | *m += 1; |
| 40 | info!("short operation: count = {}", *m); | 40 | info!("short operation: count = {}", *m); |
diff --git a/examples/nrf52840/src/bin/nvmc.rs b/examples/nrf52840/src/bin/nvmc.rs index 31c6fe4b6..624829863 100644 --- a/examples/nrf52840/src/bin/nvmc.rs +++ b/examples/nrf52840/src/bin/nvmc.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::nvmc::Nvmc; | 7 | use embassy_nrf::nvmc::Nvmc; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; | 9 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| @@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) { | |||
| 15 | info!("Hello NVMC!"); | 15 | info!("Hello NVMC!"); |
| 16 | 16 | ||
| 17 | // probe-rs run breaks without this, I'm not sure why. | 17 | // probe-rs run breaks without this, I'm not sure why. |
| 18 | Timer::after(Duration::from_secs(1)).await; | 18 | Timer::after_secs(1).await; |
| 19 | 19 | ||
| 20 | let mut f = Nvmc::new(p.NVMC); | 20 | let mut f = Nvmc::new(p.NVMC); |
| 21 | const ADDR: u32 = 0x80000; | 21 | const ADDR: u32 = 0x80000; |
diff --git a/examples/nrf52840/src/bin/pdm.rs b/examples/nrf52840/src/bin/pdm.rs index 444b9137f..bff323974 100644 --- a/examples/nrf52840/src/bin/pdm.rs +++ b/examples/nrf52840/src/bin/pdm.rs | |||
| @@ -6,7 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::pdm::{self, Config, Pdm}; | 7 | use embassy_nrf::pdm::{self, Config, Pdm}; |
| 8 | use embassy_nrf::{bind_interrupts, peripherals}; | 8 | use embassy_nrf::{bind_interrupts, peripherals}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use fixed::types::I7F1; | 10 | use fixed::types::I7F1; |
| 11 | use num_integer::Roots; | 11 | use num_integer::Roots; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -28,7 +28,7 @@ async fn main(_p: Spawner) { | |||
| 28 | pdm.start().await; | 28 | pdm.start().await; |
| 29 | 29 | ||
| 30 | // wait some time till the microphon settled | 30 | // wait some time till the microphon settled |
| 31 | Timer::after(Duration::from_millis(1000)).await; | 31 | Timer::after_millis(1000).await; |
| 32 | 32 | ||
| 33 | const SAMPLES: usize = 2048; | 33 | const SAMPLES: usize = 2048; |
| 34 | let mut buf = [0i16; SAMPLES]; | 34 | let mut buf = [0i16; SAMPLES]; |
| @@ -51,7 +51,7 @@ async fn main(_p: Spawner) { | |||
| 51 | info!("samples: {:?}", &buf); | 51 | info!("samples: {:?}", &buf); |
| 52 | 52 | ||
| 53 | pdm.stop().await; | 53 | pdm.stop().await; |
| 54 | Timer::after(Duration::from_millis(100)).await; | 54 | Timer::after_millis(100).await; |
| 55 | } | 55 | } |
| 56 | } | 56 | } |
| 57 | } | 57 | } |
diff --git a/examples/nrf52840/src/bin/pubsub.rs b/examples/nrf52840/src/bin/pubsub.rs index cca60ebc9..17d902227 100644 --- a/examples/nrf52840/src/bin/pubsub.rs +++ b/examples/nrf52840/src/bin/pubsub.rs | |||
| @@ -6,7 +6,7 @@ use defmt::unwrap; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | 7 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; |
| 8 | use embassy_sync::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; | 8 | use embassy_sync::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {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 |
| @@ -39,7 +39,7 @@ async fn main(spawner: Spawner) { | |||
| 39 | 39 | ||
| 40 | let mut index = 0; | 40 | let mut index = 0; |
| 41 | loop { | 41 | loop { |
| 42 | Timer::after(Duration::from_millis(500)).await; | 42 | Timer::after_millis(500).await; |
| 43 | 43 | ||
| 44 | let message = match index % 3 { | 44 | let message = match index % 3 { |
| 45 | 0 => Message::A, | 45 | 0 => Message::A, |
| @@ -81,7 +81,7 @@ async fn fast_logger(mut messages: Subscriber<'static, ThreadModeRawMutex, Messa | |||
| 81 | async fn slow_logger(mut messages: DynSubscriber<'static, Message>) { | 81 | async fn slow_logger(mut messages: DynSubscriber<'static, Message>) { |
| 82 | loop { | 82 | loop { |
| 83 | // Do some work | 83 | // Do some work |
| 84 | Timer::after(Duration::from_millis(2000)).await; | 84 | Timer::after_millis(2000).await; |
| 85 | 85 | ||
| 86 | // If the publisher has used the `publish_immediate` function, then we may receive a lag message here | 86 | // If the publisher has used the `publish_immediate` function, then we may receive a lag message here |
| 87 | let message = messages.next_message().await; | 87 | let message = messages.next_message().await; |
| @@ -98,7 +98,7 @@ async fn slow_logger(mut messages: DynSubscriber<'static, Message>) { | |||
| 98 | async fn slow_logger_pure(mut messages: DynSubscriber<'static, Message>) { | 98 | async fn slow_logger_pure(mut messages: DynSubscriber<'static, Message>) { |
| 99 | loop { | 99 | loop { |
| 100 | // Do some work | 100 | // Do some work |
| 101 | Timer::after(Duration::from_millis(2000)).await; | 101 | Timer::after_millis(2000).await; |
| 102 | 102 | ||
| 103 | // Instead of receiving lags here, we just ignore that and read the next message | 103 | // Instead of receiving lags here, we just ignore that and read the next message |
| 104 | let message = messages.next_message_pure().await; | 104 | let message = messages.next_message_pure().await; |
diff --git a/examples/nrf52840/src/bin/pwm.rs b/examples/nrf52840/src/bin/pwm.rs index 1698c0bc8..9750935c8 100644 --- a/examples/nrf52840/src/bin/pwm.rs +++ b/examples/nrf52840/src/bin/pwm.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; | 7 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | // for i in range(1024): print(int((math.sin(i/512*math.pi)*0.4+0.5)**2*32767), ', ', end='') | 11 | // for i in range(1024): print(int((math.sin(i/512*math.pi)*0.4+0.5)**2*32767), ', ', end='') |
| @@ -84,6 +84,6 @@ async fn main(_spawner: Spawner) { | |||
| 84 | pwm.set_duty(1, DUTY[(i + 256) % 1024]); | 84 | pwm.set_duty(1, DUTY[(i + 256) % 1024]); |
| 85 | pwm.set_duty(2, DUTY[(i + 512) % 1024]); | 85 | pwm.set_duty(2, DUTY[(i + 512) % 1024]); |
| 86 | pwm.set_duty(3, DUTY[(i + 768) % 1024]); | 86 | pwm.set_duty(3, DUTY[(i + 768) % 1024]); |
| 87 | Timer::after(Duration::from_millis(3)).await; | 87 | Timer::after_millis(3).await; |
| 88 | } | 88 | } |
| 89 | } | 89 | } |
diff --git a/examples/nrf52840/src/bin/pwm_double_sequence.rs b/examples/nrf52840/src/bin/pwm_double_sequence.rs index 16e50e909..1bfe6e15a 100644 --- a/examples/nrf52840/src/bin/pwm_double_sequence.rs +++ b/examples/nrf52840/src/bin/pwm_double_sequence.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_nrf::pwm::{ | 7 | use embassy_nrf::pwm::{ |
| 8 | Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, StartSequence, | 8 | Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, StartSequence, |
| 9 | }; | 9 | }; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| @@ -36,6 +36,6 @@ async fn main(_spawner: Spawner) { | |||
| 36 | // we can abort a sequence if we need to before its complete with pwm.stop() | 36 | // we can abort a sequence if we need to before its complete with pwm.stop() |
| 37 | // or stop is also implicitly called when the pwm peripheral is dropped | 37 | // or stop is also implicitly called when the pwm peripheral is dropped |
| 38 | // when it goes out of scope | 38 | // when it goes out of scope |
| 39 | Timer::after(Duration::from_millis(40000)).await; | 39 | Timer::after_millis(40000).await; |
| 40 | info!("pwm stopped early!"); | 40 | info!("pwm stopped early!"); |
| 41 | } | 41 | } |
diff --git a/examples/nrf52840/src/bin/pwm_sequence.rs b/examples/nrf52840/src/bin/pwm_sequence.rs index b9aca9aaa..f282cf910 100644 --- a/examples/nrf52840/src/bin/pwm_sequence.rs +++ b/examples/nrf52840/src/bin/pwm_sequence.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; | 7 | use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -31,6 +31,6 @@ async fn main(_spawner: Spawner) { | |||
| 31 | // we can abort a sequence if we need to before its complete with pwm.stop() | 31 | // we can abort a sequence if we need to before its complete with pwm.stop() |
| 32 | // or stop is also implicitly called when the pwm peripheral is dropped | 32 | // or stop is also implicitly called when the pwm peripheral is dropped |
| 33 | // when it goes out of scope | 33 | // when it goes out of scope |
| 34 | Timer::after(Duration::from_millis(20000)).await; | 34 | Timer::after_millis(20000).await; |
| 35 | info!("pwm stopped early!"); | 35 | info!("pwm stopped early!"); |
| 36 | } | 36 | } |
diff --git a/examples/nrf52840/src/bin/pwm_sequence_ws2812b.rs b/examples/nrf52840/src/bin/pwm_sequence_ws2812b.rs index 711c8a17b..8596e6545 100644 --- a/examples/nrf52840/src/bin/pwm_sequence_ws2812b.rs +++ b/examples/nrf52840/src/bin/pwm_sequence_ws2812b.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_nrf::pwm::{ | 7 | use embassy_nrf::pwm::{ |
| 8 | Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, SingleSequencer, | 8 | Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, SingleSequencer, |
| 9 | }; | 9 | }; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | // WS2812B LED light demonstration. Drives just one light. | 13 | // WS2812B LED light demonstration. Drives just one light. |
| @@ -52,7 +52,7 @@ async fn main(_spawner: Spawner) { | |||
| 52 | let sequences = SingleSequencer::new(&mut pwm, &seq_words, seq_config.clone()); | 52 | let sequences = SingleSequencer::new(&mut pwm, &seq_words, seq_config.clone()); |
| 53 | unwrap!(sequences.start(SingleSequenceMode::Times(1))); | 53 | unwrap!(sequences.start(SingleSequenceMode::Times(1))); |
| 54 | 54 | ||
| 55 | Timer::after(Duration::from_millis(50)).await; | 55 | Timer::after_millis(50).await; |
| 56 | 56 | ||
| 57 | if bit_value == T0H { | 57 | if bit_value == T0H { |
| 58 | if color_bit == 20 { | 58 | if color_bit == 20 { |
diff --git a/examples/nrf52840/src/bin/pwm_servo.rs b/examples/nrf52840/src/bin/pwm_servo.rs index 19228f433..92ded1f88 100644 --- a/examples/nrf52840/src/bin/pwm_servo.rs +++ b/examples/nrf52840/src/bin/pwm_servo.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; | 7 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -19,29 +19,29 @@ async fn main(_spawner: Spawner) { | |||
| 19 | pwm.set_max_duty(2500); | 19 | pwm.set_max_duty(2500); |
| 20 | info!("pwm initialized!"); | 20 | info!("pwm initialized!"); |
| 21 | 21 | ||
| 22 | Timer::after(Duration::from_millis(5000)).await; | 22 | Timer::after_millis(5000).await; |
| 23 | 23 | ||
| 24 | // 1ms 0deg (1/.008=125), 1.5ms 90deg (1.5/.008=187.5), 2ms 180deg (2/.008=250), | 24 | // 1ms 0deg (1/.008=125), 1.5ms 90deg (1.5/.008=187.5), 2ms 180deg (2/.008=250), |
| 25 | loop { | 25 | loop { |
| 26 | info!("45 deg"); | 26 | info!("45 deg"); |
| 27 | // poor mans inverting, subtract our value from max_duty | 27 | // poor mans inverting, subtract our value from max_duty |
| 28 | pwm.set_duty(0, 2500 - 156); | 28 | pwm.set_duty(0, 2500 - 156); |
| 29 | Timer::after(Duration::from_millis(5000)).await; | 29 | Timer::after_millis(5000).await; |
| 30 | 30 | ||
| 31 | info!("90 deg"); | 31 | info!("90 deg"); |
| 32 | pwm.set_duty(0, 2500 - 187); | 32 | pwm.set_duty(0, 2500 - 187); |
| 33 | Timer::after(Duration::from_millis(5000)).await; | 33 | Timer::after_millis(5000).await; |
| 34 | 34 | ||
| 35 | info!("135 deg"); | 35 | info!("135 deg"); |
| 36 | pwm.set_duty(0, 2500 - 218); | 36 | pwm.set_duty(0, 2500 - 218); |
| 37 | Timer::after(Duration::from_millis(5000)).await; | 37 | Timer::after_millis(5000).await; |
| 38 | 38 | ||
| 39 | info!("180 deg"); | 39 | info!("180 deg"); |
| 40 | pwm.set_duty(0, 2500 - 250); | 40 | pwm.set_duty(0, 2500 - 250); |
| 41 | Timer::after(Duration::from_millis(5000)).await; | 41 | Timer::after_millis(5000).await; |
| 42 | 42 | ||
| 43 | info!("0 deg"); | 43 | info!("0 deg"); |
| 44 | pwm.set_duty(0, 2500 - 125); | 44 | pwm.set_duty(0, 2500 - 125); |
| 45 | Timer::after(Duration::from_millis(5000)).await; | 45 | Timer::after_millis(5000).await; |
| 46 | } | 46 | } |
| 47 | } | 47 | } |
diff --git a/examples/nrf52840/src/bin/qspi_lowpower.rs b/examples/nrf52840/src/bin/qspi_lowpower.rs index 22a5c0c6d..42b5454e0 100644 --- a/examples/nrf52840/src/bin/qspi_lowpower.rs +++ b/examples/nrf52840/src/bin/qspi_lowpower.rs | |||
| @@ -8,7 +8,7 @@ use defmt::{info, unwrap}; | |||
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_nrf::qspi::Frequency; | 9 | use embassy_nrf::qspi::Frequency; |
| 10 | use embassy_nrf::{bind_interrupts, peripherals, qspi}; | 10 | use embassy_nrf::{bind_interrupts, peripherals, qspi}; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | // Workaround for alignment requirements. | 14 | // Workaround for alignment requirements. |
| @@ -79,6 +79,6 @@ async fn main(_p: Spawner) { | |||
| 79 | 79 | ||
| 80 | // Sleep for 1 second. The executor ensures the core sleeps with a WFE when it has nothing to do. | 80 | // Sleep for 1 second. The executor ensures the core sleeps with a WFE when it has nothing to do. |
| 81 | // During this sleep, the nRF chip should only use ~3uA | 81 | // During this sleep, the nRF chip should only use ~3uA |
| 82 | Timer::after(Duration::from_secs(1)).await; | 82 | Timer::after_secs(1).await; |
| 83 | } | 83 | } |
| 84 | } | 84 | } |
diff --git a/examples/nrf52840/src/bin/raw_spawn.rs b/examples/nrf52840/src/bin/raw_spawn.rs index 1b067f5e4..717b0faa6 100644 --- a/examples/nrf52840/src/bin/raw_spawn.rs +++ b/examples/nrf52840/src/bin/raw_spawn.rs | |||
| @@ -7,21 +7,21 @@ use cortex_m_rt::entry; | |||
| 7 | use defmt::{info, unwrap}; | 7 | use defmt::{info, unwrap}; |
| 8 | use embassy_executor::raw::TaskStorage; | 8 | use embassy_executor::raw::TaskStorage; |
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use static_cell::StaticCell; | 11 | use static_cell::StaticCell; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | async fn run1() { | 14 | async fn run1() { |
| 15 | loop { | 15 | loop { |
| 16 | info!("BIG INFREQUENT TICK"); | 16 | info!("BIG INFREQUENT TICK"); |
| 17 | Timer::after(Duration::from_ticks(64000)).await; | 17 | Timer::after_ticks(64000).await; |
| 18 | } | 18 | } |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | async fn run2() { | 21 | async fn run2() { |
| 22 | loop { | 22 | loop { |
| 23 | info!("tick"); | 23 | info!("tick"); |
| 24 | Timer::after(Duration::from_ticks(13000)).await; | 24 | Timer::after_ticks(13000).await; |
| 25 | } | 25 | } |
| 26 | } | 26 | } |
| 27 | 27 | ||
diff --git a/examples/nrf52840/src/bin/saadc.rs b/examples/nrf52840/src/bin/saadc.rs index ffd9a7f4b..d651834f5 100644 --- a/examples/nrf52840/src/bin/saadc.rs +++ b/examples/nrf52840/src/bin/saadc.rs | |||
| @@ -6,7 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::saadc::{ChannelConfig, Config, Saadc}; | 7 | use embassy_nrf::saadc::{ChannelConfig, Config, Saadc}; |
| 8 | use embassy_nrf::{bind_interrupts, saadc}; | 8 | use embassy_nrf::{bind_interrupts, saadc}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | bind_interrupts!(struct Irqs { | 12 | bind_interrupts!(struct Irqs { |
| @@ -24,6 +24,6 @@ async fn main(_p: Spawner) { | |||
| 24 | let mut buf = [0; 1]; | 24 | let mut buf = [0; 1]; |
| 25 | saadc.sample(&mut buf).await; | 25 | saadc.sample(&mut buf).await; |
| 26 | info!("sample: {=i16}", &buf[0]); | 26 | info!("sample: {=i16}", &buf[0]); |
| 27 | Timer::after(Duration::from_millis(100)).await; | 27 | Timer::after_millis(100).await; |
| 28 | } | 28 | } |
| 29 | } | 29 | } |
diff --git a/examples/nrf52840/src/bin/saadc_continuous.rs b/examples/nrf52840/src/bin/saadc_continuous.rs index a25e17465..a5f8a4dd7 100644 --- a/examples/nrf52840/src/bin/saadc_continuous.rs +++ b/examples/nrf52840/src/bin/saadc_continuous.rs | |||
| @@ -7,7 +7,6 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_nrf::saadc::{CallbackResult, ChannelConfig, Config, Saadc}; | 7 | use embassy_nrf::saadc::{CallbackResult, ChannelConfig, Config, Saadc}; |
| 8 | use embassy_nrf::timer::Frequency; | 8 | use embassy_nrf::timer::Frequency; |
| 9 | use embassy_nrf::{bind_interrupts, saadc}; | 9 | use embassy_nrf::{bind_interrupts, saadc}; |
| 10 | use embassy_time::Duration; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| 13 | // Demonstrates both continuous sampling and scanning multiple channels driven by a PPI linked timer | 12 | // Demonstrates both continuous sampling and scanning multiple channels driven by a PPI linked timer |
| @@ -32,7 +31,7 @@ async fn main(_p: Spawner) { | |||
| 32 | 31 | ||
| 33 | // This delay demonstrates that starting the timer prior to running | 32 | // This delay demonstrates that starting the timer prior to running |
| 34 | // the task sampler is benign given the calibration that follows. | 33 | // the task sampler is benign given the calibration that follows. |
| 35 | embassy_time::Timer::after(Duration::from_millis(500)).await; | 34 | embassy_time::Timer::after_millis(500).await; |
| 36 | saadc.calibrate().await; | 35 | saadc.calibrate().await; |
| 37 | 36 | ||
| 38 | let mut bufs = [[[0; 3]; 500]; 2]; | 37 | let mut bufs = [[[0; 3]; 500]; 2]; |
diff --git a/examples/nrf52840/src/bin/self_spawn.rs b/examples/nrf52840/src/bin/self_spawn.rs index 31ea6c81e..8a58396a4 100644 --- a/examples/nrf52840/src/bin/self_spawn.rs +++ b/examples/nrf52840/src/bin/self_spawn.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_time::{Duration, Timer}; | 7 | use embassy_time::Timer; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | mod config { | 10 | mod config { |
| @@ -13,7 +13,7 @@ mod config { | |||
| 13 | 13 | ||
| 14 | #[embassy_executor::task(pool_size = config::MY_TASK_POOL_SIZE)] | 14 | #[embassy_executor::task(pool_size = config::MY_TASK_POOL_SIZE)] |
| 15 | async fn my_task(spawner: Spawner, n: u32) { | 15 | async fn my_task(spawner: Spawner, n: u32) { |
| 16 | Timer::after(Duration::from_secs(1)).await; | 16 | Timer::after_secs(1).await; |
| 17 | info!("Spawning self! {}", n); | 17 | info!("Spawning self! {}", n); |
| 18 | unwrap!(spawner.spawn(my_task(spawner, n + 1))); | 18 | unwrap!(spawner.spawn(my_task(spawner, n + 1))); |
| 19 | } | 19 | } |
diff --git a/examples/nrf52840/src/bin/self_spawn_current_executor.rs b/examples/nrf52840/src/bin/self_spawn_current_executor.rs index 8a179886c..65d50f8c3 100644 --- a/examples/nrf52840/src/bin/self_spawn_current_executor.rs +++ b/examples/nrf52840/src/bin/self_spawn_current_executor.rs | |||
| @@ -4,12 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_time::{Duration, Timer}; | 7 | use embassy_time::Timer; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::task(pool_size = 2)] | 10 | #[embassy_executor::task(pool_size = 2)] |
| 11 | async fn my_task(n: u32) { | 11 | async fn my_task(n: u32) { |
| 12 | Timer::after(Duration::from_secs(1)).await; | 12 | Timer::after_secs(1).await; |
| 13 | info!("Spawning self! {}", n); | 13 | info!("Spawning self! {}", n); |
| 14 | unwrap!(Spawner::for_current_executor().await.spawn(my_task(n + 1))); | 14 | unwrap!(Spawner::for_current_executor().await.spawn(my_task(n + 1))); |
| 15 | } | 15 | } |
diff --git a/examples/nrf52840/src/bin/temp.rs b/examples/nrf52840/src/bin/temp.rs index 70957548f..d94dea38d 100644 --- a/examples/nrf52840/src/bin/temp.rs +++ b/examples/nrf52840/src/bin/temp.rs | |||
| @@ -6,7 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::temp::Temp; | 7 | use embassy_nrf::temp::Temp; |
| 8 | use embassy_nrf::{bind_interrupts, temp}; | 8 | use embassy_nrf::{bind_interrupts, temp}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | bind_interrupts!(struct Irqs { | 12 | bind_interrupts!(struct Irqs { |
| @@ -21,6 +21,6 @@ async fn main(_spawner: Spawner) { | |||
| 21 | loop { | 21 | loop { |
| 22 | let value = temp.read().await; | 22 | let value = temp.read().await; |
| 23 | info!("temperature: {}℃", value.to_num::<u16>()); | 23 | info!("temperature: {}℃", value.to_num::<u16>()); |
| 24 | Timer::after(Duration::from_secs(1)).await; | 24 | Timer::after_secs(1).await; |
| 25 | } | 25 | } |
| 26 | } | 26 | } |
diff --git a/examples/nrf52840/src/bin/timer.rs b/examples/nrf52840/src/bin/timer.rs index c22b5acd5..9b9bb3eb4 100644 --- a/examples/nrf52840/src/bin/timer.rs +++ b/examples/nrf52840/src/bin/timer.rs | |||
| @@ -4,14 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_time::{Duration, Timer}; | 7 | use embassy_time::Timer; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::task] | 10 | #[embassy_executor::task] |
| 11 | async fn run1() { | 11 | async fn run1() { |
| 12 | loop { | 12 | loop { |
| 13 | info!("BIG INFREQUENT TICK"); | 13 | info!("BIG INFREQUENT TICK"); |
| 14 | Timer::after(Duration::from_ticks(64000)).await; | 14 | Timer::after_ticks(64000).await; |
| 15 | } | 15 | } |
| 16 | } | 16 | } |
| 17 | 17 | ||
| @@ -19,7 +19,7 @@ async fn run1() { | |||
| 19 | async fn run2() { | 19 | async fn run2() { |
| 20 | loop { | 20 | loop { |
| 21 | info!("tick"); | 21 | info!("tick"); |
| 22 | Timer::after(Duration::from_ticks(13000)).await; | 22 | Timer::after_ticks(13000).await; |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
| 25 | 25 | ||
diff --git a/examples/nrf52840/src/bin/twim_lowpower.rs b/examples/nrf52840/src/bin/twim_lowpower.rs index 0970d3c3c..bf9f966ef 100644 --- a/examples/nrf52840/src/bin/twim_lowpower.rs +++ b/examples/nrf52840/src/bin/twim_lowpower.rs | |||
| @@ -14,7 +14,7 @@ use defmt::*; | |||
| 14 | use embassy_executor::Spawner; | 14 | use embassy_executor::Spawner; |
| 15 | use embassy_nrf::twim::{self, Twim}; | 15 | use embassy_nrf::twim::{self, Twim}; |
| 16 | use embassy_nrf::{bind_interrupts, peripherals}; | 16 | use embassy_nrf::{bind_interrupts, peripherals}; |
| 17 | use embassy_time::{Duration, Timer}; | 17 | use embassy_time::Timer; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | const ADDRESS: u8 = 0x50; | 20 | const ADDRESS: u8 = 0x50; |
| @@ -48,6 +48,6 @@ async fn main(_p: Spawner) { | |||
| 48 | 48 | ||
| 49 | // Sleep for 1 second. The executor ensures the core sleeps with a WFE when it has nothing to do. | 49 | // Sleep for 1 second. The executor ensures the core sleeps with a WFE when it has nothing to do. |
| 50 | // During this sleep, the nRF chip should only use ~3uA | 50 | // During this sleep, the nRF chip should only use ~3uA |
| 51 | Timer::after(Duration::from_secs(1)).await; | 51 | Timer::after_secs(1).await; |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
diff --git a/examples/nrf52840/src/bin/usb_hid_mouse.rs b/examples/nrf52840/src/bin/usb_hid_mouse.rs index edf634a5e..96fcf8a66 100644 --- a/examples/nrf52840/src/bin/usb_hid_mouse.rs +++ b/examples/nrf52840/src/bin/usb_hid_mouse.rs | |||
| @@ -10,7 +10,7 @@ use embassy_futures::join::join; | |||
| 10 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; | 10 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; |
| 11 | use embassy_nrf::usb::Driver; | 11 | use embassy_nrf::usb::Driver; |
| 12 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; | 12 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; |
| 13 | use embassy_time::{Duration, Timer}; | 13 | use embassy_time::Timer; |
| 14 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; | 14 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; |
| 15 | use embassy_usb::control::OutResponse; | 15 | use embassy_usb::control::OutResponse; |
| 16 | use embassy_usb::{Builder, Config}; | 16 | use embassy_usb::{Builder, Config}; |
| @@ -83,7 +83,7 @@ async fn main(_spawner: Spawner) { | |||
| 83 | let hid_fut = async { | 83 | let hid_fut = async { |
| 84 | let mut y: i8 = 5; | 84 | let mut y: i8 = 5; |
| 85 | loop { | 85 | loop { |
| 86 | Timer::after(Duration::from_millis(500)).await; | 86 | Timer::after_millis(500).await; |
| 87 | 87 | ||
| 88 | y = -y; | 88 | y = -y; |
| 89 | let report = MouseReport { | 89 | let report = MouseReport { |
