#![no_std]
#![no_main]
const FRONTEND: board::logging::Frontend = board::logging::Frontend::Log;
const BACKEND: board::logging::Backend = board::logging::BACKEND;
use hal::snvs::srtc::EnabledState;
use imxrt_hal as hal;
#[imxrt_rt::entry]
fn main() -> ! {
let (
board::Common {
usb1,
usbnc1,
usbphy1,
mut dma,
srtc,
mut snvs_lp_core,
..
},
board::Specifics { led, console, .. },
) = board::new();
let usbd = hal::usbd::Instances {
usb: usb1,
usbnc: usbnc1,
usbphy: usbphy1,
};
let dma_a = dma[board::BOARD_DMA_A_INDEX].take().unwrap();
let mut poller = board::logging::init(FRONTEND, BACKEND, console, dma_a, usbd);
let (srtc, was_enabled) = match srtc.try_enable(&mut snvs_lp_core, 1600000000, 0) {
EnabledState::AlreadyCounting { srtc, .. } => (srtc, true),
EnabledState::SetTime(srtc) => (srtc, false),
};
let mut then = 0;
loop {
poller.poll();
let now = srtc.get();
if now != then {
then = now;
led.toggle();
log::info!("SRTC time: {now}. Was enabled? {was_enabled}");
defmt::println!("SRTC time: {=u32}. Was enable? {=bool}", now, was_enabled);
}
}
}