pub struct Timer { /* private fields */ }
Expand description
A 64-bit timer based on SysTick.
Stores wraparounds in 2 32-bit atomics. Scales the systick counts to arbitrary frequency.
Implementations§
Source§impl Timer
impl Timer
Sourcepub fn systick_handler(&self)
pub fn systick_handler(&self)
SysTick handler.
Call this from the SysTick interrupt handler.
Sourcepub fn systick_interrupt_for_nested(&self)
pub fn systick_interrupt_for_nested(&self)
Interrupt handler for nested interrupts.
Call this instead of systick_handler from the interrupt handler, if you have nested interrupts enabled.
Sourcepub fn now(&self) -> u64
pub fn now(&self) -> u64
Returns the current 64-bit tick count, scaled to the configured frequency tick_hz
.
Sourcepub const fn new(tick_hz: u64, reload_value: u32, systick_freq: u64) -> Self
pub const fn new(tick_hz: u64, reload_value: u32, systick_freq: u64) -> Self
Creates a new timer that converts SysTick cycles to ticks at a specified frequency.
§Arguments
tick_hz
- The desired output frequency in Hz (e.g., 1000 for millisecond ticks)reload_value
- The SysTick reload value. Must be between 1 and 2^24-1. This determines how many cycles occur between interrupts.systick_freq
- The frequency of the SysTick counter in Hz (typically CPU frequency)
§Panics
- If
reload_value
is 0 or greater than 2^24-1 (16,777,215) - If
systick_freq
is 0
§Examples
// Create a millisecond-resolution timer on a 48MHz CPU with reload value of 47,999
let timer = Timer::new(1000, 47_999, 48_000_000);
Auto Trait Implementations§
impl !Freeze for Timer
impl RefUnwindSafe for Timer
impl Send for Timer
impl Sync for Timer
impl Unpin for Timer
impl UnwindSafe for Timer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more