pub struct Chained<const L: u8, const H: u8> { /* private fields */ }
Expand description
Two chained PIT timer channels.
When the low timer counts down to zero, the high timer is decremented by one. This doubles the width of the timer.
Timers must be chained in sequence. For example, timer 2 (high) can be chained to timer 1 (low). But, timer 3 cannot be chained to timer 1.
Chaining channel 1 and 0 enables the lifetime register. The lifetime register allows us to read two 32-bit registers without rollover. Otherwise, the implementation handles rollovers in software with a small loop and comparison.
Implementations§
source§impl Chained<0, 1>
impl Chained<0, 1>
sourcepub fn new(low: Pit<0>, high: Pit<1>) -> Self
pub fn new(low: Pit<0>, high: Pit<1>) -> Self
Chain together channels 0 and 1.
This creates the lifetime timer.
sourcepub fn lifetime_value(&self) -> u64
pub fn lifetime_value(&self) -> u64
Read the lifetime register value.
This is only supported when chaining channels 0 and
channel 1. Returns 0
if the timer is disabled. The
lifetime registers account for rollover possibility
in hardware.
This method implements the recommended fix for errata ERR050130.
source§impl<const L: u8, const H: u8> Chained<L, H>
impl<const L: u8, const H: u8> Chained<L, H>
sourcepub fn release(self) -> (Pit<L>, Pit<H>)
pub fn release(self) -> (Pit<L>, Pit<H>)
Release the chained timers.
When release
returns, the timer chain is disabled, and the
timer channels are disabled.
sourcepub fn set_interrupt_enable(&mut self, enable: bool)
pub fn set_interrupt_enable(&mut self, enable: bool)
Enable (true) or disable (false) interrupt generation when the chained timer expires.
sourcepub fn is_interrupt_enabled(&self) -> bool
pub fn is_interrupt_enabled(&self) -> bool
Indicates if timeouts will (true) or will not (false) generate interrupts.
sourcepub fn set_load_timer_value(&mut self, ticks: u64)
pub fn set_load_timer_value(&mut self, ticks: u64)
Loads the timer value for the next timer run.
ticks
is in clock ticks.
sourcepub fn load_timer_value(&self) -> u64
pub fn load_timer_value(&self) -> u64
Returns the load timer value for the next timer run, in ticks.
sourcepub fn current_timer_value(&self) -> u64
pub fn current_timer_value(&self) -> u64
Reads the current timer value, in clock ticks.
Returns 0
if the timer is disabled.
sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns true
if the chained timer is enabled.
sourcepub fn is_elapsed(&self) -> bool
pub fn is_elapsed(&self) -> bool
Returns true
if the chained timer has elapsed.
sourcepub fn clear_elapsed(&mut self)
pub fn clear_elapsed(&mut self)
Clear the elapsed flag.