Public functions of the HSPWM PRAL driver. More...
Functions | |
volatile uint16_t | p33c_PwmGenerator_GetInstance (volatile struct P33C_PWM_GENERATOR_s *pg) |
Get the PWM generator instance index of a known PWM object pointer address. More... | |
volatile uint16_t | p33c_PwmGenerator_GetGroup (volatile struct P33C_PWM_GENERATOR_s *pg) |
Get the PWM generator group. More... | |
volatile uint16_t | p33c_PwmModule_Initialize (void) |
Initializes the PWM base module by resetting all its registers to default. More... | |
volatile struct P33C_PWM_MODULE_s * | p33c_PwmModule_GetHandle (void) |
Gets pointer to PWM module SFR set. More... | |
volatile uint16_t | p33c_PwmModule_Dispose (void) |
Resets all PWM base module registers to their RESET default values. More... | |
volatile struct P33C_PWM_MODULE_s | p33c_PwmModule_ConfigRead (void) |
Read the current configuration from the PWM base module registers. More... | |
volatile uint16_t | p33c_PwmModule_ConfigWrite (volatile struct P33C_PWM_MODULE_s pwmConfig) |
Writes a user-defined configuration to the PWM base module registers. More... | |
volatile struct P33C_PWM_GENERATOR_s | p33c_PwmGenerator_ConfigRead (volatile uint16_t pgInstance) |
Disposes a given PWM generator by resetting all its registers to default. More... | |
volatile uint16_t | p33c_PwmGenerator_ConfigWrite (volatile uint16_t pgInstance, volatile struct P33C_PWM_GENERATOR_s pgConfig) |
Disposes a given PWM generator by resetting all its registers to default. More... | |
volatile uint16_t | p33c_PwmGenerator_Initialize (volatile uint16_t pgInstance) |
Initializes a given PWM generator by resetting all its registers to default. More... | |
volatile uint16_t | p33c_PwmGenerator_Dispose (volatile uint16_t pgInstance) |
Disposes a given PWM generator by resetting all its registers to default. More... | |
volatile uint16_t | p33c_PwmGenerator_Enable (volatile struct P33C_PWM_GENERATOR_s *pg) |
Enables a given PWM generator with output pins disabled. More... | |
volatile uint16_t | p33c_PwmGenerator_Disable (volatile struct P33C_PWM_GENERATOR_s *pg) |
Disables a given PWM generator. More... | |
volatile uint16_t | p33c_PwmGenerator_Resume (volatile struct P33C_PWM_GENERATOR_s *pg) |
Disables a PWM generator IOs. More... | |
volatile uint16_t | p33c_PwmGenerator_Suspend (volatile struct P33C_PWM_GENERATOR_s *pg) |
Disables the PWM generator outputs but keeps the module running. More... | |
volatile uint16_t | p33c_PwmGenerator_SetPeriod (volatile struct P33C_PWM_GENERATOR_s *pg, volatile uint16_t period) |
Sets the period of a given PWM generator. More... | |
volatile uint16_t | p33c_PwmGenerator_SetDutyCycle (volatile struct P33C_PWM_GENERATOR_s *pg, volatile uint16_t duty) |
Sets the on-time of a given PWM generator. More... | |
volatile uint16_t | p33c_PwmGenerator_SetDeadTimes (volatile struct P33C_PWM_GENERATOR_s *pg, volatile uint16_t dead_time_rising, volatile uint16_t dead_time_falling) |
Sets the dead-times of a given PWM generator. More... | |
volatile struct P33C_PWM_GENERATOR_s * | p33c_PwmGenerator_GetHandle (volatile uint16_t pgInstance) |
Returns the PWM generator index. More... | |
volatile uint16_t | p33c_PwmGenerator_SyncGenerators (volatile struct P33C_PWM_GENERATOR_s *pgHandleMother, volatile uint16_t pgMotherTriggerOutput, volatile struct P33C_PWM_GENERATOR_s *pgHandleChild, volatile bool ChildImmediateUpdate) |
Sets the synchronization triggers of two PWM generators, of which the Mother PWM generator is the trigger provider and the Child PWM generator is the synchronization trigger receiver. More... | |
Public functions of the HSPWM PRAL driver.
This is the detailed description of public functions of the HSPWM PRAL driver
struct P33C_PWM_GENERATOR_s p33c_PwmGenerator_ConfigRead | ( | volatile uint16_t | pgInstance | ) |
Disposes a given PWM generator by resetting all its registers to default.
pgInstance | Instance of the PWM generator (e.g. 1 = PG1, 2=PG2, etc.) of type unsigned integer |
This function copies the contents of all PWM generator registers of the specified generator instance (e.g. PG2) to a user variable of type P33C_PWM_GENERATOR_t. This 'virtual' PWM configuration can then , for
example, be analyzed and/or modified in user code and applied to another PWM generator using the function p33c_PwmGenerator_ConfigWrite(...).
Definition at line 158 of file p33c_pwm.c.
uint16_t p33c_PwmGenerator_ConfigWrite | ( | volatile uint16_t | pgInstance, |
volatile struct P33C_PWM_GENERATOR_s | pgConfig | ||
) |
Disposes a given PWM generator by resetting all its registers to default.
pgInstance | Instance of the PWM generator of type unsigned integer (e.g. 1=PG1, 2=PG2, etc.) |
pgConfig | Generic PWM generator Special Function Register set of type struct P33C_PWM_GENERATOR_s |
This function writes a user-defined PWM generator configuration of type P33C_PWM_GENERATOR_t to the given PWM generator peripheral instance (e.g. PG2).
Definition at line 217 of file p33c_pwm.c.
uint16_t p33c_PwmGenerator_Disable | ( | volatile struct P33C_PWM_GENERATOR_s * | pg | ) |
Disables a given PWM generator.
pg | Pointer to PWM generator peripheral instance register set of type struct P33C_PWM_GENERATOR_s |
This function disables the PWM Generator and locks its PWM output pins in a safe state.
Definition at line 366 of file p33c_pwm.c.
uint16_t p33c_PwmGenerator_Dispose | ( | volatile uint16_t | pgInstance | ) |
Disposes a given PWM generator by resetting all its registers to default.
pgInstance | Instance of the PWM generator of type unsigned integer (e.g. 1=PG1, 2=PG2, etc.) |
This function disables the specified PWM Generator and clears all its Special Function Registers (SFR) to their RESET default values.
Definition at line 290 of file p33c_pwm.c.
uint16_t p33c_PwmGenerator_Enable | ( | volatile struct P33C_PWM_GENERATOR_s * | pg | ) |
Enables a given PWM generator with output pins disabled.
pg | Pointer to PWM generator peripheral instance register set of type struct P33C_PWM_GENERATOR_s |
This function enables the PWM Generator and adds delay before enabling
PWM output pins. After having successfully enabled the generator, users need to call function PWM_Generator_Resume to allow the PWM generator
Definition at line 316 of file p33c_pwm.c.
volatile uint16_t p33c_PwmGenerator_GetGroup | ( | volatile struct P33C_PWM_GENERATOR_s * | pg | ) |
Get the PWM generator group.
volatile uint16_t p33c_PwmGenerator_GetGroup(volatile struct P33C_PWM_GENERATOR_s* pg)
pg | Pointer to PWM generator peripheral instance register set of type struct P33C_PWM_GENERATOR_s |
This function identify the group to which the PWM generator instance belongs (1 = [PG1-PG4], 2 = [PG5-PG8]) and verifies if the PWMgenerator group is valid and available. If no group is found, the function returns '0'
Definition at line 612 of file p33c_pwm.c.
struct P33C_PWM_GENERATOR_s * p33c_PwmGenerator_GetHandle | ( | volatile uint16_t | pgInstance | ) |
Returns the PWM generator index.
pgInstance | Instance of the PWM generator of type unsigned integer (e.g. 1=PG1, 2=PG2, etc.) |
This function returns the address pointer (pgHandle) of the PWM generator Special Function Register set specified by parameter pgInstance. pgHandle can be used to assign a global variable in user code, which allows to directly read from/write to PWM registers of the selected PWM generator with zero API overhead.
Definition at line 555 of file p33c_pwm.c.
volatile uint16_t p33c_PwmGenerator_GetInstance | ( | volatile struct P33C_PWM_GENERATOR_s * | pg | ) |
Get the PWM generator instance index of a known PWM object pointer address.
volatile uint16_t p33c_PwmGenerator_GetInstance(volatile struct P33C_PWM_GENERATOR_s* pg)
pg | Pointer to PWM generator peripheral instance register set of type struct P33C_PWM_GENERATOR_s |
This function returns the non-zero PWM generator instance index of the PWM generator of the PWM generator Special Function Register set referenced by the pointer address of function parameter pg. If the memory address does not match any available PWM generator instance start address, this function returns '0'.
Definition at line 580 of file p33c_pwm.c.
uint16_t p33c_PwmGenerator_Initialize | ( | volatile uint16_t | pgInstance | ) |
Initializes a given PWM generator by resetting all its registers to default.
pgInstance | Instance of the PWM generator of type unsigned integer (e.g. 1=PG1, 2=PG2, etc.) |
This function initializes the specified PWM Generator with default input clock settings and high resolution mode enabled. All other Special Function Registers (SFR) are reset to their RESET default values.
Definition at line 250 of file p33c_pwm.c.
uint16_t p33c_PwmGenerator_Resume | ( | volatile struct P33C_PWM_GENERATOR_s * | pg | ) |
Disables a PWM generator IOs.
pg | Pointer to PWM generator peripheral instance register set of type struct P33C_PWM_GENERATOR_s |
This function enables the PWM Generator IO instance allowing signals to be routed to the output pins. This on/off transition occurs synchronously to the PWM period.
Definition at line 400 of file p33c_pwm.c.
uint16_t p33c_PwmGenerator_SetDeadTimes | ( | volatile struct P33C_PWM_GENERATOR_s * | pg, |
volatile uint16_t | dead_time_rising, | ||
volatile uint16_t | dead_time_falling | ||
) |
Sets the dead-times of a given PWM generator.
pg | Pointer to PWM generator peripheral instance register set of type struct P33C_PWM_GENERATOR_s |
dead_time_rising | Rising edge dead time counter value of type unsigned integer / |
dead_time_falling | Falling edge dead time counter value of type unsigned integer |
This function writes the value specified by 'duty' to the DUTY CYCLE register of the specified PWM generator.
Definition at line 524 of file p33c_pwm.c.
uint16_t p33c_PwmGenerator_SetDutyCycle | ( | volatile struct P33C_PWM_GENERATOR_s * | pg, |
volatile uint16_t | duty | ||
) |
Sets the on-time of a given PWM generator.
pg | Pointer to PWM generator peripheral instance register set of type struct P33C_PWM_GENERATOR_s |
duty | Duty cycle counter value of type unsigned integer |
This function writes the value specified by 'duty' to the DUTY CYCLE register of the specified PWM generator.
Definition at line 490 of file p33c_pwm.c.
uint16_t p33c_PwmGenerator_SetPeriod | ( | volatile struct P33C_PWM_GENERATOR_s * | pg, |
volatile uint16_t | period | ||
) |
Sets the period of a given PWM generator.
pg | Pointer to PWM generator peripheral instance register set of type struct P33C_PWM_GENERATOR_s |
period | Counter compare value of type unsigned integer of the PWM generator time base |
This function writes the value specified by 'period' to the PERIOD register of the specified PWM generator.
Definition at line 457 of file p33c_pwm.c.
uint16_t p33c_PwmGenerator_Suspend | ( | volatile struct P33C_PWM_GENERATOR_s * | pg | ) |
Disables the PWM generator outputs but keeps the module running.
pg | Pointer to PWM generator peripheral instance register set of type struct P33C_PWM_GENERATOR_s |
This function disables the PWM Generator IO instance preventing signals to be routed to the output pins. This on/off transition occurs synchronously to the PWM period.
Definition at line 428 of file p33c_pwm.c.
uint16_t p33c_PwmGenerator_SyncGenerators | ( | volatile struct P33C_PWM_GENERATOR_s * | pgHandleMother, |
volatile uint16_t | pgMotherTriggerOutput, | ||
volatile struct P33C_PWM_GENERATOR_s * | pgHandleChild, | ||
volatile bool | ChildImmediateUpdate | ||
) |
Sets the synchronization triggers of two PWM generators, of which the Mother PWM generator is the trigger provider and the Child PWM generator is the synchronization trigger receiver.
pgHandleMother | Pointer to PWM generator object of type struct P33C_PWM_GENERATOR_s of triggering PWM generator (sync trigger provider) |
pgMotherTriggerOutput | Trigger output selection of type unsigned integer of Sync Trigger Provider of the selected PWM generator instance 0 = EOC/SOC 1 = PGxTRIGA 2 = PGxTRIGB 3 = PGxTRIGC |
pgHandleChild | Pointer to PWM generator object of type struct P33C_PWM_GENERATOR_s of triggered PWM generator (sync trigger receiver) |
ChildImmediateUpdate | true = synchronization trigger synchronizes Child PWM generator at trigger edge false = synchronization trigger synchronizes Child PWM generator at EOC/SOC |
This function sets the synchronization triggers of two PWM generators, of which the Mother PWM generator is the trigger provider and the Child PWM generator is the synchronization trigger receiver.
The Mother PWM generator is configured to broadcast its UPDATE bit and provides one of four, selectable synchronization trigger outputs (EOC/SOC, PGxTRIGA, PGxTRIGB or PGxTRIGC). The Mother PWM generator can be independent or being triggered by another PWM generator.
The Child PWM generator is configured to trigger on the event generated by the Mother PWM generator as configured above. The optional selection of immediate synchronization or synchronization of the SOC event is set by parameter ChildImmediateUpdate.
Definition at line 670 of file p33c_pwm.c.
struct P33C_PWM_MODULE_s p33c_PwmModule_ConfigRead | ( | void | ) |
Read the current configuration from the PWM base module registers.
This function reads all registers with their current configuration into a data structure of type P33C_PWM_MODULE_s. Users can read and verify of modify the configuration to write it back to the PWM module
base registers.
Definition at line 104 of file p33c_pwm.c.
uint16_t p33c_PwmModule_ConfigWrite | ( | volatile struct P33C_PWM_MODULE_s | pwmConfig | ) |
Writes a user-defined configuration to the PWM base module registers.
pwmConfig | PWM module register set of type struct P33C_PWM_MODULE_s |
This function writes a user-defined PWM module configuration of type P33C_PWM_MODULE_s to the PWM module base registers. The individual register configurations have to be set in user-code before calling this function. To simplify the configuration process of standard functions, this driver provides templates, which can be loaded and written directly (see function p33c_PwmInitialize(void) for details)
Definition at line 158 of file p33c_pwm.c.
uint16_t p33c_PwmModule_Dispose | ( | void | ) |
Resets all PWM base module registers to their RESET default values.
This function clears all PWM module base registers to their default values set when the device comes out of RESET.
Default configuration:
Definition at line 104 of file p33c_pwm.c.
struct P33C_PWM_MODULE_s * p33c_PwmModule_GetHandle | ( | void | ) |
Gets pointer to PWM module SFR set.
This function returns the PWM generator index, the PWM generator group (1 = [PG1-PG4], 2 = [PG5-PG8]) and the address pointer (handle) of the PWM generator Special Function Register set. handle can be used to directly read from/write to PWM registers of the selected PWM generator with zero API overhead.
Definition at line 74 of file p33c_pwm.c.
uint16_t p33c_PwmModule_Initialize | ( | void | ) |
Initializes the PWM base module by resetting all its registers to default.
This function initializes the PWM module base registers with default values for maximum performance.
Default configuration:
Definition at line 50 of file p33c_pwm.c.