Trait rtic::Monotonic [−][src]
A monotonic clock / counter definition.
Codegen extensions provided
The RTIC codegen will implement an infallible Monotonic::now()
that simply gets the value
from the Clock::try_now()
, and an Monotonic::zero()
which returns the zero time for use
in #[init]
.
Correctness
When implementing this trait it is important to decide if one want to have a fixed baseline and
utilize the reset
method. If not, one can implement reset
as an empty method. If
reset
is not empty, it is not allowed for try_now()
/now()
to return
nonsensical values if called before reset
is invoked by the runtime. Therefore implementation
authors should have methods in place for making sure of this, for example a flag in the timer
which tracks if the reset
method has been called yet, and if not always return 0
.
The embedded_time::Clock
implementation must be infallible.
Associated Constants
pub const DISABLE_INTERRUPT_ON_EMPTY_QUEUE: bool
[src]
This tells RTIC if it should disable the interrupt bound to the monotonic if there are no
scheduled tasks. One may want to set this to false
if one is using the on_interrupt
method to perform housekeeping and need overflow interrupts to happen, such as when
extending a 16 bit timer to 32/64 bits, even if there are no scheduled tasks.
Required methods
pub unsafe fn reset(&mut self)
[src]
Optionally resets the counter to zero for a fixed baseline in a system.
This method will be called exactly once by the RTIC runtime after #[init]
returns and
before tasks can start.
Correctness
The user may not call this method.
pub fn set_compare(&mut self, instant: &Instant<Self>)
[src]
Set the compare value of the timer interrupt.
pub fn clear_compare_flag(&mut self)
[src]
Clear the compare interrupt flag.
Provided methods
pub fn on_interrupt(&mut self)
[src]
Optional. Commonly used for performing housekeeping of a timer when it has been extended, e.g. a 16 bit timer extended to 32/64 bits. This will be called at the end of the interrupt handler after all other operations have finished.
pub fn enable_timer(&mut self)
[src]
Optional. This is used to save power, this is called when the Monotonic interrupt is enabled.
pub fn disable_timer(&mut self)
[src]
Optional. This is used to save power, this is called when the Monotonic interrupt is disabled.