Ftm_common

Detailed Description

Data Structures

struct  ftm_state_t
 FlexTimer state structure of the driver. More...
 
struct  ftm_pwm_sync_t
 FlexTimer Registers sync parameters Please don't use software and hardware trigger simultaneously Implements : ftm_pwm_sync_t_Class. More...
 
struct  ftm_user_config_t
 Configuration structure that the user needs to set. More...
 

Macros

#define FTM_RMW_SC(base, mask, value)   (((base)->SC) = ((((base)->SC) & ~(mask)) | (value)))
 FTM_SC - Read and modify and write to Status And Control (RW) More...
 
#define FTM_RMW_CNT(base, mask, value)   (((base)->CNT) = ((((base)->CNT) & ~(mask)) | (value)))
 FTM_CNT - Read and modify and write to Counter (RW) More...
 
#define FTM_RMW_MOD(base, mask, value)   (((base)->MOD) = ((((base)->MOD) & ~(mask)) | (value)))
 FTM_MOD - Read and modify and write Modulo (RW) More...
 
#define FTM_RMW_CNTIN(base, mask, value)   (((base)->CNTIN) = ((((base)->CNTIN) & ~(mask)) | (value)))
 FTM_CNTIN - Read and modify and write Counter Initial Value (RW) More...
 
#define FTM_RMW_STATUS(base, mask, value)   (((base)->STATUS) = ((((base)->STATUS) & ~(mask)) | (value)))
 FTM_STATUS - Read and modify and write Capture And Compare Status (RW) More...
 
#define FTM_RMW_MODE(base, mask, value)   (((base)->MODE) = ((((base)->MODE) & ~(mask)) | (value)))
 FTM_MODE - Read and modify and write Counter Features Mode Selection (RW) More...
 
#define FTM_RMW_CnSCV_REG(base, channel, mask, value)   (((base)->CONTROLS[channel].CnSC) = ((((base)->CONTROLS[channel].CnSC) & ~(mask)) | (value)))
 FTM_CnSCV - Read and modify and write Channel (n) Status And Control (RW) More...
 
#define FTM_RMW_DEADTIME(base, mask, value)   (((base)->DEADTIME) = ((((base)->DEADTIME) & ~(mask)) | (value)))
 FTM_DEADTIME - Read and modify and write Dead-time Insertion Control (RW) More...
 
#define FTM_RMW_EXTTRIG_REG(base, mask, value)   (((base)->EXTTRIG) = ((((base)->EXTTRIG) & ~(mask)) | (value)))
 FTM_EXTTRIG - Read and modify and write External Trigger Control (RW) More...
 
#define FTM_RMW_FLTCTRL(base, mask, value)   (((base)->FLTCTRL) = ((((base)->FLTCTRL) & ~(mask)) | (value)))
 FTM_FLTCTRL - Read and modify and write Fault Control (RW) More...
 
#define FTM_RMW_FMS(base, mask, value)   (((base)->FMS) = ((((base)->FMS) & ~(mask)) | (value)))
 FTM_FMS - Read and modify and write Fault Mode Status (RW) More...
 
#define FTM_RMW_CONF(base, mask, value)   (((base)->CONF) = ((((base)->CONF) & ~(mask)) | (value)))
 FTM_CONF - Read and modify and write Configuration (RW) More...
 
#define FTM_RMW_POL(base, mask, value)   (((base)->POL) = ((((base)->POL) & ~(mask)) | (value)))
 POL - Read and modify and write Polarity (RW) More...
 
#define FTM_RMW_FILTER(base, mask, value)   (((base)->FILTER) = ((((base)->FILTER) & ~(mask)) | (value)))
 FILTER - Read and modify and write Filter (RW) More...
 
#define FTM_RMW_SYNC(base, mask, value)   (((base)->SYNC) = ((((base)->SYNC) & ~(mask)) | (value)))
 SYNC - Read and modify and write Synchronization (RW) More...
 
#define FTM_RMW_QDCTRL(base, mask, value)   (((base)->QDCTRL) = ((((base)->QDCTRL) & ~(mask)) | (value)))
 QDCTRL - Read and modify and write Quadrature Decoder Control And Status (RW) More...
 
#define FTM_RMW_PAIR0DEADTIME(base, mask, value)   (((base)->PAIR0DEADTIME) = ((((base)->PAIR0DEADTIME) & ~(mask)) | (value)))
 FTM_PAIR0DEADTIME - Read and modify and write Dead-time Insertion Control for the pair 0 (RW) More...
 
#define FTM_RMW_PAIR1DEADTIME(base, mask, value)   (((base)->PAIR1DEADTIME) = ((((base)->PAIR1DEADTIME) & ~(mask)) | (value)))
 FTM_PAIR1DEADTIME - Read and modify and write Dead-time Insertion Control for the pair 1 (RW) More...
 
#define FTM_RMW_PAIR2DEADTIME(base, mask, value)   (((base)->PAIR2DEADTIME) = ((((base)->PAIR2DEADTIME) & ~(mask)) | (value)))
 FTM_PAIR2DEADTIME - Read and modify and write Dead-time Insertion Control for the pair 2 (RW) More...
 
#define FTM_RMW_PAIR3DEADTIME(base, mask, value)   (((base)->PAIR3DEADTIME) = ((((base)->PAIR3DEADTIME) & ~(mask)) | (value)))
 FTM_PAIR3DEADTIME - Read and modify and write Dead-time Insertion Control for the pair 3 (RW) More...
 
#define FTM_RMW_MOD_MIRROR(base, mask, value)   (((base)->MOD_MIRROR) = ((((base)->MOD_MIRROR) & ~(mask)) | (value)))
 FTM_MOD_MIRROR - Read and modify and write mirror of modulo value for the FTM counter (RW) More...
 
#define FTM_RMW_CnV_MIRROR(base, channel, mask, value)   (((base)->CV_MIRROR[channel]) = ((((base)->CV_MIRROR[channel]) & ~(mask)) | (value)))
 FTM_CnV_MIRROR - Read and modify and write mirror of channel (n) match value (RW) More...
 
#define CHAN0_IDX   (0U)
 Channel number for CHAN1. More...
 
#define CHAN1_IDX   (1U)
 Channel number for CHAN2. More...
 
#define CHAN2_IDX   (2U)
 Channel number for CHAN3. More...
 
#define CHAN3_IDX   (3U)
 Channel number for CHAN4. More...
 
#define CHAN4_IDX   (4U)
 Channel number for CHAN5. More...
 
#define CHAN5_IDX   (5U)
 Channel number for CHAN6. More...
 
#define CHAN6_IDX   (6U)
 Channel number for CHAN7. More...
 
#define CHAN7_IDX   (7U)
 

Enumerations

enum  ftm_config_mode_t {
  FTM_MODE_NOT_INITIALIZED = 0x00U, FTM_MODE_INPUT_CAPTURE = 0x01U, FTM_MODE_OUTPUT_COMPARE = 0x02U, FTM_MODE_EDGE_ALIGNED_PWM = 0x03U,
  FTM_MODE_CEN_ALIGNED_PWM = 0x04U, FTM_MODE_QUADRATURE_DECODER = 0x05U, FTM_MODE_UP_TIMER = 0x06U, FTM_MODE_UP_DOWN_TIMER = 0x07U
}
 FlexTimer operation mode. More...
 
enum  ftm_clock_source_t { FTM_CLOCK_SOURCE_NONE = 0x00U, FTM_CLOCK_SOURCE_SYSTEMCLK = 0x01U, FTM_CLOCK_SOURCE_FIXEDCLK = 0x02U, FTM_CLOCK_SOURCE_EXTERNALCLK = 0x03U }
 FlexTimer clock source selection. More...
 
enum  ftm_clock_ps_t {
  FTM_CLOCK_DIVID_BY_1 = 0x00U, FTM_CLOCK_DIVID_BY_2 = 0x01U, FTM_CLOCK_DIVID_BY_4 = 0x02U, FTM_CLOCK_DIVID_BY_8 = 0x03U,
  FTM_CLOCK_DIVID_BY_16 = 0x04U, FTM_CLOCK_DIVID_BY_32 = 0x05U, FTM_CLOCK_DIVID_BY_64 = 0x06U, FTM_CLOCK_DIVID_BY_128 = 0x07U
}
 FlexTimer pre-scaler factor selection for the clock source. In quadrature decoder mode set FTM_CLOCK_DIVID_BY_1. More...
 
