PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
Waveform Generator (WFG)

the operation mode of WFG module More...

Data Structures

struct  stc_wfg_ctrl_bits
 
struct  stc_mft_wfg_intern_data
 
struct  stc_wfg_nzcl_config
 
struct  stc_dtif_int_sel
 
struct  stc_dtif_int_cb
 
struct  stc_mft_wfg_instance_data
 

Macros

#define WFG_INSTANCE_COUNT
 Macro to return the number of enabled MFT instances. More...
 
#define stc_mftn_wfg_t   FM4_MFT_WFG_TypeDef
 
#define MFT0_WFG   (*((volatile stc_mftn_wfg_t *) FM4_MFT0_WFG_BASE))
 
#define MFT1_WFG   (*((volatile stc_mftn_wfg_t *) FM4_MFT1_WFG_BASE))
 
#define MFT2_WFG   (*((volatile stc_mftn_wfg_t *) FM4_MFT2_WFG_BASE))
 
#define MFT_WFG_CH0   0
 
#define MFT_WFG_CH1   1
 
#define MFT_WFG_CH2   2
 
#define MFT_WFG_CH3   3
 
#define MFT_WFG_CH4   4
 
#define MFT_WFG_CH5   5
 
#define MFT_WFG_CH10   0
 
#define MFT_WFG_CH32   1
 
#define MFT_WFG_CH54   2
 
#define MFT_WFG_MAXCH   3
 

Typedefs

typedef enum en_wfg_instance_index en_wfg_instance_index_t
 Enumeration to define an index for each WFG instance. More...
 
typedef enum en_mft_wfg_mode en_mft_wfg_mode_t
 
typedef enum en_gten_bits en_gten_bits_t
 
typedef enum en_psel_bits en_psel_bits_t
 
typedef enum en_pgen_bits en_pgen_bits_t
 
typedef enum en_dmod_bit en_dmod_bit_t
 
typedef struct stc_wfg_ctrl_bits stc_wfg_ctrl_bits
 
typedef enum en_wfg_timer_clock en_wfg_timer_clock_t
 
typedef struct
stc_mft_wfg_intern_data 
stc_mft_wfg_intern_data_t
 
typedef enum en_nzcl_filter_width en_nzcl_filter_width_t
 
typedef struct stc_wfg_nzcl_config stc_wfg_nzcl_config_t
 
typedef struct stc_dtif_int_sel stc_dtif_int_sel_t
 
typedef struct stc_dtif_int_cb stc_dtif_int_cb_t
 
typedef struct
stc_mft_wfg_instance_data 
stc_mft_wfg_instance_data_t
 

Enumerations

enum  en_wfg_instance_index {
  WfgInstanceIndexWfg0 = 0,
  WfgInstanceIndexWfg1,
  WfgInstanceIndexWfg2
}
 Enumeration to define an index for each WFG instance. More...
 
enum  en_mft_wfg_mode {
  WfgThroughMode = 0,
  WfgRtPpgMode = 1,
  WfgTimerPpgMode = 2,
  WfgRtDeadTimerMode = 4,
  WfgRtDeadTimerFilterMode = 5,
  WfgPpgDeadTimerFilterMode = 6,
  WfgPpgDeadTimerMode = 7
}
 
enum  en_gten_bits {
  GtenBits00B = 0,
  GtenBits01B,
  GtenBits10B,
  GtenBits11B
}
 
enum  en_psel_bits {
  PselBits00B = 0,
  PselBits01B,
  PselBits10B,
  PselBits11B
}
 
enum  en_pgen_bits {
  PgenBits00B = 0,
  PgenBits01B,
  PgenBits10B,
  PgenBits11B
}
 
enum  en_dmod_bit {
  DmodBit0B = 0,
  DmodBit1B
}
 
enum  en_wfg_timer_clock {
  WfgPlckDiv1 = 0,
  WfgPlckDiv2,
  WfgPlckDiv4,
  WfgPlckDiv8,
  WfgPlckDiv16,
  WfgPlckDiv32,
  WfgPlckDiv64,
  WfgPlckDiv128
}
 
enum  en_nzcl_filter_width {
  NzlcNoFilter,
  NzlcWidth4Cycle,
  NzlcWidth8Cycle,
  NzlcWidth16Cycle,
  NzlcWidth32Cycle,
  NzlcWidth64Cycle,
  NzlcWidth128Cycle
}
 

Functions

static stc_mft_wfg_intern_data_t * MftGetInternDataPtr (volatile FM4_MFT_WFG_TypeDef *pstcWfg)
 Return the internal data for a certain WFG instance. More...
 
void Mft_Wfg_IrqHandler (volatile FM4_MFT_WFG_TypeDef *pstcMft, stc_mft_wfg_intern_data_t *pstcMftWfgInternData)
 WFG interrupt handler sub function. More...
 
