eFlexPwm
Arduino eFlexPwm library for Teensy 4.x
eFlex::SubModule

Submodule. More...

#include <eFlexPwmSubmodule.h>

Collaboration diagram for eFlex::SubModule:

Public Member Functions

 SubModule (int pinChanA, int pinChanB=-1)
 Construct a new SubModule object. More...
 
bool isValid () const
 Checks the validity of the parameters passed to the constructor. More...
 
bool configure (const Config &config)
 Configures the peripheral for basic operation. More...
 
const Configconfig () const
 Current configuration.
 
bool begin (bool doStart=true, bool doSync=true)
 Sets up the PWM signals for a PWM submodule. More...
 
void enable (bool value=true)
 Enable or disable the submodule. More...
 
void disable ()
 Disable the submodule. More...
 
bool isEnabled () const
 Returns true if the outputsof submodule were enabled.
 
void start (bool value=true)
 Starts the PWM counter for this submodule. More...
 
void stop ()
 Stops the PWM counter for this submodule.
 
void setPwmLdok (bool value=true)
 Sets or clears the PWM LDOK bit on all instantiated submodules for this timer. More...
 
Timertimer ()
 Returns the parent PWM module.
 
uint8_t index () const
 Returns the Submodule index (0 for Submodule0...)
 
bool setPwmFrequency (uint32_t freq, bool doSync=true, bool adjustPrescaler=false)
 Set the Pwm Frequency. More...
 
uint32_t pwmFrequency () const
 Current PWM signal frequency in Hz. More...
 
bool setPwmMode (pwm_mode_t mode, bool doSync=true)
 Set the Pwm operation mode. More...
 
pwm_mode_t pwmMode () const
 Current PWM signal frequency in Hz. More...
 
void setupOutputEnable (Channel channel, bool activate=true)
 Setting output enable before calling begin. More...
 
void setupOutputEnable (bool activate=true)
 Setting output enable for all channels before calling begin. More...
 
bool outputEnableSetting (Channel channel)
 value of the parameter set by setupOutputEnable (Channel, bool) More...
 
void setupDutyCyclePercent (Channel channel, uint8_t dutyCyclePercent)
 Setting the duty cycle before calling begin. More...
 
void setupDutyCyclePercent (uint8_t dutyCyclePercent)
 Setting the duty cycle for all channels before calling begin. More...
 
uint8_t dutyCyclePercentSetting (Channel channel)
 value of the parameter set by setupDutyCyclePercent (Channel, uint8_t) More...
 
void setupLevel (Channel channel, pwm_level_select_t level)
 Setting the output pulse mode before calling begin. More...
 
void setupLevel (pwm_level_select_t level)
 Setting the output pulse mode for all channels before calling begin. More...
 
pwm_level_select_t levelSetting (Channel channel)
 value of the parameter set by setupLevel (Channel, pwm_level_select_t) More...
 
void setupDeadtime (Channel channel, uint16_t deadtimeValue, uint32_t unit=1)
 Setting the deadtime before calling begin. More...
 
void setupDeadtime (uint16_t deadtimeValue, uint32_t unit=1)
 Setting the deadtime for all channels before calling begin. More...
 
uint16_t deadtimeSetting (Channel channel)
 value of the parameter set by setupDeadtime (Channel, uint16_t) More...
 
void setupFaultState (Channel channel, pwm_fault_state_t faultState)
 Setting the output fault status before calling begin. More...
 
void setupFaultState (pwm_fault_state_t faultState)
 Setting the output fault status for all channels before calling begin. More...
 
pwm_fault_state_t faultStateSetting (Channel channel)
 value of the parameter set by setupFaultState (Channel, pwm_fault_state_t) More...
 
bool updateSetting (bool doSync=true)
 Update PWM signals for a PWM submodule. More...
 
void setInitValue (uint16_t value)
 Set the PWM INIT register. More...
 
void setVal0Value (uint16_t value)
 Set the PWM VAL0 register. More...
 
void setVal1Value (uint16_t value)
 Set the PWM VAL1 register. More...
 
void setVal2Value (uint16_t value)
 Set the PWM VAL2 register. More...
 
void setVal3Value (uint16_t value)
 Set the PWM VAL3 register. More...
 
void setVal4Value (uint16_t value)
 Set the PWM VAL4 register. More...
 
void setVal5Value (uint16_t value)
 Set the PWM VAL5 register. More...
 
uint16_t initValue ()
 Get the PWM INIT register. More...
 
uint16_t val0Value ()
 Get the PWM VAL1 register. More...
 
uint16_t val1Value ()
 Get the PWM VAL1 register. More...
 
uint16_t val2Value ()
 Get the PWM VAL2 register. More...
 
uint16_t val3Value ()
 Get the PWM VAL3 register. More...
 
uint16_t val4Value ()
 Get the PWM VAL4 register. More...
 
uint16_t val5Value ()
 Get the PWM VAL5 register. More...
 
void printRegs (Stream &out=Serial)
 Print submodule registers to stream out. More...
 
void updateDutyCyclePercent (uint8_t dutyCyclePercent, Channel channel=ChanA)
 Updates the PWM signal's dutycycle. More...
 