enum  ftm_interrupt_option_t {
  FTM_CHANNEL0_INT_ENABLE = 0x00000001U, FTM_CHANNEL1_INT_ENABLE = 0x00000002U, FTM_CHANNEL2_INT_ENABLE = 0x00000004U, FTM_CHANNEL3_INT_ENABLE = 0x00000008U,
  FTM_CHANNEL4_INT_ENABLE = 0x00000010U, FTM_CHANNEL5_INT_ENABLE = 0x00000020U, FTM_CHANNEL6_INT_ENABLE = 0x00000040U, FTM_CHANNEL7_INT_ENABLE = 0x00000080U,
  FTM_FAULT_INT_ENABLE = 0x00000100U, FTM_TIME_OVER_FLOW_INT_ENABLE = 0x00000200U, FTM_RELOAD_INT_ENABLE = 0x00000400U
}
 List of FTM interrupts. More...
 
enum  ftm_status_flag_t {
  FTM_CHANNEL0_FLAG = 0x00000001U, FTM_CHANNEL1_FLAG = 0x00000002U, FTM_CHANNEL2_FLAG = 0x00000004U, FTM_CHANNEL3_FLAG = 0x00000008U,
  FTM_CHANNEL4_FLAG = 0x00000010U, FTM_CHANNEL5_FLAG = 0x00000020U, FTM_CHANNEL6_FLAG = 0x00000040U, FTM_CHANNEL7_FLAG = 0x00000080U,
  FTM_FAULT_FLAG = 0x00000100U, FTM_TIME_OVER_FLOW_FLAG = 0x00000200U, FTM_RELOAD_FLAG = 0x00000400U, FTM_CHANNEL_TRIGGER_FLAG = 0x00000800U
}
 List of FTM flags. More...
 
enum  ftm_reg_update_t { FTM_SYSTEM_CLOCK = 0U, FTM_PWM_SYNC = 1U }
 FTM sync source. More...
 
enum  ftm_pwm_sync_mode_t { FTM_WAIT_LOADING_POINTS = 0U, FTM_UPDATE_NOW = 1U }
 FTM update register. More...
 
enum  ftm_deadtime_ps_t { FTM_DEADTIME_DIVID_BY_1 = 0x01U, FTM_DEADTIME_DIVID_BY_4 = 0x02U, FTM_DEADTIME_DIVID_BY_16 = 0x03U }
 FlexTimer pre-scaler factor for the dead-time insertion. More...
 
enum  ftm_quad_decode_mode_t { FTM_QUAD_PHASE_ENCODE = 0x00U, FTM_QUAD_COUNT_AND_DIR = 0x01U }
 FlexTimer quadrature decode modes, phase encode or count and direction mode. More...
 
enum  ftm_quad_phase_polarity_t { FTM_QUAD_PHASE_NORMAL = 0x00U, FTM_QUAD_PHASE_INVERT = 0x01U }
 FlexTimer quadrature phase polarities, normal or inverted polarity. More...
 
enum  ftm_bdm_mode_t { FTM_BDM_MODE_00 = 0x00U, FTM_BDM_MODE_01 = 0x01U, FTM_BDM_MODE_10 = 0x02U, FTM_BDM_MODE_11 = 0x03U }
 Options for the FlexTimer behavior in BDM Mode. More...
 

Functions

static void FTM_DRV_SetClockFilterPs (FTM_Type *const ftmBase, uint8_t filterPrescale)
 Sets the filter Pre-scaler divider. More...
 
static uint8_t FTM_DRV_GetClockFilterPs (const FTM_Type *ftmBase)
 Reads the FTM filter clock divider. More...
 
static uint16_t FTM_DRV_GetCounter (const FTM_Type *ftmBase)
 Returns the FTM peripheral current counter value. More...
 
static uint16_t FTM_DRV_GetMod (const FTM_Type *ftmBase)
 Returns the FTM peripheral counter modulo value. More...
 
static uint16_t FTM_DRV_GetCounterInitVal (const FTM_Type *ftmBase)
 Returns the FTM peripheral counter initial value. More...
 
static void FTM_DRV_ClearChSC (FTM_Type *const ftmBase, uint8_t channel)
 Clears the content of Channel (n) Status And Control. More...
 
static uint8_t FTM_DRV_GetChnEdgeLevel (const FTM_Type *ftmBase, uint8_t channel)
 Gets the FTM peripheral timer channel edge level. More...
 
static void FTM_DRV_SetChnIcrstCmd (FTM_Type *const ftmBase, uint8_t channel, bool enable)
 Configure the feature of FTM counter reset by the selected input capture event. More...
 
static bool FTM_DRV_IsChnIcrst (const FTM_Type *ftmBase, uint8_t channel)
 Returns whether the FTM FTM counter is reset. More...
 
static void FTM_DRV_SetChnDmaCmd (FTM_Type *const ftmBase, uint8_t channel, bool enable)
 Enables or disables the FTM peripheral timer channel DMA. More...
 
static bool FTM_DRV_IsChnDma (const FTM_Type *ftmBase, uint8_t channel)
 Returns whether the FTM peripheral timer channel DMA is enabled. More...
 
static void FTM_DRV_SetTrigModeControlCmd (FTM_Type *const ftmBase, uint8_t channel, bool enable)
 Enables or disables the trigger generation on FTM channel outputs. More...
 
static bool FTM_DRV_GetTriggerControled (const FTM_Type *ftmBase, uint8_t channel)
 Returns whether the trigger mode is enabled. More...
 
static bool FTM_DRV_GetChInputState (const FTM_Type *ftmBase, uint8_t channel)
 Get the state of channel input. More...
 
static bool FTM_DRV_GetChOutputValue (const FTM_Type *ftmBase, uint8_t channel)
 Get the value of channel output. More...
 
static uint16_t FTM_DRV_GetChnCountVal (const FTM_Type *ftmBase, uint8_t channel)
 Gets the FTM peripheral timer channel counter value. More...
 
static bool FTM_DRV_GetChnEventStatus (const FTM_Type *ftmBase, uint8_t channel)
 Gets the FTM peripheral timer channel event status. More...
 
static uint32_t FTM_DRV_GetEventStatus (const FTM_Type *ftmBase)
 Gets the FTM peripheral timer status info for all channels. More...
 
static void FTM_DRV_ClearChnEventStatus (FTM_Type *const ftmBase, uint8_t channel)
 Clears the FTM peripheral timer all channel event status. More...
 
static void FTM_DRV_SetChnOutputMask (FTM_Type *const ftmBase, uint8_t channel, bool mask)
 Sets the FTM peripheral timer channel output mask. More...
 
static void FTM_DRV_SetChnOutputInitStateCmd (FTM_Type *const ftmBase, uint8_t channel, bool state)
 Sets the FTM peripheral timer channel output initial state 0 or 1. More...
 
static void FTM_DRV_DisableFaultInt (FTM_Type *const ftmBase)
 Disables the FTM peripheral timer fault interrupt. More...
 
static void FTM_DRV_SetCaptureTestCmd (FTM_Type *const ftmBase, bool enable)
 Enables or disables the FTM peripheral timer capture test mode. More...
 
static bool FTM_DRV_IsFtmEnable (const FTM_Type *ftmBase)
 Get status of the FTMEN bit in the FTM_MODE register. More...
 
static void FTM_DRV_SetCountReinitSyncCmd (FTM_Type *const ftmBase, bool enable)
 Determines if the FTM counter is re-initialized when the selected trigger for synchronization is detected. More...
 
static bool FTM_DRV_IsWriteProtectionEnabled (const FTM_Type *ftmBase)
 Checks whether the write protection is enabled. More...
 
static bool FTM_DRV_IsFaultInputEnabled (const FTM_Type *ftmBase)
 Checks whether the logic OR of the fault inputs is enabled. More...
 
static bool FTM_DRV_IsFaultFlagDetected (const FTM_Type *ftmBase, uint8_t channel)
 Checks whether a fault condition is detected at the fault input. More...
 
