Skip to content

hal::timer

A one-shot compare timer: “interrupt me after_us microseconds from now”.

Distinct from [crate::clock] (a free-running counter, “what time is it”) and [crate::tick] (the periodic scheduling interrupt). The kernel’s alarm module drives one of these for the radio’s microsecond timers, selecting one implementation with the SoC so its neutral half names no chip.

clear_alarm and clear_interrupt are called from the alarm’s interrupt handler, which is registered IRAM-safe so it keeps firing while a flash operation has the instruction cache off. An implementation’s bodies for those two must therefore be in RAM (or inline into the caller), exactly like the driver methods underneath them; a flash-resident forwarder would wedge the moment the cache went away.

trait CompareTimer: Sized {
unsafe fn claim() -> Option<Self>
fn interrupt_source(&self) -> u8
fn enable_interrupt(&self)
fn set_after_us(&self, after_us: u64)
fn clear_alarm(&self)
fn clear_interrupt(&self)
}

A one-shot compare timer, selected by the kernel together with the SoC.