pub struct TimerDevice {
pub vect: u8,
pub priority: u8,
pub enabled: bool,
/* private fields */
}Expand description
A timer device that triggers an interrupt after a configured number (or range) of instructions.
This is not part of LC-3 specification, so the design decision made (such as default interrupt vector, priority level) are not reflective of LC-3’s choices.
Fields§
§vect: u8The interrupt vector.
priority: u8The priority.
Note that if this exceeds 7, it will be treated as though it is 7.
enabled: boolWhether this timer can trigger an interrupt.
Implementations§
source§impl TimerDevice
impl TimerDevice
sourcepub fn new(
seed: Option<u64>,
range: impl RangeBounds<u32>,
vect: u8,
priority: u8,
) -> Self
pub fn new( seed: Option<u64>, range: impl RangeBounds<u32>, vect: u8, priority: u8, ) -> Self
Creates a new timer device.
seed: Sets the seed for the timer’s RNG. This can beNoneif RNG does not need to be deterministic or if range can only be exactly one value.range: Sets the range of possible number of instructions before interrupt trigger.vectandpriority: Initializes the interrupt vector and priority values.
sourcepub fn get_range(&self) -> impl RangeBounds<u32>
pub fn get_range(&self) -> impl RangeBounds<u32>
Gets the range of possible number of instructions before the interrupt is triggered.
sourcepub fn set_range(&mut self, r: impl RangeBounds<u32>) -> &mut Self
pub fn set_range(&mut self, r: impl RangeBounds<u32>) -> &mut Self
Sets the number of instructions before the interrupt is triggered to a range of values.
sourcepub fn set_exact(&mut self, n: u32) -> &mut Self
pub fn set_exact(&mut self, n: u32) -> &mut Self
Sets the number of instructions before the interrupt is triggered to an exact number.
sourcepub fn get_remaining(&self) -> u32
pub fn get_remaining(&self) -> u32
Gets the number of instructions remaining until the interrupt triggers.
sourcepub fn reset_remaining(&mut self)
pub fn reset_remaining(&mut self)
Resets the remaining time.