Struct stm32f3xx_hal::timer::Timer

source ·
pub struct Timer<TIM> { /* private fields */ }
Expand description

Hardware timers

Implementations§

source§

impl<TIM> Timer<TIM>where TIM: Instance,

source

pub fn new(tim: TIM, clocks: Clocks, apb: &mut <TIM as RccBus>::Bus) -> Self

Configures a TIM peripheral as a periodic count down timer

source

pub fn stop(&mut self)

Stops the timer

source

pub fn enable_interrupt(&mut self, event: Event)

Enable or disable the interrupt for the specified Event.

source

pub fn disable_interrupt(&mut self, event: Event)

Enable or disable the interrupt for the specified Event.

source

pub fn interrupt(&self) -> <TIM as InterruptNumber>::Interrupt

Obtain the associated interupt number for the serial peripheral.

Used to unmask / enable the interrupt with cortex_m::peripheral::NVIC::unmask(). This is useful for all cortex_m::peripheral::INTERRUPT functions.

Note

This is the easier alternative to obatain the interrupt for:

use cortex_m::peripheral::INTERRUPT;
use stm32f3xx_hal::pac::TIM1;
use stm32f3xx_hal::interrupts::InterruptNumber;

const INTERRUPT: Interrupt = <TIM2 as InterruptNumber>::INTERRUPT;

though this function can not be used in a const context.

source

pub fn configure_interrupt(&mut self, event: Event, enable: bool)

Enable or disable the interrupt for the specified Event.

source

pub fn configure_interrupts(&mut self, events: EnumSet<Event>)

Enable or disable interrupt for the specified Events.

Like Timer::configure_interrupt, but instead using an enumset. The corresponding interrupt for every Event in the set will be enabled, every other interrupt will be disabled.

source

pub fn is_interrupt_configured(&self, event: Event) -> bool

Check if an interrupt is configured for the Event

source

pub fn configured_interrupts(&mut self) -> EnumSet<Event>

Check which interrupts are enabled for all Events

source

pub fn is_event_triggered(&self, event: Event) -> bool

Check if an interrupt event happened.

source

pub fn triggered_events(&self) -> EnumSet<Event>

Get an EnumSet of all fired interrupt events.

source

pub fn clear_event(&mut self, event: Event)

Clear the given interrupt event flag.

source

pub fn clear_events(&mut self)

Clear all interrupt events.

source

pub unsafe fn peripheral(&mut self) -> &mut TIM

Get access to the underlying register block.

Safety

This function is not memory unsafe per se, but does not guarantee anything about assumptions of invariants made in this implementation.

Changing specific options can lead to un-expected behavior and nothing is guaranteed.

source

pub fn free(self) -> TIM

Releases the TIM peripheral

Trait Implementations§

source§

impl<TIM> Cancel for Timer<TIM>where TIM: Instance,

§

type Error = AlreadyCancled

Error returned when a countdown can’t be canceled.
source§

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

Tries to cancel this countdown. Read more
source§

impl<TIM: Debug> Debug for Timer<TIM>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<TIM> CountDown for Timer<TIM>where TIM: Instance,

source§

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

Wait until Event::Update / the timer has elapsed and than clear the event.

§

type Time = Generic<u32>

The unit of time used by this timer
source§

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

Starts a new count down
source§

impl<TIM> Periodic for Timer<TIM>where TIM: Instance,

Auto Trait Implementations§

§

impl<TIM> RefUnwindSafe for Timer<TIM>where TIM: RefUnwindSafe,

§

impl<TIM> Send for Timer<TIM>where TIM: Send,

§

impl<TIM> Sync for Timer<TIM>where TIM: Sync,

§

impl<TIM> Unpin for Timer<TIM>where TIM: Unpin,

§

impl<TIM> UnwindSafe for Timer<TIM>where TIM: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.