pub trait GenericTimer {
Show 14 methods
// Required methods
fn frequency_hz(&self) -> u32;
fn counter(&self) -> u64;
fn counter_compare(&self) -> u64;
fn counter_compare_set(&mut self, value: u64);
fn countdown(&self) -> u32;
fn countdown_set(&mut self, duration_ticks: u32);
fn enabled(&self) -> bool;
fn enable(&self, enabled: bool);
fn interrupt_masked(&self) -> bool;
fn interrupt_mask(&mut self, mask: bool);
fn interrupt_status(&self) -> bool;
// Provided methods
fn delay_ticks(&mut self, ticks: u32) { ... }
fn delay_ms(&mut self, ms: u32) { ... }
fn delay_us(&mut self, us: u32) { ... }
}
Expand description
Describes either a Physical or Virtual timer
Required Methods§
Sourcefn frequency_hz(&self) -> u32
fn frequency_hz(&self) -> u32
Get the timer frequency
Sourcefn counter(&self) -> u64
fn counter(&self) -> u64
Get the current counter value.
This is a 64-bit value that goes up. It can be used to measure the passing of time.
Note that speculative reads are allowed and reads may occur out of order. Add ISB and DSB fences before/after this call as required.
Sourcefn counter_compare(&self) -> u64
fn counter_compare(&self) -> u64
Get the counter compare value.
Sourcefn counter_compare_set(&mut self, value: u64)
fn counter_compare_set(&mut self, value: u64)
Set the counter compare value.
The timer condition is met when the counter - compare_value >= 0
. This
therefore operates as a count-up timer.
Sourcefn countdown_set(&mut self, duration_ticks: u32)
fn countdown_set(&mut self, duration_ticks: u32)
Set the value of the count-down timer.
Sets a value which is decremented on every counter tick. When it reaches zero, the timer fires.
Sourcefn interrupt_masked(&self) -> bool
fn interrupt_masked(&self) -> bool
Is this timer’s interrupt masked?
Sourcefn interrupt_mask(&mut self, mask: bool)
fn interrupt_mask(&mut self, mask: bool)
Mask (or unmask) this timer’s interrupt.
Sourcefn interrupt_status(&self) -> bool
fn interrupt_status(&self) -> bool
Has this timer’s interrupt fired?
Provided Methods§
Sourcefn delay_ticks(&mut self, ticks: u32)
fn delay_ticks(&mut self, ticks: u32)
Wait for some number of clock ticks