#![no_main]
#![no_std]
extern crate panic_semihosting;
use cortex_m_rt::entry;
use cortex_m_semihosting::heprintln;
use hal::prelude::*;
use lpc55_hal as hal;
pub fn delay_cycles(delay: u64) {
let current = hal::get_cycle_count() as u64;
let mut target = current + delay;
if target > 0xFFFF_FFFF {
target -= 0xFFFF_FFFF;
while target < hal::get_cycle_count() as u64 {
continue;
}
}
while target > hal::get_cycle_count() as u64 {
continue;
}
}
#[entry]
fn main() -> ! {
let hal = hal::new();
let mut anactrl = hal.anactrl;
let mut pmc = hal.pmc;
let mut syscon = hal.syscon;
let clocks = hal::ClockRequirements::default()
.system_frequency(96.MHz())
.configure(&mut anactrl, &mut pmc, &mut syscon)
.unwrap();
let token_32k_fro = clocks.enable_32k_fro(&mut pmc);
let mut rtc = hal.rtc.enabled(&mut syscon, token_32k_fro);
hal::enable_cycle_counter();
rtc.reset();
loop {
delay_cycles(10_000_000);
heprintln!("{:?}", rtc.uptime());
}
}