[][src]Struct esp32_hal::timer::Timer

pub struct Timer<TIMG: TimerGroup, INST: TimerInst> { /* fields omitted */ }

Hardware timers

The timers can be programmed in a high level way via start, wait, cancel.

Lower level access is provided by the other functions.

Implementations

impl<TIMG: TimerGroup> Timer<TIMG, Timer0>[src]

pub fn new(
    timg: TIMG,
    clock_control_config: ClockControlConfig
) -> (Timer<TIMG, Timer0>, Timer<TIMG, Timer1>, Timer<TIMG, TimerLact>, Watchdog<TIMG>)
[src]

Create new timer resources

This function will create 2 timers and 1 watchdog for a timer group. It uses the clock_control_config for obtaining the clock configuration.

Note: time to clock tick conversions are done with the clock frequency when the start function is called. The clock frequency is not locked.

impl<INST: TimerInst> Timer<TIMG0, INST>[src]

pub fn release(
    _timer0: Timer<TIMG0, Timer0>,
    _timer1: Timer<TIMG0, Timer1>,
    _timer2: Timer<TIMG0, TimerLact>
) -> TIMG0
[src]

Releases the timer resources. Requires to release all timers and watchdog belonging to the same group at once.

impl<INST: TimerInst> Timer<TIMG1, INST>[src]

pub fn release(
    _timer0: Timer<TIMG1, Timer0>,
    _timer1: Timer<TIMG1, Timer1>,
    _timer2: Timer<TIMG1, TimerLact>
) -> TIMG1
[src]

Releases the timer resources. Requires to release all timers and watchdog belonging to the same group at once.

Trait Implementations

impl<TIMG: TimerGroup> Cancel for Timer<TIMG, Timer0>[src]

type Error = Error

Error returned when a countdown can't be canceled.

fn cancel(&mut self) -> Result<(), Self::Error>[src]

Cancel running timer.

This will stop the timer if running and returns error when not running.

impl<TIMG: TimerGroup> Cancel for Timer<TIMG, Timer1>[src]

type Error = Error

Error returned when a countdown can't be canceled.

fn cancel(&mut self) -> Result<(), Self::Error>[src]

Cancel running timer.

This will stop the timer if running and returns error when not running.

impl<TIMG: TimerGroup> Cancel for Timer<TIMG, TimerLact>[src]

type Error = Error

Error returned when a countdown can't be canceled.

fn cancel(&mut self) -> Result<(), Self::Error>[src]

Cancel running timer.

This will stop the timer if running and returns error when not running.

impl<TIMG: TimerGroup> CountDown for Timer<TIMG, Timer0>[src]

type Time = NanoSecondsU64

The unit of time used by this timer

fn start<T: Into<Self::Time>>(&mut self, timeout: T)[src]

Start timer

fn wait(&mut self) -> Result<(), Void>[src]

Wait for timer to finish

Note: if the timeout is handled via an interrupt, this will never return.

impl<TIMG: TimerGroup> CountDown for Timer<TIMG, Timer1>[src]

type Time = NanoSecondsU64

The unit of time used by this timer

fn start<T: Into<Self::Time>>(&mut self, timeout: T)[src]

Start timer

fn wait(&mut self) -> Result<(), Void>[src]

Wait for timer to finish

Note: if the timeout is handled via an interrupt, this will never return.

impl<TIMG: TimerGroup> CountDown for Timer<TIMG, TimerLact>[src]

type Time = NanoSecondsU64

The unit of time used by this timer

fn start<T: Into<Self::Time>>(&mut self, timeout: T)[src]

Start timer

fn wait(&mut self) -> Result<(), Void>[src]

Wait for timer to finish

Note: if the timeout is handled via an interrupt, this will never return.

impl<TIMG: TimerGroup> Periodic for Timer<TIMG, Timer0>[src]

impl<TIMG: TimerGroup> Periodic for Timer<TIMG, Timer1>[src]

impl<TIMG: TimerGroup> Periodic for Timer<TIMG, TimerLact>[src]

impl<TIMG: TimerGroup, INST: TimerInst> Send for Timer<TIMG, INST>[src]

impl<TIMG: TimerGroup> TimerWithInterrupt for Timer<TIMG, Timer0>[src]

fn listen(&mut self, event: Event)[src]

Starts listening for an event

fn unlisten(&mut self, event: Event)[src]

Stops listening for an event

fn clear_interrupt(&mut self) -> &mut Self[src]

Clear interrupt once fired

fn set_value<T: Into<TicksU64>>(&mut self, value: T) -> &mut Self[src]

Set timer value

fn get_value(&self) -> TicksU64[src]

Get timer value

fn get_value_in_ns(&self) -> NanoSecondsU64[src]

Get timer value in ns

fn get_alarm(&self) -> TicksU64[src]

Get alarm value

fn get_alarm_in_ns(&self) -> NanoSecondsU64[src]

Get alarm value in ns

fn set_alarm<T: Into<TicksU64>>(&mut self, value: T) -> &mut Self[src]

Set alarm value

Note: timer is not disabled, so there is a risk for false triggering between setting upper and lower 32 bits.

fn set_alarm_in_ns<T: Into<NanoSecondsU64>>(&mut self, value: T) -> &mut Self[src]

Set alarm value in ns

Note: timer is not disabled, so there is a risk for false triggering between setting upper and lower 32 bits.

fn enable(&mut self, enable: bool) -> &mut Self[src]

Enable or disables the timer

fn is_enabled(&mut self) -> bool[src]

Enable or disables the timer

fn stop(&mut self)[src]

Stop the timer

fn increasing(&mut self, enable: bool) -> &mut Self[src]

Set to true to increase the timer value on each tick, set to false to decrease the timer value on each tick.