void updateDutyCycle (uint16_t dutyCycle, Channel channel=ChanA)
 Updates the PWM signal's dutycycle with 16-bit accuracy. More...
 
bool setupPwmPhaseShift (Channel channel, uint8_t shiftvalue, bool doSync=true)
 Set PWM phase shift for PWM channel running on channel PWM_A, PWM_B which with 50% duty cycle.. More...
 
void setupInputCapture (Channel channel, const pwm_input_capture_param_t *inputCaptureParams)
 Sets up the PWM input capture. More...
 
void setupForceSignal (Channel channel, pwm_force_signal_t mode)
 Selects the signal to output on a PWM pin when a FORCE_OUT signal is asserted. More...
 
uint32_t statusFlags ()
 Gets the PWM status flags. More...
 
void clearStatusFlags (uint32_t mask)
 Clears the PWM status flags. More...
 
void enableInterrupts (uint32_t mask)
 Enables the selected PWM interrupts. More...
 
void disableInterrupts (uint32_t mask)
 Disables the selected PWM interrupts. More...
 
uint32_t enabledInterrupts ()
 Gets the enabled PWM interrupts. More...
 
void setDMAWatermarkControl (pwm_watermark_control_t pwm_watermark_control)
 Capture DMA Enable Source Select. More...
 
void setDMACaptureSourceSelect (pwm_dma_source_select_t pwm_dma_source_select)
 Capture DMA Enable Source Select. More...
 
void enableDMACapture (uint16_t mask, bool activate=true)
 Enables or disables the selected PWM DMA Capture read request. More...
 
void enableDMAWrite (bool activate)
 Enables or disables the PWM DMA write request. More...
 
void setVALxValue (pwm_value_register_t valueRegister, uint16_t value)
 Set the PWM VALx registers. More...
 
uint16_t VALxValue (pwm_value_register_t valueRegister)
 Get the PWM VALx registers. More...
 
void enableOutputTrigger (pwm_value_register_t valueRegister, bool activate=true)
 Enables or disables the PWM output trigger. More...
 
void enableOutputTrigger (uint16_t valueRegisterMask)
 Enables the PWM output trigger. More...
 
void disableOutputTrigger (uint16_t valueRegisterMask)
 Disables the PWM output trigger. More...
 
void setupSwCtrlOut (Channel channel, bool value)
 Sets the software control output for a pin to high or low. More...
 
void setPwmFaultState (Channel channel, pwm_fault_state_t faultState)
 Set PWM output fault status. More...
 
void setupFaultDisableMap (Channel channel, pwm_fault_channels_t pwm_fault_channels, uint16_t value)
 Set PWM fault disable mapping. More...
 
void enableOutput (Channel channel)
 Set PWM output enable. More...
 
void disableOutput (Channel channel)
 Set PWM output disable. More...
 
uint8_t dutyCyclePercent (Channel channel)
 Get the dutycycle value. More...
 
bool setOutputToIdle (Channel channel, bool idleStatus)
 Set PWM output in idle status (high or low). More...
 
void setPrescaler (pwm_clock_prescale_t prescaler)
 Set the pwm submodule prescaler. More...
 
void setClockMode (pwm_clock_prescale_t prescaler)
 Set the pwm submodule prescaler. More...
 
pwm_clock_prescale_t prescaler () const
 the pwm submodule prescaler
 
void setPwmForceOutputToZero (Channel channel, bool forcetozero)
 This function enables-disables the forcing of the output of a given eFlexPwm channel to logic 0. More...
 
void setChannelOutput (Channel channel, pwm_output_state_t outputstate)
 This function set the output state of the PWM pin as requested for the current cycle. More...
 
uint32_t minPwmFrequency () const
 Current minimal PWM frequency in Hz. More...
 
bool adjustPrescaler (uint32_t pwmFreq)
 Adjust the prescaler if necessary. More...
 

Detailed Description

Submodule.

This class is used to perform most operations.

Definition at line 20 of file eFlexPwmSubmodule.h.

Constructor & Destructor Documentation

◆ SubModule()

eFlex::SubModule::SubModule ( int  pinChanA,
int  pinChanB = -1 
)

Construct a new SubModule object.

If the pin is valid (eFlexPwm type), its channel is configured with default values: pwmchannelenable = true; level = kPWM_HighTrue; dutyCyclePercent = 50; deadtimeValue = 0; faultState = kPWM_PwmFaultState0;

Parameters
pinChanAArduino pin number of output A, this pin must correspond to an output A (23) of an eFlexPWM sub-module (refer to the datasheet)
pinChanBArduino pin number of output B, this pin must correspond to output B (45) of the same submodule as pinA (refer to datasheet)

Member Function Documentation

◆ adjustPrescaler()

bool eFlex::SubModule::adjustPrescaler ( uint32_t  pwmFreq)

Adjust the prescaler if necessary.

Checks if pwmFreq is less than the minPwmFrequency() and increases the prescaler if necessary. Otherwise and if the prescaler is greater than 1, try to reduce it to the minimum.

Parameters
pwmFreqthe desired PWM frequency
Returns
true if adjustment made, false otherwise

◆ begin()

bool eFlex::SubModule::begin ( bool  doStart = true,
bool  doSync = true 
)

