diff options
| author | Dario Nieuwenhuis <[email protected]> | 2020-12-26 23:44:53 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2020-12-26 23:44:53 +0100 |
| commit | 692d8bb813f15f8add4783150768b9c4cae15182 (patch) | |
| tree | d01f0af03c129d6dbc4b6889d7095571a918def3 /examples/src/bin/rtc_async.rs | |
| parent | 8b7a42a4f9271c337d550be1f34e7d163f9eb905 (diff) | |
More efficient timer queue, integrated into Executor directly.
Diffstat (limited to 'examples/src/bin/rtc_async.rs')
| -rw-r--r-- | examples/src/bin/rtc_async.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/src/bin/rtc_async.rs b/examples/src/bin/rtc_async.rs index b4ee736b7..aec70a072 100644 --- a/examples/src/bin/rtc_async.rs +++ b/examples/src/bin/rtc_async.rs | |||
| @@ -10,7 +10,7 @@ use core::mem::MaybeUninit; | |||
| 10 | use cortex_m_rt::entry; | 10 | use cortex_m_rt::entry; |
| 11 | use nrf52840_hal::clocks; | 11 | use nrf52840_hal::clocks; |
| 12 | 12 | ||
| 13 | use embassy::executor::{task, TimerExecutor}; | 13 | use embassy::executor::{task, Executor}; |
| 14 | use embassy::time::{Clock, Duration, Timer}; | 14 | use embassy::time::{Clock, Duration, Timer}; |
| 15 | use embassy::util::Forever; | 15 | use embassy::util::Forever; |
| 16 | use embassy_nrf::pac; | 16 | use embassy_nrf::pac; |
| @@ -33,7 +33,8 @@ async fn run2() { | |||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | static RTC: Forever<rtc::RTC<pac::RTC1>> = Forever::new(); | 35 | static RTC: Forever<rtc::RTC<pac::RTC1>> = Forever::new(); |
| 36 | static EXECUTOR: Forever<TimerExecutor<rtc::Alarm<pac::RTC1>>> = Forever::new(); | 36 | static ALARM: Forever<rtc::Alarm<pac::RTC1>> = Forever::new(); |
| 37 | static EXECUTOR: Forever<Executor> = Forever::new(); | ||
| 37 | 38 | ||
| 38 | #[entry] | 39 | #[entry] |
| 39 | fn main() -> ! { | 40 | fn main() -> ! { |
| @@ -51,7 +52,8 @@ fn main() -> ! { | |||
| 51 | 52 | ||
| 52 | unsafe { embassy::time::set_clock(rtc) }; | 53 | unsafe { embassy::time::set_clock(rtc) }; |
| 53 | 54 | ||
| 54 | let executor = EXECUTOR.put(TimerExecutor::new(rtc.alarm0(), cortex_m::asm::sev)); | 55 | let alarm = ALARM.put(rtc.alarm0()); |
| 56 | let executor = EXECUTOR.put(Executor::new_with_alarm(alarm, cortex_m::asm::sev)); | ||
| 55 | 57 | ||
| 56 | unwrap!(executor.spawn(run1())); | 58 | unwrap!(executor.spawn(run1())); |
| 57 | unwrap!(executor.spawn(run2())); | 59 | unwrap!(executor.spawn(run2())); |