static en_result_t Mft_Wfg_InitIrq (volatile FM4_MFT_WFG_TypeDef *pstcMft)
 Device dependent initialization of interrupts according CMSIS with level defined in l3.h. More...
 
static en_result_t Mft_Wfg_DeInitIrq (volatile FM4_MFT_WFG_TypeDef *pstcMft)
 Device dependent de-initialization of interrupts according CMSIS. More...
 
en_result_t Mft_Wfg_ConfigMode (volatile FM4_MFT_WFG_TypeDef *pstcMft, uint8_t u8CoupleCh, en_mft_wfg_mode_t enMode)
 configure WFG mode More...
 
en_result_t Mft_Wfg_ConfigCtrlBits (volatile FM4_MFT_WFG_TypeDef *pstcMft, uint8_t u8CoupleCh, stc_wfg_ctrl_bits *pstcCtrlBits)
 configure WFG control bit More...
 
en_result_t Mft_Wfg_InitTimerClock (volatile FM4_MFT_WFG_TypeDef *pstcMft, uint8_t u8CoupleCh, en_wfg_timer_clock_t enClk)
 init timer clock More...
 
en_result_t Mft_Wfg_EnableTimerInt (volatile FM4_MFT_WFG_TypeDef *pstcMft, uint8_t u8CoupleCh, func_ptr_t pfnCallback)
 enable WFG timer interrupt More...
 
en_result_t Mft_Wfg_DisableTimerInt (volatile FM4_MFT_WFG_TypeDef *pstcMft, uint8_t u8CoupleCh)
 disable WFG timer interrupt More...
 
en_result_t Mft_Wfg_StartTimer (volatile FM4_MFT_WFG_TypeDef *pstcMft, uint8_t u8CoupleCh)
 Start WFG timer. More...
 
en_result_t Mft_Wfg_StopTimer (volatile FM4_MFT_WFG_TypeDef *pstcMft, uint8_t u8CoupleCh)
 Stop WFG timer. More...
 
en_int_flag_t Mft_Wfg_GetTimerIntFlag (volatile FM4_MFT_WFG_TypeDef *pstcMft, uint8_t u8CoupleCh)
 get WFG timer interrupt flag More...
 
en_result_t Mft_Wfg_ClrTimerIntFlag (volatile FM4_MFT_WFG_TypeDef *pstcMft, uint8_t u8CoupleCh)
 clear WFG timer interrupt flag More...
 
en_result_t Mft_Wfg_WriteTimerCountCycle (volatile FM4_MFT_WFG_TypeDef *pstcMft, uint8_t u8CoupleCh, uint16_t u16CycleA, uint16_t u16CycleB)
 write timer count cycle More...
 
en_result_t Mft_Wfg_SetTimerCycle (volatile FM4_MFT_WFG_TypeDef *pstcMft, uint8_t u8CoupleCh, uint16_t u16Count)
 set wfg pulse counter More...
 
uint16_t Mft_Wfg_GetTimerCurCycle (volatile FM4_MFT_WFG_TypeDef *pstcMft, uint8_t u8CoupleCh)
 get current pulse counter More...
 
en_result_t Mft_Wfg_ConfigNzcl (volatile FM4_MFT_WFG_TypeDef *pstcMft, stc_wfg_nzcl_config_t *pstcNzclConfig)
 configure NZCL More...
 
en_result_t Mft_Wfg_EnableDtifInt (volatile FM4_MFT_WFG_TypeDef *pstcMft, stc_dtif_int_sel_t *pstcIntSel, stc_dtif_int_cb_t *pstcCallback)
 Enable DTIF interrupt. More...
 
en_result_t Mft_Wfg_DisableDtifInt (volatile FM4_MFT_WFG_TypeDef *pstcMft, stc_dtif_int_sel_t *pstcIntSel)
 Disable DTIF interrupt. More...
 
en_result_t Mft_Wfg_SwTiggerDtif (volatile FM4_MFT_WFG_TypeDef *pstcMft)
 set software trigger DTIF More...
 
en_int_flag_t Mft_Wfg_GetDigitalFilterIntFlag (volatile FM4_MFT_WFG_TypeDef *pstcMft)
 get Digital filter interrupt flag More...
 
en_result_t Mft_Wfg_ClrDigitalFilterIntFlag (volatile FM4_MFT_WFG_TypeDef *pstcMft)
 clear Digital filter interrupt flag More...
 
en_int_flag_t Mft_Wfg_GetAnalogFilterIntFlag (volatile FM4_MFT_WFG_TypeDef *pstcMft)
 get Analgo filter interrupt flag More...
 
en_result_t Mft_Wfg_ClrAnalogFilterIntFlag (volatile FM4_MFT_WFG_TypeDef *pstcMft)
 clear analog filter interrupt flag More...
 

Variables