static void FTM_DRV_ClearFaultFlagDetected (FTM_Type *const ftmBase, uint8_t channel)
 Clear a fault condition is detected at the fault input. More...
 
static void FTM_DRV_SetDualChnInvertCmd (FTM_Type *const ftmBase, uint8_t chnlPairNum, bool enable)
 Enables or disables the channel invert for a channel pair. More...
 
static void FTM_DRV_SetChnSoftwareCtrlCmd (FTM_Type *const ftmBase, uint8_t channel, bool enable)
 Enables or disables the channel software output control. More...
 
static void FTM_DRV_SetChnSoftwareCtrlVal (FTM_Type *const ftmBase, uint8_t channel, bool enable)
 Sets the channel software output control value. More...
 
static void FTM_DRV_SetGlobalLoadCmd (FTM_Type *const ftmBase)
 Set the global load mechanism. More...
 
static void FTM_DRV_SetLoadCmd (FTM_Type *const ftmBase, bool enable)
 Enable the global load. More...
 
static void FTM_DRV_SetHalfCycleCmd (FTM_Type *const ftmBase, bool enable)
 Enable the half cycle reload. More...
 
static void FTM_DRV_SetPwmLoadCmd (FTM_Type *const ftmBase, bool enable)
 Enables or disables the loading of MOD, CNTIN and CV with values of their write buffer. More...
 
static void FTM_DRV_SetPwmLoadChnSelCmd (FTM_Type *const ftmBase, uint8_t channel, bool enable)
 Includes or excludes the channel in the matching process. More...
 
static void FTM_DRV_SetInitTrigOnReloadCmd (FTM_Type *const ftmBase, bool enable)
 Enables or disables the FTM initialization trigger on Reload Point. More...
 
static void FTM_DRV_SetGlobalTimeBaseOutputCmd (FTM_Type *const ftmBase, bool enable)
 Enables or disables the FTM global time base signal generation to other FTM's. More...
 
static void FTM_DRV_SetGlobalTimeBaseCmd (FTM_Type *const ftmBase, bool enable)
 Enables or disables the FTM timer global time base. More...
 
static void FTM_DRV_SetLoadFreq (FTM_Type *const ftmBase, uint8_t val)
 Sets the FTM timer TOF Frequency. More...
 
static void FTM_DRV_SetExtPairDeadtimeValue (FTM_Type *const ftmBase, uint8_t channelPair, uint8_t value)
 Sets the FTM extended dead-time value for the channel pair. More...
 
static void FTM_DRV_SetPairDeadtimePrescale (FTM_Type *const ftmBase, uint8_t channelPair, ftm_deadtime_ps_t divider)
 Sets the FTM dead time divider for the channel pair. More...
 
static void FTM_DRV_SetPairDeadtimeCount (FTM_Type *const ftmBase, uint8_t channelPair, uint8_t count)
 Sets the FTM dead-time value for the channel pair. More...
 
static void FTM_DRV_SetMirrorMod (FTM_Type *const ftmBase, uint16_t value)
 Sets the mirror of the modulo integer value. More...
 
static uint16_t FTM_DRV_GetMirrorMod (const FTM_Type *ftmBase)
 Returns the mirror of the FTM peripheral counter modulo value. More...
 
static uint8_t FTM_DRV_GetModFracVal (const FTM_Type *ftmBase)
 Returns The modulo fractional value is used in the PWM period dithering. More...
 
static void FTM_DRV_SetMirrorChnMatchVal (FTM_Type *const ftmBase, uint8_t channel, uint16_t value)
 Sets the mirror of the channel (n) match integer value. More...
 
static uint16_t FTM_DRV_GetMirrorChnMatchVal (const FTM_Type *ftmBase, uint8_t channel)
 Returns the mirror of the channel (n) match integer value. More...
 
static uint8_t FTM_DRV_GetChnMatchFracVal (const FTM_Type *ftmBase, uint8_t channel)
 Returns the channel (n) match fractional value. More...
 
status_t FTM_DRV_Init (uint32_t instance, const ftm_user_config_t *info, ftm_state_t *state)
 Initializes the FTM driver. More...
 
status_t FTM_DRV_Deinit (uint32_t instance)
 Shuts down the FTM driver. More...
 
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 channels. More...
 
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 event. More...
 
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. More...
 
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 function it's mandatory to mask the match events using FTM_DRV_MaskOutputChannels and to enable software output control using FTM_DRV_SetSoftwareOutputChannelControl. More...
 
status_t FTM_DRV_SetSoftwareOutputChannelControl (uint32_t instance, uint8_t channelsMask, bool softwareTrigger)
 This function will configure which output channel can be software controlled. More...
 
status_t FTM_DRV_SetAllChnSoftwareOutputControl (uint32_t instance, uint8_t channelMask, uint8_t channelValueMask)
 This function will control list of channels by software to force the output to specified value. More...
 
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. More...
 
status_t FTM_DRV_SetModuloCounterValue (uint32_t instance, uint16_t counterValue, bool softwareTrigger)
 This function configure the maximum counter value. More...
 
status_t FTM_DRV_SetOutputlevel (uint32_t instance, uint8_t channel, uint8_t level)
 This function will set the channel edge or level on the selection of the channel mode. More...
 
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). More...
 
status_t FTM_DRV_EnableInterrupts (uint32_t instance, uint32_t interruptMask)
 This function will enable the generation a list of interrupts. It includes the FTM overflow interrupts, the reload point interrupt, the fault interrupt and the channel (n) interrupt. More...
 
void FTM_DRV_DisableInterrupts (uint32_t instance, uint32_t interruptMask)
 This function is used to disable some interrupts. More...
 
uint32_t FTM_DRV_GetEnabledInterrupts (uint32_t instance)
 This function will get the enabled FTM interrupts. More...
 
uint32_t FTM_DRV_GetStatusFlags (uint32_t instance)
 This function will get the FTM status flags. More...
 
void FTM_DRV_ClearStatusFlags (uint32_t instance, uint32_t flagMask)
 This function is used to clear the FTM status flags. More...
 
uint32_t FTM_DRV_GetFrequency (uint32_t instance)
 Retrieves the frequency of the clock source feeding the FTM counter. More...
 
uint16_t FTM_DRV_ConvertFreqToPeriodTicks (uint32_t instance, uint32_t freqencyHz)
 This function is used to covert the given frequency to period in ticks. More...
 

Variables

FTM_Type *const g_ftmBase [(2u)]
 Table of base addresses for FTM instances. More...
 
const IRQn_Type g_ftmIrqId [(2u)][(8U)]
 Interrupt vectors for the FTM peripheral. More...
 
const IRQn_Type g_ftmFaultIrqId [(2u)]
 
const IRQn_Type g_ftmOverflowIrqId [(2u)]
 
const IRQn_Type g_ftmReloadIrqId [(2u)]
 
ftm_state_tftmStatePtr [(2u)]
 Pointer to runtime state structure. More...
 

Macro Definition Documentation

#define CHAN0_IDX   (0U)

Channel number for CHAN1.

Definition at line 197 of file ftm_common.h.

#define CHAN1_IDX   (1U)

Channel number for CHAN2.

Definition at line 199 of file ftm_common.h.

#define CHAN2_IDX   (2U)

Channel number for CHAN3.

Definition at line 201 of file ftm_common.h.

#define CHAN3_IDX   (3U)

Channel number for CHAN4.

Definition at line 203 of file ftm_common.h.

#define CHAN4_IDX   (4U)

Channel number for CHAN5.

Definition at line 205 of file ftm_common.h.

#define CHAN5_IDX   (5U)

Channel number for CHAN6.

Definition at line 207 of file ftm_common.h.

#define CHAN6_IDX   (6U)

Channel number for CHAN7.

Definition at line 209 of file ftm_common.h.

#define CHAN7_IDX   (7U)

Definition at line 211 of file ftm_common.h.

#define FTM_RMW_CnSCV_REG (   base,
  channel,
  mask,
  value 
)    (((base)->CONTROLS[channel].CnSC) = ((((base)->CONTROLS[channel].CnSC) & ~(mask)) | (value)))

