aboutsummaryrefslogtreecommitdiff
path: root/examples/src/bin/rtc_async.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/src/bin/rtc_async.rs')
-rw-r--r--examples/src/bin/rtc_async.rs65
1 files changed, 0 insertions, 65 deletions
diff --git a/examples/src/bin/rtc_async.rs b/examples/src/bin/rtc_async.rs
deleted file mode 100644
index dcdeb7049..000000000
--- a/examples/src/bin/rtc_async.rs
+++ /dev/null
@@ -1,65 +0,0 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5#[path = "../example_common.rs"]
6mod example_common;
7use example_common::*;
8
9use core::mem::MaybeUninit;
10use cortex_m_rt::entry;
11use defmt::panic;
12use embassy::executor::{task, Executor};
13use embassy::time::{Clock, Duration, Timer};
14use embassy::util::Forever;
15use embassy_nrf::pac;
16use embassy_nrf::{interrupt, rtc};
17use nrf52840_hal::clocks;
18
19#[task]
20async fn run1() {
21 loop {
22 info!("BIG INFREQUENT TICK");
23 Timer::after(Duration::from_ticks(64000)).await;
24 }
25}
26
27#[task]
28async fn run2() {
29 loop {
30 info!("tick");
31 Timer::after(Duration::from_ticks(13000)).await;
32 }
33}
34
35static RTC: Forever<rtc::RTC<pac::RTC1>> = Forever::new();
36static ALARM: Forever<rtc::Alarm<pac::RTC1>> = Forever::new();
37static EXECUTOR: Forever<Executor> = Forever::new();
38
39#[entry]
40fn main() -> ! {
41 info!("Hello World!");
42
43 let p = unwrap!(embassy_nrf::pac::Peripherals::take());
44
45 clocks::Clocks::new(p.CLOCK)
46 .enable_ext_hfosc()
47 .set_lfclk_src_external(clocks::LfOscConfiguration::NoExternalNoBypass)
48 .start_lfclk();
49
50 let rtc = RTC.put(rtc::RTC::new(p.RTC1, interrupt::take!(RTC1)));
51 rtc.start();
52
53 unsafe { embassy::time::set_clock(rtc) };
54
55 let alarm = ALARM.put(rtc.alarm0());
56 let executor = EXECUTOR.put(Executor::new_with_alarm(alarm, cortex_m::asm::sev));
57
58 unwrap!(executor.spawn(run1()));
59 unwrap!(executor.spawn(run2()));
60
61 loop {
62 executor.run();
63 cortex_m::asm::wfe();
64 }
65}