| PDL for FM0+ Version1.0 Peripheral Driverl Library for FM0+

- Main Page
- Modules
- Data Structures
- Files

Data Structures | Defines | Typedefs | Enumerations | Functions | Variables
Waveform Generator (WFG)

## 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
## Defines
#define | stc_mftn_wfg_t FM0P_MFT_WFG_TypeDef
#define | MFT0_WFG (*((volatile stc_mftn_wfg_t *) FM0P_MFT0_WFG_BASE))
#define | MFT1_WFG (*((volatile stc_mftn_wfg_t *) FM0P_MFT1_WFG_BASE))
#define | MFT2_WFG (*((volatile stc_mftn_wfg_t *) FM0P_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
#define | WFG_INSTANCE_COUNT
## Typedefs
typedef enum en_wfg_instance_index | en_wfg_instance_index_t
| Enumeration to define an index for each WFG instance.
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_t
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 FM0P_MFT_WFG_TypeDef *pstcWfg)
| Return the internal data for a certain WFG instance.
void | Mft_Wfg_IrqHandler (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, stc_mft_wfg_intern_data_t *pstcMftWfgInternData)
| WFG interrupt handler sub function.
static void | Mft_Wfg_InitIrq (volatile FM0P_MFT_WFG_TypeDef *pstcWfg)
| Device dependent initialization of interrupts according CMSIS with level defined in pdl.h.
static void | Mft_Wfg_DeInitIrq (volatile FM0P_MFT_WFG_TypeDef *pstcWfg)
| Device dependent de-initialization of interrupts according CMSIS.
en_result_t | Mft_Wfg_ConfigMode (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, uint8_t u8CoupleCh, en_mft_wfg_mode_t enMode)
| configure WFG mode
en_result_t | Mft_Wfg_ConfigCtrlBits (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, uint8_t u8CoupleCh, stc_wfg_ctrl_bits_t *pstcCtrlBits)
| configure WFG control bit
en_result_t | Mft_Wfg_InitTimerClock (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, uint8_t u8CoupleCh, en_wfg_timer_clock_t enClk)
| init timer clock
en_result_t | Mft_Wfg_EnableTimerInt (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, uint8_t u8CoupleCh, func_ptr_t pfnCallback)
| enable WFG timer interrupt
en_result_t | Mft_Wfg_DisableTimerInt (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, uint8_t u8CoupleCh)
| disable WFG timer interrupt
en_result_t | Mft_Wfg_StartTimer (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, uint8_t u8CoupleCh)
| Start WFG timer.
en_result_t | Mft_Wfg_StopTimer (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, uint8_t u8CoupleCh)
| Stop WFG timer.
en_int_flag_t | Mft_Wfg_GetTimerIntFlag (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, uint8_t u8CoupleCh)
| get WFG timer interrupt flag
en_result_t | Mft_Wfg_ClrTimerIntFlag (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, uint8_t u8CoupleCh)
| clear WFG timer interrupt flag
en_result_t | Mft_Wfg_WriteTimerCountCycle (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, uint8_t u8CoupleCh, uint16_t u16CycleA, uint16_t u16CycleB)
| write timer count cycle
en_result_t | Mft_Wfg_SetTimerCycle (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, uint8_t u8CoupleCh, uint16_t u16Count)
| set cycle of WFG timer
uint16_t | Mft_Wfg_GetTimerCurCycle (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, uint8_t u8CoupleCh)
| get cycle of WFG timer
en_result_t | Mft_Wfg_ConfigNzcl (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, stc_wfg_nzcl_config_t *pstcNzclConfig)
| configure NZCL
en_result_t | Mft_Wfg_EnableDtifInt (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, stc_dtif_int_sel_t *pstcIntSel, stc_dtif_int_cb_t *pstcCallback)
| Enable DTIF interrupt.
en_result_t | Mft_Wfg_DisableDtifInt (volatile FM0P_MFT_WFG_TypeDef *pstcWfg, stc_dtif_int_sel_t *pstcIntSel)
| Disable DTIF interrupt.
en_result_t | Mft_Wfg_SwTiggerDtif (volatile FM0P_MFT_WFG_TypeDef *pstcWfg)
| set software trigger DTIF
en_int_flag_t | Mft_Wfg_GetDigitalFilterIntFlag (volatile FM0P_MFT_WFG_TypeDef *pstcWfg)
| get Digital filter interrupt flag
en_result_t | Mft_Wfg_ClrDigitalFilterIntFlag (volatile FM0P_MFT_WFG_TypeDef *pstcWfg)
| clear Digital filter interrupt flag
en_int_flag_t | Mft_Wfg_GetAnalogFilterIntFlag (volatile FM0P_MFT_WFG_TypeDef *pstcWfg)
| get Analog Filter interrupt flag
en_result_t | Mft_Wfg_ClrAnalogFilterIntFlag (volatile FM0P_MFT_WFG_TypeDef *pstcWfg)
| clear Analog Filter interrupt flag
## Variables
stc_mft_wfg_instance_data_t | m_astcMftWfgInstanceDataLut [(PDL_PERIPHERAL_ENABLE_MFT0_WFG==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_MFT1_WFG==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_MFT2_WFG==PDL_ON?1:0)]
| Look-up table for all enabled WFG instances and their internal data.
stc_mft_wfg_instance_data_t | m_astcMftWfgInstanceDataLut [(PDL_PERIPHERAL_ENABLE_MFT0_WFG==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_MFT1_WFG==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_MFT2_WFG==PDL_ON?1:0)]
| Look-up table for all enabled WFG instances and their internal data.