FTM_CnSCV - Read and modify and write Channel (n) Status And Control (RW)

Definition at line 115 of file ftm_common.h.

#define FTM_RMW_CNT (   base,
  mask,
  value 
)    (((base)->CNT) = ((((base)->CNT) & ~(mask)) | (value)))

FTM_CNT - Read and modify and write to Counter (RW)

Definition at line 90 of file ftm_common.h.

#define FTM_RMW_CNTIN (   base,
  mask,
  value 
)    (((base)->CNTIN) = ((((base)->CNTIN) & ~(mask)) | (value)))

FTM_CNTIN - Read and modify and write Counter Initial Value (RW)

Definition at line 100 of file ftm_common.h.

#define FTM_RMW_CnV_MIRROR (   base,
  channel,
  mask,
  value 
)    (((base)->CV_MIRROR[channel]) = ((((base)->CV_MIRROR[channel]) & ~(mask)) | (value)))

FTM_CnV_MIRROR - Read and modify and write mirror of channel (n) match value (RW)

Channel number for CHAN0.

Definition at line 190 of file ftm_common.h.

#define FTM_RMW_CONF (   base,
  mask,
  value 
)    (((base)->CONF) = ((((base)->CONF) & ~(mask)) | (value)))

FTM_CONF - Read and modify and write Configuration (RW)

Definition at line 139 of file ftm_common.h.

#define FTM_RMW_DEADTIME (   base,
  mask,
  value 
)    (((base)->DEADTIME) = ((((base)->DEADTIME) & ~(mask)) | (value)))

FTM_DEADTIME - Read and modify and write Dead-time Insertion Control (RW)

Definition at line 120 of file ftm_common.h.

#define FTM_RMW_EXTTRIG_REG (   base,
  mask,
  value 
)    (((base)->EXTTRIG) = ((((base)->EXTTRIG) & ~(mask)) | (value)))

FTM_EXTTRIG - Read and modify and write External Trigger Control (RW)

Definition at line 124 of file ftm_common.h.

#define FTM_RMW_FILTER (   base,
  mask,
  value 
)    (((base)->FILTER) = ((((base)->FILTER) & ~(mask)) | (value)))

FILTER - Read and modify and write Filter (RW)

Definition at line 149 of file ftm_common.h.

#define FTM_RMW_FLTCTRL (   base,
  mask,
  value 
)    (((base)->FLTCTRL) = ((((base)->FLTCTRL) & ~(mask)) | (value)))

FTM_FLTCTRL - Read and modify and write Fault Control (RW)

Definition at line 129 of file ftm_common.h.

#define FTM_RMW_FMS (   base,
  mask,
  value 
)    (((base)->FMS) = ((((base)->FMS) & ~(mask)) | (value)))

FTM_FMS - Read and modify and write Fault Mode Status (RW)

Definition at line 134 of file ftm_common.h.

#define FTM_RMW_MOD (   base,
  mask,
  value 
)    (((base)->MOD) = ((((base)->MOD) & ~(mask)) | (value)))

FTM_MOD - Read and modify and write Modulo (RW)

Definition at line 95 of file ftm_common.h.

#define FTM_RMW_MOD_MIRROR (   base,
  mask,
  value 
)    (((base)->MOD_MIRROR) = ((((base)->MOD_MIRROR) & ~(mask)) | (value)))

FTM_MOD_MIRROR - Read and modify and write mirror of modulo value for the FTM counter (RW)

Definition at line 185 of file ftm_common.h.

#define FTM_RMW_MODE (   base,
  mask,
  value 
)    (((base)->MODE) = ((((base)->MODE) & ~(mask)) | (value)))

FTM_MODE - Read and modify and write Counter Features Mode Selection (RW)

Definition at line 110 of file ftm_common.h.

#define FTM_RMW_PAIR0DEADTIME (   base,
  mask,
  value 
)    (((base)->PAIR0DEADTIME) = ((((base)->PAIR0DEADTIME) & ~(mask)) | (value)))

FTM_PAIR0DEADTIME - Read and modify and write Dead-time Insertion Control for the pair 0 (RW)

Definition at line 164 of file ftm_common.h.

#define FTM_RMW_PAIR1DEADTIME (   base,
  mask,
  value 
)    (((base)->PAIR1DEADTIME) = ((((base)->PAIR1DEADTIME) & ~(mask)) | (value)))

FTM_PAIR1DEADTIME - Read and modify and write Dead-time Insertion Control for the pair 1 (RW)

Definition at line 169 of file ftm_common.h.

#define FTM_RMW_PAIR2DEADTIME (   base,
  mask,
  value 
)    (((base)->PAIR2DEADTIME) = ((((base)->PAIR2DEADTIME) & ~(mask)) | (value)))

FTM_PAIR2DEADTIME - Read and modify and write Dead-time Insertion Control for the pair 2 (RW)

Definition at line 174 of file ftm_common.h.

#define FTM_RMW_PAIR3DEADTIME (   base,
  mask,
  value 
)    (((base)->PAIR3DEADTIME) = ((((base)->PAIR3DEADTIME) & ~(mask)) | (value)))

FTM_PAIR3DEADTIME - Read and modify and write Dead-time Insertion Control for the pair 3 (RW)

Definition at line 179 of file ftm_common.h.

#define FTM_RMW_POL (   base,
  mask,
  value 
)    (((base)->POL) = ((((base)->POL) & ~(mask)) | (value)))

POL - Read and modify and write Polarity (RW)

Definition at line 144 of file ftm_common.h.

#define FTM_RMW_QDCTRL (   base,
  mask,
  value 
)    (((base)->QDCTRL) = ((((base)->QDCTRL) & ~(mask)) | (value)))

QDCTRL - Read and modify and write Quadrature Decoder Control And Status (RW)

Definition at line 159 of file ftm_common.h.

#define FTM_RMW_SC (   base,
  mask,
  value 
)    (((base)->SC) = ((((base)->SC) & ~(mask)) | (value)))

FTM_SC - Read and modify and write to Status And Control (RW)

Definition at line 85 of file ftm_common.h.

#define FTM_RMW_STATUS (   base,
  mask,
  value 
)    (((base)->STATUS) = ((((base)->STATUS) & ~(mask)) | (value)))

FTM_STATUS - Read and modify and write Capture And Compare Status (RW)

Definition at line 105 of file ftm_common.h.

#define FTM_RMW_SYNC (   base,
  mask,
  value 
)    (((base)->SYNC) = ((((base)->SYNC) & ~(mask)) | (value)))

SYNC - Read and modify and write Synchronization (RW)

Definition at line 154 of file ftm_common.h.

Enumeration Type Documentation

Options for the FlexTimer behavior in BDM Mode.

Implements : ftm_bdm_mode_t_Class

Enumerator
FTM_BDM_MODE_00 

FTM counter stopped, CH(n)F bit can be set, FTM channels in functional mode, writes to MOD,CNTIN and C(n)V registers bypass the register buffers

FTM_BDM_MODE_01 

FTM counter stopped, CH(n)F bit is not set, FTM channels outputs are forced to their safe value , writes to MOD,CNTIN and C(n)V registers bypass the register buffers

FTM_BDM_MODE_10 

FTM counter stopped, CH(n)F bit is not set, FTM channels outputs are frozen when chip enters in BDM mode, writes to MOD, CNTIN and C(n)V registers bypass the register buffers

FTM_BDM_MODE_11 

FTM counter in functional mode, CH(n)F bit can be set, FTM channels in functional mode, writes to MOD,CNTIN and C(n)V registers is in fully functional mode

Definition at line 370 of file ftm_common.h.

FlexTimer pre-scaler factor selection for the clock source. In quadrature decoder mode set FTM_CLOCK_DIVID_BY_1.

Implements : ftm_clock_ps_t_Class

Enumerator
FTM_CLOCK_DIVID_BY_1 

Divide by 1

FTM_CLOCK_DIVID_BY_2 

Divide by 2

FTM_CLOCK_DIVID_BY_4 

Divide by 4

FTM_CLOCK_DIVID_BY_8 

Divide by 8

FTM_CLOCK_DIVID_BY_16 

Divide by 16

