97 uint8_t chnlPairNum = 0U;
99 uint8_t hwChannel = 0U;
106 FTM_DRV_SetClockSource(ftmBase, FTM_CLOCK_SOURCE_NONE);
107 FTM_DRV_SetCounterInitVal(ftmBase, 0U);
109 FTM_DRV_SetCpwms(ftmBase,
false);
111 FTM_DRV_SetDualChnMofCombineCmd(ftmBase, chnlPairNum,
false);
112 FTM_DRV_SetDualChnCombineCmd(ftmBase, chnlPairNum,
false);
117 chnlPairNum = (uint8_t)(hwChannel >> 1U);
122 if (hwChannel < CHAN4_IDX)
130 FTM_DRV_SetChnInputCaptureFilter(ftmBase, hwChannel, 0U);
137 FTM_DRV_SetDualEdgeCaptureCmd(ftmBase, chnlPairNum,
false);
139 FTM_DRV_SetChnMSnBAMode(ftmBase, hwChannel, 0U);
145 FTM_DRV_EnableChnInt(ftmBase, hwChannel);
151 FTM_DRV_SetDualEdgeCaptureCmd(ftmBase, chnlPairNum,
true);
153 FTM_DRV_SetDualChnDecapCmd(ftmBase, chnlPairNum,
true);
158 FTM_DRV_SetChnMSnBAMode(ftmBase, hwChannel, 3U);
163 FTM_DRV_SetChnMSnBAMode(ftmBase, hwChannel, 2U);
170 FTM_DRV_SetChnEdgeLevel(ftmBase, hwChannel, 1U);
174 FTM_DRV_SetChnEdgeLevel(ftmBase, (uint8_t)(hwChannel + 1U), 2U);
180 FTM_DRV_SetChnEdgeLevel(ftmBase, (uint8_t)(hwChannel + 1U), 1U);
185 FTM_DRV_SetChnEdgeLevel(ftmBase, hwChannel, 2U);
189 FTM_DRV_SetChnEdgeLevel(ftmBase, (uint8_t)(hwChannel + 1U), 1U);
195 FTM_DRV_SetChnEdgeLevel(ftmBase, (uint8_t)(hwChannel + 1U), 2U);
205 FTM_DRV_EnableChnInt(ftmBase, (uint8_t)(hwChannel + 1U));
242 uint8_t chnlPairNum = 0U;
244 uint8_t hwChannel = 0U;
248 FTM_DRV_SetClockSource(ftmBase, FTM_CLOCK_SOURCE_NONE);
249 FTM_DRV_SetCounterInitVal(ftmBase, 0U);
250 FTM_DRV_SetMod(ftmBase, 0xFFFFU);
251 FTM_DRV_SetCpwms(ftmBase,
false);
255 chnlPairNum = (uint8_t)(hwChannel >> 1U);
257 if (hwChannel < CHAN4_IDX)
259 FTM_DRV_SetChnInputCaptureFilter(ftmBase, hwChannel, 0U);
262 FTM_DRV_SetDualChnCombineCmd(ftmBase, chnlPairNum,
false);
263 FTM_DRV_SetDualEdgeCaptureCmd(ftmBase, chnlPairNum,
false);
264 FTM_DRV_SetChnEdgeLevel(ftmBase, hwChannel, (uint8_t)0U);
265 FTM_DRV_DisableChnInt(ftmBase, hwChannel);
313 uint8_t chnlPairNum = (uint8_t)(channel >> 1U);
321 FTM_DRV_ClearChnEventFlag(ftmBase, (uint8_t)(channel + 1U));
322 FTM_DRV_ClearChnEventFlag(ftmBase, channel);
324 FTM_DRV_SetDualChnDecapCmd(ftmBase, chnlPairNum,
true);
458 if (second_event_time < first_event_time)
466 state->
measurementResults[channelPair << 1U] = (uint16_t)(second_event_time - first_event_time);
470 FTM_DRV_ClearChnEventFlag(ftmBase, (uint8_t)(channelPair << 1U));
471 FTM_DRV_ClearChnEventFlag(ftmBase, (uint8_t)((channelPair << 1U) + 1U));
486 FTM_DRV_ClearChnEventFlag(ftmBase, (uint8_t)(channelPair << 1U));
498 FTM_DRV_ClearChnEventFlag(ftmBase, (uint8_t)((channelPair << 1U) + 1U));
void FTM1_Ch0_Ch1_IRQHandler(void)
#define FTM_FEATURE_INPUT_CAPTURE_SINGLE_SHOT
void FTM2_Ch2_Ch3_IRQHandler(void)
void FTM0_Ch4_Ch5_IRQHandler(void)
static uint16_t FTM_DRV_GetChnCountVal(const FTM_Type *ftmBase, uint8_t channel)
Gets the FTM peripheral timer channel counter value.
FlexTimer state structure of the driver.
void FTM1_Ch4_Ch5_IRQHandler(void)
FTM_Type *const g_ftmBase[FTM_INSTANCE_COUNT]
Table of base addresses for FTM instances.
void FTM2_Ch0_Ch1_IRQHandler(void)
status_t FTM_DRV_StartNewSignalMeasurement(uint32_t instance, uint8_t channel)
Starts new single-shot signal measurement of the given channel.
void FTM1_Ch2_Ch3_IRQHandler(void)
void FTM3_Ch4_Ch5_IRQHandler(void)
ftm_state_t * ftmStatePtr[FTM_INSTANCE_COUNT]
Pointer to runtime state structure.
static void FTM_DRV_InputCaptureHandler(uint32_t instance, uint8_t channelPair)
void FTM3_Ch0_Ch1_IRQHandler(void)
void FTM2_Ch6_Ch7_IRQHandler(void)
static void FTM_DRV_IrqHandler(uint32_t instance, uint8_t channelPair)
#define FEATURE_FTM_CHANNEL_COUNT
void * channelsCallbacksParams[FEATURE_FTM_CHANNEL_COUNT]
void FTM3_Ch2_Ch3_IRQHandler(void)
static uint8_t FTM_DRV_GetChnMode(const FTM_Type *ftmBase, uint8_t channel)
Gets the FTM peripheral timer channel mode.
static bool FTM_DRV_GetDualChnCombineCmd(const FTM_Type *ftmBase, uint8_t chnlPairNum)
Verify if an channels pair is used in combine mode or not.
ftm_clock_source_t ftmClockSource
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 measur...
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
#define FTM_INSTANCE_COUNT
uint16_t measurementResults[FEATURE_FTM_CHANNEL_COUNT]
status_t FTM_DRV_DeinitInputCapture(uint32_t instance, const ftm_input_param_t *param)
Disables input capture mode and clears FTM timer configuration.
static bool FTM_DRV_GetDualEdgeCaptureBit(const FTM_Type *ftmBase, uint8_t chnlPairNum)
Enables the FTM peripheral timer dual edge capture mode.
ftm_channel_event_callback_t channelsCallbacks[FEATURE_FTM_CHANNEL_COUNT]
void FTM1_Ch6_Ch7_IRQHandler(void)
ftm_signal_measurement_mode_t
FlexTimer input capture measurement type for dual edge input capture.
ftm_config_mode_t ftmMode
void FTM0_Ch6_Ch7_IRQHandler(void)
void INT_SYS_EnableIRQ(IRQn_Type irqNumber)
Enables an interrupt for a given IRQ number.
static bool FTM_DRV_HasChnEventOccurred(const FTM_Type *ftmBase, uint8_t channel)
Returns whether any event for the FTM peripheral timer channel has occurred.
static uint16_t FTM_DRV_GetMod(const FTM_Type *ftmBase)
Returns the FTM peripheral counter modulo value.
void FTM3_Ch6_Ch7_IRQHandler(void)
void FTM2_Ch4_Ch5_IRQHandler(void)
void FTM0_Ch2_Ch3_IRQHandler(void)
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 ...
const IRQn_Type g_ftmIrqId[FTM_INSTANCE_COUNT][FEATURE_FTM_CHANNEL_COUNT]
Interrupt vectors for the FTM peripheral.
void FTM0_Ch0_Ch1_IRQHandler(void)