aboutsummaryrefslogtreecommitdiff
path: root/examples/src/bin/rtc_async.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2020-12-26 23:44:53 +0100
committerDario Nieuwenhuis <[email protected]>2020-12-26 23:44:53 +0100
commit692d8bb813f15f8add4783150768b9c4cae15182 (patch)
treed01f0af03c129d6dbc4b6889d7095571a918def3 /examples/src/bin/rtc_async.rs
parent8b7a42a4f9271c337d550be1f34e7d163f9eb905 (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.rs8
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;
10use cortex_m_rt::entry; 10use cortex_m_rt::entry;
11use nrf52840_hal::clocks; 11use nrf52840_hal::clocks;
12 12
13use embassy::executor::{task, TimerExecutor}; 13use embassy::executor::{task, Executor};
14use embassy::time::{Clock, Duration, Timer}; 14use embassy::time::{Clock, Duration, Timer};
15use embassy::util::Forever; 15use embassy::util::Forever;
16use embassy_nrf::pac; 16use embassy_nrf::pac;
@@ -33,7 +33,8 @@ async fn run2() {
33} 33}
34 34
35static RTC: Forever<rtc::RTC<pac::RTC1>> = Forever::new(); 35static RTC: Forever<rtc::RTC<pac::RTC1>> = Forever::new();
36static EXECUTOR: Forever<TimerExecutor<rtc::Alarm<pac::RTC1>>> = Forever::new(); 36static ALARM: Forever<rtc::Alarm<pac::RTC1>> = Forever::new();
37static EXECUTOR: Forever<Executor> = Forever::new();
37 38
38#[entry] 39#[entry]
39fn main() -> ! { 40fn 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()));