Sets up the PWM signals for a PWM submodule.

The function initializes the submodule according to the parameters passed in by the user. The function also sets up the value compare registers to match the PWM signal requirements. If the dead time insertion logic is enabled, the pulse period is reduced by the dead time period specified by the user.

Parameters
doStartstarts signal generation
doSyncsynchronizes the operation by surrounding it with setPwmLdok (false) / setPwmLdok (true)
Returns
Returns false if there was error setting up the signal; true otherwise

◆ clearStatusFlags()

void eFlex::SubModule::clearStatusFlags ( uint32_t  mask)
inline

Clears the PWM status flags.

Parameters
maskThe status flags to clear. This is a logical OR of members of the enumeration pwm_status_flags_t

Definition at line 654 of file eFlexPwmSubmodule.h.

◆ configure()

bool eFlex::SubModule::configure ( const Config config)

Configures the peripheral for basic operation.

Note
This API should be called at the beginning of the application using the PWM driver.
Parameters
configReference to user's PWM config structure.
Returns
true means success; if false is returned, begin should not be called !

◆ deadtimeSetting()

uint16_t eFlex::SubModule::deadtimeSetting ( Channel  channel)
inline

value of the parameter set by setupDeadtime (Channel, uint16_t)

Parameters
channelPWM channel to read; ChanA or ChanB

Definition at line 333 of file eFlexPwmSubmodule.h.

References _pwm_signal_param::deadtimeValue.

◆ disable()

void eFlex::SubModule::disable ( )
inline

Disable the submodule.

This function allows you to disable the output pins without changing anything in the configuration. When the submodule is disabled, its output pins are forced to zero.

Definition at line 101 of file eFlexPwmSubmodule.h.

References enable().

Here is the call graph for this function:

◆ disableInterrupts()

void eFlex::SubModule::disableInterrupts ( uint32_t  mask)
inline

Disables the selected PWM interrupts.

Parameters
maskThe interrupts to enable. This is a logical OR of members of the enumeration pwm_interrupt_enable_t

Definition at line 674 of file eFlexPwmSubmodule.h.

◆ disableOutput()

void eFlex::SubModule::disableOutput ( Channel  channel)
inline

Set PWM output disable.

This feature allows the user to disable the PWM output.

Parameters
channelPWM channel to configure

Definition at line 852 of file eFlexPwmSubmodule.h.

◆ disableOutputTrigger()

void eFlex::SubModule::disableOutputTrigger ( uint16_t  valueRegisterMask)
inline

Disables the PWM output trigger.

This function allows the user to disables one or more (VAL0-5) PWM trigger.

Parameters
valueRegisterMaskValue register mask that will Deactivate one or more (VAL0-5) trigger enumeration _pwm_value_register_mask

Definition at line 785 of file eFlexPwmSubmodule.h.

◆ dutyCyclePercent()

uint8_t eFlex::SubModule::dutyCyclePercent ( Channel  channel)
inline

Get the dutycycle value.

Parameters
channelPWM channel to configure
Returns
Current channel dutycycle between 0 to 100.

Definition at line 863 of file eFlexPwmSubmodule.h.

Referenced by setupDutyCyclePercent(), and updateDutyCyclePercent().

◆ dutyCyclePercentSetting()

uint8_t eFlex::SubModule::dutyCyclePercentSetting ( Channel  channel)
inline

value of the parameter set by setupDutyCyclePercent (Channel, uint8_t)

Parameters
channelPWM channel to read; ChanA or ChanB

Definition at line 260 of file eFlexPwmSubmodule.h.

References _pwm_signal_param::dutyCyclePercent.

◆ enable()

void eFlex::SubModule::enable ( bool  value = true)

Enable or disable the submodule.

This function allows you to enable/disable the output pins without changing anything in the configuration. When the submodule is disabled, its output pins are forced to zero.

Parameters
valuetrue to enable, false otherwise

Referenced by disable().

◆ enabledInterrupts()

uint32_t eFlex::SubModule::enabledInterrupts ( )
inline

Gets the enabled PWM interrupts.

Returns
The enabled interrupts. This is the logical OR of members of the enumeration pwm_interrupt_enable_t

Definition at line 684 of file eFlexPwmSubmodule.h.

◆ enableDMACapture()

void eFlex::SubModule::enableDMACapture ( uint16_t  mask,
bool  activate = true 
)
inline

Enables or disables the selected PWM DMA Capture read request.

Parameters
maskThe DMA to enable or disable. This is a logical OR of members of the enumeration pwm_dma_enable_t
activatetrue: Enable DMA read request; false: Disable DMA read request

Definition at line 713 of file eFlexPwmSubmodule.h.

◆ enableDMAWrite()

void eFlex::SubModule::enableDMAWrite ( bool  activate)
inline

Enables or disables the PWM DMA write request.

Parameters
activatetrue: Enable DMA write request; false: Disable DMA write request

Definition at line 722 of file eFlexPwmSubmodule.h.

◆ enableInterrupts()

void eFlex::SubModule::enableInterrupts ( uint32_t  mask)
inline

Enables the selected PWM interrupts.

Parameters
maskThe interrupts to enable. This is a logical OR of members of the enumeration pwm_interrupt_enable_t

