![]() |
Kinetis SDK v.1.2 API Reference Manual
Rev. 0
Freescale Semiconductor, Inc.
|
This section describes the programming interface of the FlexTimer HAL driver.
Data Structures | |
struct | quadtmr_counter_params_t |
Quad timer counter parameters. More... | |
Enumerations | |
enum | quadtmr_pri_count_source_t { kQuadTmrCntr0InpPin = 0, kQuadTmrCntr1InpPin, kQuadTmrCntr2InpPin, kQuadTmrCntr3InpPin, kQuadTmrCntr0Out, kQuadTmrCntr1Out, kQuadTmrCntr2Out, kQuadTmrCntr3Out, kQuadTmrClkDiv1, kQuadTmrClkDiv2, kQuadTmrClkDiv4, kQuadTmrClkDiv8, kQuadTmrClkDiv16, kQuadTmrClkDiv32, kQuadTmrClkDiv64, kQuadTmrClkDiv128 } |
Quad timer primary clock source selection. | |
enum | quadtmr_input_source_t { kQuadTmr0InpPin = 0, kQuadTmr1InpPin, kQuadTmr2InpPin, kQuadTmr3InpPin } |
Quad timer input sources selection. | |
enum | quadtmr_counting_mode_t { kQuadTmrCntNoOper = 0, kQuadTmrCntPriSrcRiseEdge, kQuadTmrCntPriSrcRiseAndFallEdge, kQuadTmrCntPriSrcRiseEdgeSecInpHigh, kQuadTmrQuadCntMode, kQuadTmrCntPriSrcRiseEdgeSecDir, kQuadTmrSecSrcTrigPriCnt, kQuadTmrCascadeCnt } |
Quad timer counting mode selection. More... | |
enum | quadtmr_output_mode_t { kQuadTmrAssertWhenCntActive = 0, kQuadTmrClearOnCompare, kQuadTmrSetOnCompare, kQuadTmrTogOnCompare, kQuadTmrTogOnAltCompReg, kQuadTmrSetOnCompareClearOnSecSrcInp, kQuadTmrSetOnCompareClearOnCntRoll, kQuadTmrEnableGateClk } |
Quad timer output mode selection. More... | |
enum | quadtmr_input_capture_edge_mode_t { kQuadTmrNoCapture = 0, kQuadTmrRisingEdge, kQuadTmrFallingEdge, kQuadTmrRisingAndFallingEdge } |
Quad timers input capture edge mode, rising edge, or falling edge. More... | |
enum | quadtmr_preload_control_t { kQuadTmrNoPreload = 0, kQuadTmrLoadOnComp1, kQuadTmrLoadOnComp2, kQuadTmrReserved } |
Quad timers input capture edge mode, rising edge, or falling edge. More... | |
Functions | |
void | QUADTMR_HAL_Init (TMR_Type *tmrBase) |
Initializes the Quad Timer registers. More... | |
void | QUADTMR_HAL_SetupCounter (TMR_Type *tmrBase, quadtmr_counter_params_t *params, bool src_polarity) |
Sets the Quad timer's counter properties. More... | |
void | QUADTMR_HAL_ForceOutVal (TMR_Type *tmrBase, bool val, bool pol) |
Enables the user to write a value out on the OFLAG pin. More... | |
void | QUADTMR_HAL_OutPulses (TMR_Type *tmrBase, uint16_t numOfPulses, quadtmr_pri_count_source_t src) |
Enables the user to output a certain number of pulses. More... | |
void | QUADTMR_HAL_OutPwmSignal (TMR_Type *tmrBase, quadtmr_pri_count_source_t src, uint16_t highPulseCount, uint16_t lowPulseCount) |
Outputs a PWM signal on the OFLAG pin. More... | |
void | QUADTMR_HAL_SetupInputCapture (TMR_Type *tmrBase, quadtmr_pri_count_source_t countSrc, quadtmr_input_source_t captureSrc, quadtmr_input_capture_edge_mode_t mode, bool inputPol) |
Allows the user to count the source clock cycles until a capture event arrives. More... | |
void | QUADTMR_HAL_SetupComparePreload (TMR_Type *tmrBase, uint8_t compareRegNum, uint16_t preloadVal, quadtmr_preload_control_t preloadProps) |
Sets up the Quad timers compare preload feature. More... | |
static void | QUADTMR_HAL_SetCounter (TMR_Type *tmrBase, uint16_t val) |
Sets the Quad timer current counter value. More... | |
static void | QUADTMR_HAL_SetComp1Val (TMR_Type *tmrBase, uint16_t val) |
Sets the Quad Timer compare register 1 value used in count up mode. More... | |
static void | QUADTMR_HAL_SetComp1PreloadVal (TMR_Type *tmrBase, uint16_t val) |
Sets up the preload register for Quad Timer compare 1 register. More... | |
static void | QUADTMR_HAL_SetComp2Val (TMR_Type *tmrBase, uint16_t val) |
Sets the Quad Timer compare register 2 value used in count up mode. More... | |
static void | QUADTMR_HAL_SetComp2PreloadVal (TMR_Type *tmrBase, uint16_t val) |
Sets up the preload register for Quad Timer compare 2 register. More... | |
static void | QUADTMR_HAL_SetLoadVal (TMR_Type *tmrBase, uint16_t val) |
Sets the Quad timer counter initial value. More... | |
static uint16_t | QUADTMR_HAL_GetHoldVal (TMR_Type *tmrBase) |
Returns the Quad timer peripheral hold regiter value. More... | |
static uint16_t | QUADTMR_HAL_GetCaptureVal (TMR_Type *tmrBase) |
Gets the Quad timer peripherals counter capture value. More... | |
static uint16_t | QUADTMR_HAL_GetCounterVal (TMR_Type *tmrBase) |
Gets the Quad timer peripherals counter value. More... | |
static void | QUADTMR_HAL_SetCountMode (TMR_Type *tmrBase, quadtmr_counting_mode_t mode) |
Sets up the Quad timer counter mode. More... | |
static void | QUADTMR_HAL_SetPriCountSrc (TMR_Type *tmrBase, quadtmr_pri_count_source_t src) |
Sets up the Quad timer primary count source. More... | |
static void | QUADTMR_HAL_SetSecCountSrc (TMR_Type *tmrBase, quadtmr_input_source_t src) |
Sets up the Quad timer secondary count source. More... | |
static void | QUADTMR_HAL_SetCountOnceCmd (TMR_Type *tmrBase, bool once) |
Sets up the count once bit. More... | |
static void | QUADTMR_HAL_SetOutputMode (TMR_Type *tmrBase, quadtmr_output_mode_t mode) |
Sets up the Quad timer output mode. More... | |
static void | QUADTMR_HAL_SetInputPolSelCmd (TMR_Type *tmrBase, bool ips) |
Modifies the Quad timers input polarity select bit. More... | |
static bool | QUADTMR_HAL_GetExtInputSignal (TMR_Type *tmrBase) |
Reads the Quad timers external input signal bit. More... | |
static void | QUADTMR_HAL_SetCaptureMode (TMR_Type *tmrBase, quadtmr_input_capture_edge_mode_t mode) |
Sets the Quad timers input capture mode. More... | |
static void | QUADTMR_HAL_SetOutEnableCmd (TMR_Type *tmrBase, bool enable) |
Modifies the value for the Quad timers output enable bit. More... | |
static void | QUADTMR_HAL_SetInputFilterCnt (TMR_Type *tmrBase, uint8_t cnt) |
Sets input filter sample count. More... | |
static void | QUADTMR_HAL_SetInputFilterPeriod (TMR_Type *tmrBase, uint8_t period) |
Sets input filter sample period. More... | |
struct quadtmr_counter_params_t |
Data Fields | |
uint16_t | counterVal |
Value to be written to the counter register. | |
uint16_t | counterLoadVal |
Value to be loaded into the counter on compare or overflow. | |
uint16_t | countUpCompareVal |
Value to be written to the count up compare register. | |
uint16_t | countDownCompareVal |
Value to be written to the count down compare register. | |
quadtmr_pri_count_source_t | primarySrc |
Specify the primary count source. | |
quadtmr_input_source_t | secondarySrc |
Specify the secondary count source. | |
bool | countOnce |
true: if counter should stop on compare, false: to run repeatedly | |
bool | countLength |
true: re-initialize on compare match, false: count till roll-over | |
bool | countDir |
true: Count down, false: Count up | |
void QUADTMR_HAL_Init | ( | TMR_Type * | tmrBase | ) |
tmrBase | The Quad timer base address pointer |
void QUADTMR_HAL_SetupCounter | ( | TMR_Type * | tmrBase, |
quadtmr_counter_params_t * | params, | ||
bool | src_polarity | ||
) |
The primary source and in some cases secondary clock control how the to increment the counter. The parameters provided by the user will be used to setup counter properties like match value, rollover behaviour, direction. The function will not start the counter, the user will have to make a separate call to QUADTMR_HAL_SetCountMode to set count mode.
tmrBase | The Quad timer base address pointer |
params | Used to setup the counter behaviour. |
src_polarity | true: Source clock will be inverted, false: no inversion of the input signal |
void QUADTMR_HAL_ForceOutVal | ( | TMR_Type * | tmrBase, |
bool | val, | ||
bool | pol | ||
) |
tmrBase | The Quad timer base address pointer |
val | true: high value is written, false: low value is written |
pol | true: invert polarity of the output signal, false: no inversion |
void QUADTMR_HAL_OutPulses | ( | TMR_Type * | tmrBase, |
uint16_t | numOfPulses, | ||
quadtmr_pri_count_source_t | src | ||
) |
The number of pulses to be outputted is provided as an argument. The output pulse stream has the same frequency as the source clock provided.
tmrBase | The Quad timer base address pointer |
numOfPulses | The number of pulses to be outputted on the OFLAG pin |
src | Source clock for the counter that is used to generate the pulse stream |
void QUADTMR_HAL_OutPwmSignal | ( | TMR_Type * | tmrBase, |
quadtmr_pri_count_source_t | src, | ||
uint16_t | highPulseCount, | ||
uint16_t | lowPulseCount | ||
) |
The high and low pulse width values should be a count in terms of number of source clock cycles. The user has to calculate these values based on the source clock frequency, desired PWM frequncy and duty cycle.
tmrBase | The Quad timer base address pointer |
src | Source clock for the counter that is used to generate the PWM signal |
highPulseCount | Specify the number of source clock cycles to get the high period |
low | PulseCount Specify the number of source clock cycles to get the low period |
void QUADTMR_HAL_SetupInputCapture | ( | TMR_Type * | tmrBase, |
quadtmr_pri_count_source_t | countSrc, | ||
quadtmr_input_source_t | captureSrc, | ||
quadtmr_input_capture_edge_mode_t | mode, | ||
bool | inputPol | ||
) |
The count will be stored in the capture register.
tmrBase | The Quad timer base address pointer |
src | Source clock for the counter |
captureSrc | Pin through which we will receive the input signal to trigger the capture |
mode | Specifies which edge of the input signal will trigger a capture |
pol | true: invert polarity of the input signal, false: no inversion |
void QUADTMR_HAL_SetupComparePreload | ( | TMR_Type * | tmrBase, |
uint8_t | compareRegNum, | ||
uint16_t | preloadVal, | ||
quadtmr_preload_control_t | preloadProps | ||
) |
tmrBase | The Quad timer base address pointer |
compareRegNum | Options are 1 or 2, 1=COMP1; 2=COMP2 |
preloadVal | Value to be written to the comparators preload register |
preloadProps | Controls when a compare register is preloaded with the value from the preload reg. |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
val | Quad timer counter value to be set |
|
inlinestatic |
tmrBase | The Quad Timer base address pointer |
val | The value to be set |
|
inlinestatic |
tmrBase | The Quad Timer base address pointer |
val | The value to be set |
|
inlinestatic |
tmrBase | The Quad Timer base address pointer |
val | The value to be set |
|
inlinestatic |
tmrBase | The Quad Timer base address pointer |
val | The value to be set |
|
inlinestatic |
tmrBase | The FTM base address pointer |
val | initial value to be set |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
mode | Count mode, options available in quadtmr_counting_mode_t enum |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
src | Primary count source, options available in the quadtmr_pri_count_source_t enum |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
src | Secondary count source, options available in the quadtmr_input_source_t enum |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
once | true: count until compare and then stop, false: count repeatedly |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
mode | Output mode, options available in the quadtmr_output_mode_t enum |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
ips | true: inverts the input signal polarity, false: no inversion |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
mode | Capture mode, options specified in the quadtmr_input_capture_edge_mode_t enum |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
enable | true: OFLAG output signal driven on pin, false: External pin configured as input |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
count | Input filter sample count |
|
inlinestatic |
tmrBase | The Quad timer base address pointer |
count | Input filter sample period |