stc_mft_wfg_instance_data_t m_astcMftWfgInstanceDataLut []
 Look-up table for all enabled WFG instances and their internal data. More...
 
stc_mft_wfg_instance_data_t m_astcMftWfgInstanceDataLut []
 Look-up table for all enabled WFG instances and their internal data. More...
 

Detailed Description

the operation mode of WFG module

Provided functions of WFG module:

The WFG can be configured to following mode:

how to operate WFG with Through mode (one of usages).

Before using WFG, the FRT used to connect with applying OCU must be initialed first and OCU must be initialed then. For how to configure FRT, see the description in the mft_frt.h For how to configure OCU, see the description in the mft_ocu.h

Set the control bits with Mft_Wfg_ConfigCtrlBits() with a structure of the type stc_wfg_ctrl_bits

Configure WFG to Through mode with Mft_Wfg_ConfigMode()

Enable OCU operation and RT signal will output to RTO pin directly. Changing the value of control bits will influence RTO output.

how to operate WFG with RT-PPG mode (one of usages).

Before using WFG, the FRT used to connect with applying OCU must be initialized first and OCU must be initialed then, PPG should be initialized at the following. For how to configure FRT, see the description in the mft_frt.h For how to configure OCU, see the description in the mft_ocu.h For how to configure PPG, see the description in the ppg.h

Set the control bits with Mft_Wfg_ConfigCtrlBits() with a structure of the type stc_wfg_ctrl_bits

Configure WFG to RT-PPG mode with Mft_Wfg_ConfigMode()

Start PPG0 and enable OCU operation.

In this case RTO0 will outputs the logic AND signal of RT0 signal and PPG0, RTO1 will outputs the logic AND signal of RT1 signal and PPG0. Changing the value of control bits will influence RTO output.

how to operate WFG with Timer-PPG mode (one of usages).

Before using WFG, the FRT used to connect with applying OCU must be initialized first and OCU must be initialed then, PPG and WFG timer should be initialized at the following. For how to configure FRT, see the description in the mft_frt.h For how to configure OCU, see the description in the mft_ocu.h For how to configure PPG, see the description in the ppg.h For how to initialize WFG timer, see the description at the following.

Set the control bits with Mft_Wfg_ConfigCtrlBits() with a structure of the type stc_wfg_ctrl_bits

Configure WFG to Timer-PPG mode with Mft_Wfg_ConfigMode()

Start PPG0, enable OCU operation and start WFG timer.

In this case RTO0 will outputs the logic AND signal of WFG timer flag 0 and PPG0, RTO1 will outputs the logic AND signal of WFG timer flag 1 and PPG0. Changing the value of control bits will influence RTO output.

how to operate WFG with RT-dead timer mode (one of usages).

Before using WFG, the FRT used to connect with applying OCU must be initialized first and OCU must be initialed then, WFG timer should be initialized at the following. For how to configure FRT, see the description in the mft_frt.h For how to configure OCU, see the description in the mft_ocu.h For how to initialize WFG timer, see the description at the following.

Configure WFG to RT-dead timer mode with Mft_Wfg_ConfigMode()

Set the control bits with Mft_Wfg_ConfigCtrlBits() with a structure of the type stc_wfg_ctrl_bits

Enable OCU operation and start WFG timer.

In this case, RT(1) will trigger the WFG timer to start, WFG will output the generated non-overlap singal. Changing the value of control bits will influence RTO output.

how to operate WFG with PPG-dead timer mode (one of usages).

Before using WFG, WFG timer should be initialized at the following. For how to initialize WFG timer, see the description at the following.

Configure WFG to PPG-dead timer mode with Mft_Wfg_ConfigMode()

Set the control bits with Mft_Wfg_ConfigCtrlBits() with a structure of the type stc_wfg_ctrl_bits

Start WFG timer.

In this case, PPG0 will trigger the WFG timer to start, WFG will output the generated non-overlap singal. Changing the value of control bits will influence RTO output.

How to use the WFG timer

Mft_Wfg_InitTimerClock() must be used for configuration of a Free-Run timer (FRT) channel with a structure of the type en_wfg_timer_clock_t.

A WFG timer interrupt can be enabled by the function Mft_Wfg_EnableTimerInt(). This function can set callback function for each channel too.

With Mft_Wfg_WriteTimerCountCycle() the WFG timer cycle is set to the value given in the parameter Mft_Wfg_WriteTimerCountCycle::u16CycleA and Mft_Wfg_WriteTimerCountCycle::u16CycleB.

After above setting, calling Mft_Wfg_SetTimerCycle() will start WFG timer.

With Mft_Wfg_GetTimerCurCycle() the current WFG timer count can be read when WFG timer is running.

With interrupt mode, when the interrupt occurs, the interrupt flag will be cleared and run into user interrupt callback function.