Definition at line 664 of file eFlexPwmSubmodule.h.

◆ enableOutput()

void eFlex::SubModule::enableOutput ( Channel  channel)
inline

Set PWM output enable.

This feature allows the user to enable the PWM Output.

Parameters
channelPWM channel to configure

Definition at line 841 of file eFlexPwmSubmodule.h.

◆ enableOutputTrigger() [1/2]

void eFlex::SubModule::enableOutputTrigger ( pwm_value_register_t  valueRegister,
bool  activate = true 
)
inline

Enables or disables the PWM output trigger.

This function allows the user to enable or disable the PWM trigger. The PWM has 2 triggers. Trigger 0 is activated when the counter matches VAL 0, VAL 2, or VAL 4 register. Trigger 1 is activated when the counter matches VAL 1, VAL 3, or VAL 5 register.

Parameters
valueRegisterValue register that will activate the trigger
activatetrue: Enable the trigger; false: Disable the trigger

Definition at line 761 of file eFlexPwmSubmodule.h.

◆ enableOutputTrigger() [2/2]

void eFlex::SubModule::enableOutputTrigger ( uint16_t  valueRegisterMask)
inline

Enables the PWM output trigger.

This function allows the user to enable one or more (VAL0-5) PWM trigger.

Parameters
valueRegisterMaskValue register mask that will activate one or more (VAL0-5) trigger enumeration _pwm_value_register_mask

Definition at line 773 of file eFlexPwmSubmodule.h.

◆ faultStateSetting()

pwm_fault_state_t eFlex::SubModule::faultStateSetting ( Channel  channel)
inline

value of the parameter set by setupFaultState (Channel, pwm_fault_state_t)

Parameters
channelPWM channel to read; ChanA or ChanB

Definition at line 367 of file eFlexPwmSubmodule.h.

References _pwm_signal_param::faultState.

◆ initValue()

uint16_t eFlex::SubModule::initValue ( )
inline

Get the PWM INIT register.

Returns
The register value

Definition at line 489 of file eFlexPwmSubmodule.h.

◆ isValid()

bool eFlex::SubModule::isValid ( ) const

Checks the validity of the parameters passed to the constructor.

Warning
If this function returns false, the call to functions configure and begin will fail.
Returns
returns true if all of these conditions are true:
  • the pins passed to the constructor are of type eFlexPWM
  • pinA corresponds to output A of the submodule
  • pinB corresponds to output B of the submodule

false otherwise

◆ levelSetting()

pwm_level_select_t eFlex::SubModule::levelSetting ( Channel  channel)
inline

value of the parameter set by setupLevel (Channel, pwm_level_select_t)

Parameters
channelPWM channel to read; ChanA or ChanB

Definition at line 292 of file eFlexPwmSubmodule.h.

References _pwm_signal_param::level.

◆ minPwmFrequency()

uint32_t eFlex::SubModule::minPwmFrequency ( ) const
inline

Current minimal PWM frequency in Hz.

this value is calculated by configure() and updated by setPrescaler()

Definition at line 936 of file eFlexPwmSubmodule.h.

◆ outputEnableSetting()

bool eFlex::SubModule::outputEnableSetting ( Channel  channel)
inline

value of the parameter set by setupOutputEnable (Channel, bool)

Parameters
channelPWM channel to read; ChanA or ChanB

Definition at line 227 of file eFlexPwmSubmodule.h.

References _pwm_signal_param::pwmchannelenable.

◆ printRegs()

void eFlex::SubModule::printRegs ( Stream &  out = Serial)

Print submodule registers to stream out.

Parameters
outthe output stream, Serial by default

◆ pwmFrequency()

uint32_t eFlex::SubModule::pwmFrequency ( ) const
inline

Current PWM signal frequency in Hz.

Returns
uint32_t

Definition at line 170 of file eFlexPwmSubmodule.h.

References config(), and eFlex::Config::pwmFreqHz().

Here is the call graph for this function:

◆ pwmMode()

pwm_mode_t eFlex::SubModule::pwmMode ( ) const
inline

Current PWM signal frequency in Hz.

Returns
uint32_t

Definition at line 194 of file eFlexPwmSubmodule.h.

References config(), and eFlex::Config::mode().

Here is the call graph for this function:

◆ setChannelOutput()

void eFlex::SubModule::setChannelOutput ( Channel  channel,
pwm_output_state_t  outputstate 
)
inline

This function set the output state of the PWM pin as requested for the current cycle.

Parameters
channelPWM channel to configure
outputstateSet pwm output state, see pwm_output_state_t.

Definition at line 927 of file eFlexPwmSubmodule.h.

◆ setClockMode()

void eFlex::SubModule::setClockMode ( pwm_clock_prescale_t  prescaler)
inline

Set the pwm submodule prescaler.

Deprecated:
will be removed in next major release, use setPrescaler() instead
Parameters
prescalerSet prescaler value

Definition at line 899 of file eFlexPwmSubmodule.h.

References prescaler(), and setPrescaler().

Here is the call graph for this function:

◆ setDMACaptureSourceSelect()

void eFlex::SubModule::setDMACaptureSourceSelect ( pwm_dma_source_select_t  pwm_dma_source_select)
inline

