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 index. 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.
uint16_t | pgInstance: Instance of the PWM generator (e.g. 1 = PG1, 2=PG2, etc.) |
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 (e.g. 1 = PG1, 2=PG2, etc.) |
struct | P33C_PWM_GENERATOR_s: generic PWM generator Special Function Register set |
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.
struct | P33C_PWM_GENERATOR_s* pg |
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.
uint16_t | pgInstance: Instance of the PWM generator (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.
struct | P33C_PWM_GENERATOR_s* pg |
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)
struct | P33C_PWM_GENERATOR_s* pg: Pointer to PWM generator instance SFRs |
This function identify the group toi which PWM generator belongs (1 = [PG1-PG4], 2 = [PG5-PG8]) and verify if the PWMgenerator group is valid and available. If no group is found, the function returns '0'
Definition at line 614 of file p33c_pwm.c.
struct P33C_PWM_GENERATOR_s * p33c_PwmGenerator_GetHandle | ( | volatile uint16_t | pgInstance | ) |
Returns the PWM generator index.
uint16_t | pgInstance: Index of the selected PWM generator (1=PG1, 2=PG2, etc.) |
This function returns the PWM generator index, the PWM generator group (1 = [PG1-PG4], 2 = [PG5-PG8]) and the address pointer (pgHandle) of the PWM generator Special Function Register set. pgHandle can be used 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 index.
volatile uint16_t p33c_PwmGenerator_GetInstance(volatile struct P33C_PWM_GENERATOR_s* pg)
struct | P33C_PWM_GENERATOR_s* pg: Pointer to PWM generator instance SFRs |
This function gets the PWM generator index, the PWM generator group (1 = [PG1-PG4], 2 = [PG5-PG8]) and the address pointer (pgInstance) of the PWM generator Special Function Register set. pgInstance can be used to directly read from/write to PWM registers of the selected PWM generator with zero API overhead.
Definition at line 582 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.
uint16_t | pgInstance: Instance of the PWM generator (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.
struct | P33C_PWM_GENERATOR_s* pg |
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.
struct | P33C_PWM_GENERATOR_s* pg |
uint16_t | dead_time_rising / |
uint16_t | dead_time_falling |
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.
struct | P33C_PWM_GENERATOR_s* pg |
uint16_t | duty |
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.
struct | P33C_PWM_GENERATOR_s* pg |
uint16_t | period: Counter compare value of the 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.
struct | P33C_PWM_GENERATOR_s* pg |
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.
struct | P33C_PWM_GENERATOR_s* pgHandleMother: PWM generator object of triggering PWM generator (sync trigger provider) |
uint16_t | pgMotherTriggerOutput: Trigger output selection of sync trigger provider PWM generator 0 = EOC/SOC 1 = PGxTRIGA 2 = PGxTRIGB 3 = PGxTRIGC |
struct | P33C_PWM_GENERATOR_s* pgHandleChild: PWM generator object of triggered PWM generator (sync trigger receiver) |
bool | 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 672 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.
struct | P33C_PWM_MODULE_s pwmConfig |
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.