pub struct Timer<TIMERX> { /* private fields */ }Expand description
A stopped timer, holding the peripheral and the frequency feeding it.
Clocked and reset on construction, but the counter is not running.
Implementations§
Source§impl<TIMERX: Instance> Timer<TIMERX>
impl<TIMERX: Instance> Timer<TIMERX>
Sourcepub fn start(self, psc: u16, car: u16) -> CountDownTimer<TIMERX>
pub fn start(self, psc: u16, car: u16) -> CountDownTimer<TIMERX>
Starts the counter, which then rolls over every car + 1 ticks of
clk / (psc + 1).
The dividers reach the counter before it runs, so the first
wait already measures the full interval.
Sourcepub fn start_interval<const NOM: u64, const DENOM: u64>(
self,
interval: Duration<u32, NOM, DENOM>,
) -> CountDownTimer<TIMERX>
pub fn start_interval<const NOM: u64, const DENOM: u64>( self, interval: Duration<u32, NOM, DENOM>, ) -> CountDownTimer<TIMERX>
Starts the counter, which then rolls over once per interval.
Any scale works with no conversion at the call site — 5.secs(),
500.millis(), 100.micros(). Truncating, so the realised interval is at
most one prescaler cycle short. Intervals past what the 16-bit dividers
span (just under a minute at 72 MHz) saturate; zero becomes one tick.
Sourcepub fn into_delay(self) -> Delay<TIMERX>
pub fn into_delay(self) -> Delay<TIMERX>
Hands the timer over to blocking delays; every delay
sets up its own interval and tears it down again.
Sourcepub fn into_pwm(self, psc: u16, car: u16) -> Pwm<TIMERX>
pub fn into_pwm(self, psc: u16, car: u16) -> Pwm<TIMERX>
Hands the timer over to PWM and starts it on the given period.
The counter cycle is shared by every channel, and car + 1 is also their
duty resolution: a larger reload buys finer steps at a lower frequency.
Sourcepub fn into_pwm_interval<const NOM: u64, const DENOM: u64>(
self,
interval: Duration<u32, NOM, DENOM>,
) -> Pwm<TIMERX>
pub fn into_pwm_interval<const NOM: u64, const DENOM: u64>( self, interval: Duration<u32, NOM, DENOM>, ) -> Pwm<TIMERX>
Hands the timer over to PWM, taking the period as a duration.
Splits it like start_interval, keeping the
reload large — here that is what leaves the duty the most steps.
Sourcepub fn into_capture(self, psc: u16) -> Capture<TIMERX>
pub fn into_capture(self, psc: u16) -> Capture<TIMERX>
Sets the counter free running and hands out the input capture role.
Only the prescaler is a choice: it trades resolution against the longest interval that still fits between two rollovers. The reload is pinned to the maximum.