FlexTimer Input Capture Peripheral Driver.
The FTM of the S32K1xx is based on a 16 bits counter and supports: input capture, output compare, PWM and some instances include quadrature decoder.
For all operation modes (without Quadrature Decoder mode) the user need to configure ftm_user_config_t. This structure will be used for initialization (FTM_DRV_Init). The next functions used are specific for each operation mode.
For this mode the user needs to configure parameters such: maximum counter value, number of channels, input capture operation mode (for single edge input are used edge detect mode) and edge alignment. All this information is included in the ftm_input_param_t structure.
Example:
FTM_DRV_GetInputCaptureMeasurement is now used in interrupt mode and this function is used to save time stamps in internal buffers.
Data Structures | |
struct | ftm_input_ch_param_t |
FlexTimer driver Input capture parameters for each channel. More... | |
struct | ftm_input_param_t |
FlexTimer driver input capture parameters. More... | |
Functions | |
status_t | FTM_DRV_InitInputCapture (uint32_t instance, const ftm_input_param_t *param) |
Configures Channel Input Capture for either getting time-stamps on edge detection or on signal measurement . When the edge specified in the captureMode argument occurs on the channel the FTM counter is captured into the CnV register. The user will have to read the CnV register separately to get this value. The filter function is disabled if the filterVal argument passed in is 0. The filter function is available only on channels 0,1,2,3. More... | |
status_t | FTM_DRV_DeinitInputCapture (uint32_t instance, const ftm_input_param_t *param) |
Disables input capture mode and clears FTM timer configuration. More... | |
uint16_t | FTM_DRV_GetInputCaptureMeasurement (uint32_t instance, uint8_t channel) |
This function is used to calculate the measurement and/or time stamps values which are read from the C(n, n+1)V registers and stored to the static buffers. More... | |
status_t | FTM_DRV_StartNewSignalMeasurement (uint32_t instance, uint8_t channel) |
Starts new single-shot signal measurement of the given channel. More... | |
status_t | FTM_IC_DRV_SetChannelMode (uint32_t instance, uint8_t channel, ftm_ic_op_mode_t inputMode, bool enableContinuousCapture) |
Set mode operation for channel in the input captue mode. More... | |
FlexTimer input capture edge mode, rising edge, or falling edge.
Implements : ftm_edge_alignment_mode_t_Class
Enumerator | |
---|---|
FTM_NO_PIN_CONTROL |
No trigger |
FTM_RISING_EDGE |
Rising edge trigger |
FTM_FALLING_EDGE |
Falling edge trigger |
FTM_BOTH_EDGES |
Rising and falling edge trigger |
Definition at line 70 of file ftm_ic_driver.h.
enum ftm_ic_op_mode_t |
The measurement type for input capture mode Implements : ftm_ic_op_mode_t_Class.
Definition at line 82 of file ftm_ic_driver.h.
enum ftm_input_op_mode_t |
FTM status.
Implements : ftm_input_op_mode_t_Class
Enumerator | |
---|---|
FTM_EDGE_DETECT |
FTM edge detect |
FTM_SIGNAL_MEASUREMENT |
FTM signal measurement |
FTM_NO_OPERATION |
FTM no operation |
Definition at line 44 of file ftm_ic_driver.h.
FlexTimer input capture measurement type for dual edge input capture.
Implements : ftm_signal_measurement_mode_t_Class
Definition at line 56 of file ftm_ic_driver.h.
status_t FTM_DRV_DeinitInputCapture | ( | uint32_t | instance, |
const ftm_input_param_t * | param | ||
) |
Disables input capture mode and clears FTM timer configuration.
[in] | instance | The FTM peripheral instance number. |
[in] | param | Configuration of the output compare channel. |
Definition at line 285 of file ftm_ic_driver.c.
uint16_t FTM_DRV_GetInputCaptureMeasurement | ( | uint32_t | instance, |
uint8_t | channel | ||
) |
This function is used to calculate the measurement and/or time stamps values which are read from the C(n, n+1)V registers and stored to the static buffers.
[in] | instance | The FTM peripheral instance number. |
[in] | channel | For getting the time stamp of the last edge (in normal input capture) this parameter represents the channel number. For getting the last measured value (in dual edge input capture) this parameter is the lowest channel number of the pair (EX: 0, 2, 4, 6). |
Definition at line 337 of file ftm_ic_driver.c.
status_t FTM_DRV_InitInputCapture | ( | uint32_t | instance, |
const ftm_input_param_t * | param | ||
) |
Configures Channel Input Capture for either getting time-stamps on edge detection or on signal measurement . When the edge specified in the captureMode argument occurs on the channel the FTM counter is captured into the CnV register. The user will have to read the CnV register separately to get this value. The filter function is disabled if the filterVal argument passed in is 0. The filter function is available only on channels 0,1,2,3.
[in] | instance | The FTM peripheral instance number. |
[in] | param | Configuration of the input capture channel. |
Definition at line 136 of file ftm_ic_driver.c.
status_t FTM_DRV_StartNewSignalMeasurement | ( | uint32_t | instance, |
uint8_t | channel | ||
) |
Starts new single-shot signal measurement of the given channel.
[in] | instance | The FTM peripheral instance number. |
[in] | channel | Configuration of the output compare channel. |
Definition at line 361 of file ftm_ic_driver.c.
status_t FTM_IC_DRV_SetChannelMode | ( | uint32_t | instance, |
uint8_t | channel, | ||
ftm_ic_op_mode_t | inputMode, | ||
bool | enableContinuousCapture | ||
) |
Set mode operation for channel in the input captue mode.
This function will change the channel mode at run time or when stopping channel. The channel mode is selected in the ftm_ic_op_mode_t enumeration type.
[in] | instance | The input capture instance number. |
[in] | channel | The channel number. |
[in] | inputMode | The channel operation mode. |
[in] | enableContinuousCapture | Enable/disable the continuous capture mode. |
Definition at line 399 of file ftm_ic_driver.c.