S32 SDK
FTM Driver

Detailed Description

FlexTimer Peripheral Driver.

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...
 
struct  ftm_timer_param_t
 FlexTimer driver timer mode configuration structure. More...
 
struct  ftm_pwm_ch_fault_param_t
 FlexTimer driver PWM Fault channel parameters. More...
 
struct  ftm_pwm_fault_param_t
 FlexTimer driver PWM Fault parameter. More...
 
struct  ftm_independent_ch_param_t
 FlexTimer driver independent PWM parameter. More...
 
struct  ftm_combined_ch_param_t
 FlexTimer driver combined PWM parameter. More...
 
struct  ftm_pwm_param_t
 FlexTimer driver PWM parameters. More...
 
struct  ftm_input_ch_param_t
 FlexTimer driver Input capture parameters for each channel. More...
 
struct  ftm_input_param_t
 FlexTimer driver input capture parameters. More...
 
struct  ftm_output_cmp_ch_param_t
 FlexTimer driver PWM parameters. More...
 
struct  ftm_output_cmp_param_t
 FlexTimer driver PWM parameters. More...
 
struct  ftm_phase_params_t
 FlexTimer quadrature decoder channel parameters. More...
 
struct  ftm_quad_decode_config_t
 FTM quadrature configure structure. More...
 
struct  ftm_quad_decoder_state_t
 FTM quadrature state(counter value and flags) More...
 

Macros

#define FTM_MAX_DUTY_CYCLE   (0x8000U)
 Maximum value for PWM duty cycle. More...
 
#define FTM_DUTY_TO_TICKS_SHIFT   (15U)
 Shift value which converts duty to ticks. More...
 

Typedefs

typedef void(* ftm_channel_event_callback_t) (void *userData)
 Channel event callback function. More...
 

Enumerations

enum  ftm_input_op_mode_t { FTM_EDGE_DETECT = 0U, FTM_SIGNAL_MEASUREMENT = 1U, FTM_NO_OPERATION = 2U }
 FTM status. More...
 
enum  ftm_signal_measurement_mode_t {
  FTM_NO_MEASUREMENT = 0x00U, FTM_RISING_EDGE_PERIOD_MEASUREMENT = 0x01U, FTM_FALLING_EDGE_PERIOD_MEASUREMENT = 0x02U, FTM_PERIOD_ON_MEASUREMENT = 0x03U,
  FTM_PERIOD_OFF_MEASUREMENT = 0x04U
}
 FlexTimer input capture measurement type for dual edge input capture. More...
 
enum  ftm_output_compare_update_t { FTM_RELATIVE_VALUE = 0x00U, FTM_ABSOLUTE_VALUE = 0x01U }
 FlexTimer input capture type of the next output compare value. More...
 
enum  ftm_pwm_update_option_t { FTM_PWM_UPDATE_IN_DUTY_CYCLE = 0x00U, FTM_PWM_UPDATE_IN_TICKS = 0x01U }
 FlexTimer Configure type of PWM update in the duty cycle or in ticks. More...
 
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_output_compare_mode_t { FTM_DISABLE_OUTPUT = 0x00U, FTM_TOGGLE_ON_MATCH = 0x01U, FTM_CLEAR_ON_MATCH = 0x02U, FTM_SET_ON_MATCH = 0x03U }
 FlexTimer Mode configuration for output compare mode. More...
 
enum  ftm_edge_alignment_mode_t { FTM_NO_PIN_CONTROL = 0x00U, FTM_RISING_EDGE = 0x01U, FTM_FALLING_EDGE = 0x02U, FTM_BOTH_EDGES = 0x03U }
 FlexTimer input capture edge mode, rising edge, or falling edge. More...
 

Functions

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_InitCounter (uint32_t instance, const ftm_timer_param_t *timer)
 Initialize the FTM counter. More...
 
status_t FTM_DRV_CounterStart (uint32_t instance)
 Starts the FTM counter. More...
 
status_t FTM_DRV_CounterStop (uint32_t instance)
 Stops the FTM counter. More...
 
uint32_t FTM_DRV_CounterRead (uint32_t instance)
 Reads back the current value of the FTM counter. More...
 
status_t FTM_DRV_DeinitPwm (uint32_t instance)
 Stops all PWM channels . More...
 
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 param. More...
 
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). More...
 
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 which modify the period of PWM signal on the channel output. 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_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_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_InitOutputCompare (uint32_t instance, const ftm_output_cmp_param_t *param)
 Configures the FTM to generate timed pulses(Output compare mode). More...
 
