S32 SDK
ftm_driver.c File Reference
#include "ftm_driver.h"

Go to the source code of this file.

Functions

static void FTM_DRV_InputCaptureHandler (uint32_t instance, uint8_t channelPair)
 
static void FTM_DRV_IrqHandler (uint32_t instance, uint8_t channelPair)
 
void FTM0_Ch0_Ch1_IRQHandler (void)
 
void FTM0_Ch2_Ch3_IRQHandler (void)
 
void FTM0_Ch4_Ch5_IRQHandler (void)
 
void FTM0_Ch6_Ch7_IRQHandler (void)
 
void FTM1_Ch0_Ch1_IRQHandler (void)
 
void FTM1_Ch2_Ch3_IRQHandler (void)
 
void FTM1_Ch4_Ch5_IRQHandler (void)
 
void FTM1_Ch6_Ch7_IRQHandler (void)
 
void FTM2_Ch0_Ch1_IRQHandler (void)
 
void FTM2_Ch2_Ch3_IRQHandler (void)
 
void FTM2_Ch4_Ch5_IRQHandler (void)
 
void FTM2_Ch6_Ch7_IRQHandler (void)
 
void FTM3_Ch0_Ch1_IRQHandler (void)
 
void FTM3_Ch2_Ch3_IRQHandler (void)
 
void FTM3_Ch4_Ch5_IRQHandler (void)
 
void FTM3_Ch6_Ch7_IRQHandler (void)
 
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] = FTM_BASE_PTRS
 Table of base addresses for FTM instances. More...
 
const IRQn_Type g_ftmIrqId [FTM_INSTANCE_COUNT][FEATURE_FTM_CHANNEL_COUNT] = FTM_IRQS
 Interrupt vectors for the FTM peripheral. More...
 
const IRQn_Type g_ftmFaultIrqId [FTM_INSTANCE_COUNT] = FTM_Fault_IRQS
 
const IRQn_Type g_ftmOverflowIrqId [FTM_INSTANCE_COUNT] = FTM_Overflow_IRQS
 
const IRQn_Type g_ftmReloadIrqId [FTM_INSTANCE_COUNT] = FTM_Reload_IRQS
 
ftm_state_tftmStatePtr [FTM_INSTANCE_COUNT] = {NULL}
 Pointer to runtime state structure. More...
 
static const clock_names_t g_ftmExtClockSel [FTM_INSTANCE_COUNT][2]
 Select external clock pin or clock source for peripheral. More...
 

Function Documentation

void FTM0_Ch0_Ch1_IRQHandler ( void  )

Definition at line 1625 of file ftm_driver.c.

void FTM0_Ch2_Ch3_IRQHandler ( void  )

Definition at line 1631 of file ftm_driver.c.

void FTM0_Ch4_Ch5_IRQHandler ( void  )

Definition at line 1637 of file ftm_driver.c.

void FTM0_Ch6_Ch7_IRQHandler ( void  )

Definition at line 1643 of file ftm_driver.c.

void FTM1_Ch0_Ch1_IRQHandler ( void  )

Definition at line 1649 of file ftm_driver.c.

void FTM1_Ch2_Ch3_IRQHandler ( void  )

Definition at line 1655 of file ftm_driver.c.

void FTM1_Ch4_Ch5_IRQHandler ( void  )

Definition at line 1661 of file ftm_driver.c.

void FTM1_Ch6_Ch7_IRQHandler ( void  )

Definition at line 1667 of file ftm_driver.c.

void FTM2_Ch0_Ch1_IRQHandler ( void  )

Definition at line 1673 of file ftm_driver.c.

void FTM2_Ch2_Ch3_IRQHandler ( void  )

Definition at line 1679 of file ftm_driver.c.

void FTM2_Ch4_Ch5_IRQHandler ( void  )

Definition at line 1685 of file ftm_driver.c.

void FTM2_Ch6_Ch7_IRQHandler ( void  )

Definition at line 1691 of file ftm_driver.c.

void FTM3_Ch0_Ch1_IRQHandler ( void  )

Definition at line 1697 of file ftm_driver.c.

void FTM3_Ch2_Ch3_IRQHandler ( void  )

Definition at line 1703 of file ftm_driver.c.

void FTM3_Ch4_Ch5_IRQHandler ( void  )

Definition at line 1709 of file ftm_driver.c.

void FTM3_Ch6_Ch7_IRQHandler ( void  )

Definition at line 1715 of file ftm_driver.c.

static void FTM_DRV_InputCaptureHandler ( uint32_t  instance,
uint8_t  channelPair 
)
static

Definition at line 1735 of file ftm_driver.c.

static void FTM_DRV_IrqHandler ( uint32_t  instance,
uint8_t  channelPair 
)
static

Definition at line 1720 of file ftm_driver.c.

Variable Documentation

ftm_state_t* ftmStatePtr[FTM_INSTANCE_COUNT] = {NULL}

Pointer to runtime state structure.

Definition at line 79 of file ftm_driver.c.