Expand description
Monotonic
implementation for RP2040’s Timer peripheral.
Always runs at a fixed rate of 1 MHz.
§Example
use rtic_monotonics::rp2040::prelude::*;
// Create the type `Mono`. It will manage the TIMER peripheral,
// which is a 1 MHz, 64-bit timer.
rp2040_timer_monotonic!(Mono);
fn init() {
// Start the monotonic - passing ownership of an rp2040_pac object for
// TIMER0, and temporary access to one for the RESET peripheral.
Mono::start(TIMER, &mut RESETS);
}
async fn usage() {
loop {
// You can use the monotonic to get the time...
let timestamp = Mono::now();
// ...and you can use it to add a delay to this async function
Mono::delay(100.millis()).await;
}
}
Modules§
- prelude
- Common definitions and traits for using the RP2040 timer monotonic
Structs§
- RESETS
- RESETS
- TIMER
- Controls time and alarms
time is a 64 bit value indicating the time in usec since power-on
timeh is the top 32 bits of time & timel is the bottom 32 bits
to change time write to timelw before timehw
to read time read from timelr before timehr
An alarm is set by setting alarm_enable and writing to the corresponding alarm register
When an alarm is pending, the corresponding alarm_running signal will be high
An alarm can be cancelled before it has finished by clearing the alarm_enable
When an alarm fires, the corresponding alarm_irq is set and alarm_running is cleared
To clear the interrupt write a 1 to the corresponding alarm_irq - Timer
Backend - Timer implementing
TimerQueueBackend
.