pub struct LpTimer<M: CountMode> { /* private fields */ }
Expand description

Low-Power Timer (LPTIM).

The Low-Power Timer is a 16-bit timer with a prescaler of up to 128. It can run off of the APB1, LSI, HSI16, or LSE clocks. With LSE, the slowest clock at 32.768 kHz, this results in a maximum timeout of 256 seconds, or 4 minutes and 16 seconds.

The timer can be initialized either in one-shot mode or in periodic mode, using init_oneshot or init_periodic respectively. In periodic mode, the embedded-hal Periodic marker trait is implemented and the CountDown implementation uses Hertz as the time unit. In one-shot mode, the CountDown implementation instead uses Microseconds, allowing for a multi-second timeout to be configured (with the tradeoff being a larger code size due to use of 64-bit arithmetic).

Implementations

Initializes the Low-Power Timer in periodic mode.

The timer needs to be started by calling .start(freq).

Initializes the Low-Power Timer in one-shot mode.

The timer needs to be started by calling .start(freq).

Initializes the Low-Power Timer in encoder mode.

The start method must be called to enable the encoder input.

Enable the timer and begin counting encoder pulses.

The provided value is stored in the ARR (Auto Reload Register). The timer’s internal counter will wrap when this value is reached.

Disable the timer.

Get the current count of the encoder.

Clear all LPTIM interrupt flags

Disables and destructs the timer, returning the raw LPTIM peripheral.

Disables the timer and enables the given interrupts.

Disables the timer and disables the given interrupts.

Trait Implementations

The unit of time used by this timer

Starts a new count down

Non-blockingly “waits” until the count down finishes Read more

The unit of time used by this timer

Starts a new count down

Non-blockingly “waits” until the count down finishes Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.