pub struct Submodule<const N: u8, const M: u8>(/* private fields */);
Expand description

A PWM submodule.

Submodules implement PWM timers. Comparisons in Submodule value registers generate PWM outputs.

The PWM submodule FlexPWM2_3 is represented as

type PWM2_3 = Submodule<2, 3>;

Implementations§

source§

impl<const N: u8, const M: u8> Submodule<N, M>

source

pub const MASK: Mask = _

The mask for this submodule.

source

pub const fn mask(&self) -> Mask

Returns the mask for this submodule.

source

pub fn count(&self) -> i16

Read the counter register.

source

pub fn initial_count(&self) -> i16

Read the initial counter register.

This is the value loaded into the submodule counter when a reload event happens. Note: this reads the buffered value set with set_initial_counter when the hardware is waiting to load the value.

source

pub fn set_initial_count(&self, pwm: &Pwm<N>, counter: i16)

Set the initial counter register.

Note: this value is buffered. It is not reloaded until the LDOK signal is set and the reload cycle happens. You cannot write the value when LDOK is set.

source

pub fn load_frequency(&self) -> u16

Returns the load frequency.

The load frequency describes how many PWM “opportuntities” it will take before the hardware loads buffered register values into their registers. This value is between 1 and 16.

An “opportunity” is one of

  • a full cycle reload (VAL1 matches), if full reload is set.
  • a half cycle reload (VAL0 matches), if half reload is set.
source

pub fn set_load_frequency(&mut self, ldfq: u16)

Set the load frequency.

See load_frequency for a description of load frequency. The implementation clamps the values between 1 and 16.

source

pub fn prescaler(&self) -> Prescaler

Returns the prescaler value.

source

pub fn set_prescaler(&mut self, prescaler: Prescaler)

Set the PWM clock prescaler.

source

pub fn pair_operation(&self) -> PairOperation

Returns the pair operation setting.

source

pub fn set_pair_operation(&mut self, pair_operation: PairOperation)

Set the pair operation setting.

source

pub fn debug_enable(&self) -> bool

Returns true if debug enable is set.

When set, the PWM continues to run when in debug mode. When clear, the PWM stops in debug mode, and restarts when debug mode exits.

source

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

Set debug enable.

See debug_enable for more information on debug enable.

source

pub fn wait_enable(&self) -> bool

Returns true if wait enable is set.

When set, the PWM continues to run when in wait mode. When clear, the PWM stops in wait mode, and restarts when wait mode exits.

source

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

Set wait enable.

See wait_enable for more information on debug enable.

source

pub fn clock_select(&self) -> ClockSelect

Returns the clock selection.

source

pub fn set_clock_select(&mut self, clock_select: ClockSelect)

Set the clock selection.

Panics

You cannot use submodule 0’s clock for submodule 0. If the submodule 0 clock is selected for submodule 0, this call panics.

source

pub fn load_mode(&self) -> LoadMode

Returns the load mode.

source

pub fn set_load_mode(&mut self, load_mode: LoadMode)

Set the load mode.

Panics

Panics if the load mode is reload cycle, yet neither full nor half is set. Use the LoadMode helper methods to ensure one of these flags are set.

source

pub fn status(&self) -> Status

Read the status flags.

source

pub fn clear_status(&self, status: Status)

Clear status flags.

The high bits are cleared. The implementation will clear the non-W1C bits, so it’s safe to call this with Status::all().

source

pub fn interrupts(&self) -> Interrupts

Read the interrupt flags.

source

pub fn set_interrupts(&self, interrupts: Interrupts)

Set the interrupt flags.

source

pub fn value(&self, value_register: ValueRegister) -> i16

Read one of the six value registers.

The return indicates the count value that will cause a comparison.

source

pub fn turn_on(&self, channel: Channel) -> i16

Get the turn on value for a channel.

This is the same as using turn_on() to produce a value register, then calling value() with that result.

source

pub fn turn_off(&self, channel: Channel) -> i16

Get the turn off value for a channel.

This is the same as using turn_off() to produce a value register, then calling value() with that result.

source

pub fn set_value(&self, value_register: ValueRegister, value: i16)

Set one of the six value registers to compare at value.

source

pub fn set_turn_on(&self, channel: Channel, compare: i16)

Set the turn on compare for a channel.

This is the same as using turn_on() to produce a value register, then calling set_value() with that result.

source

pub fn set_turn_off(&self, channel: Channel, compare: i16)

Set the turn off compare for a channel.

This is the same as using turn_off() to produce a value register, then calling set_value() with that result.

source

pub fn load_ok(&self, pwm: &Pwm<N>) -> bool

Returns true if this submodule’s LDOK bit is set.

source

pub fn set_load_ok(&self, pwm: &mut Pwm<N>)

Set the LDOK bit for this submodule.

source

pub fn clear_load_ok(&self, pwm: &mut Pwm<N>)

Clear the LDOK bit for this submodule.

source

pub fn is_running(&self, pwm: &Pwm<N>) -> bool

Returns true if the submodule is running.

source

pub fn output_enable(&self, pwm: &Pwm<N>, channel: Channel) -> bool

Indicates if a PWM output channel is enabled.

source

pub fn set_output_enable( &self, pwm: &mut Pwm<N>, channel: Channel, enable: bool )

Enable or disable an output channel.

source

pub fn set_running(&self, pwm: &mut Pwm<N>, run: bool)

Set or clear the running bit for this submodule.

Trait Implementations§

source§

impl<const N: u8, const M: u8> Deref for Submodule<N, M>

§

type Target = RegisterBlock

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<const N: u8, const M: u8> Send for Submodule<N, M>

Auto Trait Implementations§

§

impl<const N: u8, const M: u8> !RefUnwindSafe for Submodule<N, M>

§

impl<const N: u8, const M: u8> !Sync for Submodule<N, M>

§

impl<const N: u8, const M: u8> Unpin for Submodule<N, M>

§

impl<const N: u8, const M: u8> !UnwindSafe for Submodule<N, M>

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.