With polling mode, user can use Mft_Wfg_GetTimerIntFlag() to check if the interrupt occurs, and clear the interrupt flag by Mft_Wfg_ClrTimerIntFlag().

When stopping the WFG, use Mft_Wfg_DisableTimerInt() to disable WFG timer and Mft_Wfg_DisableTimerInt() to disable WFG timer interrupt.

How to use the NZCL (used for motor emergency shutdown)

Mft_Wfg_ConfigNzcl() must be used for configuration of the WFG NZCL with a structure of the type stc_wfg_nzcl_config_t.

Both analog noise filter and digital noise filter can be used to filter the signal input from DTTIX pin. WFG NTCL interrupt with filter user mode can be enabled by the function Mft_Wfg_EnableDtifInt(). This function can set callback function for each channel too. With this funcion, the operation of WFG NZCL is also enabled.

With interrupt mode, when the interrupt occurs, the interrupt flag will be cleared and run into user interrupt callback function.

With polling mode, user can use Mft_Wfg_GetDigitalFilterIntFlag() to check if the interrupt of digital noise filter occurs, and clear the interrupt flag by Mft_Wfg_ClrDigitalFilterIntFlag(). user can use Mft_Wfg_GetAnalogFilterIntFlag() to check if the interrupt of digital noise filter occurs, and clear the interrupt flag by Mft_Wfg_ClrAnalogFilterIntFlag().

Mft_Wfg_SwTiggerDtif() is used to trigger the DTIF interrupt by software, regardless of DTTIX pin input status.

When stopping the WFG NZCL, use Mft_Wfg_DisableDtifInt() to disable WFG NZCL operation as well as WFG NZCL interrupt.

Macro Definition Documentation

#define MFT0_WFG   (*((volatile stc_mftn_wfg_t *) FM4_MFT0_WFG_BASE))

Definition at line 276 of file mft_wfg.h.

Referenced by Mft_Wfg_ConfigNzcl(), Mft_Wfg_DeInitIrq(), and Mft_Wfg_InitIrq().

#define MFT1_WFG   (*((volatile stc_mftn_wfg_t *) FM4_MFT1_WFG_BASE))

Definition at line 277 of file mft_wfg.h.

Referenced by Mft_Wfg_ConfigNzcl(), Mft_Wfg_DeInitIrq(), and Mft_Wfg_InitIrq().

#define MFT2_WFG   (*((volatile stc_mftn_wfg_t *) FM4_MFT2_WFG_BASE))

Definition at line 278 of file mft_wfg.h.

Referenced by Mft_Wfg_ConfigNzcl(), Mft_Wfg_DeInitIrq(), and Mft_Wfg_InitIrq().

#define MFT_WFG_CH0   0

Definition at line 280 of file mft_wfg.h.

#define MFT_WFG_CH1   1

Definition at line 281 of file mft_wfg.h.

#define MFT_WFG_CH2   2

Definition at line 282 of file mft_wfg.h.

#define MFT_WFG_CH3   3

Definition at line 283 of file mft_wfg.h.

#define MFT_WFG_CH4   4

Definition at line 284 of file mft_wfg.h.

#define MFT_WFG_CH5   5

Definition at line 285 of file mft_wfg.h.

#define stc_mftn_wfg_t   FM4_MFT_WFG_TypeDef

Definition at line 274 of file mft_wfg.h.

Referenced by Mft_Wfg_DeInitIrq(), and Mft_Wfg_InitIrq().

