143 FTM_Type * ftmBase = g_ftmBase[instance];
147 if (ftmStatePtr[instance] != NULL)
157 ftmStatePtr[instance] = state;
208 FTM_Type * ftmBase = g_ftmBase[instance];
212 ftmStatePtr[instance] = NULL;
234 FTM_Type * ftmBase = g_ftmBase[instance];
237 uint8_t channel = 0U;
290 FTM_Type * ftmBase = g_ftmBase[instance];
311 FTM_Type * ftmBase = g_ftmBase[instance];
331 FTM_Type const * ftmBase = g_ftmBase[instance];
346 FTM_Type * ftmBase = g_ftmBase[instance];
355 chnlPairNum = (uint8_t)(channel >> 1U);
406 uint8_t hwChannel = 0U;
407 uint8_t fltChannel = 0U;
408 uint8_t chnlPairNum = 0U;
409 uint8_t channelId = 0U;
411 FTM_Type * ftmBase = g_ftmBase[instance];
428 chnlPairNum = (uint8_t)(channelId >> 1U);
450 chnlPairNum = (uint8_t)(channelId >> 1U);
500 if (
true == (param->
faultConfig)->ftmFaultChannelParam[fltChannel].faultChannelEnabled)
507 ((param->
faultConfig)->ftmFaultChannelParam[fltChannel].faultFilterEnabled) ?
true :
false);
510 ((param->
faultConfig)->ftmFaultChannelParam[fltChannel].ftmFaultPinPolarity));
515 if (
true == ((param->
faultConfig)->pwmFaultInterrupt))
611 bool softwareTrigger)
615 uint16_t hwFirstEdge = 0U;
616 uint16_t hwSecondEdge = 0U;
617 uint16_t ftmPeriod = 0U;
618 uint8_t chnlPairNum = (uint8_t)(channel >> 1U);
619 FTM_Type * ftmBase = g_ftmBase[instance];
628 ftmPeriod = (uint16_t)(ftmPeriod << 1U);
632 ftmPeriod = (uint16_t)(ftmPeriod + 1U);
655 hwFirstEdge = (uint16_t)(hwFirstEdge + 1U);
667 hwFirstEdge = firstEdge;
668 hwSecondEdge = secondEdge;
741 bool softwareTrigger)
745 uint32_t ftmPeriod = 0U;
746 FTM_Type * ftmBase = g_ftmBase[instance];
753 ftmPeriod = newValue;
757 if (newValue <= state->ftmSourceClockFrequency)
775 ftmPeriod = (ftmPeriod >> 1U);
779 ftmPeriod = (ftmPeriod - 1U);
802 uint32_t channelsMask,
803 bool softwareTrigger)
806 FTM_Type * ftmBase = g_ftmBase[instance];
826 uint16_t counterValue,
827 bool softwareTrigger)
830 FTM_Type * ftmBase = g_ftmBase[instance];
850 uint16_t reloadPoint,
851 bool softwareTrigger)
854 FTM_Type * ftmBase = g_ftmBase[instance];
876 uint8_t channelsValues,
877 bool softwareTrigger)
880 FTM_Type * ftmBase = g_ftmBase[instance];
899 uint8_t channelsMask,
900 bool softwareTrigger)
903 FTM_Type * ftmBase = g_ftmBase[instance];
922 uint8_t channelsPairMask,
923 bool softwareTrigger)
926 FTM_Type * ftmBase = g_ftmBase[instance];
945 uint16_t counterValue,
946 bool softwareTrigger)
949 FTM_Type * ftmBase = g_ftmBase[instance];
975 FTM_Type * ftmBase = g_ftmBase[instance];
1052 FTM_Type * ftmBase = g_ftmBase[instance];
1054 uint8_t hwChannel = 0U;
1055 uint8_t chnlPairNum = 0U;
1073 chnlPairNum = (uint8_t)(hwChannel >> 1U);
1115 FTM_Type * ftmBase = g_ftmBase[instance];
1117 uint8_t hwChannel = 0U;
1154 uint16_t nextComparematchValue,
1156 bool softwareTrigger)
1161 uint16_t compareValue = 0U;
1162 uint16_t maxCounterValue;
1163 FTM_Type * ftmBase = g_ftmBase[instance];
1169 if ((uint16_t)(counterValue + nextComparematchValue) > maxCounterValue)
1171 compareValue = (uint16_t)(nextComparematchValue - (maxCounterValue - counterValue));
1175 compareValue = (uint16_t)(counterValue + nextComparematchValue);
1180 compareValue = nextComparematchValue;
1185 if (softwareTrigger)
1210 FTM_Type * ftmBase = g_ftmBase[instance];
1211 uint8_t chnlPairNum = 0U;
1213 uint8_t hwChannel = 0U;
1231 chnlPairNum = (uint8_t)(hwChannel >> 1U);
1355 FTM_Type * ftmBase = g_ftmBase[instance];
1356 uint8_t chnlPairNum = 0U;
1358 uint8_t hwChannel = 0U;
1369 chnlPairNum = (uint8_t)(hwChannel >> 1U);
1407 const ftm_state_t * state = ftmStatePtr[instance];
1426 FTM_Type * ftmBase = g_ftmBase[instance];
1427 uint8_t chnlPairNum = (uint8_t)(channel >> 1U);
1462 FTM_Type * ftmBase = g_ftmBase[instance];
1519 FTM_Type * ftmBase = g_ftmBase[instance];
1540 FTM_Type const * ftmBase = g_ftmBase[instance];
1564 FTM_Type const * ftmBase = g_ftmBase[instance];
1568 uint32_t frequency = 0U;
1569 const ftm_state_t * state = ftmStatePtr[instance];
1601 return (uint32_t)(frequency / clkPs);
1613 uint32_t freqencyHz)
1618 const ftm_state_t * state = ftmStatePtr[instance];
1621 return (uint16_t)(uFTMhz / freqencyHz);
1721 uint8_t channelPair)
1723 const ftm_state_t * state = ftmStatePtr[instance];
1736 uint8_t channelPair)
1739 FTM_Type * ftmBase = g_ftmBase[instance];
1747 if (second_event_time < first_event_time)
1755 state->
measurementResults[channelPair << 1U] = (uint16_t)(second_event_time - first_event_time);
static void FTM_HAL_SetInitTriggerCmd(FTM_Type *const ftmBase, bool enable)
Enables or disables the generation of the trigger when the FTM counter is equal to the CNTIN register...
static void FTM_DRV_InputCaptureHandler(uint32_t instance, uint8_t channelPair)
ftm_reg_update_t initCounterSync
static void FTM_HAL_SetDualChnPwmSyncCmd(FTM_Type *const ftmBase, uint8_t chnlPairNum, bool enable)
Enables or disables the FTM peripheral timer channel pair counter PWM sync.
ftm_pwm_sync_t syncMethod
status_t FTM_DRV_SetInvertingControl(uint32_t instance, uint8_t channelsPairMask, bool softwareTrigger)
This function will configure if the second channel of a pair will be inverted or not.
static void FTM_HAL_SetSwoctrlPwmSyncModeCmd(FTM_Type *const ftmBase, ftm_reg_update_t mode)
Sets the SWOCTRL register PWM synchronization mode.
static void FTM_HAL_SetExtDeadtimeValue(FTM_Type *const ftmBase, uint8_t value)
Sets the FTM extended dead-time value.
status_t FTM_DRV_InitCounter(uint32_t instance, const ftm_timer_param_t *timer)
Initialize the FTM counter.
FlexTimer state structure of the driver.
void FTM3_Ch0_Ch1_IRQHandler(void)
static void FTM_HAL_SetQuadDecoderCmd(FTM_Type *const ftmBase, bool enable)
Enables the channel quadrature decoder.
static void FTM_HAL_SetChnOutputPolarityCmd(FTM_Type *const ftmBase, uint8_t channel, ftm_polarity_t polarity)
Sets the FTM peripheral timer channel output polarity.
static void FTM_HAL_DisableChnInt(FTM_Type *const ftmBase, uint8_t channel)
Disables the FTM peripheral timer channel(n) interrupt.
static void FTM_HAL_SetDualChnMofCombineCmd(FTM_Type *const ftmBase, uint8_t chnlPairNum, bool enable)
Enables the FTM peripheral timer channel modified combine mode.
static void FTM_HAL_SetQuadPhaseAFilterCmd(FTM_Type *const ftmBase, bool enable)
Enables or disables the phase A input filter.
Configuration structure that the user needs to set.
static void FTM_HAL_SetOutmaskPwmSyncModeCmd(FTM_Type *const ftmBase, bool enable)
Determines when the OUTMASK register is updated with the value of its buffer.
const IRQn_Type g_ftmReloadIrqId[FTM_INSTANCE_COUNT]
static void FTM_HAL_EnablePwmChannelOutputs(FTM_Type *const ftmBase, uint8_t channel)
Enable PWM channel Outputs.
void FTM_HAL_SetChnTriggerCmd(FTM_Type *const ftmBase, uint8_t channel, bool enable)
Enables or disables the generation of the FTM peripheral timer channel trigger when the FTM counter i...
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).
void FTM2_Ch4_Ch5_IRQHandler(void)
static void FTM_HAL_SetDualChnFaultCmd(FTM_Type *const ftmBase, uint8_t chnlPairNum, bool enable)
Enables the FTM peripheral timer channel pair fault control.
status_t FTM_DRV_UpdatePwmPeriod(uint32_t instance, ftm_pwm_update_option_t typeOfUpdate, uint32_t newValue, bool softwareTrigger)
This function will update the new period in the frequency or in the counter value into mode register ...
static void FTM_HAL_SetPwmSyncMode(FTM_Type *const ftmBase, bool enable)
Sets the FTM peripheral timer sync mode.
FTM_Type *const g_ftmBase[FTM_INSTANCE_COUNT]
Table of base addresses for FTM instances.
static void FTM_HAL_SetBdmMode(FTM_Type *const ftmBase, ftm_bdm_mode_t val)
Sets the BDM mode.
void FTM2_Ch0_Ch1_IRQHandler(void)
static void FTM_HAL_SetSwoctrlHardwareSyncModeCmd(FTM_Type *const ftmBase, bool enable)
Sets the sync mode for the FTM SWOCTRL register when using a hardware trigger.
static void FTM_HAL_SetChnEdgeLevel(FTM_Type *const ftmBase, uint8_t channel, uint8_t level)
Sets the FTM peripheral timer channel edge level.
status_t FTM_DRV_StartNewSignalMeasurement(uint32_t instance, uint8_t channel)
Starts new single-shot signal measurement of the given channel.
status_t FTM_DRV_QuadDecodeStop(uint32_t instance)
De-activates the quadrature decode mode.
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.
void FTM0_Ch4_Ch5_IRQHandler(void)
static void FTM_HAL_Enable(FTM_Type *const ftmBase, bool enable)
Enables the FTM peripheral timer group.
IRQn_Type
Defines the Interrupt Numbers definitions.
FlexTimer Registers sync parameters Please don't use software and hardware trigger simultaneously Imp...
const ftm_combined_ch_param_t * pwmCombinedChannelConfig
ftm_output_compare_mode_t chMode
static void FTM_HAL_SetChnCountVal(FTM_Type *const ftmBase, uint8_t channel, uint16_t value)
Sets the FTM peripheral timer channel counter value.
#define FTM_FEATURE_INPUT_CAPTURE_SINGLE_SHOT
FlexTimer driver timer mode configuration structure.
static void FTM_HAL_SetInvctrlReg(FTM_Type *const ftmBase, uint32_t regVal)
Writes the provided value to the Inverting control register.
status_t FTM_DRV_SetModuloCounterValue(uint32_t instance, uint16_t counterValue, bool softwareTrigger)
This function configure the maximum counter value.
void FTM1_Ch6_Ch7_IRQHandler(void)
static void FTM_HAL_SetSwoctrlSoftwareSyncModeCmd(FTM_Type *const ftmBase, bool enable)
Sets sync mode for FTM SWOCTRL register when using a software trigger.
status_t FTM_DRV_QuadDecodeStart(uint32_t instance, const ftm_quad_decode_config_t *config)
Configures the quadrature mode and starts measurement.
static bool FTM_HAL_GetQuadTimerOverflowDir(const FTM_Type *ftmBase)
Gets the Timer overflow direction in quadrature mode.
ftm_deadtime_ps_t deadTimePrescaler
static void FTM_HAL_SetWriteProtectionCmd(FTM_Type *const ftmBase, bool enable)
Enables or disables the FTM write protection.
uint8_t nNumCombinedPwmChannels
status_t FTM_DRV_Init(uint32_t instance, const ftm_user_config_t *info, ftm_state_t *state)
Initializes the FTM driver.
static const clock_names_t g_ftmExtClockSel[FTM_INSTANCE_COUNT][2]
Select external clock pin or clock source for peripheral.
ftm_quad_decoder_state_t FTM_DRV_QuadGetState(uint32_t instance)
Return the current quadrature decoder state (counter value, overflow flag and overflow direction) ...
static void FTM_HAL_SetQuadPhaseBFilterCmd(FTM_Type *const ftmBase, bool enable)
Enables or disables the phase B input filter.
static bool FTM_HAL_GetCpwms(const FTM_Type *ftmBase)
Gets the FTM count direction bit.
status_t FTM_DRV_CounterStart(uint32_t instance)
Starts the FTM counter.
void INT_SYS_DisableIRQ(IRQn_Type irqNumber)
Disables an interrupt for a given IRQ number.
void * channelsCallbacksParams[FEATURE_FTM_CHANNEL_COUNT]
static void FTM_HAL_SetTimerOverflowInt(FTM_Type *const ftmBase, bool state)
Enables the FTM peripheral timer overflow interrupt.
const IRQn_Type g_ftmFaultIrqId[FTM_INSTANCE_COUNT]
void FTM0_Ch0_Ch1_IRQHandler(void)
static void FTM_HAL_DisablePwmChannelOutputs(FTM_Type *const ftmBase, uint8_t channel)
Disable PWM channel Outputs.
void FTM1_Ch4_Ch5_IRQHandler(void)
ftm_phase_params_t phaseAConfig
static bool FTM_HAL_HasTimerOverflowed(const FTM_Type *ftmBase)
Returns the FTM peripheral timer overflow interrupt flag.
static void FTM_HAL_SetFaultInputFilterCmd(FTM_Type *const ftmBase, uint8_t inputNum, bool enable)
Enables or disables the fault input filter.
status_t FTM_DRV_MaskOutputChannels(uint32_t instance, uint32_t channelsMask, bool softwareTrigger)
This function will mask the output of the channels and at match events will be ignored by the masked ...
static void FTM_HAL_SetFaultInt(FTM_Type *const ftmBase, bool state)
Enables/disables the FTM peripheral timer fault interrupt.
static bool FTM_HAL_GetQuadDir(const FTM_Type *ftmBase)
Gets the FTM counter direction in quadrature mode.
status_t FTM_DRV_InitPwm(uint32_t instance, const ftm_pwm_param_t *param)
Configures the duty cycle and frequency and starts outputting the PWM on all channels configured in p...
static void FTM_HAL_SetHalfCycleValue(FTM_Type *const ftmBase, uint16_t value)
Sets the value for the half cycle reload register.
uint32_t FTM_DRV_GetFrequency(uint32_t instance)
Retrieves the frequency of the clock source feeding the FTM counter.
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 FTM_DRV_UpdatePwmChannel(uint32_t instance, uint8_t channel, ftm_pwm_update_option_t typeOfUpdate, uint16_t firstEdge, uint16_t secondEdge, bool softwareTrigger)
This function updates the waveform output in PWM mode (duty cycle and phase).
static uint8_t FTM_HAL_GetChnMode(const FTM_Type *ftmBase, uint8_t channel)
Gets the FTM peripheral timer channel mode.
static void FTM_HAL_SetDualChnDeadtimeCmd(FTM_Type *const ftmBase, uint8_t chnlPairNum, bool enable)
Enables or disabled the FTM peripheral timer channel pair deadtime insertion.
const IRQn_Type g_ftmIrqId[FTM_INSTANCE_COUNT][FEATURE_FTM_CHANNEL_COUNT]
Interrupt vectors for the FTM peripheral.
ftm_phase_params_t phaseBConfig
status_t FTM_DRV_SetSoftwareOutputChannelControl(uint32_t instance, uint8_t channelsMask, bool softwareTrigger)
This function will configure which output channel can be software controlled.
static void FTM_HAL_SetModCntinCvHardwareSyncModeCmd(FTM_Type *const ftmBase, bool enable)
Sets sync mode for FTM MOD, CNTIN and CV registers when using a hardware trigger. ...
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 ...
peripheral_clock_source_t
PCC clock source select Implements peripheral_clock_source_t_Class.
status_t CLOCK_SYS_GetFreq(clock_names_t clockName, uint32_t *frequency)
Gets the clock frequency for a specific clock name.
ftm_clock_source_t ftmClockSource
status_t FTM_DRV_CounterStop(uint32_t instance)
Stops the FTM counter.
static void FTM_HAL_SetFaultInputFilterVal(FTM_Type *const ftmBase, uint32_t value)
Sets the fault input filter value.
uint16_t FTM_DRV_ConvertFreqToPeriodTicks(uint32_t instance, uint32_t freqencyHz)
This function is used to covert the given frequency to period in ticks.
#define FTM_DUTY_TO_TICKS_SHIFT
Shift value which converts duty to ticks.
const ftm_pwm_fault_param_t * faultConfig
#define CHAN1_IDX
Channel number for CHAN2.
void FTM1_Ch2_Ch3_IRQHandler(void)
static void FTM_HAL_SetDualChnDecapCmd(FTM_Type *const ftmBase, uint8_t chnlPairNum, bool enable)
Enables or disables the FTM peripheral timer channel dual edge capture.
ftm_pwm_sync_mode_t syncPoint
ftm_quad_decode_mode_t mode
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
#define FEATURE_FTM_CHANNEL_COUNT
static void FTM_HAL_SetInvctrlHardwareSyncModeCmd(FTM_Type *const ftmBase, bool enable)
Sets sync mode for FTM INVCTRL register when using a hardware trigger.
static void FTM_HAL_SetAllChnSoftwareCtrlCmd(FTM_Type *const ftmBase, uint8_t channelsMask)
Enables or disables the channel software output control.The main difference between this function and...
#define FTM2_IDX
Instance number for FTM3.
FTM quadrature configure structure.
static void FTM_HAL_EnableChnInt(FTM_Type *const ftmBase, uint8_t channel)
Enables the FTM peripheral timer channel(n) interrupt.
void FTM3_Ch2_Ch3_IRQHandler(void)
void FTM_HAL_SetChnInputCaptureFilter(FTM_Type *const ftmBase, uint8_t channel, uint8_t value)
Sets the FTM peripheral timer channel input capture filter value.
#define FTM1_IDX
Instance number for FTM2.
void FTM2_Ch6_Ch7_IRQHandler(void)
static void FTM_HAL_SetDualChnCombineCmd(FTM_Type *const ftmBase, uint8_t chnlPairNum, bool enable)
Enables or disables the FTM peripheral timer channel pair output combine mode.
#define FTM_INSTANCE_COUNT
uint16_t measurementResults[FEATURE_FTM_CHANNEL_COUNT]
static void FTM_HAL_SetCntinPwmSyncModeCmd(FTM_Type *const ftmBase, ftm_reg_update_t mode)
Sets the CNTIN register PWM synchronization mode.
#define CHAN4_IDX
Channel number for CHAN5.
uint16_t uDutyCyclePercent
const ftm_output_cmp_ch_param_t * outputChannelConfig
static uint16_t FTM_HAL_GetMod(const FTM_Type *ftmBase)
Returns the FTM peripheral counter modulo value.
static void FTM_HAL_SetMinLoadingCmd(FTM_Type *const ftmBase, bool enable)
Enables or disables the FTM peripheral timer minimum loading points.
static void FTM_HAL_SetCpwms(FTM_Type *const ftmBase, bool mode)
Sets the FTM count direction bit.
static void FTM_HAL_ClearChnEventFlag(FTM_Type *const ftmBase, uint8_t channel)
Clear the channel flag by writing a 0 to the CHF bit.
bool enableSecondChannelOutput
void FTM3_Ch6_Ch7_IRQHandler(void)
uint8_t nNumIndependentPwmChannels
bool enableInitializationTrigger
static void FTM_HAL_SetDeadtimePrescale(FTM_Type *const ftmBase, ftm_deadtime_ps_t divider)
Sets the FTM dead time divider.
#define FTM_Overflow_IRQS
#define FTM_FEATURE_FAULT_CHANNELS
static void FTM_HAL_SetHardwareSyncTriggerSrc(FTM_Type *const ftmBase, uint8_t trigger_num, bool enable)
Sets the FTM hardware synchronization trigger.
static void FTM_HAL_SetCounterSoftwareSyncModeCmd(FTM_Type *const ftmBase, ftm_pwm_sync_mode_t update_mode)
Sets sync mode for FTM counter register when using a software trigger.
void FTM0_Ch6_Ch7_IRQHandler(void)
ftm_pwm_update_option_t
FlexTimer Configure type of PWM update in the duty cycle or in ticks.
FlexTimer driver PWM parameters.
static void FTM_HAL_SetPwmFaultBehavior(FTM_Type *const ftmBase, bool enable)
Configures the behavior of the PWM outputs when a fault is detected.
static void FTM_HAL_SetInvctrlPwmSyncModeCmd(FTM_Type *const ftmBase, ftm_reg_update_t mode)
Sets the INVCTRL register PWM synchronization mode.
static void FTM_HAL_ClearTimerOverflow(FTM_Type *const ftmBase)
Clears the timer overflow interrupt flag.
static bool FTM_HAL_GetDualChnCombineCmd(const FTM_Type *ftmBase, uint8_t chnlPairNum)
Verify if an channels pair is used in combine mode or not.
ftm_reg_update_t inverterSync
ftm_channel_event_callback_t channelsCallbacks[FEATURE_FTM_CHANNEL_COUNT]
clock_names_t
Clock names.
bool enableExternalTrigger
status_t FTM_DRV_SetInitialCounterValue(uint32_t instance, uint16_t counterValue, bool softwareTrigger)
This function configure the initial counter value. The counter will get this value after an overflow ...
static void FTM_HAL_ClearFaultControl(FTM_Type *const ftmBase)
Clears the entire content value of the Fault control register.
status_t FTM_DRV_Deinit(uint32_t instance)
Shuts down the FTM driver.
ftm_polarity_t mainChannelPolarity
bool enableExternalTriggerOnNextChn
ftm_state_t * ftmStatePtr[FTM_INSTANCE_COUNT]
Pointer to runtime state structure.
void FTM_HAL_Init(FTM_Type *const ftmBase, ftm_clock_ps_t ftmClockPrescaler)
Initializes the FTM. This function will enable the flexTimer module and selects one pre-scale factor ...
static void FTM_HAL_SetFaultInputCmd(FTM_Type *const ftmBase, uint8_t inputNum, bool enable)
Enables or disables the fault input.
ftm_config_mode_t ftmMode
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_HAL_GetDualEdgeCaptureBit(const FTM_Type *ftmBase, uint8_t chnlPairNum)
Enables the FTM peripheral timer dual edge capture mode.
ftm_signal_measurement_mode_t
FlexTimer input capture measurement type for dual edge input capture.
static void FTM_HAL_SetOutmaskReg(FTM_Type *const ftmBase, uint32_t regVal)
Writes the provided value to the OUTMASK register.
static peripheral_clock_source_t PCC_HAL_GetClockSourceSel(const PCC_Type *const base, const clock_names_t clockName)
Gets the selection of a clock source for a specific peripheral.
static void FTM_HAL_SetFaultControlMode(FTM_Type *const ftmBase, ftm_fault_mode_t mode)
Defines the FTM fault control mode.
status_t FTM_DRV_SetHalfCycleReloadPoint(uint32_t instance, uint16_t reloadPoint, bool softwareTrigger)
This function configure the value of the counter which will generates an reload point.
static void FTM_HAL_SetModCntinCvSoftwareSyncModeCmd(FTM_Type *const ftmBase, bool enable)
Sets sync mode for FTM MOD, CNTIN and CV registers when using a software trigger. ...
static void FTM_HAL_SetInvctrlSoftwareSyncModeCmd(FTM_Type *const ftmBase, bool enable)
Sets sync mode for FTM INVCTRL register when using a software trigger.
static void FTM_HAL_SetSoftwareTriggerCmd(FTM_Type *const ftmBase, bool enable)
Enables or disables the FTM peripheral timer software trigger.
ftm_second_channel_polarity_t secondChannelPolarity
static void FTM_HAL_SetMod(FTM_Type *const ftmBase, uint16_t value)
Sets the FTM peripheral timer modulo value.
void FTM3_Ch4_Ch5_IRQHandler(void)
static void FTM_HAL_SetDualChnCompCmd(FTM_Type *const ftmBase, uint8_t chnlPairNum, ftm_second_channel_polarity_t polarity)
Enables or disables the FTM peripheral timer channel pair output complement mode. ...
static void FTM_HAL_SetCounterInitVal(FTM_Type *const ftmBase, uint16_t value)
Sets the FTM peripheral timer counter initial value.
ftm_config_mode_t ftmMode
static void FTM_HAL_SetCounterHardwareSyncModeCmd(FTM_Type *const ftmBase, bool enable)
Sets sync mode for FTM counter register when using a hardware trigger.
static void FTM_HAL_SetChnMSnBAMode(FTM_Type *const ftmBase, uint8_t channel, uint8_t selection)
Sets the FTM peripheral timer channel mode.
FlexTimer driver PWM parameters.
bool enableExternalTrigger
static void FTM_HAL_SetOutmaskSoftwareSyncModeCmd(FTM_Type *const ftmBase, bool enable)
Sets sync mode for FTM OUTMASK register when using a software trigger.
static void FTM_HAL_SetQuadMode(FTM_Type *const ftmBase, ftm_quad_decode_mode_t quadMode)
Sets the encoding mode used in quadrature decoding mode.
void INT_SYS_EnableIRQ(IRQn_Type irqNumber)
Enables an interrupt for a given IRQ number.
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 bool FTM_HAL_GetDualChnMofCombineCmd(const FTM_Type *ftmBase, uint8_t chnlPairNum)
Verify if an channels pair is used in the modified combine mode or not.
ftm_reg_update_t maskRegSync
const ftm_independent_ch_param_t * pwmIndependentChannelConfig
uint8_t nNumOutputChannels
static void FTM_HAL_SetDeadtimeCount(FTM_Type *const ftmBase, uint8_t count)
Sets the FTM deadtime value.
void FTM0_Ch2_Ch3_IRQHandler(void)
static uint8_t FTM_HAL_GetClockSource(const FTM_Type *ftmBase)
Reads the FTM clock source.
static void FTM_HAL_SetChnFaultInputPolarityCmd(FTM_Type *const ftmBase, uint8_t fltChannel, ftm_polarity_t polarity)
Sets the FTM peripheral timer channel fault input polarity.
ftm_output_compare_update_t
FlexTimer input capture type of the next output compare value.
status_t FTM_DRV_SetSync(uint32_t instance, const ftm_pwm_sync_t *param)
This function configures sync mechanism for some FTM registers (MOD, CNINT, HCR, CnV, OUTMASK, INVCTRL, SWOCTRL).
static void FTM_HAL_SetOutmaskHardwareSyncModeCmd(FTM_Type *const ftmBase, bool enable)
Sets sync mode for FTM OUTMASK register when using a hardware trigger.
void FTM_HAL_Reset(FTM_Type *const ftmBase)
Resets the FTM registers. All the register use in the driver should be reset to default value of each...
static void FTM_HAL_SetMaxLoadingCmd(FTM_Type *const ftmBase, bool enable)
Enables or disables the FTM peripheral timer maximum loading points.
#define FTM_MAX_DUTY_CYCLE
Maximum value for PWM duty cycle.
static void FTM_HAL_SetInitChnOutputCmd(FTM_Type *const ftmBase, bool enable)
Initializes the channels output.
status_t FTM_DRV_SetSoftOutChnValue(uint32_t instance, uint8_t channelsValues, bool softwareTrigger)
This function will force the output value of a channel to a specific value. Before using this functio...
static void FTM_DRV_IrqHandler(uint32_t instance, uint8_t channelPair)
static void FTM_HAL_SetAllChnSoftwareCtrlVal(FTM_Type *const ftmBase, uint8_t channelsValues)
Sets the channel software output control value.
uint32_t FTM_DRV_CounterRead(uint32_t instance)
Reads back the current value of the FTM counter.
const IRQn_Type g_ftmOverflowIrqId[FTM_INSTANCE_COUNT]
bool enableExternalTrigger
static void FTM_HAL_SetPwmSyncModeCmd(FTM_Type *const ftmBase, bool mode)
Sets the PWM synchronization mode to enhanced or legacy.
static uint8_t FTM_HAL_GetClockPs(const FTM_Type *ftmBase)
Reads the FTM clock divider.
static uint16_t FTM_HAL_GetChnCountVal(const FTM_Type *ftmBase, uint8_t channel)
Gets the FTM peripheral timer channel counter value.
ftm_quad_phase_polarity_t phasePolarity
status_t FTM_DRV_DeinitPwm(uint32_t instance)
Stops all PWM channels .
ftm_clock_source_t ftmClockSource
static void FTM_HAL_SetHwTriggerSyncModeCmd(FTM_Type *const ftmBase, bool enable)
Sets hardware trigger mode.
void FTM2_Ch2_Ch3_IRQHandler(void)
void FTM1_Ch0_Ch1_IRQHandler(void)
static void FTM_HAL_SetQuadPhaseAPolarity(FTM_Type *const ftmBase, ftm_quad_phase_polarity_t mode)
Selects polarity for the quadrature decode phase A input.
#define CHAN0_IDX
Channel number for CHAN1.
uint32_t ftmSourceClockFrequency
static bool FTM_HAL_HasChnEventOccurred(const FTM_Type *ftmBase, uint8_t channel)
Returns whether any event for the FTM peripheral timer channel has occurred.
FTM quadrature state(counter value and flags)
ftm_reg_update_t outRegSync
static void FTM_HAL_SetQuadPhaseBPolarity(FTM_Type *const ftmBase, ftm_quad_phase_polarity_t mode)
Selects polarity for the quadrature decode phase B input.
static void FTM_HAL_SetClockSource(FTM_Type *const ftmBase, ftm_clock_source_t clock)
Sets the FTM clock source.
static uint16_t FTM_HAL_GetCounter(const FTM_Type *ftmBase)
Returns the FTM peripheral current counter value.
static void FTM_HAL_SetCounter(FTM_Type *const ftmBase, uint16_t value)
Sets the FTM peripheral current counter value.
ftm_clock_ps_t ftmPrescaler
bool enableModifiedCombine
static void FTM_HAL_SetDualEdgeCaptureCmd(FTM_Type *const ftmBase, uint8_t chnlPairNum, bool enable)
Enables the FTM peripheral timer dual edge capture mode.