pub struct Submodule<const N: u8, const M: u8>(/* private fields */);
Expand description
A PWM submodule.
Submodule
s 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>
impl<const N: u8, const M: u8> Submodule<N, M>
sourcepub fn initial_count(&self) -> i16
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.
sourcepub fn set_initial_count(&self, pwm: &Pwm<N>, counter: i16)
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.
sourcepub fn load_frequency(&self) -> u16
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.
sourcepub fn set_load_frequency(&mut self, ldfq: u16)
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.
sourcepub fn set_prescaler(&mut self, prescaler: Prescaler)
pub fn set_prescaler(&mut self, prescaler: Prescaler)
Set the PWM clock prescaler.
sourcepub fn pair_operation(&self) -> PairOperation
pub fn pair_operation(&self) -> PairOperation
Returns the pair operation setting.
sourcepub fn set_pair_operation(&mut self, pair_operation: PairOperation)
pub fn set_pair_operation(&mut self, pair_operation: PairOperation)
Set the pair operation setting.
sourcepub fn debug_enable(&self) -> bool
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.
sourcepub fn set_debug_enable(&mut self, enable: bool)
pub fn set_debug_enable(&mut self, enable: bool)
Set debug enable.
See debug_enable
for more information on debug
enable.
sourcepub fn wait_enable(&self) -> bool
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.
sourcepub fn set_wait_enable(&mut self, enable: bool)
pub fn set_wait_enable(&mut self, enable: bool)
Set wait enable.
See wait_enable
for more information on debug
enable.
sourcepub fn clock_select(&self) -> ClockSelect
pub fn clock_select(&self) -> ClockSelect
Returns the clock selection.
sourcepub fn set_clock_select(&mut self, clock_select: ClockSelect)
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.
sourcepub fn set_load_mode(&mut self, load_mode: LoadMode)
pub fn set_load_mode(&mut self, load_mode: LoadMode)
sourcepub fn clear_status(&self, status: Status)
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()
.
sourcepub fn interrupts(&self) -> Interrupts
pub fn interrupts(&self) -> Interrupts
Read the interrupt flags.
sourcepub fn set_interrupts(&self, interrupts: Interrupts)
pub fn set_interrupts(&self, interrupts: Interrupts)
Set the interrupt flags.
sourcepub fn value(&self, value_register: ValueRegister) -> i16
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.
sourcepub fn turn_off(&self, channel: Channel) -> i16
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.
sourcepub fn set_value(&self, value_register: ValueRegister, value: i16)
pub fn set_value(&self, value_register: ValueRegister, value: i16)
Set one of the six value registers to compare at value
.
sourcepub fn set_turn_on(&self, channel: Channel, compare: i16)
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.
sourcepub fn set_turn_off(&self, channel: Channel, compare: i16)
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.
sourcepub fn set_load_ok(&self, pwm: &mut Pwm<N>)
pub fn set_load_ok(&self, pwm: &mut Pwm<N>)
Set the LDOK
bit for this submodule.
sourcepub fn clear_load_ok(&self, pwm: &mut Pwm<N>)
pub fn clear_load_ok(&self, pwm: &mut Pwm<N>)
Clear the LDOK
bit for this submodule.
sourcepub fn is_running(&self, pwm: &Pwm<N>) -> bool
pub fn is_running(&self, pwm: &Pwm<N>) -> bool
Returns true
if the submodule is running.
sourcepub fn output_enable(&self, pwm: &Pwm<N>, channel: Channel) -> bool
pub fn output_enable(&self, pwm: &Pwm<N>, channel: Channel) -> bool
Indicates if a PWM output channel is enabled.
sourcepub fn set_output_enable(
&self,
pwm: &mut Pwm<N>,
channel: Channel,
enable: bool,
)
pub fn set_output_enable( &self, pwm: &mut Pwm<N>, channel: Channel, enable: bool, )
Enable or disable an output channel.
sourcepub fn set_running(&self, pwm: &mut Pwm<N>, run: bool)
pub fn set_running(&self, pwm: &mut Pwm<N>, run: bool)
Set or clear the running bit for this submodule.