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 new(tim: impl Peripheral<P = T> + 'd) -> Self
pub fn new(tim: impl Peripheral<P = T> + 'd) -> Self
Create a new timer driver.
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 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.
Auto Trait Implementations§
impl<'d, T> Freeze for Timer<'d, T>where
T: Freeze,
impl<'d, T> RefUnwindSafe for Timer<'d, T>where
T: RefUnwindSafe,
impl<'d, T> Send for Timer<'d, T>where
T: Send,
impl<'d, T> Sync for Timer<'d, T>where
T: Sync,
impl<'d, T> Unpin for Timer<'d, T>where
T: Unpin,
impl<'d, T> !UnwindSafe for Timer<'d, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more