pub struct Timer<'d, T: Instance> { /* private fields */ }Expand description
Low-level timer driver.
Implementations§
Source§impl<'d, T: Instance> Timer<'d, T>
impl<'d, T: Instance> Timer<'d, T>
Sourcepub fn single_mode_start(&self)
pub fn single_mode_start(&self)
Start the timer in single pulse mode.
Sourcepub fn continuous_mode_start(&self)
pub fn continuous_mode_start(&self)
Start the timer in continuous mode.
Sourcepub fn set_frequency(&self, frequency: Hertz)
pub fn set_frequency(&self, frequency: Hertz)
Set the frequency of how many times per second the timer counts up to the max value or down to 0.
Sourcepub fn get_frequency(&self) -> Hertz
pub fn get_frequency(&self) -> Hertz
Get the timer frequency.
Sourcepub fn get_clock_frequency(&self) -> Hertz
pub fn get_clock_frequency(&self) -> Hertz
Get the clock frequency of the timer (before prescaler is applied).
Sourcepub fn set_trigger_source(&self, source: u8)
pub fn set_trigger_source(&self, source: u8)
Select the trigger source used when external trigger start is enabled.
The source index maps to device-specific lptim_ext_trigX inputs (0..=7).
Sourcepub fn set_trigger_mode(&self, mode: Trigen)
pub fn set_trigger_mode(&self, mode: Trigen)
Configure how trigger edges start the counter.
Use [Trigen::Software] for software start. Any edge mode enables
external trigger start.
Sourcepub fn set_trigger_filter(&self, filter: Filter)
pub fn set_trigger_filter(&self, filter: Filter)
Configure the digital filter applied to trigger input transitions.
Sourcepub fn configure_external_trigger(
&self,
source: u8,
edge: Trigen,
filter: Filter,
)
pub fn configure_external_trigger( &self, source: u8, edge: Trigen, filter: Filter, )
Convenience helper to enable external trigger start with source, edge and filter.
Sourcepub fn get_max_compare_value(&self) -> u16
pub fn get_max_compare_value(&self) -> u16
Get max compare value. This depends on the timer frequency and the clock frequency from RCC.
Source§impl<'d, T: Instance> Timer<'d, T>
impl<'d, T: Instance> Timer<'d, T>
Sourcepub fn enable_channel(&self, channel: Channel, enable: bool)
pub fn enable_channel(&self, channel: Channel, enable: bool)
Enable/disable a channel.
Sourcepub fn get_channel_enable_state(&self, channel: Channel) -> bool
pub fn get_channel_enable_state(&self, channel: Channel) -> bool
Get enable/disable state of a channel
Sourcepub fn set_compare_value(&self, channel: Channel, value: u16)
pub fn set_compare_value(&self, channel: Channel, value: u16)
Set compare value for a channel.
Sourcepub fn get_compare_value(&self, channel: Channel) -> u16
pub fn get_compare_value(&self, channel: Channel) -> u16
Get compare value for a channel.
Sourcepub fn set_channel_direction(
&self,
channel: Channel,
direction: ChannelDirection,
)
pub fn set_channel_direction( &self, channel: Channel, direction: ChannelDirection, )
Set channel direction.
Sourcepub fn enable_interrupt(&self)
pub fn enable_interrupt(&self)
Enable the timer interrupt.
Sourcepub fn disable_interrupt(&self)
pub fn disable_interrupt(&self)
Disable the timer interrupt.
Sourcepub fn is_interrupt_enabled(&self) -> bool
pub fn is_interrupt_enabled(&self) -> bool
Check if the timer interrupt is enabled.
Sourcepub fn is_interrupt_pending(&self) -> bool
pub fn is_interrupt_pending(&self) -> bool
Check if the timer interrupt is pending.
Sourcepub fn clear_interrupt(&self)
pub fn clear_interrupt(&self)
Clear the timer interrupt.