FlexTimer Quadrature Decoder 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 like: maximum counter value, initial counter value, mode (Count and Direction Encoding mode), and for both input phases polarity and filtering. All this information is included in ftm_quad_decode_config_t. In this mode, the counter is clocked by the phase A and phase B. The current state of the decoder can be obtained using FTM_DRV_QuadGetState.
In count and direction mode if initial value of the PHASE_A is HIGH the counter will be incremented.
Example:
Data Structures | |
struct | ftm_phase_params_t |
FlexTimer quadrature decoder channel parameters. More... | |
struct | ftm_quad_decode_config_t |
FTM quadrature configure structure. More... | |
struct | ftm_quad_decoder_state_t |
FTM quadrature state(counter value and flags) More... | |
Functions | |
status_t | FTM_DRV_QuadDecodeStart (uint32_t instance, const ftm_quad_decode_config_t *config) |
Configures the quadrature mode and starts measurement. More... | |
status_t | FTM_DRV_QuadDecodeStop (uint32_t instance) |
De-activates the quadrature decode mode. More... | |
ftm_quad_decoder_state_t | FTM_DRV_QuadGetState (uint32_t instance) |
Return the current quadrature decoder state (counter value, overflow flag and overflow direction) More... | |
status_t FTM_DRV_QuadDecodeStart | ( | uint32_t | instance, |
const ftm_quad_decode_config_t * | config | ||
) |
Configures the quadrature mode and starts measurement.
[in] | instance | Instance number of the FTM module. |
[in] | config | Configuration structure(quadrature decode mode, polarity for both phases, initial and maximum value for the counter, filter configuration). |
Definition at line 50 of file ftm_qd_driver.c.
status_t FTM_DRV_QuadDecodeStop | ( | uint32_t | instance | ) |
De-activates the quadrature decode mode.
[in] | instance | Instance number of the FTM module. |
Definition at line 109 of file ftm_qd_driver.c.
ftm_quad_decoder_state_t FTM_DRV_QuadGetState | ( | uint32_t | instance | ) |
Return the current quadrature decoder state (counter value, overflow flag and overflow direction)
[in] | instance | Instance number of the FTM module. |
Definition at line 130 of file ftm_qd_driver.c.