FTM_CLOCK_DIVID_BY_32 

Divide by 32

FTM_CLOCK_DIVID_BY_64 

Divide by 64

FTM_CLOCK_DIVID_BY_128 

Divide by 128

Definition at line 252 of file ftm_common.h.

FlexTimer clock source selection.

Implements : ftm_clock_source_t_Class

Enumerator
FTM_CLOCK_SOURCE_NONE 

None use clock for FTM

FTM_CLOCK_SOURCE_SYSTEMCLK 

System clock

FTM_CLOCK_SOURCE_FIXEDCLK 

Fixed clock

FTM_CLOCK_SOURCE_EXTERNALCLK 

External clock

Definition at line 238 of file ftm_common.h.

FlexTimer operation mode.

Implements : ftm_config_mode_t_Class

Enumerator
FTM_MODE_NOT_INITIALIZED 

The driver is not initialized

FTM_MODE_INPUT_CAPTURE 

Input capture

FTM_MODE_OUTPUT_COMPARE 

Output compare

FTM_MODE_EDGE_ALIGNED_PWM 

Edge aligned PWM

FTM_MODE_CEN_ALIGNED_PWM 

Center aligned PWM

FTM_MODE_QUADRATURE_DECODER 

Quadrature decoder

FTM_MODE_UP_TIMER 

Timer with up counter

FTM_MODE_UP_DOWN_TIMER 

timer with up-down counter

Definition at line 221 of file ftm_common.h.

FlexTimer pre-scaler factor for the dead-time insertion.

Implements : ftm_deadtime_ps_t_Class

Enumerator
FTM_DEADTIME_DIVID_BY_1 

Divide by 1

FTM_DEADTIME_DIVID_BY_4 

Divide by 4

FTM_DEADTIME_DIVID_BY_16 

Divide by 16

Definition at line 334 of file ftm_common.h.

List of FTM interrupts.

Implements : ftm_interrupt_option_t_Class

Enumerator
FTM_CHANNEL0_INT_ENABLE 

Channel 0 interrupt

FTM_CHANNEL1_INT_ENABLE 

Channel 1 interrupt

FTM_CHANNEL2_INT_ENABLE 

Channel 2 interrupt

FTM_CHANNEL3_INT_ENABLE 

Channel 3 interrupt

FTM_CHANNEL4_INT_ENABLE 

Channel 4 interrupt

FTM_CHANNEL5_INT_ENABLE 

Channel 5 interrupt

FTM_CHANNEL6_INT_ENABLE 

Channel 6 interrupt

FTM_CHANNEL7_INT_ENABLE 

Channel 7 interrupt

FTM_FAULT_INT_ENABLE 

Fault interrupt

FTM_TIME_OVER_FLOW_INT_ENABLE 

Time overflow interrupt

FTM_RELOAD_INT_ENABLE 

Reload interrupt; Available only on certain SoC's

Definition at line 269 of file ftm_common.h.

FTM update register.

Implements : ftm_pwm_sync_mode_t_Class

Enumerator
FTM_WAIT_LOADING_POINTS 

FTM register is updated at first loading point

FTM_UPDATE_NOW 

FTM register is updated immediately

Definition at line 323 of file ftm_common.h.

FlexTimer quadrature decode modes, phase encode or count and direction mode.

Implements : ftm_quad_decode_mode_t_Class

Enumerator
FTM_QUAD_PHASE_ENCODE 

Phase encoding mode

FTM_QUAD_COUNT_AND_DIR 

Counter and direction encoding mode

Definition at line 346 of file ftm_common.h.

FlexTimer quadrature phase polarities, normal or inverted polarity.

Implements : ftm_quad_phase_polarity_t_Class

Enumerator
FTM_QUAD_PHASE_NORMAL 

Phase input signal is not inverted before identifying the rising and falling edges of this signal

FTM_QUAD_PHASE_INVERT 

Phase input signal is inverted before identifying the rising and falling edges of this signal

Definition at line 357 of file ftm_common.h.

FTM sync source.

Implements : ftm_reg_update_t_Class

Enumerator
FTM_SYSTEM_CLOCK 

Register is updated with its buffer value at all rising edges of system clock

FTM_PWM_SYNC 

Register is updated with its buffer value at the FTM synchronization

Definition at line 310 of file ftm_common.h.

List of FTM flags.

Implements : ftm_status_flag_t_Class

Enumerator
FTM_CHANNEL0_FLAG 

Channel 0 Flag

FTM_CHANNEL1_FLAG 

Channel 1 Flag

FTM_CHANNEL2_FLAG 

Channel 2 Flag

FTM_CHANNEL3_FLAG 

Channel 3 Flag

FTM_CHANNEL4_FLAG 

Channel 4 Flag

FTM_CHANNEL5_FLAG 

Channel 5 Flag

FTM_CHANNEL6_FLAG 

Channel 6 Flag

FTM_CHANNEL7_FLAG 

Channel 7 Flag

FTM_FAULT_FLAG 

Fault Flag

FTM_TIME_OVER_FLOW_FLAG 

Time overflow Flag

FTM_RELOAD_FLAG 

Reload Flag; Available only on certain SoC's

FTM_CHANNEL_TRIGGER_FLAG 

Channel trigger Flag

Definition at line 289 of file ftm_common.h.

Function Documentation

static void FTM_DRV_ClearChnEventStatus ( FTM_Type *const  ftmBase,
uint8_t  channel 
)
inlinestatic

Clears the FTM peripheral timer all channel event status.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number

Implements : FTM_DRV_ClearChnEventStatus_Activity

Definition at line 796 of file ftm_common.h.

static void FTM_DRV_ClearChSC ( FTM_Type *const  ftmBase,
uint8_t  channel 
)
inlinestatic

Clears the content of Channel (n) Status And Control.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number

Implements : FTM_DRV_ClearChSC_Activity

Definition at line 543 of file ftm_common.h.

static void FTM_DRV_ClearFaultFlagDetected ( FTM_Type *const  ftmBase,
uint8_t  channel 
)
inlinestatic

Clear a fault condition is detected at the fault input.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel

Implements : FTM_DRV_ClearFaultFlagDetected_Activity

Definition at line 982 of file ftm_common.h.

void FTM_DRV_ClearStatusFlags ( uint32_t  instance,
uint32_t  flagMask 
)

This function is used to clear the FTM status flags.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]flagMaskThe status flags to clear. This is a logical OR of members of the enumeration ftm_status_flag_t

Definition at line 681 of file ftm_common.c.

uint16_t FTM_DRV_ConvertFreqToPeriodTicks ( uint32_t  instance,
uint32_t  freqencyHz 
)

This function is used to covert the given frequency to period in ticks.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]freqencyHzFrequency value in Hz.
Returns
The value in ticks of the frequency

Definition at line 788 of file ftm_common.c.

status_t FTM_DRV_Deinit ( uint32_t  instance)

Shuts down the FTM driver.

Parameters
[in]instanceThe FTM peripheral instance number.
Returns
operation status
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 196 of file ftm_common.c.

static void FTM_DRV_DisableFaultInt ( FTM_Type *const  ftmBase)
inlinestatic

Disables the FTM peripheral timer fault interrupt.

Parameters
[in]ftmBaseThe FTM base address pointer

Implements : FTM_DRV_DisableFaultInt_Activity

Definition at line 869 of file ftm_common.h.

void FTM_DRV_DisableInterrupts ( uint32_t  instance,
uint32_t  interruptMask 
)

This function is used to disable some interrupts.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]interruptMaskThe mask of interrupt. This is a logical OR of members of the enumeration ftm_interrupt_option_t

Definition at line 536 of file ftm_common.c.

status_t FTM_DRV_EnableInterrupts ( uint32_t  instance,
uint32_t  interruptMask 
)

This function will enable the generation a list of interrupts. It includes the FTM overflow interrupts, the reload point interrupt, the fault interrupt and the channel (n) interrupt.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]interruptMaskThe mask of interrupt. This is a logical OR of members of the enumeration ftm_interrupt_option_t
Returns
operation status
  • STATUS_SUCCESS : Completed successfully.

Definition at line 485 of file ftm_common.c.

