CountdownTimer

Struct CountdownTimer 

Source
pub struct CountdownTimer { /* private fields */ }
Expand description

Hardware timers

Implementations§

Source§

impl CountdownTimer

Source

pub fn new<Tim: TimInstance>(_tim: Tim, sys_clk: Hertz) -> Self

Create a countdown timer structure for a given TIM peripheral.

This does not enable the timer. You can use the Self::load, Self::start, Self::enable_interrupt and Self::enable API to set up and configure the countdown timer.

Source

pub fn perid(&self) -> u32

Source

pub fn enable(&mut self)

Source

pub fn disable(&mut self)

Source

pub fn enable_interrupt(&mut self, irq_cfg: InterruptConfig)

Source

pub fn disable_interrupt(&mut self)

This function only clears the interrupt enable bit.

It does not mask the interrupt in the NVIC or un-route the IRQ.

Source

pub fn start(&mut self, frequency: impl Into<Hertz>)

Calls Self::load to configure the specified frequency and then calls Self::enable.

Source

pub fn wait(&mut self) -> Result<(), Infallible>

Return Ok if the timer has wrapped. Peripheral will automatically clear the flag and restart the time if configured correctly

Source

pub fn load(&mut self, timeout: impl Into<Hertz>)

Load the count down timer with a timeout but do not start it.

Source

pub fn set_reload(&mut self, val: u32)

Source

pub fn set_count(&mut self, val: u32)

Source

pub fn counter(&self) -> u32

Source

pub fn auto_disable(&mut self, enable: bool)

Disable the counter, setting both enable and active bit to 0

Source

pub fn auto_deactivate(&mut self, enable: bool)

This option only applies when the Auto-Disable functionality is 0.

The active bit is changed to 0 when count reaches 0, but the counter stays enabled. When Auto-Disable is 1, Auto-Deactivate is implied

Source

pub fn cascade_control(&mut self, ctrl: CascadeControl)

Configure the cascade parameters

Source

pub fn cascade_source( &mut self, cascade_index: CascadeSelect, src: CascadeSource, ) -> Result<(), InvalidCascadeSourceId>

Source

pub fn curr_freq(&self) -> Hertz

Source

pub fn stop_with_clock_disable(self)

Disables the TIM and the dedicated TIM clock.

Trait Implementations§

Source§

impl DelayNs for CountdownTimer

Source§

fn delay_ns(&mut self, ns: u32)

Pauses execution for at minimum ns nanoseconds. Pause can be longer if the implementation requires it due to precision/timing issues.
Source§

fn delay_us(&mut self, us: u32)

Pauses execution for at minimum us microseconds. Pause can be longer if the implementation requires it due to precision/timing issues.
Source§

fn delay_ms(&mut self, ms: u32)

Pauses execution for at minimum ms milliseconds. Pause can be longer if the implementation requires it due to precision/timing issues.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.