Trait nrf52840_hal::timer::Instance
source · pub trait Instance: Sealed {
const INTERRUPT: Interrupt;
// Required method
fn as_timer0(&self) -> &RegisterBlock;
// Provided methods
fn timer_start<Time>(&self, cycles: Time)
where Time: Into<u32> { ... }
fn timer_reset_event(&self) { ... }
fn timer_cancel(&self) { ... }
fn timer_running(&self) -> bool { ... }
fn read_counter(&self) -> u32 { ... }
fn disable_interrupt(&self) { ... }
fn enable_interrupt(&self) { ... }
fn set_shorts_periodic(&self) { ... }
fn set_shorts_oneshot(&self) { ... }
fn set_periodic(&self) { ... }
fn set_oneshot(&self) { ... }
}
Expand description
Implemented by all TIMER* instances.
Required Associated Constants§
Required Methods§
sourcefn as_timer0(&self) -> &RegisterBlock
fn as_timer0(&self) -> &RegisterBlock
Returns the register block for the timer instance.
Provided Methods§
sourcefn timer_start<Time>(&self, cycles: Time)
fn timer_start<Time>(&self, cycles: Time)
Starts the timer after clearing the counter register and setting the events compare trigger
correctly to the numer of cycles
.
sourcefn timer_reset_event(&self)
fn timer_reset_event(&self)
Resets event for CC[0] register.
sourcefn timer_cancel(&self)
fn timer_cancel(&self)
Cancels timer by setting it to stop mode and resetting the events.
sourcefn timer_running(&self) -> bool
fn timer_running(&self) -> bool
Checks if the timer is still running which means no event is yet generated for CC[0].
fn read_counter(&self) -> u32
sourcefn disable_interrupt(&self)
fn disable_interrupt(&self)
Disables interrupt for event COMPARE[0].
sourcefn enable_interrupt(&self)
fn enable_interrupt(&self)
Enables interrupt for event COMPARE[0].
sourcefn set_shorts_periodic(&self)
fn set_shorts_periodic(&self)
Sets timer into periodic mode.
sourcefn set_shorts_oneshot(&self)
fn set_shorts_oneshot(&self)
Sets timer into oneshot mode.
sourcefn set_periodic(&self)
fn set_periodic(&self)
Sets up timer for 1 MHz prescaled periods with 32 bits accuracy.
This is only safe to call when the timer is stopped.
sourcefn set_oneshot(&self)
fn set_oneshot(&self)
Sets up timer for a 1 MHz prescaled oneshot with 32 bits accuracy.
This is only safe to call when the timer is stopped.