#define WFG_INSTANCE_COUNT
Value:
(uint32_t)(sizeof(m_astcMftWfgInstanceDataLut) \

Macro to return the number of enabled MFT instances.

Definition at line 71 of file mft_wfg.c.

Referenced by MftGetInternDataPtr().

Typedef Documentation

typedef enum en_dmod_bit en_dmod_bit_t

Enumeration to define an index for each WFG instance.

Enumeration Type Documentation

Enumerator
DmodBit0B 

output RTO1 and RTO0 signals without changing the level

DmodBit1B 

output both RTO1 and RTO0 signals reversed

Definition at line 358 of file mft_wfg.h.

Enumerator
GtenBits00B 

GTEN == b'00.

GtenBits01B 

GTEN == b'01.

GtenBits10B 

GTEN == b'10.

GtenBits11B 

GTEN == b'11.

Definition at line 322 of file mft_wfg.h.

Enumerator
WfgThroughMode 

through mode

WfgRtPpgMode 

RT-PPG mode.

WfgTimerPpgMode 

Timer-PPG mode.

WfgRtDeadTimerMode 

RT-dead timer mode.

WfgRtDeadTimerFilterMode 

RT-dead timer filter mode.

WfgPpgDeadTimerFilterMode 

PPG-dead timer filter mode.

WfgPpgDeadTimerMode 

PPG-dead timer mode.

Definition at line 307 of file mft_wfg.h.

Enumerator
NzlcNoFilter 

no noise-canceling

NzlcWidth4Cycle 

4 PCLK cycles

NzlcWidth8Cycle 

8 PCLK cycles

NzlcWidth16Cycle 

16 PCLK cycles

NzlcWidth32Cycle 

32 PCLK cycles

NzlcWidth64Cycle 

64 PCLK cycles

NzlcWidth128Cycle 

128 PCLK cycles

Definition at line 408 of file mft_wfg.h.

Enumerator
PgenBits00B 

PGEN == b'00.

PgenBits01B 

PGEN == b'01.

PgenBits10B 

PGEN == b'10.

PgenBits11B 

PGEN == b'11.

Definition at line 346 of file mft_wfg.h.

Enumerator
PselBits00B 

PSEL == b'00.

PselBits01B 

PSEL == b'01.

PselBits10B 

PSEL == b'10.

PselBits11B 

PSEL == b'11.

Definition at line 334 of file mft_wfg.h.

Enumeration to define an index for each WFG instance.

Enumerator
WfgInstanceIndexWfg0 

Instance index of WFG0.

WfgInstanceIndexWfg1 

Instance index of WFG1.

WfgInstanceIndexWfg2 

Instance index of WFG2.

Definition at line 296 of file mft_wfg.h.

Enumerator
WfgPlckDiv1 

WFG timer clock prescaler: None.

WfgPlckDiv2 

WFG timer clock prescaler: 1/2.

WfgPlckDiv4 

WFG timer clock prescaler: 1/4.

WfgPlckDiv8 

WFG timer clock prescaler: 1/8.

WfgPlckDiv16 

WFG timer clock prescaler: 1/16.

WfgPlckDiv32 

WFG timer clock prescaler: 1/32.

WfgPlckDiv64 

WFG timer clock prescaler: 1/64.

WfgPlckDiv128 

WFG timer clock prescaler: 1/128.

Definition at line 380 of file mft_wfg.h.

Function Documentation

en_result_t Mft_Wfg_ClrAnalogFilterIntFlag ( volatile FM4_MFT_WFG_TypeDef *  pstcMft)

clear analog filter interrupt flag

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
Return values
OkInternal data has been setup
ErrorInvalidParameterpstcMft == NULL u8CoupleCh out of range

Definition at line 1042 of file mft_wfg.c.

References ErrorInvalidParameter, and Ok.

en_result_t Mft_Wfg_ClrDigitalFilterIntFlag ( volatile FM4_MFT_WFG_TypeDef *  pstcMft)

clear Digital filter interrupt flag

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
Return values
OkInternal data has been setup
ErrorInvalidParameterpstcMft == NULL u8CoupleCh out of range

Definition at line 997 of file mft_wfg.c.

References ErrorInvalidParameter, and Ok.

en_result_t Mft_Wfg_ClrTimerIntFlag ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
uint8_t  u8CoupleCh 
)

clear WFG timer interrupt flag

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]u8CoupleChchannel of WFG couple
  • MFT_WFG_CH10 ~ MFT_WFG_CH54
Return values
OkInternal data has been setup
ErrorInvalidParameterpstcMft == NULL u8CoupleCh out of range

Definition at line 669 of file mft_wfg.c.

References ErrorInvalidParameter, MFT_WFG_CH10, MFT_WFG_CH32, MFT_WFG_CH54, MFT_WFG_MAXCH, and Ok.

Referenced by Mft_Wfg_IrqHandler().

Here is the caller graph for this function:

en_result_t Mft_Wfg_ConfigCtrlBits ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
uint8_t  u8CoupleCh,
stc_wfg_ctrl_bits *  pstcCtrlBits 
)

configure WFG control bit

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]u8CoupleChchannel of WFG couple
  • MFT_WFG_CH10 ~ MFT_WFG_CH54
[in]pstcCtrlBitsstructure of control bit
Return values
OkInternal data has been setup
ErrorInvalidParameterpstcMft == NULL u8CoupleCh out of range

Definition at line 362 of file mft_wfg.c.

References stc_wfg_ctrl_bits::enDmodBit, stc_wfg_ctrl_bits::enGtenBits, stc_wfg_ctrl_bits::enPgenBits, stc_wfg_ctrl_bits::enPselBits, ErrorInvalidParameter, MFT_WFG_MAXCH, and Ok.

en_result_t Mft_Wfg_ConfigMode ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
uint8_t  u8CoupleCh,
en_mft_wfg_mode_t  enMode 
)

configure WFG mode

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]u8CoupleChchannel of WFG couple
  • MFT_WFG_CH10 ~ MFT_WFG_CH54
[in]enModeenum of WFG mode
  • en_mft_wfg_mode_t
Return values
OkInternal data has been setup
ErrorInvalidParameterpstcMft == NULL u8CoupleCh out of range Other invalid configuration