status_t FTM_DRV_DeinitOutputCompare (uint32_t instance, const ftm_output_cmp_param_t *param)
 Disables compare match output control and clears FTM timer configuration. More...
 
status_t FTM_DRV_UpdateOutputCompareChannel (uint32_t instance, uint8_t channel, uint16_t nextComparematchValue, ftm_output_compare_update_t update, bool softwareTrigger)
 Sets the next compare match value based on the current counter value. More...
 
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 measurement . When the edge specified in the captureMode argument occurs on the channel the FTM counter is captured into the CnV register. The user will have to read the CnV register separately to get this value. The filter function is disabled if the filterVal argument passed in is 0. The filter function is available only on channels 0,1,2,3. More...
 
status_t FTM_DRV_DeinitInputCapture (uint32_t instance, const ftm_input_param_t *param)
 Disables input capture mode and clears FTM timer configuration. More...
 
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 C(n, n+1)V registers and stored to the static buffers. More...
 
status_t FTM_DRV_StartNewSignalMeasurement (uint32_t instance, uint8_t channel)
 Starts new single-shot signal measurement of the given channel. More...
 
status_t FTM_DRV_QuadDecodeStart (uint32_t instance, const ftm_quad_decode_config_t *config)
 Configures the quadrature mode and starts measurement. More...
 
status_t FTM_DRV_QuadDecodeStop (uint32_t instance)
 De-activates the quadrature decode mode. More...
 
ftm_quad_decoder_state_t FTM_DRV_QuadGetState (uint32_t instance)
 Return the current quadrature decoder state (counter value, overflow flag and overflow direction) 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 [FTM_INSTANCE_COUNT]
 Table of base addresses for FTM instances. More...
 
const IRQn_Type g_ftmIrqId [FTM_INSTANCE_COUNT][FEATURE_FTM_CHANNEL_COUNT]
 Interrupt vectors for the FTM peripheral. More...
 
const IRQn_Type g_ftmFaultIrqId [FTM_INSTANCE_COUNT]
 
const IRQn_Type g_ftmOverflowIrqId [FTM_INSTANCE_COUNT]
 
const IRQn_Type g_ftmReloadIrqId [FTM_INSTANCE_COUNT]
 

Macro Definition Documentation

#define FTM_DUTY_TO_TICKS_SHIFT   (15U)

Shift value which converts duty to ticks.

Definition at line 63 of file ftm_driver.h.

#define FTM_MAX_DUTY_CYCLE   (0x8000U)

Maximum value for PWM duty cycle.

Definition at line 61 of file ftm_driver.h.

Typedef Documentation

typedef void(* ftm_channel_event_callback_t) (void *userData)

Channel event callback function.

Callback functions are called by the FTM driver in Input Capture mode when an event is detected(change in logical state of a pin or measurement complete)

Definition at line 149 of file ftm_driver.h.

Enumeration Type Documentation

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 118 of file ftm_driver.h.

FlexTimer input capture edge mode, rising edge, or falling edge.

Implements : ftm_edge_alignment_mode_t_Class

Enumerator
FTM_NO_PIN_CONTROL 

No trigger

FTM_RISING_EDGE 

Rising edge trigger

FTM_FALLING_EDGE 

Falling edge trigger

FTM_BOTH_EDGES 

Rising and falling edge trigger

Definition at line 317 of file ftm_driver.h.

FTM status.

Implements : ftm_input_op_mode_t_Class

Enumerator
FTM_EDGE_DETECT 

FTM edge detect

FTM_SIGNAL_MEASUREMENT 

FTM signal measurement

FTM_NO_OPERATION 

FTM no operation

Definition at line 70 of file ftm_driver.h.

FlexTimer Mode configuration for output compare mode.

Implements : ftm_output_compare_mode_t_Class

Enumerator
FTM_DISABLE_OUTPUT 

No action on output pin

FTM_TOGGLE_ON_MATCH 

Toggle on match

FTM_CLEAR_ON_MATCH 

Clear on match

FTM_SET_ON_MATCH 

Set on match

Definition at line 135 of file ftm_driver.h.

FlexTimer input capture type of the next output compare value.

Implements : ftm_output_compare_update_t_Class

Enumerator
FTM_RELATIVE_VALUE 

Next compared value is relative to current value

FTM_ABSOLUTE_VALUE 

Next compared value is absolute

Definition at line 96 of file ftm_driver.h.

FlexTimer Configure type of PWM update in the duty cycle or in ticks.

Implements : ftm_pwm_update_option_t_Class

Enumerator
FTM_PWM_UPDATE_IN_DUTY_CYCLE 

