29 #include "ftm_hw_access.h"
52 uint8_t hwChannel = 0U;
53 uint8_t chnlPairNum = 0U;
60 FTM_DRV_SetCpwms(ftmBase,
false);
62 FTM_DRV_ClearTimerOverflow(ftmBase);
63 FTM_DRV_SetCounterInitVal(ftmBase, 0U);
65 FTM_DRV_SetCounter(ftmBase, 0U);
66 FTM_DRV_SetQuadDecoderCmd(ftmBase,
false);
71 chnlPairNum = (uint8_t)(hwChannel >> 1U);
72 FTM_DRV_SetDualChnMofCombineCmd(ftmBase, chnlPairNum,
false);
73 FTM_DRV_SetDualChnCombineCmd(ftmBase, chnlPairNum,
false);
74 FTM_DRV_SetDualEdgeCaptureCmd(ftmBase, chnlPairNum,
false);
78 FTM_DRV_SetChnMSnBAMode(ftmBase, hwChannel, 1U);
82 FTM_DRV_EnablePwmChannelOutputs(ftmBase, hwChannel);
88 FTM_DRV_SetSoftwareTriggerCmd(ftmBase,
true);
115 uint8_t hwChannel = 0U;
121 FTM_DRV_ClearTimerOverflow(ftmBase);
122 FTM_DRV_SetCounterInitVal(ftmBase, 0U);
127 FTM_DRV_SetChnEdgeLevel(ftmBase, hwChannel, (uint8_t)0U);
129 FTM_DRV_SetChnCountVal(ftmBase, hwChannel, 0U);
131 FTM_DRV_DisablePwmChannelOutputs(ftmBase, hwChannel);
135 FTM_DRV_SetMod(ftmBase, 0U);
136 FTM_DRV_SetCounter(ftmBase, 0U);
152 uint16_t nextComparematchValue,
154 bool softwareTrigger)
159 uint16_t compareValue = 0U;
160 uint16_t maxCounterValue;
167 if (nextComparematchValue > (maxCounterValue - counterValue))
169 compareValue = (uint16_t)(nextComparematchValue - (maxCounterValue - counterValue));
173 compareValue = (uint16_t)(counterValue + nextComparematchValue);
178 compareValue = nextComparematchValue;
182 FTM_DRV_SetChnCountVal(
g_ftmBase[instance], channel, compareValue);
183 FTM_DRV_SetSoftwareTriggerCmd(ftmBase, softwareTrigger);
FlexTimer state structure of the driver.
ftm_state_t * ftmStatePtr[(2u)]
Pointer to runtime state structure.
#define FEATURE_FTM_CHANNEL_COUNT
ftm_output_cmp_ch_param_t * outputChannelConfig
ftm_output_compare_mode_t chMode
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).
ftm_output_compare_update_t
FlexTimer input capture type of the next output compare value.
ftm_clock_source_t ftmClockSource
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
#define FTM_INSTANCE_COUNT
ftm_config_mode_t ftmMode
FlexTimer driver PWM parameters.
bool enableExternalTrigger
uint8_t nNumOutputChannels
static uint16_t FTM_DRV_GetMod(const FTM_Type *ftmBase)
Returns the FTM peripheral counter modulo value.
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.
static uint16_t FTM_DRV_GetCounter(const FTM_Type *ftmBase)
Returns the FTM peripheral current counter value.
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.
FTM_Type *const g_ftmBase[(2u)]
Table of base addresses for FTM instances.