Programmable Delay Block Peripheral Driver.
This section describes the programming interface of the PDB Peripheral driver. The PDB peripheral driver configures the PDB (Programmable Delay Block). It handles the triggers for ADC and pulse out to the CMP and the PDB counter.
There is one main PDB counter for all triggers. When the indicated external trigger input arrives, the PDB counter launches and is increased by setting clock. The counter trigger milestones for ADC and the PDB counter and wait for the PDB counter. Once the PDB counter hits each milestone, also called the critical delay value, the corresponding event is triggered and the trigger signal is sent out to trigger other peripherals. Therefore, the PDB module is a collector and manager of triggers.
The core feature of the PDB module is a programmable timer/counter. Additional features enable and set the milestone for the corresponding trigger. The user should provide a configuration suitable for the application requirements. Call the API of PDB_DRV_Init() function to initialize the PDB timer/counter.
All triggers share the same counter.
The basic timing/counting step is set when initializing the main PDB counter:
The basic timing/counting step = F_BusClkHz / pdb_timer_config_t.clkPreDiv / pdb_timer_config_t.clkPreMultFactor
The F_BusClkHz is the frequency of bus clock in Hertz. The "clkPreDiv" and "clkPreMultFactor" are in the pdb_timer_config_t structure. All triggering milestones are based on this step.
Three kinds of typical use cases are designed for the PDB module.
These are the examples to initialize and configure the PDB driver for typical use cases.
Normal Timer/Counter:
Trigger for ADC module:
Data Structures | |
struct | pdb_timer_config_t |
Defines the type of structure for basic timer in PDB. More... | |
struct | pdb_adc_pretrigger_config_t |
Defines the type of structure for configuring ADC's pre_trigger. More... | |
Functions | |
void | PDB_DRV_Init (const uint32_t instance, const pdb_timer_config_t *userConfigPtr) |
Initializes the PDB counter and triggers input. More... | |
void | PDB_DRV_Deinit (const uint32_t instance) |
De-initializes the PDB module. More... | |
void | PDB_DRV_GetDefaultConfig (pdb_timer_config_t *const config) |
Gets the default configuration structure of PDB with default settings. More... | |
void | PDB_DRV_Enable (const uint32_t instance) |
Enables the PDB module. More... | |
void | PDB_DRV_Disable (const uint32_t instance) |
Disables the PDB module. More... | |
void | PDB_DRV_SoftTriggerCmd (const uint32_t instance) |
Triggers the PDB with a software trigger. More... | |
uint32_t | PDB_DRV_GetTimerValue (const uint32_t instance) |
Gets the current counter value in the PDB module. More... | |
bool | PDB_DRV_GetTimerIntFlag (const uint32_t instance) |
Gets the PDB interrupt flag. More... | |
void | PDB_DRV_ClearTimerIntFlag (const uint32_t instance) |
Clears the interrupt flag. More... | |
void | PDB_DRV_LoadValuesCmd (const uint32_t instance) |
Executes the command of loading values. More... | |
void | PDB_DRV_SetTimerModulusValue (const uint32_t instance, const uint16_t value) |
Sets the value of timer modulus. More... | |
void | PDB_DRV_SetValueForTimerInterrupt (const uint32_t instance, const uint16_t value) |
Sets the value for the timer interrupt. More... | |
void | PDB_DRV_ConfigAdcPreTrigger (const uint32_t instance, const uint32_t chn, const pdb_adc_pretrigger_config_t *configPtr) |
Configures the ADC pre_trigger in the PDB module. More... | |
uint32_t | PDB_DRV_GetAdcPreTriggerFlags (const uint32_t instance, const uint32_t chn, const uint32_t preChnMask) |
Gets the ADC pre_trigger flag in the PDB module. More... | |
void | PDB_DRV_ClearAdcPreTriggerFlags (const uint32_t instance, const uint32_t chn, const uint32_t preChnMask) |
Clears the ADC pre_trigger flag in the PDB module. More... | |
uint32_t | PDB_DRV_GetAdcPreTriggerSeqErrFlags (const uint32_t instance, const uint32_t chn, const uint32_t preChnMask) |
Gets the ADC pre_trigger flag in the PDB module. More... | |
void | PDB_DRV_ClearAdcPreTriggerSeqErrFlags (const uint32_t instance, const uint32_t chn, const uint32_t preChnMask) |
Clears the ADC pre_trigger flag in the PDB module. More... | |
void | PDB_DRV_SetAdcPreTriggerDelayValue (const uint32_t instance, const uint32_t chn, const uint32_t preChn, const uint32_t value) |
Sets the ADC pre_trigger delay value in the PDB module. More... | |
void | PDB_DRV_SetCmpPulseOutEnable (const uint32_t instance, const uint32_t pulseChnMask, bool enable) |
Switches on/off the CMP pulse out in the PDB module. More... | |
void | PDB_DRV_SetCmpPulseOutDelayForHigh (const uint32_t instance, const uint32_t pulseChn, const uint32_t value) |
Sets the CMP pulse out delay value for high in the PDB module. More... | |
void | PDB_DRV_SetCmpPulseOutDelayForLow (const uint32_t instance, const uint32_t pulseChn, const uint32_t value) |
Sets the CMP pulse out delay value for low in the PDB module. More... | |
Defines the type of prescaler divider for the PDB counter clock. Implements : pdb_clk_prescaler_div_t_Class.
Definition at line 61 of file pdb_driver.h.
Defines the type of the multiplication source mode for PDB.
Selects the multiplication factor of the prescaler divider for the PDB counter clock. Implements : pdb_clk_prescaler_mult_factor_t_Class
Definition at line 92 of file pdb_driver.h.
Defines the type of value load mode for the PDB module.
Some timing related registers, such as the MOD, IDLY, CHnDLYm, INTx and POyDLY, buffer the setting values. Only the load operation is triggered. The setting value is loaded from a buffer and takes effect. There are four loading modes to fit different applications. Implements : pdb_load_value_mode_t_Class
Definition at line 45 of file pdb_driver.h.
enum pdb_trigger_src_t |
Defines the type of trigger source mode for the PDB.
Selects the trigger input source for the PDB. The trigger input source can be internal or the software trigger. Implements : pdb_trigger_src_t_Class
Enumerator | |
---|---|
PDB_TRIGGER_IN0 |
Source trigger comes from TRGMUX. |
PDB_SOFTWARE_TRIGGER |
Select software trigger. |
Definition at line 80 of file pdb_driver.h.
void PDB_DRV_ClearAdcPreTriggerFlags | ( | const uint32_t | instance, |
const uint32_t | chn, | ||
const uint32_t | preChnMask | ||
) |
Clears the ADC pre_trigger flag in the PDB module.
This function clears the ADC pre_trigger flags in the PDB module.
[in] | instance | PDB instance ID. |
[in] | chn | ADC channel. |
[in] | preChnMask | ADC pre_trigger channels mask. |
Definition at line 335 of file pdb_driver.c.
void PDB_DRV_ClearAdcPreTriggerSeqErrFlags | ( | const uint32_t | instance, |
const uint32_t | chn, | ||
const uint32_t | preChnMask | ||
) |
Clears the ADC pre_trigger flag in the PDB module.
This function clears the ADC pre_trigger sequence error flags in the PDB module.
[in] | instance | PDB instance ID. |
[in] | chn | ADC channel. |
[in] | preChnMask | ADC pre_trigger channels mask. |
Definition at line 371 of file pdb_driver.c.
void PDB_DRV_ClearTimerIntFlag | ( | const uint32_t | instance | ) |
Clears the interrupt flag.
This function clears the interrupt flag.
[in] | instance | PDB instance ID. |
Definition at line 234 of file pdb_driver.c.
void PDB_DRV_ConfigAdcPreTrigger | ( | const uint32_t | instance, |
const uint32_t | chn, | ||
const pdb_adc_pretrigger_config_t * | configPtr | ||
) |
Configures the ADC pre_trigger in the PDB module.
This function configures the ADC pre_trigger in the PDB module.
[in] | instance | PDB instance ID. |
[in] | chn | ADC channel. |
[in] | configPtr | Pointer to the user configuration structure. See the "pdb_adc_pretrigger_config_t". |
Definition at line 296 of file pdb_driver.c.
void PDB_DRV_Deinit | ( | const uint32_t | instance | ) |
De-initializes the PDB module.
This function de-initializes the PDB module. Calling this function shuts down the PDB module and reduces the power consumption.
[in] | instance | PDB instance ID. |
Definition at line 111 of file pdb_driver.c.
void PDB_DRV_Disable | ( | const uint32_t | instance | ) |
Disables the PDB module.
This function disables the PDB module, counter is off also.
[in] | instance | PDB instance ID. |
Definition at line 171 of file pdb_driver.c.
void PDB_DRV_Enable | ( | const uint32_t | instance | ) |
Enables the PDB module.
This function enables the PDB module, counter is on.
[in] | instance | PDB instance ID. |
Definition at line 156 of file pdb_driver.c.
uint32_t PDB_DRV_GetAdcPreTriggerFlags | ( | const uint32_t | instance, |
const uint32_t | chn, | ||
const uint32_t | preChnMask | ||
) |
Gets the ADC pre_trigger flag in the PDB module.
This function gets the ADC pre_trigger flags in the PDB module.
[in] | instance | PDB instance ID. |
[in] | chn | ADC channel. |
[in] | preChnMask | ADC pre_trigger channels mask. |
Definition at line 317 of file pdb_driver.c.
uint32_t PDB_DRV_GetAdcPreTriggerSeqErrFlags | ( | const uint32_t | instance, |
const uint32_t | chn, | ||
const uint32_t | preChnMask | ||
) |
Gets the ADC pre_trigger flag in the PDB module.
This function gets the ADC pre_trigger flags in the PDB module.
[in] | instance | PDB instance ID. |
[in] | chn | ADC channel. |
[in] | preChnMask | ADC pre_trigger channels mask. |
Definition at line 353 of file pdb_driver.c.
void PDB_DRV_GetDefaultConfig | ( | pdb_timer_config_t *const | config | ) |
Gets the default configuration structure of PDB with default settings.
This function initializes the hardware configuration structure to default values (Reference Manual Resets). This function should be called before configuring the hardware feature by PDB_DRV_Init() function, otherwise all members be written by user. This function insures that all members are written with safe values, but the user still can modify the desired members.
[out] | config | Pointer to PDB configuration structure. |
Definition at line 128 of file pdb_driver.c.
bool PDB_DRV_GetTimerIntFlag | ( | const uint32_t | instance | ) |
Gets the PDB interrupt flag.
This function gets the PDB interrupt flag. It is asserted if the PDB interrupt occurs.
[in] | instance | PDB instance ID. |
Definition at line 219 of file pdb_driver.c.
uint32_t PDB_DRV_GetTimerValue | ( | const uint32_t | instance | ) |
Gets the current counter value in the PDB module.
This function gets the current counter value.
[in] | instance | PDB instance ID. |
Definition at line 203 of file pdb_driver.c.
void PDB_DRV_Init | ( | const uint32_t | instance, |
const pdb_timer_config_t * | userConfigPtr | ||
) |
Initializes the PDB counter and triggers input.
This function initializes the PDB counter and triggers the input. It resets PDB registers and enables the PDB clock. Therefore, it should be called before any other operation. After it is initialized, the PDB can act as a triggered timer, which enables other features in PDB module.
[in] | instance | PDB instance ID. |
[in] | userConfigPtr | Pointer to the user configuration structure. See the "pdb_user_config_t". |
Definition at line 63 of file pdb_driver.c.
void PDB_DRV_LoadValuesCmd | ( | const uint32_t | instance | ) |
Executes the command of loading values.
This function executes the command of loading values.
[in] | instance | PDB instance ID. |
Definition at line 249 of file pdb_driver.c.
void PDB_DRV_SetAdcPreTriggerDelayValue | ( | const uint32_t | instance, |
const uint32_t | chn, | ||
const uint32_t | preChn, | ||
const uint32_t | value | ||
) |
Sets the ADC pre_trigger delay value in the PDB module.
This function sets Set the ADC pre_trigger delay value in the PDB module.
instance | PDB instance ID. |
chn | ADC channel. |
preChn | ADC pre_channel. |
value | Setting value. |
Definition at line 389 of file pdb_driver.c.
void PDB_DRV_SetCmpPulseOutDelayForHigh | ( | const uint32_t | instance, |
const uint32_t | pulseChn, | ||
const uint32_t | value | ||
) |
Sets the CMP pulse out delay value for high in the PDB module.
This function sets the CMP pulse out delay value for high in the PDB module.
[in] | instance | PDB instance ID. |
[in] | pulseChn | Pulse channel. |
[in] | value | Setting value. |
Definition at line 426 of file pdb_driver.c.
void PDB_DRV_SetCmpPulseOutDelayForLow | ( | const uint32_t | instance, |
const uint32_t | pulseChn, | ||
const uint32_t | value | ||
) |
Sets the CMP pulse out delay value for low in the PDB module.
This function sets the CMP pulse out delay value for low in the PDB module.
[in] | instance | PDB instance ID. |
[in] | pulseChn | Pulse channel. |
[in] | value | Setting value. |
Definition at line 444 of file pdb_driver.c.
void PDB_DRV_SetCmpPulseOutEnable | ( | const uint32_t | instance, |
const uint32_t | pulseChnMask, | ||
bool | enable | ||
) |
Switches on/off the CMP pulse out in the PDB module.
This function switches the CMP pulse on/off in the PDB module.
[in] | instance | PDB instance ID. |
[in] | pulseChnMask | Pulse channel mask. |
[in] | enable | Switcher to assert the feature. |
Definition at line 409 of file pdb_driver.c.
void PDB_DRV_SetTimerModulusValue | ( | const uint32_t | instance, |
const uint16_t | value | ||
) |
Sets the value of timer modulus.
This function sets the value of timer modulus.
[in] | instance | PDB instance ID. |
[in] | value | Setting value. |
Definition at line 264 of file pdb_driver.c.
void PDB_DRV_SetValueForTimerInterrupt | ( | const uint32_t | instance, |
const uint16_t | value | ||
) |
Sets the value for the timer interrupt.
This function sets the value for the timer interrupt.
[in] | instance | PDB instance ID. |
[in] | value | Setting value. |
Definition at line 280 of file pdb_driver.c.
void PDB_DRV_SoftTriggerCmd | ( | const uint32_t | instance | ) |
Triggers the PDB with a software trigger.
This function triggers the PDB with a software trigger. When the PDB is set to use the software trigger as input, calling this function triggers the PDB.
[in] | instance | PDB instance ID. |
Definition at line 188 of file pdb_driver.c.