Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

This section describes the programming interface of the PDB HAL driver.

Data Structures

struct  pdb_timer_config_t
 Defines the type of structure for basic timer in PDB. More...
 

Enumerations

enum  pdb_status_t {
  kStatus_PDB_Success = 0U,
  kStatus_PDB_InvalidArgument = 1U,
  kStatus_PDB_Failed = 2U
}
 PDB status return codes. More...
 
enum  pdb_load_value_mode_t {
  kPdbLoadValueImmediately = 0U,
  kPdbLoadValueAtModuloCounter = 1U,
  kPdbLoadValueAtNextTrigger = 2U,
  kPdbLoadValueAtModuloCounterOrNextTrigger = 3U
}
 Defines the type of value load mode for the PDB module. More...
 
enum  pdb_clk_prescaler_div_t {
  kPdbClkPreDivBy1 = 0U,
  kPdbClkPreDivBy2 = 1U,
  kPdbClkPreDivBy4 = 2U,
  kPdbClkPreDivBy8 = 3U,
  kPdbClkPreDivBy16 = 4U,
  kPdbClkPreDivBy32 = 5U,
  kPdbClkPreDivBy64 = 6U,
  kPdbClkPreDivBy128 = 7U
}
 Defines the type of prescaler divider for the PDB counter clock. More...
 
enum  pdb_trigger_src_t {
  kPdbTrigger0 = 0U,
  kPdbTrigger1 = 1U,
  kPdbTrigger2 = 2U,
  kPdbTrigger3 = 3U,
  kPdbTrigger4 = 4U,
  kPdbTrigger5 = 5U,
  kPdbTrigger6 = 6U,
  kPdbTrigger7 = 7U,
  kPdbTrigger8 = 8U,
  kPdbTrigger9 = 9U,
  kPdbTrigger10 = 10U,
  kPdbTrigger11 = 11U,
  kPdbTrigger12 = 12U,
  kPdbTrigger13 = 13U,
  kPdbTrigger14 = 14U,
  kPdbSoftTrigger = 15U
}
 Defines the type of trigger source mode for the PDB. More...
 
enum  pdb_clk_prescaler_mult_factor_t {
  kPdbClkPreMultFactorAs1 = 0U,
  kPdbClkPreMultFactorAs10 = 1U,
  kPdbClkPreMultFactorAs20 = 2U,
  kPdbClkPreMultFactorAs40 = 3U
}
 Defines the type of the multiplication source mode for PDB. More...
 

Functions

void PDB_HAL_Init (PDB_Type *base)
 Resets the PDB registers to a known state. More...
 
pdb_status_t PDB_HAL_ConfigTimer (PDB_Type *base, const pdb_timer_config_t *configPtr)
 Configures the PDB timer. More...
 
static void PDB_HAL_SetSoftTriggerCmd (PDB_Type *base)
 Triggers the DAC by software if enabled. More...
 
static void PDB_HAL_Enable (PDB_Type *base)
 Switches on to enable the PDB module. More...
 
static void PDB_HAL_Disable (PDB_Type *base)
 Switches to disable the PDB module. More...
 
static bool PDB_HAL_GetTimerIntFlag (PDB_Type *base)
 Gets the PDB delay interrupt flag. More...
 
static void PDB_HAL_ClearTimerIntFlag (PDB_Type *base)
 Clears the PDB delay interrupt flag. More...
 
static void PDB_HAL_SetLoadValuesCmd (PDB_Type *base)
 Loads the delay registers value for the PDB module. More...
 
static void PDB_HAL_SetTimerModulusValue (PDB_Type *base, uint32_t value)
 Sets the modulus value for the PDB module. More...
 
static uint32_t PDB_HAL_GetTimerValue (PDB_Type *base)
 Gets the PDB counter value of PDB timer. More...
 
static void PDB_HAL_SetValueForTimerInterrupt (PDB_Type *base, uint32_t value)
 Sets the interrupt delay milestone of the PDB counter. More...
 
void PDB_HAL_SetAdcPreTriggerBackToBackEnable (PDB_Type *base, uint32_t chn, uint32_t preChnMask, bool enable)
 Switches to enable the pre-trigger back-to-back mode. More...
 
void PDB_HAL_SetAdcPreTriggerOutputEnable (PDB_Type *base, uint32_t chn, uint32_t preChnMask, bool enable)
 Switches to enable the pre-trigger output. More...
 