## Detailed Description

Provided functions of WFG module:

- Mft_Wfg_ConfigMode()
- Mft_Wfg_ConfigCtrlBits()
- Mft_Wfg_InitTimerClock()
- Mft_Wfg_EnableTimerInt()
- Mft_Wfg_DisableTimerInt()
- Mft_Wfg_WriteTimerCountCycle()
- Mft_Wfg_GetTimerIntFlag()
- Mft_Wfg_ClrTimerIntFlag();
- Mft_Wfg_SetTimerCycle()
- Mft_Wfg_GetTimerCurCycle()
- Mft_Wfg_ConfigNzcl()
- Mft_Wfg_EnableDtifInt()
- Mft_Wfg_DisableDtifInt()
- Mft_Wfg_SwTiggerDtif()
- Mft_Wfg_GetDigitalFilterIntFlag()
- Mft_Wfg_ClrDigitalFilterIntFlag()
- Mft_Wfg_GetAnalogFilterIntFlag()
- Mft_Wfg_ClrAnalogFilterIntFlag()
- Mft_Wfg_IrqHandler()

The WFG can be configured to following mode:

- Through mode
- RT-PPG mode
- Timer-PPG mode
- RT-dead timer mode
- PPG-dead timer 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_t

- enGtenBits = b'00
- enPselBits = b'00
- enPgenBits = b'00
- enDmodBit = b'0

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_t

- enGtenBits = b'00
- enPselBits = b'00 (input PPG ch.0 to WFG0)
- enPgenBits = b'11
- enDmodBit = b'0

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_t

- enGtenBits = b'00
- enPselBits = b'00 (input PPG ch.0 to WFG10)
- enPgenBits = b'11
- enDmodBit = b'0

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_t

- enGtenBits = b'00
- enPselBits = b'00
- enPgenBits = b'00
- enDmodBit = b'0

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 signal. 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_t

- enGtenBits = b'00
- enPselBits = b'00 (input PPG0 to WFG10)
- enPgenBits = b'00
- enDmodBit = b'0

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 function, 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 analog 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.

## Define Documentation

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

Definition at line 286 of file mft_wfg.h.

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

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

Definition at line 287 of file mft_wfg.h.

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

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

Definition at line 288 of file mft_wfg.h.

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

#define MFT_WFG_CH0 0

Definition at line 290 of file mft_wfg.h.

#define MFT_WFG_CH1 1

Definition at line 291 of file mft_wfg.h.

#define MFT_WFG_CH10 0

Definition at line 297 of file mft_wfg.h.

Referenced by Mft_Wfg_ClrTimerIntFlag(), Mft_Wfg_DisableTimerInt(), Mft_Wfg_EnableTimerInt(), Mft_Wfg_GetTimerIntFlag(), Mft_Wfg_StartTimer(), and Mft_Wfg_StopTimer().

#define MFT_WFG_CH2 2

Definition at line 292 of file mft_wfg.h.

#define MFT_WFG_CH3 3

Definition at line 293 of file mft_wfg.h.

#define MFT_WFG_CH32 1

Definition at line 298 of file mft_wfg.h.

