2021-09-02 12:02:31 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
2022-04-02 04:35:06 +02:00
|
|
|
use defmt::info;
|
2022-08-17 23:40:16 +02:00
|
|
|
use embassy_executor::Spawner;
|
2022-08-17 18:49:55 +02:00
|
|
|
use embassy_nrf::interrupt;
|
2021-09-02 12:02:31 +02:00
|
|
|
use embassy_nrf::timer::Timer;
|
2022-06-12 22:15:44 +02:00
|
|
|
use {defmt_rtt as _, panic_probe as _};
|
2021-09-02 12:02:31 +02:00
|
|
|
|
2022-07-29 21:58:35 +02:00
|
|
|
#[embassy_executor::main]
|
2022-08-17 18:49:55 +02:00
|
|
|
async fn main(_spawner: Spawner) {
|
|
|
|
let p = embassy_nrf::init(Default::default());
|
2021-09-02 12:02:31 +02:00
|
|
|
let mut t = Timer::new_awaitable(p.TIMER0, interrupt::take!(TIMER0));
|
|
|
|
// default frequency is 1MHz, so this triggers every second
|
|
|
|
t.cc(0).write(1_000_000);
|
|
|
|
// clear the timer value on cc[0] compare match
|
|
|
|
t.cc(0).short_compare_clear();
|
|
|
|
t.start();
|
|
|
|
|
|
|
|
loop {
|
|
|
|
// wait for compare match
|
|
|
|
t.cc(0).wait().await;
|
|
|
|
info!("hardware timer tick");
|
|
|
|
}
|
|
|
|
}
|