FlexTimer Output Compare 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 maximum counter value, number of channels used and output mode for each channel (toggle/clear/set on match). This information is stored in ftm_output_cmp_param_t structure type and are used in FTM_DRV_InitOutputCompare function. Next step is to set a value for comparison with the FTM_DRV_UpdateOutputCompareChannel function.
Example:
Data Structures | |
struct | ftm_output_cmp_ch_param_t |
FlexTimer driver PWM parameters. More... | |
struct | ftm_output_cmp_param_t |
FlexTimer driver PWM parameters. More... | |
Enumerations | |
enum | ftm_output_compare_mode_t { FTM_DISABLE_OUTPUT = 0x00U, FTM_TOGGLE_ON_MATCH = 0x01U, FTM_CLEAR_ON_MATCH = 0x02U, FTM_SET_ON_MATCH = 0x03U } |
FlexTimer Mode configuration for output compare mode. More... | |
enum | ftm_output_compare_update_t { FTM_RELATIVE_VALUE = 0x00U, FTM_ABSOLUTE_VALUE = 0x01U } |
FlexTimer input capture type of the next output compare value. More... | |
Functions | |
status_t | FTM_DRV_InitOutputCompare (uint32_t instance, const ftm_output_cmp_param_t *param) |
Configures the FTM to generate timed pulses(Output compare mode). More... | |
status_t | FTM_DRV_DeinitOutputCompare (uint32_t instance, const ftm_output_cmp_param_t *param) |
Disables compare match output control and clears FTM timer configuration. More... | |
status_t | FTM_DRV_UpdateOutputCompareChannel (uint32_t instance, uint8_t channel, uint16_t nextComparematchValue, ftm_output_compare_update_t update, bool softwareTrigger) |
Sets the next compare match value based on the current counter value. More... | |
FlexTimer Mode configuration for output compare mode.
Implements : ftm_output_compare_mode_t_Class
Enumerator | |
---|---|
FTM_DISABLE_OUTPUT |
No action on output pin |
FTM_TOGGLE_ON_MATCH |
Toggle on match |
FTM_CLEAR_ON_MATCH |
Clear on match |
FTM_SET_ON_MATCH |
Set on match |
Definition at line 44 of file ftm_oc_driver.h.
FlexTimer input capture type of the next output compare value.
Implements : ftm_output_compare_update_t_Class
Enumerator | |
---|---|
FTM_RELATIVE_VALUE |
Next compared value is relative to current value |
FTM_ABSOLUTE_VALUE |
Next compared value is absolute |
Definition at line 57 of file ftm_oc_driver.h.
status_t FTM_DRV_DeinitOutputCompare | ( | uint32_t | instance, |
const ftm_output_cmp_param_t * | param | ||
) |
Disables compare match output control and clears FTM timer configuration.
[in] | instance | The FTM peripheral instance number. |
[in] | param | Configuration of the output compare channel |
Definition at line 108 of file ftm_oc_driver.c.
status_t FTM_DRV_InitOutputCompare | ( | uint32_t | instance, |
const ftm_output_cmp_param_t * | param | ||
) |
Configures the FTM to generate timed pulses(Output compare mode).
When the FTM counter matches the value of CnV, the channel output is changed based on what is specified in the compareMode argument. The signal period can be modified using param->MaxCountValue. After this function max counter value and CnV are equal. FTM_DRV_SetNextComparematchValue function can be used to change CnV value.
[in] | instance | The FTM peripheral instance number. |
[in] | param | configuration of the output compare channels |
Definition at line 45 of file ftm_oc_driver.c.
status_t FTM_DRV_UpdateOutputCompareChannel | ( | uint32_t | instance, |
uint8_t | channel, | ||
uint16_t | nextComparematchValue, | ||
ftm_output_compare_update_t | update, | ||
bool | softwareTrigger | ||
) |
Sets the next compare match value based on the current counter value.
[in] | instance | The FTM peripheral instance number. |
[in] | channel | Configuration of the output compare channel |
[in] | nextComparematchValue | Timer value in ticks until the next compare match event should appear |
[in] | update |
|
[in] | softwareTrigger | This parameter will be true if software trigger sync is enabled and the user want to generate a software trigger (the value from buffer will be moved to register immediate or at next loading point depending on the sync configuration). Otherwise this parameter must be false and the next compared value will be stored in buffer until a trigger signal will be received. |
Definition at line 150 of file ftm_oc_driver.c.