Capture DMA Enable Source Select.

Parameters
pwm_dma_source_selectPWM capture DMA enable source select

Definition at line 702 of file eFlexPwmSubmodule.h.

◆ setDMAWatermarkControl()

void eFlex::SubModule::setDMAWatermarkControl ( pwm_watermark_control_t  pwm_watermark_control)
inline

Capture DMA Enable Source Select.

Parameters
pwm_watermark_controlPWM FIFO watermark and control

Definition at line 693 of file eFlexPwmSubmodule.h.

◆ setInitValue()

void eFlex::SubModule::setInitValue ( uint16_t  value)
inline

Set the PWM INIT register.

This function allows the user to write value into registers directly. And it will destroying the PWM clock period set by the begin()/updateSetting()/setupPwmPhaseShift() functions. Due to the registers are bufferd, the new value will not active uless call setPwmLdok() and the reload point is reached.

Parameters
valueValue that will been write into register

Definition at line 396 of file eFlexPwmSubmodule.h.

◆ setOutputToIdle()

bool eFlex::SubModule::setOutputToIdle ( Channel  channel,
bool  idleStatus 
)
inline

Set PWM output in idle status (high or low).

Note
This API should call after setupPwm() APIs, and PWMX submodule is not supported.
Parameters
channelPWM channel to configure
idleStatustrue: PWM output is high in idle status; false: PWM output is low in idle status.
Returns
false if there was error setting up the signal; true if set output idle success

Definition at line 877 of file eFlexPwmSubmodule.h.

◆ setPrescaler()

void eFlex::SubModule::setPrescaler ( pwm_clock_prescale_t  prescaler)
inline

Set the pwm submodule prescaler.

Parameters
prescalerSet prescaler value

Definition at line 886 of file eFlexPwmSubmodule.h.

References prescaler(), eFlex::Timer::prescalerToMinPwmFrequency(), and eFlex::Config::setPrescale().

Referenced by setClockMode().

Here is the call graph for this function:

◆ setPwmFaultState()

void eFlex::SubModule::setPwmFaultState ( Channel  channel,
pwm_fault_state_t  faultState 
)
inline

Set PWM output fault status.

These bits determine the fault state for the PWM_A output in fault conditions and STOP mode. It may also define the output state in WAIT and DEBUG modes depending on the settings of CTRL2[WAITEN] and CTRL2[DBGEN]. This function can update PWM output fault status.

Parameters
channelChannel to configure
faultStatePWM output fault status

Definition at line 813 of file eFlexPwmSubmodule.h.

◆ setPwmForceOutputToZero()

void eFlex::SubModule::setPwmForceOutputToZero ( Channel  channel,
bool  forcetozero 
)
inline

This function enables-disables the forcing of the output of a given eFlexPwm channel to logic 0.

Parameters
channelPWM channel to configure
forcetozerotrue: Enable the pwm force output to zero; false: Disable the pwm output resumes normal function.

Definition at line 917 of file eFlexPwmSubmodule.h.

◆ setPwmFrequency()

bool eFlex::SubModule::setPwmFrequency ( uint32_t  freq,
bool  doSync = true,
bool  adjustPrescaler = false 
)

Set the Pwm Frequency.

Parameters
freqPWM signal frequency in Hz
doSynctrue : Set LDOK bit for the submodule; false: LDOK bit don't set, need to call setPwmLdok to sync update.
adjustPrescalerfalse: no change prescaler, if freq is less than minPwmFrequency(), nothing is done and false is returned; true: calls adjustPrescaler() to try to adjust the prescaler, the prescaler is adjusted if possible, otherwise, false is returned.
Returns
false if there was error setting up the signal; true otherwise

◆ setPwmLdok()

void eFlex::SubModule::setPwmLdok ( bool  value = true)
inline

Sets or clears the PWM LDOK bit on all instantiated submodules for this timer.

Note
This operation is not useful if begin() was called with doSync=true
Parameters
valuetrue: Set LDOK bit for the submodule list; false: Clear LDOK bit

Definition at line 134 of file eFlexPwmSubmodule.h.

References index(), eFlex::Timer::setPwmLdok(), and timer().

Here is the call graph for this function:

◆ setPwmMode()

bool eFlex::SubModule::setPwmMode ( pwm_mode_t  mode,
bool  doSync = true 
)
inline

Set the Pwm operation mode.

Parameters
modePWM operation mode
doSynctrue: Set LDOK bit for the submodule; false: LDOK bit don't set, need to call setPwmLdok to sync update.
Returns
Returns false if there was error setting up the signal; true otherwise

Definition at line 184 of file eFlexPwmSubmodule.h.

References eFlex::Config::setMode(), and updateSetting().

Here is the call graph for this function:

◆ setupDeadtime() [1/2]

void eFlex::SubModule::setupDeadtime ( Channel  channel,
uint16_t  deadtimeValue,
uint32_t  unit = 1 
)
inline

Setting the deadtime before calling begin.

