Struct imxrt_hal::usbd::gpt::Gpt

source ·
pub struct Gpt<'a> { /* private fields */ }
Expand description

General purpose timer (GPT).

USB GPTs have a 1us resolution. The counter is 24 bits wide. GPTs can generate USB interrupts that are independent of USB protocol interrupts. This lets you add additional, time-driven logic into your USB ISR and driver state machine.

See the module-level documentation for an example.

Implementations§

source§

impl<'a> Gpt<'a>

source

pub fn instance(&self) -> Instance

Returns the GPT instance identifier.

source

pub fn run(&mut self)

Run the GPT timer.

Run will start counting down the timer. Use stop() to cancel a running timer.

source

pub fn is_running(&self) -> bool

Indicates if the timer is running (true) or stopped (false).

source

pub fn stop(&mut self)

Stop the timer.

source

pub fn reset(&mut self)

Reset the timer.

reset loads the counter value. It does not stop a running counter.

source

pub fn set_mode(&mut self, mode: Mode)

Set the timer mode.

source

pub fn mode(&self) -> Mode

Returns the timer mode.

source

pub fn set_load(&mut self, us: u32)

Set the counter load value.

us is the number of microseconds to count. us will saturate at a 24-bit value (0xFFFFFF, or 16.777215 seconds). A value of 0 will result in a 1us delay.

Note that the load count value is not loaded until the next call to reset() (one shot mode) or until after the timer elapses (repeat mode).

source

pub fn load(&self) -> u32

Returns the counter load value.

source

pub fn is_elapsed(&self) -> bool

Indicates if the timer has elapsed.

If the timer has elapsed, you should clear the elapsed flag with clear_elapsed().

source

pub fn clear_elapsed(&mut self)

Clear the flag that indicates the timer has elapsed.

source

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

Enable or disable interrupt generation when the timer elapses.

If enabled (true), an elapsed GPT will generate an interrupt. This happens regardless of the USB interrupt enable state.

source

pub fn is_interrupt_enabled(&self) -> bool

Indicates if interrupt generation is enabled.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Gpt<'a>

§

impl<'a> Send for Gpt<'a>

§

impl<'a> !Sync for Gpt<'a>

§

impl<'a> Unpin for Gpt<'a>

§

impl<'a> !UnwindSafe for Gpt<'a>

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>,

§

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>,

§

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.