Struct imxrt_hal::gpt::Gpt

source ·
pub struct Gpt<const N: u8> { /* private fields */ }
Expand description

A general purpose timer

The timers support three output compare registers. When a compare register matches the value of the counter, the GPT may trigger an interrupt.

By default, the timer runs in wait mode.

Implementations§

source§

impl<const N: u8> Gpt<N>

source

pub fn new(gpt: Instance<N>) -> Self

Create a GPT timer from the RAL’s GPT instance.

When new returns, the GPT is reset and disabled.

source

pub fn divider(&self) -> u32

Returns the clock divider value.

source

pub fn set_divider(&mut self, divider: u32)

Set the divider value.

The divider value is clamped between 1 and 4096. A change in the divider cause the prescaler counter to reset and a new count period to start immediately.

source

pub fn divider_24mhz(&self) -> u32

Return the 24MHz clock divider.

source

pub fn set_divider_24mhz(&mut self, divider: u32)

Set the 24MHz clock divider.

The divider value is clamped between 1 and 16. 24MHz crystal clock is divided by the divider before selected by the clock selection. If 24M crystal clock is not selected, this feild takes no effect.

source

pub fn mode(&self) -> Mode

Returns the current mode of the GPT.

source

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

Set the GPT mode.

Refer to the module level documentation for more information on the GPT modes.

source

pub fn clock_source(&self) -> ClockSource

Returns the GPT clock source

source

pub fn set_clock_source(&mut self, clock_source: ClockSource)

Set the GPT clock source.

source

pub fn set_reset_on_enable(&mut self, reset_on_enable: bool)

Set the reset on enable behavior

See the module-level docs for more information.

source

pub fn is_reset_on_enable(&self) -> bool

Returns true if the GPT counter will reset the next time it is enabled.

source

pub fn enable(&mut self)

Enable the GPT.

When enabled, the counter starts counting. The value of the counter is determined by the reset on enable setting. See set_reset_on_enable.

source

pub fn disable(&mut self)

Disable the GPT.

When disabled, the count will stop counting.

source

pub fn is_enabled(&self) -> bool

Indicates if the GPT is enabled (true) or disabled (false).

source

pub fn set_wait_mode_enable(&mut self, wait: bool)

Allow the GPT to run in wait mode; or, prevent the GPT from running in wait mode.

source

pub fn is_wait_mode_enabled(&self) -> bool

Indicates if the GPT runs while in wait mode.

source

pub fn set_output_interrupt_on_compare( &mut self, ocr: OutputCompareRegister, intr: bool )

Enable the GPT interrupt when the output compares.

source

pub fn is_output_interrupt_on_compare(&self, ocr: OutputCompareRegister) -> bool

Returns true if a comparison triggers an interrupt.

source

pub fn count(&self) -> u32

Returns the current count of the GPT.

source

pub fn set_output_compare_count(&self, ocr: OutputCompareRegister, count: u32)

Set an output compare register to trigger on the next count value of the counter.

source

pub fn output_compare_count(&self, ocr: OutputCompareRegister) -> u32

Returns the current output compare count for the specified register.

source

pub fn is_elapsed(&self, ocr: OutputCompareRegister) -> bool

Returns true if the time tracked by the OCR has elapsed.

source

pub fn clear_elapsed(&self, ocr: OutputCompareRegister)

Clear the elapsed flag.

source

pub fn set_rollover_interrupt_enable(&mut self, rov: bool)

Enable / disable an interrupt when the GPT counter rolls over from u32::max_value() to 0.

The GPT triggers a rollover regardless of the GPT mode.

source

pub fn is_rollover_interrupt_enabled(&self) -> bool

Returns true if a rollover generates an interrupt.

source

pub fn is_rollover(&self) -> bool

Returns true if the rollover flag is set.

A rollover occurs when the counter rolls over from u32::max_value() to 0. Rollover may occur regardless of the GPT mode.

source

pub fn clear_rollover(&self)

Clear the rollover status flag.

Users must clear the rollover flag if a rollover triggered an interrupt.

source

pub fn reset(&mut self)

Issue a software reset.

This reset does not change

  • the enable state.
  • the clock selection.
  • the wait, debug, and doze configurations.
source

pub fn release(self) -> Instance<N>

Release the peripheral instance.

This does not change any peripheral state; it simply releases the instance as-is. If you need to return the registers in a known, good state, consider calling reset() and disable() before this call.

Auto Trait Implementations§

§

impl<const N: u8> !RefUnwindSafe for Gpt<N>

§

impl<const N: u8> Send for Gpt<N>

§

impl<const N: u8> !Sync for Gpt<N>

§

impl<const N: u8> Unpin for Gpt<N>

§

impl<const N: u8> !UnwindSafe for Gpt<N>

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.