Note
If you want this value to take effect after the call to begin, you must call updateSetting
Parameters
channelPWM channel being setting; ChanA or ChanB
deadtimeValueThe deadtime value in clock cycles; only used if channel pair is operating in complementary mode
unitThe unit of the deadtimeValue; 1: clock cycles; 1000: milliseconds; 1000000: microseconds; 1000000000: nanoseconds

Definition at line 305 of file eFlexPwmSubmodule.h.

References _pwm_signal_param::deadtimeValue, eFlex::Timer::srcClockHz(), and timer().

Referenced by setupDeadtime().

Here is the call graph for this function:

◆ setupDeadtime() [2/2]

void eFlex::SubModule::setupDeadtime ( uint16_t  deadtimeValue,
uint32_t  unit = 1 
)
inline

Setting the deadtime for all channels before calling begin.

Note
If you want this value to take effect after the call to begin, you must call updateSetting
Parameters
deadtimeValueThe deadtime value in clock cycles; only used if channel pair is operating in complementary mode
unitThe unit of the deadtimeValue; 1: clock cycles; 1000: milliseconds; 1000000: microseconds; 1000000000: nanoseconds

Definition at line 322 of file eFlexPwmSubmodule.h.

References setupDeadtime().

Here is the call graph for this function:

◆ setupDutyCyclePercent() [1/2]

void eFlex::SubModule::setupDutyCyclePercent ( Channel  channel,
uint8_t  dutyCyclePercent 
)
inline

Setting the duty cycle before calling begin.

Note
If you want this value to take effect after the call to begin, you must call updateSetting
Parameters
channelPWM channel being setting; ChanA or ChanB
dutyCyclePercentduty cycle in percent

Definition at line 239 of file eFlexPwmSubmodule.h.

References _pwm_signal_param::dutyCyclePercent, and dutyCyclePercent().

Referenced by setupDutyCyclePercent().

Here is the call graph for this function:

◆ setupDutyCyclePercent() [2/2]

void eFlex::SubModule::setupDutyCyclePercent ( uint8_t  dutyCyclePercent)
inline

Setting the duty cycle for all channels before calling begin.

Note
If you want this value to take effect after the call to begin, you must call updateSetting
Parameters
dutyCyclePercentduty cycle in percent

Definition at line 249 of file eFlexPwmSubmodule.h.

References dutyCyclePercent(), and setupDutyCyclePercent().

Here is the call graph for this function:

◆ setupFaultDisableMap()

void eFlex::SubModule::setupFaultDisableMap ( Channel  channel,
pwm_fault_channels_t  pwm_fault_channels,
uint16_t  value 
)
inline

Set PWM fault disable mapping.

Each of the four bits of this read/write field is one-to-one associated with the four FAULTx inputs of fault channel 0/1. The PWM output will be turned off if there is a logic 1 on an FAULTx input and a 1 in the corresponding bit of this field. A reset sets all bits in this field.

Parameters
channelPWM channel to configure
pwm_fault_channelsPWM fault channel to configure
valueFault disable mapping mask value enumeration pwm_fault_disable_t

Definition at line 830 of file eFlexPwmSubmodule.h.

◆ setupFaultState() [1/2]

void eFlex::SubModule::setupFaultState ( Channel  channel,
pwm_fault_state_t  faultState 
)
inline

Setting the output fault status before calling begin.

Note
If you want this value to take effect after the call to begin, you must call updateSetting
Parameters
channelPWM channel being setting; ChanA or ChanB
faultStatethe output fault status

Definition at line 345 of file eFlexPwmSubmodule.h.

References _pwm_signal_param::faultState.

Referenced by setupFaultState().

◆ setupFaultState() [2/2]

void eFlex::SubModule::setupFaultState ( pwm_fault_state_t  faultState)
inline

Setting the output fault status for all channels before calling begin.

Note
If you want this value to take effect after the call to begin, you must call updateSetting
Parameters
faultStatethe output fault status

Definition at line 356 of file eFlexPwmSubmodule.h.

References setupFaultState().

Here is the call graph for this function:

◆ setupForceSignal()

void eFlex::SubModule::setupForceSignal ( Channel  channel,
pwm_force_signal_t  mode 
)
inline

Selects the signal to output on a PWM pin when a FORCE_OUT signal is asserted.

The user specifies which channel to configure by supplying the submodule number and whether to modify PWM A or PWM B within that submodule.

Parameters
channelChannel to configure
modeSignal to output when a FORCE_OUT is triggered

Definition at line 634 of file eFlexPwmSubmodule.h.

◆ setupInputCapture()

void eFlex::SubModule::setupInputCapture ( Channel  channel,
const pwm_input_capture_param_t inputCaptureParams 
)
inline

Sets up the PWM input capture.

Each PWM submodule has 3 pins that can be configured for use as input capture pins. This function sets up the capture parameters for each pin and enables the pin for input capture operation.

Parameters
channelChannel in the submodule to setup
inputCaptureParamsParameters passed in to set up the input pin

Definition at line 621 of file eFlexPwmSubmodule.h.

◆ setupLevel() [1/2]

void eFlex::SubModule::setupLevel ( Channel  channel,
pwm_level_select_t  level 
)
inline

Setting the output pulse mode before calling begin.

Note
If you want this value to take effect after the call to begin, you must call updateSetting
Parameters
channelPWM channel being setting; ChanA or ChanB
leveloutput pulse mode