void PDB_HAL_SetAdcPreTriggerEnable (PDB_Type *base, uint32_t chn, uint32_t preChnMask, bool enable)
 Switches to enable the pre-trigger. More...
 
static uint32_t PDB_HAL_GetAdcPreTriggerFlags (PDB_Type *base, uint32_t chn, uint32_t preChnMask)
 Gets the flag which indicates whether the PDB counter has reached the pre-trigger delay value. More...
 
void PDB_HAL_ClearAdcPreTriggerFlags (PDB_Type *base, uint32_t chn, uint32_t preChnMask)
 Clears the flag which indicates that the PDB counter has reached the pre-trigger delay value. More...
 
static uint32_t PDB_HAL_GetAdcPreTriggerSeqErrFlags (PDB_Type *base, uint32_t chn, uint32_t preChnMask)
 Gets the flag which indicates whether a sequence error is detected. More...
 
void PDB_HAL_ClearAdcPreTriggerSeqErrFlags (PDB_Type *base, uint32_t chn, uint32_t preChnMask)
 Clears the flag which indicates that a sequence error has been detected. More...
 
void PDB_HAL_SetAdcPreTriggerDelayValue (PDB_Type *base, uint32_t chn, uint32_t preChn, uint32_t value)
 Sets the pre-trigger delay value. More...
 
void PDB_HAL_SetCmpPulseOutEnable (PDB_Type *base, uint32_t pulseChnMask, bool enable)
 Switches to enable the pulse-out trigger. More...
 
static void PDB_HAL_SetCmpPulseOutDelayForHigh (PDB_Type *base, uint32_t pulseChn, uint32_t value)
 Sets the counter delay value for the pulse-out goes high. More...
 
static void PDB_HAL_SetCmpPulseOutDelayForLow (PDB_Type *base, uint32_t pulseChn, uint32_t value)
 Sets the counter delay value for the pulse-out goes low. More...
 

Data Structure Documentation

struct pdb_timer_config_t

Data Fields

pdb_load_value_mode_t loadValueMode
 Select the load mode.
 
bool seqErrIntEnable
 Enable PDB Sequence Error Interrupt.
 
pdb_clk_prescaler_div_t clkPreDiv
 Select the prescaler divider.
 
pdb_clk_prescaler_mult_factor_t clkPreMultFactor
 Select multiplication factor for prescaler.
 
pdb_trigger_src_t triggerInput
 Select the trigger input source.
 
bool continuousModeEnable
 Enable the continuous mode.
 
bool dmaEnable
 Enable the dma for timer.
 
bool intEnable
 Enable the interrupt for timer.
 

Enumeration Type Documentation

Enumerator
kStatus_PDB_Success 

Success.

kStatus_PDB_InvalidArgument 

Invalid argument existed.

kStatus_PDB_Failed 

Execution failed.

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.

Enumerator
kPdbLoadValueImmediately 

Loaded immediately after load operation.

kPdbLoadValueAtModuloCounter 

Loaded when counter hits the modulo after load operation.

kPdbLoadValueAtNextTrigger 

Loaded when detecting an input trigger after load operation.

kPdbLoadValueAtModuloCounterOrNextTrigger 

Loaded when counter hits the modulo or detecting an input trigger after load operation.

Enumerator
kPdbClkPreDivBy1 

Counting divided by multiplication factor selected by MULT.

kPdbClkPreDivBy2 

Counting divided by multiplication factor selected by 2 times of MULT.

kPdbClkPreDivBy4 

Counting divided by multiplication factor selected by 4 times of MULT.

kPdbClkPreDivBy8 

Counting divided by multiplication factor selected by 8 times of MULT.

kPdbClkPreDivBy16 

Counting divided by multiplication factor selected by 16 times of MULT.

kPdbClkPreDivBy32 

Counting divided by multiplication factor selected by 32 times of MULT.

kPdbClkPreDivBy64 

Counting divided by multiplication factor selected by 64 times of MULT.

kPdbClkPreDivBy128 

Counting divided by multiplication factor selected by 128 times of MULT.

Selects the trigger input source for the PDB. The trigger input source can be internal or external (EXTRG pin), or the software trigger.

Enumerator
kPdbTrigger0 

Select trigger-In 0.

kPdbTrigger1 