The type of PWM update in the duty cycle/pulse or also use in frequency update

FTM_PWM_UPDATE_IN_TICKS 

The type of PWM update in ticks

Definition at line 107 of file ftm_driver.h.

FlexTimer input capture measurement type for dual edge input capture.

Implements : ftm_signal_measurement_mode_t_Class

Enumerator
FTM_NO_MEASUREMENT 

No measurement

FTM_RISING_EDGE_PERIOD_MEASUREMENT 

Period measurement between two consecutive rising edges

FTM_FALLING_EDGE_PERIOD_MEASUREMENT 

Period measurement between two consecutive falling edges

FTM_PERIOD_ON_MEASUREMENT 

The time measurement taken for the pulse to remain ON or HIGH state

FTM_PERIOD_OFF_MEASUREMENT 

The time measurement taken for the pulse to remain OFF or LOW state

Definition at line 82 of file ftm_driver.h.

Function Documentation

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
uint16_t

Definition at line 1612 of file ftm_driver.c.

uint32_t FTM_DRV_CounterRead ( uint32_t  instance)

Reads back the current value of the FTM counter.

Parameters
[in]instanceThe FTM peripheral instance number.
Returns
The current counter value

Definition at line 328 of file ftm_driver.c.

status_t FTM_DRV_CounterStart ( uint32_t  instance)

Starts the FTM counter.

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

Definition at line 287 of file ftm_driver.c.

status_t FTM_DRV_CounterStop ( uint32_t  instance)

Stops the FTM counter.

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

Definition at line 308 of file ftm_driver.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 205 of file ftm_driver.c.

status_t FTM_DRV_DeinitInputCapture ( uint32_t  instance,
const ftm_input_param_t param 
)

Disables input capture mode and clears FTM timer configuration.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]paramConfiguration of the output compare channel.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 1350 of file ftm_driver.c.

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.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]paramConfiguration of the output compare channel
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 1110 of file ftm_driver.c.

status_t FTM_DRV_DeinitPwm ( uint32_t  instance)

Stops all PWM channels .

Parameters
[in]instanceThe FTM peripheral instance number.
Returns
counter the current counter value

Definition at line 343 of file ftm_driver.c.

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 1560 of file ftm_driver.c.

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 C(n, n+1)V registers and stored to the static buffers.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]channelFor getting the time stamp of the last edge (in normal input capture) this parameter represents the channel number. For getting the last measured value (in dual edge input capture) this parameter is the lowest channel number of the pair (EX: 0, 2, 4, 6).
Returns
value The measured value

Definition at line 1402 of file ftm_driver.c.

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 136 of file ftm_driver.c.

status_t FTM_DRV_InitCounter ( uint32_t  instance,
const ftm_timer_param_t timer 
)

Initialize the FTM counter.

Starts the FTM counter. This function provides access to the FTM counter settings. The counter can be run in Up counting and Up-down counting modes. To run the counter in Free running mode, choose Up counting option and provide 0x0 for the countStartVal and 0xFFFF for countFinalVal. Please call this function only when FTM is used as timer/counter.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]timerTimer configuration structure.
Returns
operation status
  • STATUS_SUCCESS : Initialized successfully.

Definition at line 228 of file ftm_driver.c.

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 measurement . When the edge specified in the captureMode argument occurs on the channel the FTM counter is captured into the CnV register. The user will have to read the CnV register separately to get this value. The filter function is disabled if the filterVal argument passed in is 0. The filter function is available only on channels 0,1,2,3.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]paramConfiguration of the input capture channel.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 1205 of file ftm_driver.c.

status_t FTM_DRV_InitOutputCompare ( uint32_t  instance,
const ftm_output_cmp_param_t param 
)

Configures the FTM to generate timed pulses(Output compare mode).

When the FTM counter matches the value of CnV, the channel output is changed based on what is specified in the compareMode argument. The signal period can be modified using param->MaxCountValue. After this function max counter value and CnV are equal. FTM_DRV_SetNextComparematchValue function can be used to change CnV value.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]paramconfiguration of the output compare channels
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 1047 of file ftm_driver.c.

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

Parameters
[in]instanceThe FTM peripheral instance number.
[in]paramFTM driver PWM parameter to configure PWM options.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 399 of file ftm_driver.c.

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 801 of file ftm_driver.c.

status_t FTM_DRV_QuadDecodeStart ( uint32_t  instance,
const ftm_quad_decode_config_t config 
)

Configures the quadrature mode and starts measurement.