Definition at line 271 of file eFlexPwmSubmodule.h.

References _pwm_signal_param::level.

Referenced by setupLevel().

◆ setupLevel() [2/2]

void eFlex::SubModule::setupLevel ( pwm_level_select_t  level)
inline

Setting the output pulse mode for all channels before calling begin.

Note
If you want this value to take effect after the call to begin, you must call updateSetting
Parameters
leveloutput pulse mode

Definition at line 281 of file eFlexPwmSubmodule.h.

References setupLevel().

Here is the call graph for this function:

◆ setupOutputEnable() [1/2]

void eFlex::SubModule::setupOutputEnable ( bool  activate = true)
inline

Setting output enable for all channels before calling begin.

Note
If you want this value to take effect after the call to begin, you must call updateSetting
Parameters
activatetrue to enable the outputs

Definition at line 216 of file eFlexPwmSubmodule.h.

References setupOutputEnable().

Here is the call graph for this function:

◆ setupOutputEnable() [2/2]

void eFlex::SubModule::setupOutputEnable ( Channel  channel,
bool  activate = true 
)
inline

Setting output enable before calling begin.

Note
If you want this value to take effect after the call to begin, you must call updateSetting
Parameters
channelPWM channel being setting; ChanA or ChanB
activatetrue to enable the output

Definition at line 205 of file eFlexPwmSubmodule.h.

References _pwm_signal_param::pwmchannelenable.

Referenced by setupOutputEnable().

◆ setupPwmPhaseShift()

bool eFlex::SubModule::setupPwmPhaseShift ( Channel  channel,
uint8_t  shiftvalue,
bool  doSync = true 
)
inline

Set PWM phase shift for PWM channel running on channel PWM_A, PWM_B which with 50% duty cycle..

Parameters
channelPWM channel to configure
shiftvaluePhase shift value
doSynctrue: Set LDOK bit for the submodule list; false: LDOK bit don't set, need to call setPwmLdok to sync update.
Returns
Returns false if there was error setting up the signal; true otherwise

Definition at line 607 of file eFlexPwmSubmodule.h.

References eFlex::Config::pwmFreqHz(), and timer().

Here is the call graph for this function:

◆ setupSwCtrlOut()

void eFlex::SubModule::setupSwCtrlOut ( Channel  channel,
bool  value 
)
inline

Sets the software control output for a pin to high or low.

The user specifies which channel to modify by supplying the submodule number and whether to modify PWM A or PWM B within that submodule.

Parameters
channelChannel to configure
valuetrue: Supply a logic 1, false: Supply a logic 0.

Definition at line 798 of file eFlexPwmSubmodule.h.

◆ setVal0Value()

void eFlex::SubModule::setVal0Value ( uint16_t  value)
inline

Set the PWM VAL0 register.

This function allows the user to write value into registers directly. And it will destroying the PWM clock period set by the begin()/updateSetting()/setupPwmPhaseShift() functions. Due to the registers are bufferd, the new value will not active uless call setPwmLdok() and the reload point is reached.

Parameters
valueValue that will been write into register

Definition at line 410 of file eFlexPwmSubmodule.h.

◆ setVal1Value()

void eFlex::SubModule::setVal1Value ( uint16_t  value)
inline

Set the PWM VAL1 register.

This function allows the user to write value into registers directly. And it will destroying the PWM clock period set by the begin()/updateSetting()/setupPwmPhaseShift() functions. Due to the registers are bufferd, the new value will not active uless call setPwmLdok() and the reload point is reached.

Parameters
valueValue that will been write into register

Definition at line 424 of file eFlexPwmSubmodule.h.

◆ setVal2Value()

void eFlex::SubModule::setVal2Value ( uint16_t  value)
inline

Set the PWM VAL2 register.

This function allows the user to write value into registers directly. And it will destroying the PWM clock period set by the begin()/updateSetting()/setupPwmPhaseShift() functions. Due to the registers are bufferd, the new value will not active uless call setPwmLdok() and the reload point is reached.

Parameters
valueValue that will been write into register

Definition at line 438 of file eFlexPwmSubmodule.h.

◆ setVal3Value()

void eFlex::SubModule::setVal3Value ( uint16_t  value)
inline

Set the PWM VAL3 register.

This function allows the user to write value into registers directly. And it will destroying the PWM clock period set by the begin()/updateSetting()/setupPwmPhaseShift() functions. Due to the registers are bufferd, the new value will not active uless call setPwmLdok() and the reload point is reached.

Parameters
valueValue that will been write into register

Definition at line 452 of file eFlexPwmSubmodule.h.

◆ setVal4Value()

void eFlex::SubModule::setVal4Value ( uint16_t  value)
inline

Set the PWM VAL4 register.

This function allows the user to write value into registers directly. And it will destroying the PWM clock period set by the begin()/updateSetting()/setupPwmPhaseShift() functions. Due to the registers are bufferd, the new value will not active uless call setPwmLdok() and the reload point is reached.

Parameters
valueValue that will been write into register

Definition at line 466 of file eFlexPwmSubmodule.h.

◆ setVal5Value()

void eFlex::SubModule::setVal5Value ( uint16_t  value)
inline