Definition at line 313 of file mft_wfg.c.

References ErrorInvalidParameter, MFT_WFG_MAXCH, MftGetInternDataPtr(), Ok, stc_mft_wfg_intern_data::pfnWfg10TimerCallback, stc_mft_wfg_intern_data::pfnWfg32TimerCallback, and stc_mft_wfg_intern_data::pfnWfg54TimerCallback.

Here is the call graph for this function:

en_result_t Mft_Wfg_ConfigNzcl ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
stc_wfg_nzcl_config_t *  pstcNzclConfig 
)

configure NZCL

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]pstcNzclConfigconfigure of NZCL
  • structure of stc_wfg_nzcl_config_t
Return values
OkInternal data has been setup
ErrorInvalidParameterpstcMft == NULL u8CoupleCh out of range

Definition at line 810 of file mft_wfg.c.

References stc_wfg_nzcl_config::bEnAnalogFilter, stc_wfg_nzcl_config::bEnDigitalFilter, stc_wfg_nzcl_config::bSwitchToGpio, stc_wfg_nzcl_config::enDigitalFilterWidth, ErrorInvalidParameter, MFT0_WFG, MFT1_WFG, MFT2_WFG, and Ok.

static en_result_t Mft_Wfg_DeInitIrq ( volatile FM4_MFT_WFG_TypeDef *  pstcMft)
static

Device dependent de-initialization of interrupts according CMSIS.

Parameters
pstcMftIcu Pointer to WFG instance
Returns
Ok Successful initialization

Definition at line 257 of file mft_wfg.c.

References MFT0_WFG, MFT1_WFG, MFT2_WFG, Ok, PDL_DEFAULT_INTERRUPT_LEVEL, and stc_mftn_wfg_t.

Referenced by Mft_Wfg_DisableDtifInt(), and Mft_Wfg_DisableTimerInt().

Here is the caller graph for this function:

en_result_t Mft_Wfg_DisableDtifInt ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
stc_dtif_int_sel_t *  pstcIntSel 
)

Disable DTIF interrupt.

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]pstcIntSelDTIF interrupt selection
  • structure of DTIF interrupt selection
Return values
OkInterrupt disable normally
ErrorInvalidParameterpstcMft == NULL pstcIntSel == NULL

Definition at line 904 of file mft_wfg.c.

References stc_dtif_int_sel::bDtifAnalogFilterInt, stc_dtif_int_sel::bDtifDigitalFilterInt, ErrorInvalidParameter, Mft_Wfg_DeInitIrq(), MftGetInternDataPtr(), Ok, stc_mft_wfg_intern_data::pfnWfgAnalogFilterCallback, stc_mft_wfg_intern_data::pfnWfgDigtalFilterCallback, and TRUE.

Here is the call graph for this function:

en_result_t Mft_Wfg_DisableTimerInt ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
uint8_t  u8CoupleCh 
)

disable WFG timer interrupt

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]u8CoupleChchannel of WFG couple
  • MFT_WFG_CH10 ~ MFT_WFG_CH54
Return values
OkInternal data has been setup
ErrorInvalidParameterpstcMft == NULL u8CoupleCh out of range

Definition at line 500 of file mft_wfg.c.

References ErrorInvalidParameter, MFT_WFG_CH10, MFT_WFG_CH32, MFT_WFG_CH54, Mft_Wfg_DeInitIrq(), MFT_WFG_MAXCH, MftGetInternDataPtr(), Ok, stc_mft_wfg_intern_data::pfnWfg10TimerCallback, stc_mft_wfg_intern_data::pfnWfg32TimerCallback, and stc_mft_wfg_intern_data::pfnWfg54TimerCallback.

Here is the call graph for this function:

en_result_t Mft_Wfg_EnableDtifInt ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
stc_dtif_int_sel_t *  pstcIntSel,
stc_dtif_int_cb_t *  pstcCallback 
)

Enable DTIF interrupt.

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]pstcIntSelDTIF interrupt selection
  • structure of DTIF interrupt selection
[in]pstcCallbackPointer to DTIF interrupt callback function array
Return values
OkInterrupt enable normally
ErrorInvalidParameterpstcMft == NULL pstcIntSel == NULL pstcCallback == NULL

Definition at line 858 of file mft_wfg.c.

References stc_dtif_int_sel::bDtifAnalogFilterInt, stc_dtif_int_sel::bDtifDigitalFilterInt, ErrorInvalidParameter, Mft_Wfg_InitIrq(), MftGetInternDataPtr(), Ok, stc_mft_wfg_intern_data::pfnWfgAnalogFilterCallback, stc_dtif_int_cb::pfnWfgAnalogFilterCallback, stc_mft_wfg_intern_data::pfnWfgDigtalFilterCallback, stc_dtif_int_cb::pfnWfgDigtalFilterCallback, and TRUE.

