Struct stm32_hal2::timer::BasicTimer
source · [−]pub struct BasicTimer<R> {
pub regs: R,
/* private fields */
}
Expand description
Represents a Basic timer, used primarily to trigger the onboard DAC. Eg Tim6 or Tim7.
Fields
regs: R
Implementations
sourceimpl<R> BasicTimer<R>where
R: Deref<Target = RegisterBlock> + RccPeriph,
impl<R> BasicTimer<R>where
R: Deref<Target = RegisterBlock> + RccPeriph,
sourcepub fn new(regs: R, freq: f32, clock_cfg: &Clocks) -> Self
pub fn new(regs: R, freq: f32, clock_cfg: &Clocks) -> Self
Initialize a Basic timer, including enabling and resetting its RCC peripheral clock.
sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if the timer is enabled.
sourcepub fn set_period(&mut self, time: f32) -> Result<(), ValueError>
pub fn set_period(&mut self, time: f32) -> Result<(), ValueError>
Set the timer period, in seconds. Overrides the period or frequency set
in the constructor. If changing period frequently, don’t use this method, as
it has computational overhead: use set_auto_reload
and set_prescaler
methods instead.
sourcepub fn set_freq(&mut self, freq: f32) -> Result<(), ValueError>
pub fn set_freq(&mut self, freq: f32) -> Result<(), ValueError>
Set the timer frequency, in Hz. Overrides the period or frequency set
in the constructor. If changing frequency frequently, don’t use this method, as
it has computational overhead: use set_auto_reload
and set_prescaler
methods instead.
sourcepub fn get_max_duty(&self) -> u16
pub fn get_max_duty(&self) -> u16
Return the integer associated with the maximum duty period.
sourcepub fn set_auto_reload(&mut self, arr: u16)
pub fn set_auto_reload(&mut self, arr: u16)
Set the auto-reload register value. Used for adjusting frequency.
sourcepub fn set_prescaler(&mut self, psc: u16)
pub fn set_prescaler(&mut self, psc: u16)
Set the prescaler value. Used for adjusting frequency.
sourcepub fn reset_count(&mut self)
pub fn reset_count(&mut self)
Reset the count; set the counter to 0.
sourcepub fn read_count(&self) -> u16
pub fn read_count(&self) -> u16
Read the current counter value.
sourcepub fn set_mastermode(&self, mode: MasterModeSelection)
pub fn set_mastermode(&self, mode: MasterModeSelection)
Allow selected information to be sent in master mode to slave timers for synchronization (TRGO).