Referenced by Mft_Wfg_ClrTimerIntFlag(), Mft_Wfg_DisableTimerInt(), Mft_Wfg_EnableTimerInt(), Mft_Wfg_GetTimerIntFlag(), Mft_Wfg_StartTimer(), and Mft_Wfg_StopTimer().

#define MFT_WFG_CH4 4

Definition at line 294 of file mft_wfg.h.

#define MFT_WFG_CH5 5

Definition at line 295 of file mft_wfg.h.

#define MFT_WFG_CH54 2

Definition at line 299 of file mft_wfg.h.

Referenced by Mft_Wfg_ClrTimerIntFlag(), Mft_Wfg_DisableTimerInt(), Mft_Wfg_EnableTimerInt(), Mft_Wfg_GetTimerIntFlag(), Mft_Wfg_StartTimer(), and Mft_Wfg_StopTimer().

#define MFT_WFG_MAXCH 3

Definition at line 300 of file mft_wfg.h.

Referenced by Mft_Wfg_ClrTimerIntFlag(), Mft_Wfg_ConfigCtrlBits(), Mft_Wfg_ConfigMode(), Mft_Wfg_DisableTimerInt(), Mft_Wfg_EnableTimerInt(), Mft_Wfg_InitTimerClock(), Mft_Wfg_StartTimer(), Mft_Wfg_StopTimer(), and Mft_Wfg_WriteTimerCountCycle().

#define stc_mftn_wfg_t FM0P_MFT_WFG_TypeDef

Definition at line 284 of file mft_wfg.h.

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

#define WFG_INSTANCE_COUNT

Value:

    (PDL_PERIPHERAL_ENABLE_MFT0_WFG == PDL_ON ? 1 : 0) + \
                                     (PDL_PERIPHERAL_ENABLE_MFT1_WFG == PDL_ON ? 1 : 0) + \
                                     (PDL_PERIPHERAL_ENABLE_MFT2_WFG == PDL_ON ? 1 : 0)

Definition at line 302 of file mft_wfg.h.

Referenced by MftGetInternDataPtr().

## Typedef Documentation

typedef enum en_dmod_bit en_dmod_bit_t

typedef enum en_gten_bits en_gten_bits_t

typedef enum en_mft_wfg_mode en_mft_wfg_mode_t

typedef enum en_nzcl_filter_width en_nzcl_filter_width_t

typedef enum en_pgen_bits en_pgen_bits_t

typedef enum en_psel_bits en_psel_bits_t

typedef enum en_wfg_instance_index en_wfg_instance_index_t

Enumeration to define an index for each WFG instance.

typedef enum en_wfg_timer_clock en_wfg_timer_clock_t

typedef struct stc_dtif_int_cb stc_dtif_int_cb_t

typedef struct stc_dtif_int_sel stc_dtif_int_sel_t

typedef struct stc_mft_wfg_instance_data stc_mft_wfg_instance_data_t

typedef struct stc_mft_wfg_intern_data stc_mft_wfg_intern_data_t

typedef struct stc_wfg_ctrl_bits stc_wfg_ctrl_bits_t

typedef struct stc_wfg_nzcl_config stc_wfg_nzcl_config_t

## Enumeration Type Documentation

enum en_dmod_bit

Enumerator:

  DmodBit0B | output RTO1 and RTO0 signals without changing the level
  DmodBit1B | output both RTO1 and RTO0 signals reversed

Definition at line 378 of file mft_wfg.h.

enum en_gten_bits

Enumerator:

  GtenBits00B | GTEN == b'00.
  GtenBits01B | GTEN == b'01.
  GtenBits10B | GTEN == b'10.
  GtenBits11B | GTEN == b'11.

Definition at line 342 of file mft_wfg.h.

enum en_mft_wfg_mode

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 327 of file mft_wfg.h.

enum en_nzcl_filter_width

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 428 of file mft_wfg.h.

enum en_pgen_bits

Enumerator:

  PgenBits00B | PGEN == b'00.
  PgenBits01B | PGEN == b'01.
  PgenBits10B | PGEN == b'10.
  PgenBits11B | PGEN == b'11.

Definition at line 366 of file mft_wfg.h.

enum en_psel_bits

Enumerator:

  PselBits00B | PSEL == b'00.
  PselBits01B | PSEL == b'01.
  PselBits10B | PSEL == b'10.
  PselBits11B | PSEL == b'11.

Definition at line 354 of file mft_wfg.h.

enum en_wfg_instance_index

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 310 of file mft_wfg.h.