Here is the call graph for this function:

en_result_t Mft_Wfg_EnableTimerInt ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
uint8_t  u8CoupleCh,
func_ptr_t  pfnCallback 
)

enable WFG timer interrupt

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]u8CoupleChchannel of WFG couple
  • MFT_WFG_CH10 ~ MFT_WFG_CH54
[in]pfnCallbackcallback function
  • func_ptr_t
Return values
OkInternal data has been setup
ErrorInvalidParameterpstcMft == NULL u8CoupleCh out of range

Definition at line 449 of file mft_wfg.c.

References ErrorInvalidParameter, MFT_WFG_CH10, MFT_WFG_CH32, MFT_WFG_CH54, Mft_Wfg_InitIrq(), MFT_WFG_MAXCH, MftGetInternDataPtr(), Ok, stc_mft_wfg_intern_data::pfnWfg10TimerCallback, stc_mft_wfg_intern_data::pfnWfg32TimerCallback, and stc_mft_wfg_intern_data::pfnWfg54TimerCallback.

Here is the call graph for this function:

en_int_flag_t Mft_Wfg_GetAnalogFilterIntFlag ( volatile FM4_MFT_WFG_TypeDef *  pstcMft)

get Analgo filter interrupt flag

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
Return values
en_int_flag_tinterrupt falg
PdlSet,PdlClr

Definition at line 1021 of file mft_wfg.c.

Referenced by Mft_Wfg_IrqHandler().

Here is the caller graph for this function:

en_int_flag_t Mft_Wfg_GetDigitalFilterIntFlag ( volatile FM4_MFT_WFG_TypeDef *  pstcMft)

get Digital filter interrupt flag

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
Return values
en_int_flag_tinterrupt falg
PdlSet,PdlClr

Definition at line 975 of file mft_wfg.c.

Referenced by Mft_Wfg_IrqHandler().

Here is the caller graph for this function:

uint16_t Mft_Wfg_GetTimerCurCycle ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
uint8_t  u8CoupleCh 
)

get current pulse counter

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]u8CoupleChchannel of WFG couple
  • MFT_WFG_CH10 ~ MFT_WFG_CH54
Return values
uint16_tvalue of pulse counter
0~65535

Definition at line 783 of file mft_wfg.c.

en_int_flag_t Mft_Wfg_GetTimerIntFlag ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
uint8_t  u8CoupleCh 
)

get WFG timer interrupt flag

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]u8CoupleChchannel of WFG couple
  • MFT_WFG_CH10 ~ MFT_WFG_CH54
Return values
en_int_flag_tinterrupt falg
PdlSet,PdlClr

Definition at line 634 of file mft_wfg.c.

References MFT_WFG_CH10, MFT_WFG_CH32, and MFT_WFG_CH54.

Referenced by Mft_Wfg_IrqHandler().

Here is the caller graph for this function:

static en_result_t Mft_Wfg_InitIrq ( volatile FM4_MFT_WFG_TypeDef *  pstcMft)
static

Device dependent initialization of interrupts according CMSIS with level defined in l3.h.

Parameters
pstcMftPointer to WFG instance
Returns
Ok Successful initialization

Definition at line 219 of file mft_wfg.c.

References MFT0_WFG, MFT1_WFG, MFT2_WFG, Ok, PDL_IRQ_LEVEL_MFT0_WFG, PDL_IRQ_LEVEL_MFT1_WFG, PDL_IRQ_LEVEL_MFT2_WFG, and stc_mftn_wfg_t.

Referenced by Mft_Wfg_EnableDtifInt(), and Mft_Wfg_EnableTimerInt().

Here is the caller graph for this function:

en_result_t Mft_Wfg_InitTimerClock ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
uint8_t  u8CoupleCh,
en_wfg_timer_clock_t  enClk 
)

init timer clock

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]u8CoupleChchannel of WFG couple
  • MFT_WFG_CH10 ~ MFT_WFG_CH54
[in]enClkcount clock cycle to PCLK multiplied
  • en_wfg_timer_clock_t
Return values
OkInternal data has been setup
ErrorInvalidParameterpstcMft == NULL u8CoupleCh out of range

Definition at line 406 of file mft_wfg.c.

References ErrorInvalidParameter, MFT_WFG_MAXCH, and Ok.

void Mft_Wfg_IrqHandler ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
stc_mft_wfg_intern_data_t *  pstcMftWfgInternData 
)

WFG interrupt handler sub function.

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]pstcMftWfgInternDatastructure of WFG callback function
  • structure of stc_mft_intern_data
Return values
void

Definition at line 158 of file mft_wfg.c.