Parameters
[in]instanceInstance number of the FTM module.
[in]configConfiguration structure(quadrature decode mode, polarity for both phases, initial and maximum value for the counter, filter configuration).
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 1457 of file ftm_driver.c.

status_t FTM_DRV_QuadDecodeStop ( uint32_t  instance)

De-activates the quadrature decode mode.

Parameters
[in]instanceInstance number of the FTM module.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 1516 of file ftm_driver.c.

ftm_quad_decoder_state_t FTM_DRV_QuadGetState ( uint32_t  instance)

Return the current quadrature decoder state (counter value, overflow flag and overflow direction)

Parameters
[in]instanceInstance number of the FTM module.
Returns
The current state of quadrature decoder

Definition at line 1537 of file ftm_driver.c.

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 849 of file ftm_driver.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 825 of file ftm_driver.c.

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]pairOfChannelsMaskThe 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 921 of file ftm_driver.c.

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 944 of file ftm_driver.c.

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 875 of file ftm_driver.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 898 of file ftm_driver.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 970 of file ftm_driver.c.

status_t FTM_DRV_StartNewSignalMeasurement ( uint32_t  instance,
uint8_t  channel 
)

Starts new single-shot signal measurement of the given channel.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]channelConfiguration of the output compare channel.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 1420 of file ftm_driver.c.

status_t FTM_DRV_UpdateOutputCompareChannel ( uint32_t  instance,
uint8_t  channel,
uint16_t  nextComparematchValue,
ftm_output_compare_update_t  update,
bool  softwareTrigger 
)

Sets the next compare match value based on the current counter value.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]channelConfiguration of the output compare channel
[in]nextComparematchValueTimer value in ticks until the next compare match event should appear
[in]update
  • FTM_RELATIVE_VALUE : nextComparemantchValue will be added to current counter value
  • FTM_ABSOLUTE_VALUE : nextComparemantchValue will be written in counter register as it is
[in]softwareTriggerThis parameter will be true if software trigger sync is enabled and the user want to generate a software trigger (the value from buffer will be moved to register immediate or at next loading point depending on the sync configuration). Otherwise this parameter must be false and the next compared value will be stored in buffer until a trigger signal will be received.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 1152 of file ftm_driver.c.

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

Parameters
[in]instanceThe FTM peripheral instance number.
[in]channelThe channel number. In combined mode, the code finds the channel.
[in]typeOfUpdateThe type of PWM update in the duty cycle/pulse or in ticks.
[in]firstEdgeDuty cycle or first edge time for PWM mode. Can take value between 0 - FTM_MAX_DUTY_CYCLE(0 = 0% from period and FTM_MAX_DUTY_CYCLE = 100% from period) Or value in ticks for the first of the PWM mode in which can have value between 0 and ftmPeriod is stored in the state structure.
[in]secondEdgeSecond edge time - only for combined mode. Can take value between 0 - FTM_MAX_DUTY_CYCLE(0 = 0% from period and FTM_MAX_DUTY_CYCLE = 100% from period). Or value in ticks for the second of the PWM mode in which can have value between 0 and ftmPeriod is stored in the state structure.
[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 606 of file ftm_driver.c.

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 which modify the period of PWM signal on the channel output.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]typeOfUpdateThe type of PWM update is a period in Hz or in ticks.
  • For FTM_PWM_UPDATE_IN_DUTY_CYCLE which reuse in FTM_DRV_UpdatePwmChannel function will update in Hz.
  • For FTM_PWM_UPDATE_IN_TICKS will update in ticks.
[in]newValueThe frequency or the counter value which will select with modified value for PWM signal. If the type of update in the duty cycle, the newValue parameter must be value between 1U and maximum is the frequency of the FTM counter. If the type of update in ticks, the newValue parameter must be value between 1U and 0xFFFFU.
[in]softwareTriggerIf true a software trigger is generate to update PWM parameters.
Returns
operation status
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 738 of file ftm_driver.c.

Variable Documentation

FTM_Type* const g_ftmBase[FTM_INSTANCE_COUNT]

Table of base addresses for FTM instances.

Definition at line 70 of file ftm_driver.c.

const IRQn_Type g_ftmFaultIrqId[FTM_INSTANCE_COUNT]

Definition at line 74 of file ftm_driver.c.

Interrupt vectors for the FTM peripheral.

Definition at line 73 of file ftm_driver.c.

const IRQn_Type g_ftmOverflowIrqId[FTM_INSTANCE_COUNT]

Definition at line 75 of file ftm_driver.c.

const IRQn_Type g_ftmReloadIrqId[FTM_INSTANCE_COUNT]

Definition at line 76 of file ftm_driver.c.