static bool FTM_DRV_GetChInputState ( const FTM_Type ftmBase,
uint8_t  channel 
)
inlinestatic

Get the state of channel input.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number
Returns
State of the channel inputs
  • true : The channel input is one
  • false: The channel input is zero

Implements : FTM_DRV_GetChInputState_Activity

Definition at line 709 of file ftm_common.h.

static uint16_t FTM_DRV_GetChnCountVal ( const FTM_Type ftmBase,
uint8_t  channel 
)
inlinestatic

Gets the FTM peripheral timer channel counter value.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number
Returns
Channel counter value

Implements : FTM_DRV_GetChnCountVal_Activity

Definition at line 746 of file ftm_common.h.

static uint8_t FTM_DRV_GetChnEdgeLevel ( const FTM_Type ftmBase,
uint8_t  channel 
)
inlinestatic

Gets the FTM peripheral timer channel edge level.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number
Returns
The ELSnB:ELSnA mode value, will be 00, 01, 10, 11

Implements : FTM_DRV_GetChnEdgeLevel_Activity

Definition at line 565 of file ftm_common.h.

static bool FTM_DRV_GetChnEventStatus ( const FTM_Type ftmBase,
uint8_t  channel 
)
inlinestatic

Gets the FTM peripheral timer channel event status.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number
Returns
Channel event status
  • true : A channel event has occurred
  • false : No channel event has occurred

Implements : FTM_DRV_GetChnEventStatus_Activity

Definition at line 766 of file ftm_common.h.

static uint8_t FTM_DRV_GetChnMatchFracVal ( const FTM_Type ftmBase,
uint8_t  channel 
)
inlinestatic

Returns the channel (n) match fractional value.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel (n)
Returns
The channel (n) match fractional value is used in the PWM edge dithering

Implements : FTM_DRV_GetChnMatchFracVal_Activity

Definition at line 1448 of file ftm_common.h.

static bool FTM_DRV_GetChOutputValue ( const FTM_Type ftmBase,
uint8_t  channel 
)
inlinestatic

Get the value of channel output.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number
Returns
Value of the channel outputs
  • true : The channel output is one
  • false: The channel output is zero

Implements : FTM_DRV_GetChOutputValue_Activity

Definition at line 728 of file ftm_common.h.

static uint8_t FTM_DRV_GetClockFilterPs ( const FTM_Type ftmBase)
inlinestatic

Reads the FTM filter clock divider.

Parameters
[in]ftmBaseThe FTM base address pointer
Returns
The FTM filter clock pre-scale divider

Implements : FTM_DRV_GetClockFilterPs_Activity

Definition at line 488 of file ftm_common.h.

static uint16_t FTM_DRV_GetCounter ( const FTM_Type ftmBase)
inlinestatic

Returns the FTM peripheral current counter value.

Parameters
[in]ftmBaseThe FTM base address pointer
Returns
The current FTM timer counter value

Implements : FTM_DRV_GetCounter_Activity

Definition at line 502 of file ftm_common.h.

static uint16_t FTM_DRV_GetCounterInitVal ( const FTM_Type ftmBase)
inlinestatic

Returns the FTM peripheral counter initial value.

Parameters
[in]ftmBaseThe FTM base address pointer
Returns
FTM timer counter initial value

Implements : FTM_DRV_GetCounterInitVal_Activity

Definition at line 530 of file ftm_common.h.

uint32_t FTM_DRV_GetEnabledInterrupts ( uint32_t  instance)

This function will get the enabled FTM interrupts.

Parameters
[in]instanceThe FTM peripheral instance number.
Returns
The enabled interrupts. This is the logical OR of members of the enumeration ftm_interrupt_option_t

Definition at line 585 of file ftm_common.c.

static uint32_t FTM_DRV_GetEventStatus ( const FTM_Type ftmBase)
inlinestatic

Gets the FTM peripheral timer status info for all channels.

Parameters
[in]ftmBaseThe FTM base address pointer
Returns
Channel event status value

Implements : FTM_DRV_GetEventStatus_Activity

Definition at line 783 of file ftm_common.h.

uint32_t FTM_DRV_GetFrequency ( uint32_t  instance)

Retrieves the frequency of the clock source feeding the FTM counter.

Function will return a 0 if no clock source is selected and the FTM counter is disabled

Parameters
[in]instanceThe FTM peripheral instance number.
Returns
The frequency of the clock source running the FTM counter (0 if counter is disabled)

Definition at line 733 of file ftm_common.c.

static uint16_t FTM_DRV_GetMirrorChnMatchVal ( const FTM_Type ftmBase,
uint8_t  channel 
)
inlinestatic

Returns the mirror of the channel (n) match integer value.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel (n)
Returns
the mirror of the channel (n) match value

Implements : FTM_DRV_GetMirrorChnMatchVal_Activity

Definition at line 1432 of file ftm_common.h.

static uint16_t FTM_DRV_GetMirrorMod ( const FTM_Type ftmBase)
inlinestatic

Returns the mirror of the FTM peripheral counter modulo value.

Parameters
[in]ftmBaseThe FTM base address pointer
Returns
the mirror of the FTM timer modulo value

Implements : FTM_DRV_GetMirrorMod_Activity

Definition at line 1387 of file ftm_common.h.

static uint16_t FTM_DRV_GetMod ( const FTM_Type ftmBase)
inlinestatic

Returns the FTM peripheral counter modulo value.

Parameters
[in]ftmBaseThe FTM base address pointer
Returns
FTM timer modulo value

Implements : FTM_DRV_GetMod_Activity

Definition at line 516 of file ftm_common.h.

static uint8_t FTM_DRV_GetModFracVal ( const FTM_Type ftmBase)
inlinestatic

Returns The modulo fractional value is used in the PWM period dithering.

Parameters
[in]ftmBaseThe FTM base address pointer
Returns
the modulo fractional value

Implements : FTM_DRV_GetModFracVal_Activity

Definition at line 1401 of file ftm_common.h.

uint32_t FTM_DRV_GetStatusFlags ( uint32_t  instance)

This function will get the FTM status flags.

Parameters
[in]instanceThe FTM peripheral instance number.
Returns
The status flags. This is the logical OR of members of the enumeration ftm_status_flag_t

Definition at line 631 of file ftm_common.c.

static bool FTM_DRV_GetTriggerControled ( const FTM_Type ftmBase,
uint8_t  channel 
)
inlinestatic

Returns whether the trigger mode is enabled.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number
Returns
State of the channel outputs
  • true : Enabled a trigger generation on channel output
  • false: PWM outputs without generating a pulse

Implements : FTM_DRV_GetTriggerControled_Activity

Definition at line 690 of file ftm_common.h.

status_t FTM_DRV_Init ( uint32_t  instance,
const ftm_user_config_t info,
ftm_state_t state 
)

Initializes the FTM driver.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]infoThe FTM user configuration structure, see ftm_user_config_t.
[out]stateThe FTM state structure of the driver.
Returns
operation status
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 117 of file ftm_common.c.

static bool FTM_DRV_IsChnDma ( const FTM_Type ftmBase,
uint8_t  channel 
)
inlinestatic

Returns whether the FTM peripheral timer channel DMA is enabled.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number
Returns
State of the FTM peripheral timer channel DMA
  • true : Enabled DMA transfers
  • false: Disabled DMA transfers

Implements : FTM_DRV_IsChnDma_Activity

Definition at line 650 of file ftm_common.h.

static bool FTM_DRV_IsChnIcrst ( const FTM_Type ftmBase,
uint8_t  channel 
)
inlinestatic

Returns whether the FTM FTM counter is reset.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number
Returns
State of the FTM peripheral timer channel ICRST
  • true : Enabled the FTM counter reset
  • false: Disabled the FTM counter reset

Implements : FTM_DRV_IsChnIcrst_Activity

Definition at line 610 of file ftm_common.h.

static bool FTM_DRV_IsFaultFlagDetected ( const FTM_Type ftmBase,
uint8_t  channel 
)
inlinestatic

Checks whether a fault condition is detected at the fault input.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel
Returns
the fault condition status
  • true : A fault condition was detected at the fault input
  • false: No fault condition was detected at the fault input

Implements : FTM_DRV_IsFaultFlagDetected_Activity

