Driver API for PWM (plib_pwm0.h) More...
Data Structures | |
| struct | PWM_INTERRUPT_FLAGS |
| PWM interrupt flags, one field per physical interrupt register bank. More... | |
Macros | |
| #define | PWM_FAULT_INPUT_COUNT (8U) /* Fault inputs (width of FMR FPOL/FMOD/FFIL) */ |
| #define | PWM_STEPPER_PAIR_COUNT (2U) /* Gray-count channel pairs (SMMR GCEN0/GCEN1) */ |
| #define | PWM_WP_GROUP_ALL ((uint32_t)(PWM_WPCR_WPRG_Msk >> PWM_WPCR_WPRG_Pos)) |
| #define | PWM_CHANNEL_COUNTER_MAX (0xFFFFU) |
| #define | PWM_CHANNEL_0 ((uint32_t)0U) |
| #define | PWM_CHANNEL_1 ((uint32_t)1U) |
| #define | PWM_CHANNEL_2 ((uint32_t)2U) |
| #define | PWM_CHANNEL_3 ((uint32_t)3U) |
Typedefs | |
| typedef void(* | PWM_CALLBACK) (PWM_INTERRUPT_FLAGS int_cause) |
| PWM interrupt callback handler type. | |
Functions | |
| bool | PWM0_EnableChannel (uint32_t channel) |
| Enables (starts) a single PWM0 channel. | |
| bool | PWM0_DisableChannel (uint32_t channel) |
| Disables (stops) a single PWM0 channel. | |
| uint32_t | PWM0_GetEnabledChannels (void) |
| Reads the mask of currently-enabled PWM0 channels. | |
| bool | PWM0_SetPeriod (uint32_t channel, uint32_t period) |
| Sets a PWM0 channel's period (glitch-free while running). | |
| uint32_t | PWM0_GetPeriod (uint32_t channel) |
| Reads a PWM0 channel's active period. | |
| bool | PWM0_SetDutyCycle (uint32_t channel, uint32_t duty) |
| Sets a PWM0 channel's duty cycle (glitch-free while running). | |
| uint32_t | PWM0_GetDutyCycle (uint32_t channel) |
| Reads a PWM0 channel's active duty cycle. | |
| uint32_t | PWM0_GetCounter (uint32_t channel) |
| Reads a PWM0 channel's live counter value. | |
| bool | PWM0_SetChannelClock (uint32_t channel, uint32_t source) |
| Selects a PWM0 channel's input clock source. | |
| bool | PWM0_SetChannelAlignment (uint32_t channel, uint32_t alignment) |
| Selects a PWM0 channel's waveform alignment. | |
| bool | PWM0_SetChannelPolarity (uint32_t channel, uint32_t polarity) |
| Selects a PWM0 channel's output polarity (glitch-free while running). | |
| bool | PWM0_SetCounterEventSelection (uint32_t channel, uint32_t event) |
| Selects when a PWM0 channel generates its counter (period) event. | |
| bool | PWM0_SetUpdateSelection (uint32_t channel, uint32_t selection) |
| Selects a PWM0 channel's synchronous update timing. | |
| bool | PWM0_SetDisabledPolarity (uint32_t channel, bool inverted) |
| Inverts a PWM0 channel's disabled-state output level. | |
| bool | PWM0_SetCounterTriggerSelection (uint32_t channel, uint32_t selection) |
| Selects a PWM0 channel's timer-counter trigger source. | |
| bool | PWM0_ConfigureClockA (uint32_t prescaler, uint32_t divider) |
| Configures the CLKA linear clock generator (source/prescaler/divider). | |
| bool | PWM0_ConfigureClockB (uint32_t prescaler, uint32_t divider) |
| Configures the CLKB linear clock generator (source/prescaler/divider). | |
| bool | PWM0_SetDeadTime (uint32_t channel, uint16_t high, uint16_t low) |
| Sets a PWM0 channel's dead-time (glitch-free while running). | |
| bool | PWM0_EnableDeadTime (uint32_t channel, bool invert_high, bool invert_low) |
| Enables a PWM0 channel's dead-time generator. | |
| bool | PWM0_DisableDeadTime (uint32_t channel) |
| Disables a PWM0 channel's dead-time generator. | |
| bool | PWM0_EnablePushPull (uint32_t channel) |
| Enables push-pull output mode on a PWM0 channel. | |
| bool | PWM0_DisablePushPull (uint32_t channel) |
| Disables push-pull output mode on a PWM0 channel. | |
| bool | PWM0_EnableOutputOverride (uint32_t channel, bool pwmh_level, bool pwml_level) |
| Forces a PWM0 channel's PWMH/PWML outputs to fixed levels. | |
| bool | PWM0_GetOutputOverrideValues (uint32_t channel, bool *pwmh_level, bool *pwml_level) |
| Reads the forced output levels programmed for a PWM0 channel. | |
| bool | PWM0_OutputOverrideIsEnabled (uint32_t channel, bool *pwmh_active, bool *pwml_active) |
| Reads whether output override is currently active on a PWM0 channel. | |
| bool | PWM0_DisableOutputOverride (uint32_t channel) |
| Releases the output override on a PWM0 channel. | |
| bool | PWM0_EnableSyncChannel (uint32_t channel) |
| Adds a channel to the PWM0 synchronous group (shares channel 0's counter). | |
| bool | PWM0_DisableSyncChannel (uint32_t channel) |
| Removes a channel from the PWM0 synchronous group. | |
| bool | PWM0_SetSyncUpdateMode (uint32_t mode) |
| Selects the synchronous-channels update method. | |
| bool | PWM0_SetSyncUpdatePeriod (uint32_t update_period) |
| Sets the automatic update period for the synchronous channels. | |
| void | PWM0_TriggerSyncUpdate (void) |
| Triggers a synchronous update of the double-buffered registers. | |
| bool | PWM0_SetCompareValue (uint32_t unit, uint32_t value) |
| Sets a PWM0 comparison unit's value (glitch-free while running). | |
| bool | PWM0_ConfigureCompare (uint32_t unit, uint32_t value_mode, uint32_t trigger, uint32_t period, uint32_t update_period) |
| Configures a PWM0 comparison unit's mode, trigger and periodicity. | |
| bool | PWM0_EnableCompare (uint32_t unit) |
| Enables a PWM0 comparison unit. | |
| bool | PWM0_DisableCompare (uint32_t unit) |
| Disables a PWM0 comparison unit. | |
| bool | PWM0_ConfigureEventLine (uint32_t line, uint32_t compare_mask) |
| Selects which comparison units drive a PWM0 event line. | |
| bool | PWM0_ConfigureFault (uint32_t fault, bool polarity, bool activation_mode, bool filter_enable) |
| Configures one PWM0 fault input's polarity, activation mode and filter. | |
| bool | PWM0_EnableFaultProtection (uint32_t channel, uint32_t fault_mask) |
| Selects which fault inputs trip fault protection on a PWM0 channel. | |
| bool | PWM0_DisableFaultProtection (uint32_t channel, uint32_t fault_mask) |
| Clears the selected fault inputs from tripping fault protection on a PWM0 channel, leaving the other fault inputs' enable state unchanged. | |
| bool | PWM0_SetFaultOutputValues (uint32_t channel, bool pwmh_level, bool pwml_level, bool pwmh_high_z, bool pwml_high_z) |
| Sets the forced output levels for a PWM0 channel during a fault. | |
| uint32_t | PWM0_GetFaultStatus (void) |
| Reads the PWM0 fault status register. | |
| void | PWM0_ClearFault (uint32_t fault_mask) |
| Clears latched PWM0 fault status. | |
| bool | PWM0_ConfigureExternalTrigger (uint32_t channel, uint32_t source, uint32_t mode, uint32_t edge, uint32_t filter) |
| Configures the external trigger source/mode/edge/filter for PWM0 channel 1 or 2. | |
| bool | PWM0_ConfigureLeadingEdgeBlanking (uint32_t channel, uint32_t delay, uint32_t edges) |
| Configures leading-edge blanking for PWM0 channel 1 or 2. | |
| bool | PWM0_EnableRecoverableFault (uint32_t channel) |
| Enables recoverable fault on PWM0 channel 1 or 2. | |
| bool | PWM0_DisableRecoverableFault (uint32_t channel) |
| Disables recoverable fault on PWM0 channel 1 or 2. | |
| uint32_t | PWM0_GetMaxTriggerCount (uint32_t channel) |
| Reads (and clears) the peak counter value captured by the external trigger on PWM0 channel 1 or 2. | |
| bool | PWM0_EnableStepperMode (uint32_t pair, bool count_down) |
| Enables gray-code stepper mode on a PWM0 channel pair. | |
| bool | PWM0_DisableStepperMode (uint32_t pair) |
| Disables gray-code stepper mode on a PWM0 channel pair. | |
| bool | PWM0_ConfigureSpreadSpectrum (uint32_t range, uint32_t mode) |
| Configures spread-spectrum modulation of the channel-0 period. | |
| bool | PWM0_SetSpreadSpectrumUpdate (uint32_t range) |
| Updates the spread-spectrum limit while channel 0 is running. | |
| bool | PWM0_WriteDMADutyCycle (uint32_t value) |
| Writes a duty-cycle value to the PWM0 DMA holding register. | |
| bool | PWM0_ConfigureDMARequest (bool on_comparison, uint32_t compare_select) |
| Selects the DMA transfer-request source for the synchronous channels. | |
| void | PWM0_EnableInterrupt (PWM_INTERRUPT_FLAGS interrupt_mask) |
| Enables one or more PWM0 interrupt sources. | |
| void | PWM0_DisableInterrupt (PWM_INTERRUPT_FLAGS interrupt_mask) |
| Disables one or more PWM0 interrupt sources. | |
| PWM_INTERRUPT_FLAGS | PWM0_GetInterruptMask (void) |
| Returns the mask of currently-enabled PWM0 interrupt sources. | |
| PWM_INTERRUPT_FLAGS | PWM0_GetInterruptStatus (void) |
| Reads and clears the pending PWM0 interrupt status flags. | |
| void | PWM0_SetCallbackHandler (PWM_CALLBACK callback) |
| Registers a function to be called from the PWM0 interrupt handler. | |
| bool | PWM0_EnableWriteProtection (uint32_t groups, bool hardware) |
| Enables write protection on the selected PWM0 register groups. | |
| bool | PWM0_DisableWriteProtection (uint32_t groups) |
| Disables software write protection on the selected PWM0 register groups. | |
| uint32_t | PWM0_GetWriteProtectionStatus (void) |
| Reads the PWM0 write-protection status register. | |
Variables | |
| uint32_t | PWM_INTERRUPT_FLAGS::channel_events |
| Bank 1 flags: channel period (CHIDx) and fault (FCHIDx) sources. | |
| uint32_t | PWM_INTERRUPT_FLAGS::compare_events |
| Bank 2 flags: sync-update (WRDY/UNRE) and comparison (CMPMx/CMPUx) sources. | |
Driver API for PWM (plib_pwm0.h)
The following example demonstrates typical usage of the PWM peripheral:
| #define PWM_CHANNEL_0 ((uint32_t)0U) |
| #define PWM_CHANNEL_1 ((uint32_t)1U) |
| #define PWM_CHANNEL_2 ((uint32_t)2U) |
| #define PWM_CHANNEL_3 ((uint32_t)3U) |
| #define PWM_CHANNEL_COUNTER_MAX (0xFFFFU) |
| #define PWM_FAULT_INPUT_COUNT (8U) /* Fault inputs (width of FMR FPOL/FMOD/FFIL) */ |
| #define PWM_STEPPER_PAIR_COUNT (2U) /* Gray-count channel pairs (SMMR GCEN0/GCEN1) */ |
| #define PWM_WP_GROUP_ALL ((uint32_t)(PWM_WPCR_WPRG_Msk >> PWM_WPCR_WPRG_Pos)) |
| typedef void(* PWM_CALLBACK) (PWM_INTERRUPT_FLAGS int_cause) |
PWM interrupt callback handler type.
| int_cause | PWM interrupt-cause flags that triggered the callback. |
| void PWM0_ClearFault | ( | uint32_t | fault_mask | ) |
Clears latched PWM0 fault status.
| fault_mask | Bitmask of fault inputs to clear (bit i clears fault i, 0..7). |
| bool PWM0_ConfigureClockA | ( | uint32_t | prescaler, |
| uint32_t | divider ) |
Configures the CLKA linear clock generator (source/prescaler/divider).
| prescaler | One of the PWM_CLK_PREA_* device macros. |
| divider | Linear divide factor (0..255); 0 turns CLKA off. |
true on success; false if divider exceeds 255. | bool PWM0_ConfigureClockB | ( | uint32_t | prescaler, |
| uint32_t | divider ) |
Configures the CLKB linear clock generator (source/prescaler/divider).
| prescaler | One of the PWM_CLK_PREB_* device macros. |
| divider | Linear divide factor (0..255); 0 turns CLKB off. |
true on success; false if divider exceeds 255. | bool PWM0_ConfigureCompare | ( | uint32_t | unit, |
| uint32_t | value_mode, | ||
| uint32_t | trigger, | ||
| uint32_t | period, | ||
| uint32_t | update_period ) |
Configures a PWM0 comparison unit's mode, trigger and periodicity.
| unit | Comparison-unit index (0..7). |
| value_mode | PWM_CMPV_CVM_COMPARE_AT_INCREMENT or _AT_DECREMENT. |
| trigger | Comparison trigger value CTR (0..15). |
| period | Comparison period CPR (0..15); matches every CPR+1 periods. |
| update_period | Comparison update period CUPR (0..15). |
true on success; false if unit, trigger, period, or update_period is out of range. | bool PWM0_ConfigureDMARequest | ( | bool | on_comparison, |
| uint32_t | compare_select ) |
Selects the DMA transfer-request source for the synchronous channels.
| on_comparison | true requests on a comparison match; false on the synchronous-update event. |
| compare_select | Comparison unit used when on_comparison is true (0..7). |
true on success; false if channel 0 is running or compare_select is out of range. | bool PWM0_ConfigureEventLine | ( | uint32_t | line, |
| uint32_t | compare_mask ) |
Selects which comparison units drive a PWM0 event line.
| line | Event-line index (0..1). |
| compare_mask | Bitmask of comparison units (bit i selects unit i, 0..7). |
true on success; false if line is out of range. | bool PWM0_ConfigureExternalTrigger | ( | uint32_t | channel, |
| uint32_t | source, | ||
| uint32_t | mode, | ||
| uint32_t | edge, | ||
| uint32_t | filter ) |
Configures the external trigger source/mode/edge/filter for PWM0 channel 1 or 2.
| channel | Channel index (1 or 2 only). |
| source | Trigger source (PWM_ETRG1_TRGSRC_Msk selects the alternate source). |
| mode | PWM_ETRG1_TRGMODE_OFF/MODE1/MODE2/MODE3. |
| edge | PWM_ETRG1_TRGEDGE_FALLING_ZERO or PWM_ETRG1_TRGEDGE_RISING_ONE. |
| filter | PWM_ETRG1_TRGFILT_Msk to filter the input, else 0. |
true on success; false if channel is not 1 or 2. | bool PWM0_ConfigureFault | ( | uint32_t | fault, |
| bool | polarity, | ||
| bool | activation_mode, | ||
| bool | filter_enable ) |
Configures one PWM0 fault input's polarity, activation mode and filter.
| fault | Fault input index (0..7). |
| polarity | true sets the fault-active polarity. |
| activation_mode | true keeps the fault latched until cleared. |
| filter_enable | true enables glitch filtering on the input. |
true on success; false if fault is out of range. | bool PWM0_ConfigureLeadingEdgeBlanking | ( | uint32_t | channel, |
| uint32_t | delay, | ||
| uint32_t | edges ) |
Configures leading-edge blanking for PWM0 channel 1 or 2.
| channel | Channel index (1 or 2 only). |
| delay | Blanking delay in peripheral-clock cycles (0..127). |
| edges | Bitmask of edges to blank (PWM_LEBR1_PWMHREN/HFEN/LREN/LFEN_Msk). |
true on success; false if channel is not 1 or 2 or delay > 127. | bool PWM0_ConfigureSpreadSpectrum | ( | uint32_t | range, |
| uint32_t | mode ) |
Configures spread-spectrum modulation of the channel-0 period.
| range | Spread-spectrum limit value (0..0xFFFF). |
| mode | PWM_SSPR_SPRDM_Msk for random mode, or 0 for triangular mode. |
true on success; false if channel 0 is running or range is out of range. | bool PWM0_DisableChannel | ( | uint32_t | channel | ) |
Disables (stops) a single PWM0 channel.
| channel | Channel index (0..3). |
true on success; false if channel is out of range. | bool PWM0_DisableCompare | ( | uint32_t | unit | ) |
Disables a PWM0 comparison unit.
| unit | Comparison-unit index (0..7). |
true on success; false if unit is out of range. | bool PWM0_DisableDeadTime | ( | uint32_t | channel | ) |
Disables a PWM0 channel's dead-time generator.
| channel | Channel index (0..3). |
true on success; false if channel is out of range or running. | bool PWM0_DisableFaultProtection | ( | uint32_t | channel, |
| uint32_t | fault_mask ) |
Clears the selected fault inputs from tripping fault protection on a PWM0 channel, leaving the other fault inputs' enable state unchanged.
| channel | Channel index (0..3). |
| fault_mask | Bitmask of fault inputs to disable (bit i disables fault input i, 0..7). |
true on success; false if channel is out of range. | void PWM0_DisableInterrupt | ( | PWM_INTERRUPT_FLAGS | interrupt_mask | ) |
Disables one or more PWM0 interrupt sources.
| interrupt_mask | Flags to disable (see PWM_INT_* macros). |
| bool PWM0_DisableOutputOverride | ( | uint32_t | channel | ) |
Releases the output override on a PWM0 channel.
| channel | Channel index (0..3). |
true on success; false if channel is out of range. | bool PWM0_DisablePushPull | ( | uint32_t | channel | ) |
Disables push-pull output mode on a PWM0 channel.
| channel | Channel index (0..3). |
true on success; false if channel is out of range or running. | bool PWM0_DisableRecoverableFault | ( | uint32_t | channel | ) |
Disables recoverable fault on PWM0 channel 1 or 2.
| channel | Channel index (1 or 2 only). |
true on success; false if channel is not 1 or 2. | bool PWM0_DisableStepperMode | ( | uint32_t | pair | ) |
Disables gray-code stepper mode on a PWM0 channel pair.
| pair | Channel-pair index (0 or 1). |
true on success; false if pair is out of range. | bool PWM0_DisableSyncChannel | ( | uint32_t | channel | ) |
Removes a channel from the PWM0 synchronous group.
| channel | Channel index (0..3). |
true on success; false if channel is out of range or running. | bool PWM0_DisableWriteProtection | ( | uint32_t | groups | ) |
Disables software write protection on the selected PWM0 register groups.
| groups | Bitmask of register groups to unprotect (6 groups). |
true on success; false if groups has bits set outside the 6 defined groups. | bool PWM0_EnableChannel | ( | uint32_t | channel | ) |
Enables (starts) a single PWM0 channel.
| channel | Channel index (0..3). |
true on success; false if channel is out of range. | bool PWM0_EnableCompare | ( | uint32_t | unit | ) |
Enables a PWM0 comparison unit.
| unit | Comparison-unit index (0..7). |
true on success; false if unit is out of range. | bool PWM0_EnableDeadTime | ( | uint32_t | channel, |
| bool | invert_high, | ||
| bool | invert_low ) |
Enables a PWM0 channel's dead-time generator.
| channel | Channel index (0..3). |
| invert_high | true inverts the PWMH dead-time output. |
| invert_low | true inverts the PWML dead-time output. |
true on success; false if channel is out of range or running. | bool PWM0_EnableFaultProtection | ( | uint32_t | channel, |
| uint32_t | fault_mask ) |
Selects which fault inputs trip fault protection on a PWM0 channel.
| channel | Channel index (0..3). |
| fault_mask | Bitmask of fault inputs (bit i enables fault input i, 0..7). |
true on success; false if channel is out of range. | void PWM0_EnableInterrupt | ( | PWM_INTERRUPT_FLAGS | interrupt_mask | ) |
Enables one or more PWM0 interrupt sources.
| interrupt_mask | Flags to enable (see PWM_INT_* macros). |
| bool PWM0_EnableOutputOverride | ( | uint32_t | channel, |
| bool | pwmh_level, | ||
| bool | pwml_level ) |
Forces a PWM0 channel's PWMH/PWML outputs to fixed levels.
| channel | Channel index (0..3). |
| pwmh_level | Forced level for PWMH (true = high). |
| pwml_level | Forced level for PWML (true = high). |
true on success; false if channel is out of range. | bool PWM0_EnablePushPull | ( | uint32_t | channel | ) |
Enables push-pull output mode on a PWM0 channel.
| channel | Channel index (0..3). |
true on success; false if channel is out of range or running. | bool PWM0_EnableRecoverableFault | ( | uint32_t | channel | ) |
Enables recoverable fault on PWM0 channel 1 or 2.
| channel | Channel index (1 or 2 only). |
true on success; false if channel is not 1 or 2. | bool PWM0_EnableStepperMode | ( | uint32_t | pair, |
| bool | count_down ) |
Enables gray-code stepper mode on a PWM0 channel pair.
| pair | Channel-pair index (0 = channels 0/1, 1 = channels 2/3). |
| count_down | true counts down; false counts up. |
true on success; false if pair is out of range. | bool PWM0_EnableSyncChannel | ( | uint32_t | channel | ) |
Adds a channel to the PWM0 synchronous group (shares channel 0's counter).
| channel | Channel index (0..3). |
true on success; false if channel is out of range or running. | bool PWM0_EnableWriteProtection | ( | uint32_t | groups, |
| bool | hardware ) |
Enables write protection on the selected PWM0 register groups.
| groups | Bitmask of register groups to protect (6 groups). |
| hardware | true for hardware protection (cleared only by a hardware reset); false for software protection. |
true on success; false if groups has bits set outside the 6 defined groups. | uint32_t PWM0_GetCounter | ( | uint32_t | channel | ) |
Reads a PWM0 channel's live counter value.
| channel | Channel index (0..3). |
channel is out of range. | uint32_t PWM0_GetDutyCycle | ( | uint32_t | channel | ) |
Reads a PWM0 channel's active duty cycle.
| channel | Channel index (0..3). |
channel is out of range. | uint32_t PWM0_GetEnabledChannels | ( | void | ) |
Reads the mask of currently-enabled PWM0 channels.
i set means channel i runs). | uint32_t PWM0_GetFaultStatus | ( | void | ) |
Reads the PWM0 fault status register.
| PWM_INTERRUPT_FLAGS PWM0_GetInterruptMask | ( | void | ) |
Returns the mask of currently-enabled PWM0 interrupt sources.
| PWM_INTERRUPT_FLAGS PWM0_GetInterruptStatus | ( | void | ) |
Reads and clears the pending PWM0 interrupt status flags.
| uint32_t PWM0_GetMaxTriggerCount | ( | uint32_t | channel | ) |
Reads (and clears) the peak counter value captured by the external trigger on PWM0 channel 1 or 2.
| channel | Channel index (1 or 2 only). |
channel is not 1 or 2. | bool PWM0_GetOutputOverrideValues | ( | uint32_t | channel, |
| bool * | pwmh_level, | ||
| bool * | pwml_level ) |
Reads the forced output levels programmed for a PWM0 channel.
| channel | Channel index (0..3). |
| pwmh_level | Set to the forced level for PWMH (true = high). |
| pwml_level | Set to the forced level for PWML (true = high). |
true on success; false if channel is out of range or either output pointer is NULL. | uint32_t PWM0_GetPeriod | ( | uint32_t | channel | ) |
Reads a PWM0 channel's active period.
| channel | Channel index (0..3). |
channel is out of range. | uint32_t PWM0_GetWriteProtectionStatus | ( | void | ) |
Reads the PWM0 write-protection status register.
| bool PWM0_OutputOverrideIsEnabled | ( | uint32_t | channel, |
| bool * | pwmh_active, | ||
| bool * | pwml_active ) |
Reads whether output override is currently active on a PWM0 channel.
| channel | Channel index (0..3). |
| pwmh_active | Set to true if PWMH is currently overridden. |
| pwml_active | Set to true if PWML is currently overridden. |
true on success; false if channel is out of range or either output pointer is NULL. | void PWM0_SetCallbackHandler | ( | PWM_CALLBACK | callback | ) |
Registers a function to be called from the PWM0 interrupt handler.
| callback | Callback pointer, or NULL to unregister. |
| bool PWM0_SetChannelAlignment | ( | uint32_t | channel, |
| uint32_t | alignment ) |
Selects a PWM0 channel's waveform alignment.
| channel | Channel index (0..3). |
| alignment | PWM_CMR_CALG_LEFT_ALIGNED or PWM_CMR_CALG_CENTER_ALIGNED. |
true on success; false if channel is out of range or running. | bool PWM0_SetChannelClock | ( | uint32_t | channel, |
| uint32_t | source ) |
Selects a PWM0 channel's input clock source.
| channel | Channel index (0..3). |
| source | One of the PWM_CMR_CPRE_* device macros. |
true on success; false if channel is out of range or running. | bool PWM0_SetChannelPolarity | ( | uint32_t | channel, |
| uint32_t | polarity ) |
Selects a PWM0 channel's output polarity (glitch-free while running).
| channel | Channel index (0..3). |
| polarity | PWM_CMR_CPOL_LOW_POLARITY or PWM_CMR_CPOL_HIGH_POLARITY. |
true on success; false if channel is out of range. | bool PWM0_SetCompareValue | ( | uint32_t | unit, |
| uint32_t | value ) |
Sets a PWM0 comparison unit's value (glitch-free while running).
| unit | Comparison-unit index (0..7). |
| value | Comparison value against the channel-0 counter (0..0xFFFF). |
true on success; false if unit or value is out of range. | bool PWM0_SetCounterEventSelection | ( | uint32_t | channel, |
| uint32_t | event ) |
Selects when a PWM0 channel generates its counter (period) event.
| channel | Channel index (0..3). |
| event | PWM_CMR_CES_SINGLE_EVENT or PWM_CMR_CES_DOUBLE_EVENT. |
true on success; false if channel is out of range or running. | bool PWM0_SetCounterTriggerSelection | ( | uint32_t | channel, |
| uint32_t | selection ) |
Selects a PWM0 channel's timer-counter trigger source.
| channel | Channel index (0..3). |
| selection | 0 or PWM_CMR_TCTS_Msk. |
true on success; false if channel is out of range or running. | bool PWM0_SetDeadTime | ( | uint32_t | channel, |
| uint16_t | high, | ||
| uint16_t | low ) |
Sets a PWM0 channel's dead-time (glitch-free while running).
| channel | Channel index (0..3). |
| high | Dead-time for PWMH, in channel-clock ticks (0..65535). |
| low | Dead-time for PWML, in channel-clock ticks (0..65535). |
true on success; false if channel is out of range. | bool PWM0_SetDisabledPolarity | ( | uint32_t | channel, |
| bool | inverted ) |
Inverts a PWM0 channel's disabled-state output level.
| channel | Channel index (0..3). |
| inverted | true inverts the level driven while disabled. |
true on success; false if channel is out of range or running. | bool PWM0_SetDutyCycle | ( | uint32_t | channel, |
| uint32_t | duty ) |
Sets a PWM0 channel's duty cycle (glitch-free while running).
| channel | Channel index (0..3). |
| duty | Duty value in channel-clock ticks (0..0xFFFF). |
true on success; false if channel or duty is out of range. | bool PWM0_SetFaultOutputValues | ( | uint32_t | channel, |
| bool | pwmh_level, | ||
| bool | pwml_level, | ||
| bool | pwmh_high_z, | ||
| bool | pwml_high_z ) |
Sets the forced output levels for a PWM0 channel during a fault.
| channel | Channel index (0..3). |
| pwmh_level | Forced level for PWMH when not high-impedance. |
| pwml_level | Forced level for PWML when not high-impedance. |
| pwmh_high_z | true drives PWMH to high-impedance on fault. |
| pwml_high_z | true drives PWML to high-impedance on fault. |
true on success; false if channel is out of range. | bool PWM0_SetPeriod | ( | uint32_t | channel, |
| uint32_t | period ) |
Sets a PWM0 channel's period (glitch-free while running).
| channel | Channel index (0..3). |
| period | Period in channel-clock ticks (0..0xFFFF). |
true on success; false if channel or period is out of range. | bool PWM0_SetSpreadSpectrumUpdate | ( | uint32_t | range | ) |
Updates the spread-spectrum limit while channel 0 is running.
| range | Spread-spectrum limit value (0..0xFFFF). |
true on success; false if range exceeds the 16-bit field. | bool PWM0_SetSyncUpdateMode | ( | uint32_t | mode | ) |
Selects the synchronous-channels update method.
| mode | PWM_SCM_UPDM_MODE0, MODE1 or MODE2. |
true on success; false if mode is invalid. | bool PWM0_SetSyncUpdatePeriod | ( | uint32_t | update_period | ) |
Sets the automatic update period for the synchronous channels.
| update_period | Update period, in PWM periods (0..15). |
true on success; false if update_period exceeds 15. | bool PWM0_SetUpdateSelection | ( | uint32_t | channel, |
| uint32_t | selection ) |
Selects a PWM0 channel's synchronous update timing.
| channel | Channel index (0..3). |
| selection | PWM_CMR_UPDS_UPDATE_AT_PERIOD or PWM_CMR_UPDS_UPDATE_AT_HALF_PERIOD. |
true on success; false if channel is out of range or running. | void PWM0_TriggerSyncUpdate | ( | void | ) |
Triggers a synchronous update of the double-buffered registers.
| bool PWM0_WriteDMADutyCycle | ( | uint32_t | value | ) |
Writes a duty-cycle value to the PWM0 DMA holding register.
| value | Duty-cycle value (0..0xFFFF). |
true on success; false if value exceeds the 16-bit field. | uint32_t PWM_INTERRUPT_FLAGS::channel_events |
Bank 1 flags: channel period (CHIDx) and fault (FCHIDx) sources.
| uint32_t PWM_INTERRUPT_FLAGS::compare_events |
Bank 2 flags: sync-update (WRDY/UNRE) and comparison (CMPMx/CMPUx) sources.