#![no_std] #![no_main] #![feature(min_type_alias_impl_trait)] #![feature(impl_trait_in_bindings)] #![feature(type_alias_impl_trait)] #![allow(incomplete_features)] #[path = "../example_common.rs"] mod example_common; use core::mem; use example_common::*; use cortex_m_rt::entry; use defmt::panic; use embassy::executor::{task, Executor}; use embassy::time::{Duration, Timer}; use embassy::util::Forever; use embassy_nrf::peripherals; use embassy_nrf::{interrupt, rtc}; use nrf52840_hal::clocks; #[task] async fn run1() { loop { info!("BIG INFREQUENT TICK"); Timer::after(Duration::from_ticks(64000)).await; } } #[task] async fn run2() { loop { info!("tick"); Timer::after(Duration::from_ticks(13000)).await; } } static RTC: Forever> = Forever::new(); static ALARM: Forever> = Forever::new(); static EXECUTOR: Forever = Forever::new(); #[entry] fn main() -> ! { info!("Hello World!"); clocks::Clocks::new(unsafe { mem::transmute(()) }) .enable_ext_hfosc() .set_lfclk_src_external(clocks::LfOscConfiguration::NoExternalNoBypass) .start_lfclk(); let p = unwrap!(embassy_nrf::Peripherals::take()); let rtc = RTC.put(rtc::RTC::new(p.RTC1, interrupt::take!(RTC1))); rtc.start(); unsafe { embassy::time::set_clock(rtc) }; let alarm = ALARM.put(rtc.alarm0()); let executor = EXECUTOR.put(Executor::new()); executor.set_alarm(alarm); executor.run(|spawner| { unwrap!(spawner.spawn(run1())); unwrap!(spawner.spawn(run2())); }); }