Definition at line 966 of file ftm_common.h.

static bool FTM_DRV_IsFaultInputEnabled ( const FTM_Type ftmBase)
inlinestatic

Checks whether the logic OR of the fault inputs is enabled.

Parameters
[in]ftmBaseThe FTM base address pointer
Returns
the enabled fault inputs status
  • true : The logic OR of the enabled fault inputs is 1
  • false: The logic OR of the enabled fault inputs is 0

Implements : FTM_DRV_IsFaultInputEnabled_Activity

Definition at line 949 of file ftm_common.h.

static bool FTM_DRV_IsFtmEnable ( const FTM_Type ftmBase)
inlinestatic

Get status of the FTMEN bit in the FTM_MODE register.

Parameters
[in]ftmBaseThe FTM base address pointer
Returns
the FTM Enable status
  • true : TPM compatibility. Free running counter and synchronization compatible with TPM
  • false: Free running counter and synchronization are different from TPM behaviour

Implements : FTM_DRV_IsFtmEnable_Activity

Definition at line 900 of file ftm_common.h.

static bool FTM_DRV_IsWriteProtectionEnabled ( const FTM_Type ftmBase)
inlinestatic

Checks whether the write protection is enabled.

Parameters
[in]ftmBaseThe FTM base address pointer
Returns
Write-protection status
  • true : If enabled
  • false: If not

Implements : FTM_DRV_IsWriteProtectionEnabled_Activity

Definition at line 933 of file ftm_common.h.

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 channels.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]channelsMaskThe mask which will select which channels will ignore match events.
[in]softwareTriggerIf true a software trigger is generate to update PWM parameters.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 216 of file ftm_common.c.

status_t FTM_DRV_SetAllChnSoftwareOutputControl ( uint32_t  instance,
uint8_t  channelMask,
uint8_t  channelValueMask 
)

This function will control list of channels by software to force the output to specified value.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]channelMaskThe mask which will configure the channels which can be software controlled.
[in]channelValueMaskThe values which will be software configured for channels.
Returns
success
  • STATUS_SUCCESS : Completed successfully.

Definition at line 321 of file ftm_common.c.

static void FTM_DRV_SetCaptureTestCmd ( FTM_Type *const  ftmBase,
bool  enable 
)
inlinestatic

Enables or disables the FTM peripheral timer capture test mode.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]enableCapture Test Mode Enable
  • true : Capture test mode is enabled
  • false: Capture test mode is disabled

Implements : FTM_DRV_SetCaptureTestCmd_Activity

Definition at line 884 of file ftm_common.h.

static void FTM_DRV_SetChnDmaCmd ( FTM_Type *const  ftmBase,
uint8_t  channel,
bool  enable 
)
inlinestatic

Enables or disables the FTM peripheral timer channel DMA.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number
[in]enableEnable DMA transfers for the channel
  • true : Enabled DMA transfers
  • false: Disabled DMA transfers

Implements : FTM_DRV_SetChnDmaCmd_Activity

Definition at line 629 of file ftm_common.h.

static void FTM_DRV_SetChnIcrstCmd ( FTM_Type *const  ftmBase,
uint8_t  channel,
bool  enable 
)
inlinestatic

Configure the feature of FTM counter reset by the selected input capture event.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number
[in]enableEnable the FTM counter reset
  • true : FTM counter is reset
  • false: FTM counter is not reset

Implements : FTM_DRV_SetChnIcrstCmd_Activity

Definition at line 589 of file ftm_common.h.

static void FTM_DRV_SetChnOutputInitStateCmd ( FTM_Type *const  ftmBase,
uint8_t  channel,
bool  state 
)
inlinestatic

Sets the FTM peripheral timer channel output initial state 0 or 1.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number
[in]stateInitial state for channels output
  • true : The initialization value is 1
  • false: The initialization value is 0

Implements : FTM_DRV_SetChnOutputInitStateCmd_Activity

Definition at line 846 of file ftm_common.h.

static void FTM_DRV_SetChnOutputMask ( FTM_Type *const  ftmBase,
uint8_t  channel,
bool  mask 
)
inlinestatic

Sets the FTM peripheral timer channel output mask.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number
[in]maskValue to set Output Mask
  • true : Channel output is masked
  • false: Channel output is not masked

Implements : FTM_DRV_SetChnOutputMask_Activity

Definition at line 819 of file ftm_common.h.

static void FTM_DRV_SetChnSoftwareCtrlCmd ( FTM_Type *const  ftmBase,
uint8_t  channel,
bool  enable 
)
inlinestatic

Enables or disables the channel software output control.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelChannel to be enabled or disabled
[in]enableState of channel software output control
  • true : To enable, channel output will be affected by software output control
  • false: To disable, channel output is unaffected

Implements : FTM_DRV_SetChnSoftwareCtrlCmd_Activity

Definition at line 1032 of file ftm_common.h.

static void FTM_DRV_SetChnSoftwareCtrlVal ( FTM_Type *const  ftmBase,
uint8_t  channel,
bool  enable 
)
inlinestatic

Sets the channel software output control value.

Parameters
[in]ftmBaseThe FTM base address pointer.
[in]channelChannel to be configured
[in]enableState of software output control value
  • true : to force 1 to the channel output
  • false: to force 0 to the channel output

Implements : FTM_DRV_SetChnSoftwareCtrlVal_Activity

Definition at line 1059 of file ftm_common.h.

static void FTM_DRV_SetClockFilterPs ( FTM_Type *const  ftmBase,
uint8_t  filterPrescale 
)
inlinestatic

Sets the filter Pre-scaler divider.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]filterPrescaleThe FTM peripheral clock pre-scale divider

Implements : FTM_DRV_SetClockFilterPs_Activity

Definition at line 473 of file ftm_common.h.

static void FTM_DRV_SetCountReinitSyncCmd ( FTM_Type *const  ftmBase,
bool  enable 
)
inlinestatic

Determines if the FTM counter is re-initialized when the selected trigger for synchronization is detected.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]enableFTM counter re-initialization selection
  • true : To update FTM counter when triggered
  • false: To count normally

Implements : FTM_DRV_SetCountReinitSyncCmd_Activity

Definition at line 916 of file ftm_common.h.

static void FTM_DRV_SetDualChnInvertCmd ( FTM_Type *const  ftmBase,
uint8_t  chnlPairNum,
bool  enable 
)
inlinestatic

Enables or disables the channel invert for a channel pair.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]chnlPairNumThe FTM peripheral channel pair number
[in]enableState of channel invert for a channel pair
  • true : To enable channel inverting
  • false: To disable channel inversion

Implements : FTM_DRV_SetDualChnInvertCmd_Activity

Definition at line 1005 of file ftm_common.h.

static void FTM_DRV_SetExtPairDeadtimeValue ( FTM_Type *const  ftmBase,
uint8_t  channelPair,
uint8_t  value 
)
inlinestatic

Sets the FTM extended dead-time value for the channel pair.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelPairThe FTM peripheral channel pair (n)
[in]valueThe FTM peripheral extend pre-scale divider using the concatenation with the dead-time value

Implements : FTM_DRV_SetExtPairDeadtimeValue_Activity

Definition at line 1258 of file ftm_common.h.

static void FTM_DRV_SetGlobalLoadCmd ( FTM_Type *const  ftmBase)
inlinestatic

Set the global load mechanism.

Parameters
[in]ftmBaseThe FTM base address pointer
  • true : LDOK bit is set
  • false: No action

Implements : FTM_DRV_SetGlobalLoadCmd_Activity

Definition at line 1085 of file ftm_common.h.

static void FTM_DRV_SetGlobalTimeBaseCmd ( FTM_Type *const  ftmBase,
bool  enable 
)
inlinestatic

Enables or disables the FTM timer global time base.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]enableState of global time base
  • true : To enable
  • false: To disable

Implements : FTM_DRV_SetGlobalTimeBaseCmd_Activity

Definition at line 1229 of file ftm_common.h.

static void FTM_DRV_SetGlobalTimeBaseOutputCmd ( FTM_Type *const  ftmBase,
bool  enable 
)
inlinestatic