Select trigger-In 1.

kPdbTrigger2 

Select trigger-In 2.

kPdbTrigger3 

Select trigger-In 3.

kPdbTrigger4 

Select trigger-In 4.

kPdbTrigger5 

Select trigger-In 5.

kPdbTrigger6 

Select trigger-In 6.

kPdbTrigger7 

Select trigger-In 7.

kPdbTrigger8 

Select trigger-In 8.

kPdbTrigger9 

Select trigger-In 8.

kPdbTrigger10 

Select trigger-In 10.

kPdbTrigger11 

Select trigger-In 11.

kPdbTrigger12 

Select trigger-In 12.

kPdbTrigger13 

Select trigger-In 13.

kPdbTrigger14 

Select trigger-In 14.

kPdbSoftTrigger 

Select software trigger.

Selects the multiplication factor of the prescaler divider for the PDB counter clock.

Enumerator
kPdbClkPreMultFactorAs1 

Multiplication factor is 1.

kPdbClkPreMultFactorAs10 

Multiplication factor is 10.

kPdbClkPreMultFactorAs20 

Multiplication factor is 20.

kPdbClkPreMultFactorAs40 

Multiplication factor is 40.

Function Documentation

void PDB_HAL_Init ( PDB_Type *  base)

This function resets the PDB registers to a known state. This state is defined in a reference manual and is power-on-reset value.

Parameters
baseRegister base address for the module.
pdb_status_t PDB_HAL_ConfigTimer ( PDB_Type *  base,
const pdb_timer_config_t configPtr 
)

This function configures the PDB basic timer.

Parameters
baseRegister base address for the module.
configPtrPointer to configuration structure, see to "pdb_timer_config_t".
Returns
Execution status.
static void PDB_HAL_SetSoftTriggerCmd ( PDB_Type *  base)
inlinestatic

If enabled, this function triggers the DAC by using software.

Parameters
baseRegister base address for the module.
static void PDB_HAL_Enable ( PDB_Type *  base)
inlinestatic

This function switches on to enable the PDB module.

Parameters
baseRegister base address for the module.
static void PDB_HAL_Disable ( PDB_Type *  base)
inlinestatic

This function switches to disable the PDB module.

Parameters
baseRegister base address for the module.
static bool PDB_HAL_GetTimerIntFlag ( PDB_Type *  base)
inlinestatic

This function gets the PDB delay interrupt flag.

Parameters
baseRegister base address for the module.
Returns
Flat status, true if the flag is set.
static void PDB_HAL_ClearTimerIntFlag ( PDB_Type *  base)
inlinestatic

This function clears the PDB delay interrupt flag.

Parameters
baseRegister base address for the module.
Returns
Flat status, true if the flag is set.
static void PDB_HAL_SetLoadValuesCmd ( PDB_Type *  base)
inlinestatic

This function sets the LDOK bit and loads the delay registers value. Writing one to this bit updates the internal registers MOD, IDLY, CHnDLYm, DACINTx, and POyDLY with the values written to their buffers. The MOD, IDLY, CHnDLYm, DACINTx, and POyDLY take effect according to the load mode settings.

After one is written to the LDOK bit, the values in the buffers of the above mentioned registers are not effective and cannot be written until the values in the buffers are loaded into their internal registers. The LDOK can be written only when the the PDB is enabled or as alone with it. It is automatically cleared either when the values in the buffers are loaded into the internal registers or when the PDB is disabled.

Parameters
baseRegister base address for the module.
static void PDB_HAL_SetTimerModulusValue ( PDB_Type *  base,
uint32_t  value 
)
inlinestatic

This function sets the modulus value for the PDB module. When the counter reaches the setting value, it is automatically reset to zero. When in continuous mode, the counter begins to increase again.

Parameters
baseRegister base address for the module.
valueThe setting value of upper limit for PDB counter.
static uint32_t PDB_HAL_GetTimerValue ( PDB_Type *  base)
inlinestatic

This function gets the PDB counter value of PDB timer.

Parameters
baseRegister base address for the module.
Returns
The current counter value.
static void PDB_HAL_SetValueForTimerInterrupt ( PDB_Type *  base,
uint32_t  value 
)
inlinestatic

This function sets the interrupt delay milestone of the PDB counter. If enabled, a PDB interrupt is generated when the counter is equal to the setting value.