enum en_wfg_timer_clock

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 400 of file mft_wfg.h.

## Function Documentation

en_result_t Mft_Wfg_ClrAnalogFilterIntFlag | ( | volatile FM0P_MFT_WFG_TypeDef * | pstcWfg | ) |

clear Analog Filter interrupt flag

Parameters:

  [in] | pstcWfg | Pointer to WFG instance

Return values:

  Ok | Analog Filter interrupt flag is clear
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL u8CoupleCh out of range

Definition at line 1036 of file mft_wfg.c.

References ErrorInvalidParameter, and Ok.

en_result_t Mft_Wfg_ClrDigitalFilterIntFlag | ( | volatile FM0P_MFT_WFG_TypeDef * | pstcWfg | ) |

clear Digital filter interrupt flag

Parameters:

  [in] | pstcWfg | Pointer to WFG instance

Return values:

  Ok | Digital filter interrupt flag is clear
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL u8CoupleCh out of range

Definition at line 991 of file mft_wfg.c.

References ErrorInvalidParameter, and Ok.

en_result_t Mft_Wfg_ClrTimerIntFlag | ( | volatile FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | uint8_t | u8CoupleCh
| ) |  |

clear WFG timer interrupt flag

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | u8CoupleCh | channel of WFG couple MFT_WFG_CH10 ~ MFT_WFG_CH54

Return values:

  Ok | WFG timer interrupt flag is clear
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL u8CoupleCh out of range

Definition at line 661 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 FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | uint8_t | u8CoupleCh,
|  | stc_wfg_ctrl_bits_t * | pstcCtrlBits
| ) |  |

configure WFG control bit

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | u8CoupleCh | channel of WFG couple MFT_WFG_CH10 ~ MFT_WFG_CH54
  [in] | pstcCtrlBits | structure of control bit stc_wfg_ctrl_bits_t, GTEN, PSEL,PGEN,DMOD

Return values:

  Ok | Control bits are set
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL u8CoupleCh out of range

Definition at line 345 of file mft_wfg.c.

References DmodBit0B, 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 FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | uint8_t | u8CoupleCh,
|  | en_mft_wfg_mode_t | enMode
| ) |  |

configure WFG mode

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | u8CoupleCh | channel of WFG couple MFT_WFG_CH10 ~ MFT_WFG_CH54
  [in] | enMode | enum of WFG mode en_mft_wfg_mode_t

Return values:

  Ok | WFG mode is configured
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL u8CoupleCh out of range Other invalid configuration

Definition at line 272 of file mft_wfg.c.

References ErrorInvalidParameter, MFT_WFG_MAXCH, MftGetInternDataPtr(), Ok, stc_mft_wfg_intern_data::pfnWfg10TimerCallback, stc_mft_wfg_intern_data::pfnWfg32TimerCallback, stc_mft_wfg_intern_data::pfnWfg54TimerCallback, WfgPpgDeadTimerFilterMode, WfgPpgDeadTimerMode, WfgRtDeadTimerFilterMode, WfgRtDeadTimerMode, WfgRtPpgMode, WfgThroughMode, and WfgTimerPpgMode.

Here is the call graph for this function:

en_result_t Mft_Wfg_ConfigNzcl | ( | volatile FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | stc_wfg_nzcl_config_t * | pstcNzclConfig
| ) |  |

configure NZCL

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | pstcNzclConfig | configure of NZCL

Return values:

  Ok | NZCL is configured
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL u8CoupleCh out of range

Definition at line 801 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 void Mft_Wfg_DeInitIrq | ( | volatile FM0P_MFT_WFG_TypeDef * | pstcWfg | ) | `[static]`

Device dependent de-initialization of interrupts according CMSIS.

Parameters:

  [in] | pstcWfg | Pointer to WFG instance

Return values:

  Ok | Successful initialization

Definition at line 232 of file mft_wfg.c.

References MFT0_WFG, MFT1_WFG, MFT2_WFG, 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 FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | stc_dtif_int_sel_t * | pstcIntSel
| ) |  |

Disable DTIF interrupt.

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | pstcIntSel | DTIF interrupt selection structure of DTIF interrupt selection

Return values:

  Ok | Interrupt disable normally
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL pstcIntSel == NULL

Definition at line 897 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 FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | uint8_t | u8CoupleCh
| ) |  |

disable WFG timer interrupt

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | u8CoupleCh | channel of WFG couple MFT_WFG_CH10 ~ MFT_WFG_CH54

