diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-01-01 22:41:59 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-01-01 22:46:32 +0100 |
| commit | 20d3dc87f95f844e747a7e93036ce9ddac369081 (patch) | |
| tree | 3842a1f3a343de0af8195a1a2a2cf0da17cb7c37 /examples/src/bin/rtc_async.rs | |
| parent | 4783222f675c1316d0e1a0fda92591f7aca63456 (diff) | |
Rename examples -> embassy-nrf-examples
Diffstat (limited to 'examples/src/bin/rtc_async.rs')
| -rw-r--r-- | examples/src/bin/rtc_async.rs | 65 |
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"] | ||
| 6 | mod example_common; | ||
| 7 | use example_common::*; | ||
| 8 | |||
| 9 | use core::mem::MaybeUninit; | ||
| 10 | use cortex_m_rt::entry; | ||
| 11 | use defmt::panic; | ||
| 12 | use embassy::executor::{task, Executor}; | ||
| 13 | use embassy::time::{Clock, Duration, Timer}; | ||
| 14 | use embassy::util::Forever; | ||
| 15 | use embassy_nrf::pac; | ||
| 16 | use embassy_nrf::{interrupt, rtc}; | ||
| 17 | use nrf52840_hal::clocks; | ||
| 18 | |||
| 19 | #[task] | ||
| 20 | async fn run1() { | ||
| 21 | loop { | ||
| 22 | info!("BIG INFREQUENT TICK"); | ||
| 23 | Timer::after(Duration::from_ticks(64000)).await; | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | #[task] | ||
| 28 | async fn run2() { | ||
| 29 | loop { | ||
| 30 | info!("tick"); | ||
| 31 | Timer::after(Duration::from_ticks(13000)).await; | ||
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 35 | static RTC: Forever<rtc::RTC<pac::RTC1>> = Forever::new(); | ||
| 36 | static ALARM: Forever<rtc::Alarm<pac::RTC1>> = Forever::new(); | ||
| 37 | static EXECUTOR: Forever<Executor> = Forever::new(); | ||
| 38 | |||
| 39 | #[entry] | ||
| 40 | fn 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 | } | ||