fn is_increasing(&mut self) -> bool[src]

Returns true if the timer is increasing, otherwise decreasing

fn auto_reload(&mut self, enable: bool) -> &mut Self[src]

Set to true if the timer needs to be reloaded to initial value once the alarm is reached.

fn enable_alarm(&mut self, enable: bool) -> &mut Self[src]

Enable alarm triggering

fn alarm_active(&mut self) -> bool[src]

Is the alarm active

fn set_divider(&mut self, divider: u32) -> Result<&mut Self, Error>[src]

Set clock divider.

Value must be between 2 and 65536 inclusive for Timer 0 and 1 and between 3 and 65535 for TimerLact.

fn get_divider(&self) -> u32[src]

Get the current clock divider

impl<TIMG: TimerGroup> TimerWithInterrupt for Timer<TIMG, Timer1>[src]

fn listen(&mut self, event: Event)[src]

Starts listening for an event

fn unlisten(&mut self, event: Event)[src]

Stops listening for an event

fn clear_interrupt(&mut self) -> &mut Self[src]

Clear interrupt once fired

fn set_value<T: Into<TicksU64>>(&mut self, value: T) -> &mut Self[src]

Set timer value

fn get_value(&self) -> TicksU64[src]

Get timer value

fn get_value_in_ns(&self) -> NanoSecondsU64[src]

Get timer value in ns

fn get_alarm(&self) -> TicksU64[src]

Get alarm value

fn get_alarm_in_ns(&self) -> NanoSecondsU64[src]

Get alarm value in ns

fn set_alarm<T: Into<TicksU64>>(&mut self, value: T) -> &mut Self[src]

Set alarm value

Note: timer is not disabled, so there is a risk for false triggering between setting upper and lower 32 bits.

fn set_alarm_in_ns<T: Into<NanoSecondsU64>>(&mut self, value: T) -> &mut Self[src]

Set alarm value in ns

Note: timer is not disabled, so there is a risk for false triggering between setting upper and lower 32 bits.

fn enable(&mut self, enable: bool) -> &mut Self[src]

Enable or disables the timer

fn is_enabled(&mut self) -> bool[src]

Enable or disables the timer

fn stop(&mut self)[src]

Stop the timer

fn increasing(&mut self, enable: bool) -> &mut Self[src]

Set to true to increase the timer value on each tick, set to false to decrease the timer value on each tick.

fn is_increasing(&mut self) -> bool[src]

Returns true if the timer is increasing, otherwise decreasing

fn auto_reload(&mut self, enable: bool) -> &mut Self[src]

Set to true if the timer needs to be reloaded to initial value once the alarm is reached.

fn enable_alarm(&mut self, enable: bool) -> &mut Self[src]

Enable alarm triggering

fn alarm_active(&mut self) -> bool[src]

Is the alarm active

fn set_divider(&mut self, divider: u32) -> Result<&mut Self, Error>[src]

Set clock divider.

Value must be between 2 and 65536 inclusive for Timer 0 and 1 and between 3 and 65535 for TimerLact.

fn get_divider(&self) -> u32[src]

Get the current clock divider

impl<TIMG: TimerGroup> TimerWithInterrupt for Timer<TIMG, TimerLact>[src]

fn listen(&mut self, event: Event)[src]

Starts listening for an event

fn unlisten(&mut self, event: Event)[src]

Stops listening for an event

fn clear_interrupt(&mut self) -> &mut Self[src]

Clear interrupt once fired

fn set_value<T: Into<TicksU64>>(&mut self, value: T) -> &mut Self[src]

Set timer value

fn get_value(&self) -> TicksU64[src]

Get timer value

fn get_value_in_ns(&self) -> NanoSecondsU64[src]

Get timer value in ns

fn get_alarm(&self) -> TicksU64[src]

Get alarm value

fn get_alarm_in_ns(&self) -> NanoSecondsU64[src]

Get alarm value in ns

fn set_alarm<T: Into<TicksU64>>(&mut self, value: T) -> &mut Self[src]

Set alarm value

Note: timer is not disabled, so there is a risk for false triggering between setting upper and lower 32 bits.

fn set_alarm_in_ns<T: Into<NanoSecondsU64>>(&mut self, value: T) -> &mut Self[src]

Set alarm value in ns

Note: timer is not disabled, so there is a risk for false triggering between setting upper and lower 32 bits.

fn enable(&mut self, enable: bool) -> &mut Self[src]

Enable or disables the timer

fn is_enabled(&mut self) -> bool[src]

Enable or disables the timer

fn stop(&mut self)[src]

Stop the timer

fn increasing(&mut self, enable: bool) -> &mut Self[src]

Set to true to increase the timer value on each tick, set to false to decrease the timer value on each tick.

fn is_increasing(&mut self) -> bool[src]

Returns true if the timer is increasing, otherwise decreasing

fn auto_reload(&mut self, enable: bool) -> &mut Self[src]

Set to true if the timer needs to be reloaded to initial value once the alarm is reached.

fn enable_alarm(&mut self, enable: bool) -> &mut Self[src]

Enable alarm triggering

fn alarm_active(&mut self) -> bool[src]

Is the alarm active

fn set_divider(&mut self, divider: u32) -> Result<&mut Self, Error>[src]

Set clock divider.

Value must be between 2 and 65536 inclusive for Timer 0 and 1 and between 3 and 65535 for TimerLact.

fn get_divider(&self) -> u32[src]

Get the current clock divider

Auto Trait Implementations

impl<TIMG, INST> !Sync for Timer<TIMG, INST>

impl<TIMG, INST> Unpin for Timer<TIMG, INST> where
    INST: Unpin,
    TIMG: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.