Return values:

  Ok | WFG timer interrupt is disabled
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL u8CoupleCh out of range

Definition at line 488 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 FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | stc_dtif_int_sel_t * | pstcIntSel,
|  | stc_dtif_int_cb_t * | pstcCallback
| ) |  |

Enable DTIF interrupt.

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | pstcIntSel | DTIF interrupt selection structure of DTIF interrupt selection
  [in] | pstcCallback | Pointer to DTIF interrupt callback function array structure of stc_wfg_nzcl_config_t

Return values:

  Ok | DTIF interrupt is enabled
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL pstcIntSel == NULL pstcCallback == NULL

Definition at line 850 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 FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | uint8_t | u8CoupleCh,
|  | func_ptr_t | pfnCallback
| ) |  |

enable WFG timer interrupt

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | u8CoupleCh | channel of WFG couple MFT_WFG_CH10 ~ MFT_WFG_CH54
  [in] | pfnCallback | callback function func_ptr_t

Return values:

  Ok | WFG timer interrupt is enabled
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL u8CoupleCh out of range

Definition at line 435 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 FM0P_MFT_WFG_TypeDef * | pstcWfg | ) |

get Analog Filter interrupt flag

Parameters:

  [in] | pstcWfg | Pointer to WFG instance

Return values:

  PdlClr | Analog Filter interrupt flag is clear
  PdlSet | Analog Filter interrupt flag is set

Definition at line 1014 of file mft_wfg.c.

References PdlClr, and PdlSet.

Referenced by Mft_Wfg_IrqHandler().

Here is the caller graph for this function:

en_int_flag_t Mft_Wfg_GetDigitalFilterIntFlag | ( | volatile FM0P_MFT_WFG_TypeDef * | pstcWfg | ) |

get Digital filter interrupt flag

Parameters:

  [in] | pstcWfg | Pointer to WFG instance

Return values:

  PdlClr | Digital Filter interrupt flag is clear
  PdlSet | Digital Filter interrupt flag is set

Definition at line 968 of file mft_wfg.c.

References PdlClr, and PdlSet.

Referenced by Mft_Wfg_IrqHandler().

Here is the caller graph for this function:

uint16_t Mft_Wfg_GetTimerCurCycle | ( | volatile FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | uint8_t | u8CoupleCh
| ) |  |

get cycle of WFG timer

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | u8CoupleCh | channel of WFG couple MFT_WFG_CH10 ~ MFT_WFG_CH54

Returns:
  Cycle value of WFG timer

Definition at line 775 of file mft_wfg.c.

en_int_flag_t Mft_Wfg_GetTimerIntFlag | ( | volatile FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | uint8_t | u8CoupleCh
| ) |  |

get WFG timer interrupt flag

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | u8CoupleCh | channel of WFG couple MFT_WFG_CH10 ~ MFT_WFG_CH54

Return values:

  PdlSet | WFG Interrupt flag is set
  PdlClr | WFG Interrupt flag is clear

Definition at line 623 of file mft_wfg.c.

References MFT_WFG_CH10, MFT_WFG_CH32, MFT_WFG_CH54, PdlClr, and PdlSet.

Referenced by Mft_Wfg_IrqHandler().

Here is the caller graph for this function:

static void Mft_Wfg_InitIrq | ( | volatile FM0P_MFT_WFG_TypeDef * | pstcWfg | ) | `[static]`

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

Parameters:

  [in] | pstcWfg | Pointer to WFG instance

Return values:

  Ok | Successful initialization

Definition at line 209 of file mft_wfg.c.

References MFT0_WFG, MFT1_WFG, MFT2_WFG, PDL_IRQ_LEVEL_MFT_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 FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | uint8_t | u8CoupleCh,
|  | en_wfg_timer_clock_t | enClk
| ) |  |

init timer clock

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | u8CoupleCh | channel of WFG couple MFT_WFG_CH10 ~ MFT_WFG_CH54
  [in] | enClk | count clock cycle to PCLK multiplied en_wfg_timer_clock_t

Return values:

  Ok | WFG timer is initialized
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL u8CoupleCh out of range

Definition at line 394 of file mft_wfg.c.

References ErrorInvalidParameter, MFT_WFG_MAXCH, and Ok.

void Mft_Wfg_IrqHandler | ( | volatile FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | stc_mft_wfg_intern_data_t * | pstcMftWfgInternData
| ) |  |

