Struct stm32f3xx_hal::timer::Timer
source · pub struct Timer<TIM> { /* private fields */ }
Expand description
Hardware timers
Implementations§
source§impl<TIM> Timer<TIM>where
TIM: Instance,
impl<TIM> Timer<TIM>where TIM: Instance,
sourcepub fn new(tim: TIM, clocks: Clocks, apb: &mut <TIM as RccBus>::Bus) -> Self
pub fn new(tim: TIM, clocks: Clocks, apb: &mut <TIM as RccBus>::Bus) -> Self
Configures a TIM peripheral as a periodic count down timer
sourcepub fn enable_interrupt(&mut self, event: Event)
pub fn enable_interrupt(&mut self, event: Event)
Enable or disable the interrupt for the specified Event
.
sourcepub fn disable_interrupt(&mut self, event: Event)
pub fn disable_interrupt(&mut self, event: Event)
Enable or disable the interrupt for the specified Event
.
sourcepub fn interrupt(&self) -> <TIM as InterruptNumber>::Interrupt
pub fn interrupt(&self) -> <TIM as InterruptNumber>::Interrupt
Obtain the associated interupt number for the serial peripheral.
Used to unmask / enable the interrupt with cortex_m::peripheral::NVIC::unmask()
.
This is useful for all cortex_m::peripheral::INTERRUPT
functions.
Note
This is the easier alternative to obatain the interrupt for:
use cortex_m::peripheral::INTERRUPT;
use stm32f3xx_hal::pac::TIM1;
use stm32f3xx_hal::interrupts::InterruptNumber;
const INTERRUPT: Interrupt = <TIM2 as InterruptNumber>::INTERRUPT;
though this function can not be used in a const context.
sourcepub fn configure_interrupt(&mut self, event: Event, enable: bool)
pub fn configure_interrupt(&mut self, event: Event, enable: bool)
Enable or disable the interrupt for the specified Event
.
sourcepub fn configure_interrupts(&mut self, events: EnumSet<Event>)
pub fn configure_interrupts(&mut self, events: EnumSet<Event>)
Enable or disable interrupt for the specified Event
s.
Like Timer::configure_interrupt
, but instead using an enumset. The corresponding
interrupt for every Event
in the set will be enabled, every other interrupt will be
disabled.
sourcepub fn is_interrupt_configured(&self, event: Event) -> bool
pub fn is_interrupt_configured(&self, event: Event) -> bool
Check if an interrupt is configured for the Event
sourcepub fn configured_interrupts(&mut self) -> EnumSet<Event>
pub fn configured_interrupts(&mut self) -> EnumSet<Event>
Check which interrupts are enabled for all Event
s
sourcepub fn is_event_triggered(&self, event: Event) -> bool
pub fn is_event_triggered(&self, event: Event) -> bool
Check if an interrupt event happened.
sourcepub fn triggered_events(&self) -> EnumSet<Event>
pub fn triggered_events(&self) -> EnumSet<Event>
Get an EnumSet
of all fired interrupt events.
sourcepub fn clear_event(&mut self, event: Event)
pub fn clear_event(&mut self, event: Event)
Clear the given interrupt event flag.
sourcepub fn clear_events(&mut self)
pub fn clear_events(&mut self)
Clear all interrupt events.
sourcepub unsafe fn peripheral(&mut self) -> &mut TIM
pub unsafe fn peripheral(&mut self) -> &mut TIM
Get access to the underlying register block.
Safety
This function is not memory unsafe per se, but does not guarantee anything about assumptions of invariants made in this implementation.
Changing specific options can lead to un-expected behavior and nothing is guaranteed.