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/bin/mutex.rs | |
| parent | 7559f9e5834799b041d899767ef4305dcfdf0181 (diff) | |
time: Update examples, tests, and other code to use new Timer::after_x convenience methods
Diffstat (limited to 'examples/nrf52840/src/bin/mutex.rs')
| -rw-r--r-- | examples/nrf52840/src/bin/mutex.rs | 8 |
1 files changed, 4 insertions, 4 deletions
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); |