Enables or disables the FTM global time base signal generation to other FTM's.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]enableState of global time base signal
  • true : To enable
  • false: To disable

Implements : FTM_DRV_SetGlobalTimeBaseOutputCmd_Activity

Definition at line 1213 of file ftm_common.h.

static void FTM_DRV_SetHalfCycleCmd ( FTM_Type *const  ftmBase,
bool  enable 
)
inlinestatic

Enable the half cycle reload.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]enableState of the half cycle match as a reload opportunity
  • true : Half cycle reload is enabled
  • false: Half cycle reload is disabled

Implements : FTM_DRV_SetHalfCycleCmd_Activity

Definition at line 1123 of file ftm_common.h.

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.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]reloadPointCounter value which generates the reload point.
[in]softwareTriggerIf true a software trigger is generate to update parameters.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 258 of file ftm_common.c.

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 event.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]counterValueInitial counter value.
[in]softwareTriggerIf true a software trigger is generate to update parameters.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 237 of file ftm_common.c.

static void FTM_DRV_SetInitTrigOnReloadCmd ( FTM_Type *const  ftmBase,
bool  enable 
)
inlinestatic

Enables or disables the FTM initialization trigger on Reload Point.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]enablebit controls whether an initialization trigger is generated
  • true : Trigger is generated when a reload point is reached
  • false: Trigger is generated on counter wrap events

Implements : FTM_DRV_SetInitTrigOnReloadCmd_Activity

Definition at line 1197 of file ftm_common.h.

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.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]channelsPairMaskThe mask which will configure which channel pair will invert the second channel.
[in]softwareTriggerIf true a software trigger is generate to update registers.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 344 of file ftm_common.c.

static void FTM_DRV_SetLoadCmd ( FTM_Type *const  ftmBase,
bool  enable 
)
inlinestatic

Enable the global load.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]enableState of the global load mechanism
  • true : Global Load OK enabled
  • false: Global Load OK disabled

Implements : FTM_DRV_SetLoadCmd_Activity

Definition at line 1100 of file ftm_common.h.

static void FTM_DRV_SetLoadFreq ( FTM_Type *const  ftmBase,
uint8_t  val 
)
inlinestatic

Sets the FTM timer TOF Frequency.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]valValue of the TOF bit set frequency

Implements : FTM_DRV_SetLoadFreq_Activity

Definition at line 1243 of file ftm_common.h.

static void FTM_DRV_SetMirrorChnMatchVal ( FTM_Type *const  ftmBase,
uint8_t  channel,
uint16_t  value 
)
inlinestatic

Sets the mirror of the channel (n) match integer value.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel (n)
[in]valueThe value to be set to the mirror of the channel (n) match integer value

Implements : FTM_DRV_SetMirrorChnMatchVal_Activity

Definition at line 1415 of file ftm_common.h.

static void FTM_DRV_SetMirrorMod ( FTM_Type *const  ftmBase,
uint16_t  value 
)
inlinestatic

Sets the mirror of the modulo integer value.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]valueThe value to be set to the timer modulo

Implements : FTM_DRV_SetMirrorMod_Activity

Definition at line 1372 of file ftm_common.h.

status_t FTM_DRV_SetModuloCounterValue ( uint32_t  instance,
uint16_t  counterValue,
bool  softwareTrigger 
)

This function configure the maximum counter value.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]counterValueMaximum counter value
[in]softwareTriggerIf true a software trigger is generate to update parameters.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 364 of file ftm_common.c.

status_t FTM_DRV_SetOutputlevel ( uint32_t  instance,
uint8_t  channel,
uint8_t  level 
)

This function will set the channel edge or level on the selection of the channel mode.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]channelThe channel number.
[in]levelThe level or edge selection for channel mode.
Returns
success
  • STATUS_SUCCESS : Completed successfully.

Definition at line 385 of file ftm_common.c.

static void FTM_DRV_SetPairDeadtimeCount ( FTM_Type *const  ftmBase,
uint8_t  channelPair,
uint8_t  count 
)
inlinestatic

Sets the FTM dead-time value for the channel pair.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelPairThe FTM peripheral channel pair (n)
[in]countThe FTM peripheral selects the dead-time value
  • 0U : no counts inserted
  • 1U : 1 count is inserted
  • 2U : 2 count is inserted
  • ... up to a possible 63 counts

Implements : FTM_DRV_SetPairDeadtimeCount_Activity

Definition at line 1336 of file ftm_common.h.

static void FTM_DRV_SetPairDeadtimePrescale ( FTM_Type *const  ftmBase,
uint8_t  channelPair,
ftm_deadtime_ps_t  divider 
)
inlinestatic

Sets the FTM dead time divider for the channel pair.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelPairThe FTM peripheral channel pair (n)
[in]dividerThe FTM peripheral pre-scaler divider
  • FTM_DEADTIME_DIVID_BY_1 : Divide by 1
  • FTM_DEADTIME_DIVID_BY_4 : Divide by 4
  • FTM_DEADTIME_DIVID_BY_16: Divide by 16

Implements : FTM_DRV_SetPairDeadtimePrescale_Activity

Definition at line 1297 of file ftm_common.h.

static void FTM_DRV_SetPwmLoadChnSelCmd ( FTM_Type *const  ftmBase,
uint8_t  channel,
bool  enable 
)
inlinestatic

Includes or excludes the channel in the matching process.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelChannel to be configured
[in]enableState of channel
  • true : means include the channel in the matching process
  • false: means do not include channel in the matching process

Implements : FTM_DRV_SetPwmLoadChnSelCmd_Activity

Definition at line 1170 of file ftm_common.h.

static void FTM_DRV_SetPwmLoadCmd ( FTM_Type *const  ftmBase,
bool  enable 
)
inlinestatic

Enables or disables the loading of MOD, CNTIN and CV with values of their write buffer.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]enableState of loading updated values
  • true : To enable
  • false: To disable

Implements : FTM_DRV_SetPwmLoadCmd_Activity

Definition at line 1146 of file ftm_common.h.

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 function it's mandatory to mask the match events using FTM_DRV_MaskOutputChannels and to enable software output control using FTM_DRV_SetSoftwareOutputChannelControl.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]channelsValuesThe values which will be software configured for channels.
[in]softwareTriggerIf true a software trigger is generate to update registers.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 281 of file ftm_common.c.

status_t FTM_DRV_SetSoftwareOutputChannelControl ( uint32_t  instance,
uint8_t  channelsMask,
bool  softwareTrigger 
)

This function will configure which output channel can be software controlled.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]channelsMaskThe mask which will configure the channels which can be software controlled.
[in]softwareTriggerIf true a software trigger is generate to update registers.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 301 of file ftm_common.c.

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).

Parameters
[in]instanceThe FTM peripheral instance number.
[in]paramThe sync configuration structure.
Returns
operation status
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 409 of file ftm_common.c.

static void FTM_DRV_SetTrigModeControlCmd ( FTM_Type *const  ftmBase,
uint8_t  channel,
bool  enable 
)
inlinestatic

Enables or disables the trigger generation on FTM channel outputs.

Parameters
[in]ftmBaseThe FTM base address pointer
[in]channelThe FTM peripheral channel number
[in]enableTrigger mode control
  • false : Enable PWM output without generating a pulse
  • true : Disable a trigger generation on channel output

Implements : FTM_DRV_SetTrigModeControlCmd_Activity

Definition at line 669 of file ftm_common.h.

Variable Documentation

ftm_state_t* ftmStatePtr[(2u)]

Pointer to runtime state structure.

Definition at line 84 of file ftm_common.c.

FTM_Type* const g_ftmBase[(2u)]

Table of base addresses for FTM instances.

Definition at line 71 of file ftm_common.c.

const IRQn_Type g_ftmFaultIrqId[(2u)]

Definition at line 75 of file ftm_common.c.

const IRQn_Type g_ftmIrqId[(2u)][(8U)]

Interrupt vectors for the FTM peripheral.

Definition at line 74 of file ftm_common.c.

const IRQn_Type g_ftmOverflowIrqId[(2u)]

Definition at line 76 of file ftm_common.c.

const IRQn_Type g_ftmReloadIrqId[(2u)]

Definition at line 77 of file ftm_common.c.