References Mft_Wfg_ClrTimerIntFlag(), Mft_Wfg_GetAnalogFilterIntFlag(), Mft_Wfg_GetDigitalFilterIntFlag(), Mft_Wfg_GetTimerIntFlag(), PdlSet, stc_mft_wfg_intern_data::pfnWfg10TimerCallback, stc_mft_wfg_intern_data::pfnWfgAnalogFilterCallback, and stc_mft_wfg_intern_data::pfnWfgDigtalFilterCallback.

Here is the call graph for this function:

en_result_t Mft_Wfg_SetTimerCycle ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
uint8_t  u8CoupleCh,
uint16_t  u16Count 
)

set wfg pulse counter

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]u8CoupleChchannel of WFG couple
  • MFT_WFG_CH10 ~ MFT_WFG_CH54
[in]u16Countwfg pulse counter value
  • 0~65535
Return values
OkInternal data has been setup
ErrorInvalidParameterpstcMft == NULL u8CoupleCh out of range

Definition at line 758 of file mft_wfg.c.

References Ok.

en_result_t Mft_Wfg_StartTimer ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
uint8_t  u8CoupleCh 
)

Start WFG timer.

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]u8CoupleChchannel of WFG couple
  • MFT_WFG_CH10 ~ MFT_WFG_CH54
Return values
OkStart timer successfully
ErrorInvalidParameterpstcMft == NULL u8CoupleCh out of range

Definition at line 552 of file mft_wfg.c.

References ErrorInvalidParameter, MFT_WFG_CH10, MFT_WFG_CH32, MFT_WFG_CH54, MFT_WFG_MAXCH, and Ok.

en_result_t Mft_Wfg_StopTimer ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
uint8_t  u8CoupleCh 
)

Stop WFG timer.

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]u8CoupleChchannel of WFG couple
  • MFT_WFG_CH10 ~ MFT_WFG_CH54
Return values
OkStart timer successfully
ErrorInvalidParameterpstcMft == NULL u8CoupleCh out of range

Definition at line 593 of file mft_wfg.c.

References ErrorInvalidParameter, MFT_WFG_CH10, MFT_WFG_CH32, MFT_WFG_CH54, MFT_WFG_MAXCH, and Ok.

en_result_t Mft_Wfg_SwTiggerDtif ( volatile FM4_MFT_WFG_TypeDef *  pstcMft)

set software trigger DTIF

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
Return values
OkInternal data has been setup
ErrorInvalidParameterpstcMft == NULL u8CoupleCh out of range

Definition at line 951 of file mft_wfg.c.

References ErrorInvalidParameter, and Ok.

en_result_t Mft_Wfg_WriteTimerCountCycle ( volatile FM4_MFT_WFG_TypeDef *  pstcMft,
uint8_t  u8CoupleCh,
uint16_t  u16CycleA,
uint16_t  u16CycleB 
)

write timer count cycle

Parameters
[in]pstcMftMFT register definition
  • structure of MFT register
[in]u8CoupleChchannel of WFG couple
  • MFT_WFG_CH10 ~ MFT_WFG_CH54
[in]u16CycleAWFTA value
  • 0~65535
[in]u16CycleBWFTB value
  • 0~65535
Return values
OkInternal data has been setup
ErrorInvalidParameterpstcMft == NULL u8CoupleCh out of range

Definition at line 714 of file mft_wfg.c.

References ErrorInvalidParameter, MFT_WFG_MAXCH, and Ok.

static stc_mft_wfg_intern_data_t* MftGetInternDataPtr ( volatile FM4_MFT_WFG_TypeDef *  pstcWfg)
static

Return the internal data for a certain WFG instance.

Parameters
pstcWfgPointer to WFG instance
Returns
Pointer to internal data or NULL if instance is not enabled (or not known)

Definition at line 125 of file mft_wfg.c.

References stc_mft_wfg_instance_data::stcInternData, and WFG_INSTANCE_COUNT.

Referenced by Mft_Wfg_ConfigMode(), Mft_Wfg_DisableDtifInt(), Mft_Wfg_DisableTimerInt(), Mft_Wfg_EnableDtifInt(), and Mft_Wfg_EnableTimerInt().

Here is the caller graph for this function:

Variable Documentation

stc_mft_wfg_instance_data_t m_astcMftWfgInstanceDataLut[]
Initial value:
=
{
{
& (*((volatile FM4_MFT_WFG_TypeDef *) FM4_MFT0_WFG_BASE)) ,
NULL
},
{
& (*((volatile FM4_MFT_WFG_TypeDef *) FM4_MFT1_WFG_BASE)) ,
NULL
},
{
& (*((volatile FM4_MFT_WFG_TypeDef *) FM4_MFT2_WFG_BASE)) ,
NULL
},
}

Look-up table for all enabled WFG instances and their internal data.

Definition at line 78 of file mft_wfg.c.

stc_mft_wfg_instance_data_t m_astcMftWfgInstanceDataLut[]

Look-up table for all enabled WFG instances and their internal data.

Definition at line 78 of file mft_wfg.c.