WFG interrupt handler sub function.

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | pstcMftWfgInternData | structure of WFG callback function structure of stc_mft_intern_data

Definition at line 149 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.

Referenced by MFT_WFG_IRQHandler().

Here is the call graph for this function:

Here is the caller graph for this function:

en_result_t Mft_Wfg_SetTimerCycle | ( | volatile FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | uint8_t | u8CoupleCh,
|  | uint16_t | u16Count
| ) |  |

set cycle of WFG timer

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | u8CoupleCh | channel of WFG couple MFT_WFG_CH10 ~ MFT_WFG_CH54
  [in] | u16Count | wfg pulse counter value 0~65535

Return values:

  Ok | cycle of WFG timer is set
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL u8CoupleCh out of range

Definition at line 752 of file mft_wfg.c.

References Ok.

en_result_t Mft_Wfg_StartTimer | ( | volatile FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | uint8_t | u8CoupleCh
| ) |  |

Start WFG timer.

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | u8CoupleCh | channel of WFG couple MFT_WFG_CH10 ~ MFT_WFG_CH54

Return values:

  Ok | Start timer successfully
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL u8CoupleCh out of range

Definition at line 542 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 FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | uint8_t | u8CoupleCh
| ) |  |

Stop WFG timer.

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | u8CoupleCh | channel of WFG couple MFT_WFG_CH10 ~ MFT_WFG_CH54

Return values:

  Ok | Stop timer successfully
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL u8CoupleCh out of range

Definition at line 583 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 FM0P_MFT_WFG_TypeDef * | pstcWfg | ) |

set software trigger DTIF

Parameters:

  [in] | pstcWfg | Pointer to WFG instance

Return values:

  Ok | DTIF is triggered by software
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL u8CoupleCh out of range

Definition at line 945 of file mft_wfg.c.

References ErrorInvalidParameter, and Ok.

en_result_t Mft_Wfg_WriteTimerCountCycle | ( | volatile FM0P_MFT_WFG_TypeDef * | pstcWfg,
|  | uint8_t | u8CoupleCh,
|  | uint16_t | u16CycleA,
|  | uint16_t | u16CycleB
| ) |  |

write timer count cycle

Parameters:

  [in] | pstcWfg | Pointer to WFG instance
  [in] | u8CoupleCh | channel of WFG couple MFT_WFG_CH10 ~ MFT_WFG_CH54
  [in] | u16CycleA | WFTA value 0~65535
  [in] | u16CycleB | WFTB value 0~65535

Return values:

  Ok | Timer count cycle is written
  ErrorInvalidParameter | If one of following conditions are met: pstcMft == NULL u8CoupleCh out of range

Definition at line 708 of file mft_wfg.c.

References ErrorInvalidParameter, MFT_WFG_MAXCH, and Ok.

static stc_mft_wfg_intern_data_t* MftGetInternDataPtr | ( | volatile FM0P_MFT_WFG_TypeDef * | pstcWfg | ) | `[static]`

Return the internal data for a certain WFG instance.

Parameters:

  pstcWfg | Pointer to WFG instance

Returns:
  Pointer to internal data or NULL if instance is not enabled (or not known)

Definition at line 121 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[(PDL_PERIPHERAL_ENABLE_MFT0_WFG==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_MFT1_WFG==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_MFT2_WFG==PDL_ON?1:0)]

Initial value:

    {

        {
            & (*((volatile  FM0P_MFT_WFG_TypeDef  *) FM0P_MFT0_WFG_BASE)) ,
            {NULL,NULL,NULL,NULL,NULL}
        },

        {
            & (*((volatile  FM0P_MFT_WFG_TypeDef  *) FM0P_MFT1_WFG_BASE)) ,
            {NULL,NULL,NULL,NULL,NULL}
        },

        {
            & (*((volatile  FM0P_MFT_WFG_TypeDef  *) FM0P_MFT2_WFG_BASE)) ,
            {NULL,NULL,NULL,NULL,NULL}
        },

    }

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

Definition at line 74 of file mft_wfg.c.

Referenced by MFT_WFG_IRQHandler().

stc_mft_wfg_instance_data_t m_astcMftWfgInstanceDataLut[(PDL_PERIPHERAL_ENABLE_MFT0_WFG==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_MFT1_WFG==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_MFT2_WFG==PDL_ON?1:0)]

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

Definition at line 74 of file mft_wfg.c.

Referenced by MFT_WFG_IRQHandler().