Parameters
baseRegister base address for the module.
valueThe setting value for interrupt delay milestone of PDB counter.
void PDB_HAL_SetAdcPreTriggerBackToBackEnable ( PDB_Type *  base,
uint32_t  chn,
uint32_t  preChnMask,
bool  enable 
)

This function switches to enable the pre-trigger back-to-back mode.

Parameters
baseRegister base address for the module.
chnADC instance index for trigger.
preChnMaskADC channel group index mask for trigger.
enableSwitcher to assert the feature.
void PDB_HAL_SetAdcPreTriggerOutputEnable ( PDB_Type *  base,
uint32_t  chn,
uint32_t  preChnMask,
bool  enable 
)

This function switches to enable pre-trigger output.

Parameters
baseRegister base address for the module.
chnADC instance index for trigger.
preChnMaskADC channel group index mask for trigger.
enableSwitcher to assert the feature.
void PDB_HAL_SetAdcPreTriggerEnable ( PDB_Type *  base,
uint32_t  chn,
uint32_t  preChnMask,
bool  enable 
)

This function switches to enable the pre-trigger.

Parameters
baseRegister base address for the module.
chnADC instance index for trigger.
preChnMaskADC channel group index mask for trigger.
enableSwitcher to assert the feature.
static uint32_t PDB_HAL_GetAdcPreTriggerFlags ( PDB_Type *  base,
uint32_t  chn,
uint32_t  preChnMask 
)
inlinestatic

This function gets the flag which indicates the PDB counter has reached the pre-trigger delay value.

Parameters
baseRegister base address for the module.
chnADC instance index for trigger.
preChnMaskADC channel group index mask for trigger.
Returns
Flag mask. Indicated bit would be 1 if the event is asserted.
void PDB_HAL_ClearAdcPreTriggerFlags ( PDB_Type *  base,
uint32_t  chn,
uint32_t  preChnMask 
)

This function clears the flag which indicates that the PDB counter has reached the pre-trigger delay value.

Parameters
baseRegister base address for the module.
chnADC instance index for trigger.
preChnMaskADC channel group index mask for trigger.
static uint32_t PDB_HAL_GetAdcPreTriggerSeqErrFlags ( PDB_Type *  base,
uint32_t  chn,
uint32_t  preChnMask 
)
inlinestatic

This function gets the flag which indicates whether a sequence error is detected.

Parameters
baseRegister base address for the module.
chnADC instance index for trigger.
preChnMaskADC channel group index mask for trigger.
Returns
Flag mask. Indicated bit would be 1 if the event is asserted.
void PDB_HAL_ClearAdcPreTriggerSeqErrFlags ( PDB_Type *  base,
uint32_t  chn,
uint32_t  preChnMask 
)

This function clears the flag which indicates that the sequence error has been detected.

Parameters
baseRegister base address for the module.
chnADC instance index for trigger.
preChnMaskADC channel group index mask for trigger.
void PDB_HAL_SetAdcPreTriggerDelayValue ( PDB_Type *  base,
uint32_t  chn,
uint32_t  preChn,
uint32_t  value 
)

This function sets the pre-trigger delay value.

Parameters
baseRegister base address for the module.
chnADC instance index for trigger.
preChnADC channel group index for trigger.
valueSetting value for pre-trigger's delay value.
void PDB_HAL_SetCmpPulseOutEnable ( PDB_Type *  base,
uint32_t  pulseChnMask,
bool  enable 
)

This function switches to enable the pulse-out trigger.

Parameters
baseRegister base address for the module.
pulseChnMaskPulse-out channel index mask for trigger.
enableSwitcher to assert the feature.
static void PDB_HAL_SetCmpPulseOutDelayForHigh ( PDB_Type *  base,
uint32_t  pulseChn,
uint32_t  value 
)
inlinestatic

This function sets the counter delay value for the pulse-out goes high.

Parameters
baseRegister base address for the module.
pulseChnPulse-out channel index for trigger.
valueSetting value for PDB delay .
static void PDB_HAL_SetCmpPulseOutDelayForLow ( PDB_Type *  base,
uint32_t  pulseChn,
uint32_t  value 
)
inlinestatic

This function sets the counter delay value for the pulse-out goes low.

Parameters
baseRegister base address for the module.
pulseChnPulse-out channel index for trigger.
valueSetting value for PDB delay .