Set the PWM VAL5 register.

This function allows the user to write value into registers directly. And it will destroying the PWM clock period set by the begin()/updateSetting()/setupPwmPhaseShift() functions. Due to the registers are bufferd, the new value will not active uless call setPwmLdok() and the reload point is reached.

Parameters
valueValue that will been write into register

Definition at line 480 of file eFlexPwmSubmodule.h.

◆ setVALxValue()

void eFlex::SubModule::setVALxValue ( pwm_value_register_t  valueRegister,
uint16_t  value 
)
inline

Set the PWM VALx registers.

This function allows the user to write value into VAL registers directly. And it will destroying the PWM clock period set by the setupPwm()/PWM_SetupPwmPhaseShift() functions. Due to VALx registers are bufferd, the new value will not active uless call setPwmLdok() and the reload point is reached.

Parameters
valueRegisterVALx register that will be writen new value
valueValue that will been write into VALx register

Definition at line 737 of file eFlexPwmSubmodule.h.

◆ start()

void eFlex::SubModule::start ( bool  value = true)
inline

Starts the PWM counter for this submodule.

Note
This operation is not useful if begin() was called with doStart=true

Definition at line 115 of file eFlexPwmSubmodule.h.

References index(), eFlex::Timer::start(), and timer().

Referenced by stop().

Here is the call graph for this function:

◆ statusFlags()

uint32_t eFlex::SubModule::statusFlags ( )
inline

Gets the PWM status flags.

Returns
The status flags. This is the logical OR of members of the enumeration pwm_status_flags_t

Definition at line 644 of file eFlexPwmSubmodule.h.

◆ updateDutyCycle()

void eFlex::SubModule::updateDutyCycle ( uint16_t  dutyCycle,
Channel  channel = ChanA 
)
inline

Updates the PWM signal's dutycycle with 16-bit accuracy.

The function updates the PWM dutycyle to the new value that is passed in. If the dead time insertion logic is enabled then the pulse period is reduced by the dead time period specified by the user.

Parameters
channelChannel (PWM A or PWM B) to update
dutyCycleNew PWM pulse width, value should be between 0 to 65535 0=inactive signal(0% duty cycle)... 65535=active signal (100% duty cycle)

Definition at line 591 of file eFlexPwmSubmodule.h.

◆ updateDutyCyclePercent()

void eFlex::SubModule::updateDutyCyclePercent ( uint8_t  dutyCyclePercent,
Channel  channel = ChanA 
)
inline

Updates the PWM signal's dutycycle.

The function updates the PWM dutycyle to the new value that is passed in. If the dead time insertion logic is enabled then the pulse period is reduced by the dead time period specified by the user.

Parameters
channelChannel (PWM A or PWM B) to update
dutyCyclePercentNew PWM pulse width, value should be between 0 to 100 0=inactive signal(0% duty cycle)... 100=active signal (100% duty cycle)

Definition at line 571 of file eFlexPwmSubmodule.h.

References dutyCyclePercent(), and eFlex::reloadValue().

Here is the call graph for this function:

◆ updateSetting()

bool eFlex::SubModule::updateSetting ( bool  doSync = true)

Update PWM signals for a PWM submodule.

The function initializes the submodule according to the parameters passed in by the user. The function also sets up the value compare registers to match the PWM signal requirements. If the dead time insertion logic is enabled, the pulse period is reduced by the dead time period specified by the user.

Parameters
doSynctrue: Set LDOK bit for the submodule; false: LDOK bit don't set, need to call setPwmLdok to sync update.
Returns
Returns false if there was error setting up the signal; true otherwise

Referenced by setPwmMode().

◆ val0Value()

uint16_t eFlex::SubModule::val0Value ( )
inline

Get the PWM VAL1 register.

Returns
The register value

Definition at line 498 of file eFlexPwmSubmodule.h.

◆ val1Value()

uint16_t eFlex::SubModule::val1Value ( )
inline

Get the PWM VAL1 register.

Returns
The register value

Definition at line 507 of file eFlexPwmSubmodule.h.

◆ val2Value()

uint16_t eFlex::SubModule::val2Value ( )
inline

Get the PWM VAL2 register.

Returns
The register value

Definition at line 516 of file eFlexPwmSubmodule.h.

◆ val3Value()

uint16_t eFlex::SubModule::val3Value ( )
inline

Get the PWM VAL3 register.

Returns
The register value

Definition at line 525 of file eFlexPwmSubmodule.h.

◆ val4Value()

uint16_t eFlex::SubModule::val4Value ( )
inline

Get the PWM VAL4 register.

Returns
The register value

Definition at line 534 of file eFlexPwmSubmodule.h.

◆ val5Value()

uint16_t eFlex::SubModule::val5Value ( )
inline

Get the PWM VAL5 register.

Returns
The register value

Definition at line 543 of file eFlexPwmSubmodule.h.

◆ VALxValue()

uint16_t eFlex::SubModule::VALxValue ( pwm_value_register_t  valueRegister)
inline

Get the PWM VALx registers.

Parameters
valueRegisterVALx register that will be read value
Returns
The VALx register value

Definition at line 747 of file eFlexPwmSubmodule.h.