PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
Programmable Pulse Generator (PPG)

How to use PPG module. More...

Data Structures

struct  stc_ppg_config
 Structure to config PPG. More...
 
struct  stc_ppg_upcnt0_config
 Up counter0 configuration. More...
 
struct  stc_timer0_gen_ch
 Up counter0 stop channels selection. More...
 
struct  stc_ppg_upcnt1_config
 Up counter1 configuration. More...
 
struct  stc_timer1_gen_ch
 Up counter1 stop channels selection. More...
 
struct  stc_ppg_upcnt2_config
 Up counter2 configuration. More...
 
struct  stc_timer2_gen_ch
 Up counter2 stop channels selection. More...
 
struct  stc_ppg_igbt_config
 structure of PPG IGBT configuration More...
 

Macros

#define PPG_CH0   0
 
#define PPG_CH1   1
 
#define PPG_CH2   2
 
#define PPG_CH3   3
 
#define PPG_CH4   4
 
#define PPG_CH5   5
 
#define PPG_CH6   6
 
#define PPG_CH7   7
 
#define PPG_CH8   8
 
#define PPG_CH9   9
 
#define PPG_CH10   10
 
#define PPG_CH11   11
 
#define PPG_CH12   12
 
#define PPG_CH13   13
 
#define PPG_CH14   14
 
#define PPG_CH15   15
 
#define PPG_CH16   16
 
#define PPG_CH17   17
 
#define PPG_CH18   18
 
#define PPG_CH19   19
 
#define PPG_CH20   20
 
#define PPG_CH21   21
 
#define PPG_CH22   22
 
#define PPG_CH23   23
 
#define PPG_COUPLE_CH01   0
 
#define PPG_COUPLE_CH23   2
 
#define PPG_COUPLE_CH45   4
 
#define PPG_COUPLE_CH67   6
 
#define PPG_COUPLE_CH89   8
 
#define PPG_COUPLE_CH1011   10
 
#define PPG_COUPLE_CH1213   12
 
#define PPG_COUPLE_CH1415   14
 
#define PPG_COUPLE_CH1617   16
 
#define PPG_COUPLE_CH1819   18
 
#define PPG_COUPLE_CH2021   20
 
#define PPG_COUPLE_CH2223   22
 
#define PPG_INT_MAX_CH   9
 
#define PPG_UP_COUNTER_CH0   0
 
#define PPG_UP_COUNTER_CH1   1
 
#define PPG_UP_COUNTER_CH2   2
 

Typedefs

typedef enum en_ppg_opt_mode en_ppg_opt_mode_t
 Enumeration to define PPG operation mode. More...
 
typedef enum en_ppg_clock en_ppg_clock_t
 Enumeration to define PPG count clock prescaler. More...
 
typedef enum en_ppg_trig en_ppg_trig_t
 Enumeration to define PPG trigger. More...
 
typedef enum en_ppg_level en_ppg_level_t
 Enumeration to define PPG output initial level. More...
 
typedef struct stc_ppg_config stc_ppg_config_t
 Structure to config PPG. More...
 
typedef enum en_ppg_gate_level en_ppg_gate_level_t
 Enumeration to define valid level of GATE signal from MFT. More...
 
typedef enum en_ppg_upcnt_clk en_ppg_upcnt_clk_t
 Enumeration to define clock prescaler of up counter in timing generator. More...
 
typedef struct
stc_ppg_upcnt0_config 
stc_ppg_upcnt0_config_t
 Up counter0 configuration. More...
 
typedef struct stc_timer0_gen_ch stc_timer0_gen_ch_t
 Up counter0 stop channels selection. More...
 
typedef struct
stc_ppg_upcnt1_config 
stc_ppg_upcnt1_config_t
 Up counter1 configuration. More...
 
typedef struct stc_timer1_gen_ch stc_timer1_gen_ch_t
 Up counter1 stop channels selection. More...
 
typedef struct
stc_ppg_upcnt2_config 
stc_ppg_upcnt2_config_t
 Up counter2 configuration. More...
 
typedef struct stc_timer2_gen_ch stc_timer2_gen_ch_t
 Up counter2 stop channels selection. More...
 
typedef enum en_ppg_int_mode en_ppg_int_mode_t
 PPG interrupt mode. More...
 
typedef enum
en_igbt_prohibition_mode 
en_igbt_prohibition_mode_t
 Enumeration to define IBGT prohibition mode. More...
 
typedef enum en_igbt_filter_width en_igbt_filter_width_t
 Enumeration to define IBGT noise filter width. More...
 
typedef enum en_igbt_level en_igbt_level_t
 Enumeration to define IBGT input/out level. More...
 
typedef struct stc_ppg_igbt_config stc_ppg_igbt_config_t
 structure of PPG IGBT configuration More...
 
typedef enum en_ppg_irq_ch en_ppg_irq_ch_t
 PPG IRQ channel. More...
 

Enumerations

enum  en_ppg_opt_mode {
  Ppg8Bit8Bit = 0,
  Ppg8Bit8Pres,
  Ppg16Bit,
  Ppg16Bit16Pres
}
 Enumeration to define PPG operation mode. More...
 
enum  en_ppg_clock {
  PpgPclkDiv1 = 0,
  PpgPclkDiv4,
  PpgPclkDiv16,
  PpgPclkDiv64
}
 Enumeration to define PPG count clock prescaler. More...
 
enum  en_ppg_trig {
  PpgSoftwareTrig = 0,
  PpgMftGateTrig,
  PpgTimingGenTrig
}
 Enumeration to define PPG trigger. More...
 
enum  en_ppg_level {
  PpgNormalLevel = 0,
  PpgReverseLevel
}
 Enumeration to define PPG output initial level. More...
 
enum  en_ppg_gate_level {
  PpgGateHighActive = 0,
  PpgGateLowActive
}
 Enumeration to define valid level of GATE signal from MFT. More...
 
enum  en_ppg_upcnt_clk {
  PpgUpCntPclkDiv2 = 0,
  PpgUpCntPclkDiv8,
  PpgUpCntPclkDiv32,
  PpgUpCntPclkDiv64
}
 Enumeration to define clock prescaler of up counter in timing generator. More...
 
enum  en_ppg_int_mode {
  PpgHighUnderflow,
  PpgHighAndLowUnderflow
}
 PPG interrupt mode. More...
 
enum  en_igbt_prohibition_mode {
  IgbtNormalMode = 0,
  IgbtStopProhibitionMode
}
 Enumeration to define IBGT prohibition mode. More...
 
enum  en_igbt_filter_width {
  IgbtNoFilter = 0,
  IgbtFilter4Pclk,
  IgbtFilter8Pclk,
  IgbtFilter16Pclk,
  IgbtFilter32Pclk
}
 Enumeration to define IBGT noise filter width. More...
 
enum  en_igbt_level {
  IgbtLevelNormal = 0,
  IgbtLevelInvert
}
 Enumeration to define IBGT input/out level. More...
 
enum  en_ppg_irq_ch {
  PpgCh024,
  PpgCh81012,
  PpgCh161820
}
 PPG IRQ channel. More...
 

Functions

static void Ppg_InitNvic (uint8_t u8Ch)
 Set NVIC Interrupt depending on PPG channel. More...
 
static void Ppg_DeInitNvic (uint8_t u8Ch)
 Clear NVIC Interrupt depending on PPG channel. More...
 
void Ppg_IrqHandler (en_ppg_irq_ch_t u8Ch)
 PPG interrupt service routine. More...
 
en_result_t Ppg_Init (uint8_t u8CoupleCh, stc_ppg_config_t *pstcConfig)
 Initialize PPG. More...
 
en_result_t Ppg_StartSoftwareTrig (uint8_t u8Ch)
 Start PPG by software trigger. More...
 
en_result_t Ppg_StopSoftwareTrig (uint8_t u8Ch)
 Stop PPG software trigger. More...
 
en_result_t Ppg_SelGateLevel (uint8_t u8EvenCh, en_ppg_gate_level_t enLevel)
 Set the valid level of GATE signal. More...
 
en_result_t Ppg_ConfigUpCnt0 (stc_ppg_upcnt0_config_t *pstcConfig)
 Configure the up counter of Timing Generator 0. More...
 
void Ppg_StartUpCnt0 (void)
 Start the up counter of Timing Generator 0. More...
 
en_stat_flag_t Ppg_GetUpCnt0Status (void)
 Get the work status of up counter of Timing Generator 0. More...
 
en_result_t Ppg_DisableTimerGen0StartTrig (stc_timer0_gen_ch_t *pstcTimer0GenCh)
 Disable start trigger of Timing Generator 0. More...
 
en_result_t Ppg_ConfigUpCnt1 (stc_ppg_upcnt1_config_t *pstcConfig)
 Configure the up counter of Timing Generator 1. More...
 
void Ppg_StartUpCnt1 (void)
 Start the up counter of Timing Generator 1. More...
 
en_stat_flag_t Ppg_GetUpCnt1Status (void)
 Get the work status of up counter of Timing Generator 1. More...
 
en_result_t Ppg_DisableTimerGen1StartTrig (stc_timer1_gen_ch_t *pstcTimer1GenCh)
 Disable start trigger of Timing Generator 1. More...
 
en_result_t Ppg_ConfigUpCnt2 (stc_ppg_upcnt2_config_t *pstcConfig)
 Configure the up counter of Timing Generator 2. More...
 
void Ppg_StartUpCnt2 (void)
 Start the up counter of Timing Generator 2. More...
 
en_stat_flag_t Ppg_GetUpCnt2Status (void)
 Get the work status of up counter of Timing Generator 2. More...
 
en_result_t Ppg_DisableTimerGen2StartTrig (stc_timer2_gen_ch_t *pstcTimer2GenCh)
 Disable start trigger of Timing Generator 2. More...
 
en_result_t Ppg_EnableInt (uint8_t u8Ch, en_ppg_int_mode_t enIntMode, func_ptr_t pfnCallback)
 Enable PPG interrupt. More...
 
en_result_t Ppg_DisableInt (uint8_t u8Ch)
 Disable PPG interrupt. More...
 
en_int_flag_t Ppg_GetIntFlag (uint8_t u8Ch)
 Get the interrupt flag of PPG. More...
 
en_result_t Ppg_ClrIntFlag (uint8_t u8Ch)
 Clear PPG interrupt flag. More...
 
en_result_t Ppg_SetLevelWidth (uint8_t u8Ch, uint8_t u8LowWidth, uint8_t u8HighWidth)
 Set the pulse width of PPG. More...
 
en_result_t Ppg_InitIgbt (stc_ppg_igbt_config_t *pstcPpgIgbt)
 Initialize IGBT mode. More...
 
void Ppg_EnableIgbtMode (void)
 Enable IGBT mode. More...
 
void Ppg_DisableIgbtMode (void)
 Disable IGBT mode. More...
 

Variables

static func_ptr_t pfnPpgCallback [9]
 Callback function pointer of PPG interrupt. More...
 

Detailed Description

How to use PPG module.

Provided functions of PPG module:

Ppg_Init() must be used for configuration of a PPG couple channel with a structure of the type stc_ppg_config_t. Three ways can trigger the PPG start:

A PPG interrupt can be enabled by the function Ppg_EnableInt(). This function can set callback function for each channel too.

With Ppg_SetLevelWidth() the PPG low/high level width is set to the value given in the parameter Ppg_SetLevelWidth::u8LowWidth and Ppg_SetLevelWidth::u8LowWidth. Ppg_GetUpCntxStatus() can get the operation status of up counter (x=0,1,2)

If use software to start PPG, calling Ppg_StartSoftwareTrig() will start PPG.

If use up counter to start PPG, initialize up counter with Ppg_ConfigUpCntx() with a structure of the type en_ppg_upcnt_clk_t, start the up counter with Ppg_StartUpCnt1() and if count value matchs with compare value, the according PPG channel will start.

If use GATE signal to trigger PPG, set the valid level with Ppg_SelGateLevel(), and if GATE signal from MFT becomes valid level, PPG will start.

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 Ppg_GetIntFlag() to check if the interrupt occurs, and clear the interrupt flag by Ppg_ClrIntFlag().

When stopping the PPG, if PPG is triggered by software, use Ppg_StopSoftwareTrig() to stop PPG output, if PPG is triggered by up counter, use Ppg_DisableTimerGen0StartTrig to stop PPG output, if PPG is triggered by GATE, set the GATE signal to invalid level in the MFT module.

IGBT mode is also supported by PPG. Ppg_InitIgbt() must be used for configuration of IGBT mode with a structure of the type stc_ppg_igbt_config_t.

Ppg_EnableIgbtMode() is used to enable IGBT mode and Ppg_DisableIgbtMode() is used to disable IGBT mode.

Macro Definition Documentation

#define PPG_CH0   0
#define PPG_CH1   1

Definition at line 142 of file ppg.h.

#define PPG_CH10   10
#define PPG_CH11   11

Definition at line 152 of file ppg.h.

#define PPG_CH12   12
#define PPG_CH13   13

Definition at line 154 of file ppg.h.

#define PPG_CH14   14

Definition at line 155 of file ppg.h.

#define PPG_CH15   15

Definition at line 156 of file ppg.h.

#define PPG_CH17   17

Definition at line 158 of file ppg.h.

#define PPG_CH18   18
#define PPG_CH19   19

Definition at line 160 of file ppg.h.

#define PPG_CH2   2
#define PPG_CH20   20
#define PPG_CH21   21

Definition at line 162 of file ppg.h.

#define PPG_CH22   22

Definition at line 163 of file ppg.h.

Referenced by Ppg_SelGateLevel().

#define PPG_CH23   23

Definition at line 164 of file ppg.h.

Referenced by Ppg_SetLevelWidth(), Ppg_StartSoftwareTrig(), and Ppg_StopSoftwareTrig().

#define PPG_CH3   3

Definition at line 144 of file ppg.h.

#define PPG_CH4   4
#define PPG_CH5   5

Definition at line 146 of file ppg.h.

#define PPG_CH6   6

Definition at line 147 of file ppg.h.

#define PPG_CH7   7

Definition at line 148 of file ppg.h.

#define PPG_CH8   8
#define PPG_CH9   9

Definition at line 150 of file ppg.h.

#define PPG_COUPLE_CH01   0

Definition at line 166 of file ppg.h.

#define PPG_COUPLE_CH1011   10

Definition at line 171 of file ppg.h.

#define PPG_COUPLE_CH1213   12

Definition at line 172 of file ppg.h.

#define PPG_COUPLE_CH1415   14

Definition at line 173 of file ppg.h.

#define PPG_COUPLE_CH1617   16

Definition at line 174 of file ppg.h.

#define PPG_COUPLE_CH1819   18

Definition at line 175 of file ppg.h.

#define PPG_COUPLE_CH2021   20

Definition at line 176 of file ppg.h.

#define PPG_COUPLE_CH2223   22

Definition at line 177 of file ppg.h.

Referenced by Ppg_Init().

#define PPG_COUPLE_CH23   2

Definition at line 167 of file ppg.h.

#define PPG_COUPLE_CH45   4

Definition at line 168 of file ppg.h.

#define PPG_COUPLE_CH67   6

Definition at line 169 of file ppg.h.

#define PPG_COUPLE_CH89   8

Definition at line 170 of file ppg.h.

#define PPG_INT_MAX_CH   9

Definition at line 179 of file ppg.h.

#define PPG_UP_COUNTER_CH0   0

Definition at line 181 of file ppg.h.

#define PPG_UP_COUNTER_CH1   1

Definition at line 182 of file ppg.h.

#define PPG_UP_COUNTER_CH2   2

Definition at line 183 of file ppg.h.

Typedef Documentation

Enumeration to define IBGT noise filter width.

Enumeration to define IBGT input/out level.

Enumeration to define IBGT prohibition mode.

Enumeration to define PPG count clock prescaler.

Enumeration to define valid level of GATE signal from MFT.

PPG interrupt mode.

PPG IRQ channel.

Enumeration to define PPG output initial level.

Enumeration to define PPG operation mode.

Note
only following combination of 4 channel is valid: Ch0_Ch1 Ch2_Ch3 Ppg8Bit8Bit Ppg8Bit8Bit Ppg8Bit8Bit Ppg8Bit8Pres Ppg8Bit8Bit Ppg16Bit Ppg8Bit8Pres Ppg8Bit8Bit Ppg8Bit8Pres Ppg8Bit8Pres Ppg8Bit8Pres Ppg16Bit Ppg16Bit Ppg8Bit8Bit Ppg16Bit Ppg8Bit8Pres Ppg16Bit Ppg16Bit Ppg16Bit16Pres Ppg16Bit16Pres [Act as Prescaler]
typedef enum en_ppg_trig en_ppg_trig_t

Enumeration to define PPG trigger.

Enumeration to define clock prescaler of up counter in timing generator.

Structure to config PPG.

structure of PPG IGBT configuration

Up counter0 configuration.

Up counter1 configuration.

Up counter2 configuration.

Up counter0 stop channels selection.

Up counter1 stop channels selection.

Up counter2 stop channels selection.

Enumeration Type Documentation

Enumeration to define IBGT noise filter width.

Enumerator
IgbtNoFilter 

No noise filter.

IgbtFilter4Pclk 

noise filter width: 4PCLK

IgbtFilter8Pclk 

noise filter width: 8PCLK

IgbtFilter16Pclk 

noise filter width: 16PCLK

IgbtFilter32Pclk 

noise filter width: 32PCLK

Definition at line 394 of file ppg.h.

Enumeration to define IBGT input/out level.

Enumerator
IgbtLevelNormal 

Normal.

IgbtLevelInvert 

Invert.

Definition at line 408 of file ppg.h.

Enumeration to define IBGT prohibition mode.

Enumerator
IgbtNormalMode 

Normal mode.

IgbtStopProhibitionMode 

Stop prohibition mode in output active.

Definition at line 383 of file ppg.h.

Enumeration to define PPG count clock prescaler.

Enumerator
PpgPclkDiv1 

PPG count clock prescaler: 1.

PpgPclkDiv4 

PPG count clock prescaler: 1/4.

PpgPclkDiv16 

PPG count clock prescaler: 1/16.

PpgPclkDiv64 

PPG count clock prescaler: 1/64.

Definition at line 215 of file ppg.h.

Enumeration to define valid level of GATE signal from MFT.

Enumerator
PpgGateHighActive 

GATE valid level: High.

PpgGateLowActive 

GATE valid level: Low.

Definition at line 266 of file ppg.h.

PPG interrupt mode.

Enumerator
PpgHighUnderflow 

Generate interrupt when high width count underflows.

PpgHighAndLowUnderflow 

Generate interrupt when high or low width count underflows.

Definition at line 372 of file ppg.h.

PPG IRQ channel.

Enumerator
PpgCh024 

IRQ 36 for PPG ch.0,2,4.

PpgCh81012 

IRQ 37 for PPG ch.8,10,12.

PpgCh161820 

IRQ 38 for PPG ch.16,18,20.

Definition at line 433 of file ppg.h.

Enumeration to define PPG output initial level.

Enumerator
PpgNormalLevel 

Inital level: Low.

PpgReverseLevel 

Inital level: High.

Definition at line 240 of file ppg.h.

Enumeration to define PPG operation mode.

Note
only following combination of 4 channel is valid: Ch0_Ch1 Ch2_Ch3 Ppg8Bit8Bit Ppg8Bit8Bit Ppg8Bit8Bit Ppg8Bit8Pres Ppg8Bit8Bit Ppg16Bit Ppg8Bit8Pres Ppg8Bit8Bit Ppg8Bit8Pres Ppg8Bit8Pres Ppg8Bit8Pres Ppg16Bit Ppg16Bit Ppg8Bit8Bit Ppg16Bit Ppg8Bit8Pres Ppg16Bit Ppg16Bit Ppg16Bit16Pres Ppg16Bit16Pres [Act as Prescaler]
Enumerator
Ppg8Bit8Bit 

Even channel: 8bit PPG, odd channel: 8bit PPG.

Ppg8Bit8Pres 

Even channel: 8bit PPG, odd channel: 8bit prescaler.

Ppg16Bit 

16bit PPG

Ppg16Bit16Pres 

16bit PPG + 16 prescaler (provided by next couple channel)

Definition at line 202 of file ppg.h.

Enumeration to define PPG trigger.

Enumerator
PpgSoftwareTrig 

Use software to trigger PPG.

PpgMftGateTrig 

Use GATE signal from MFT to trigger PPG.

PpgTimingGenTrig 

Use Timing Generator to trigger PPG.

Definition at line 228 of file ppg.h.

Enumeration to define clock prescaler of up counter in timing generator.

Enumerator
PpgUpCntPclkDiv2 

Up counter clock prescaler: 1/2.

PpgUpCntPclkDiv8 

Up counter clock prescaler: 1/8.

PpgUpCntPclkDiv32 

Up counter clock prescaler: 1/32.

PpgUpCntPclkDiv64 

Up counter clock prescaler: 1/64.

Definition at line 278 of file ppg.h.

Function Documentation

en_result_t Ppg_ClrIntFlag ( uint8_t  u8Ch)

Clear PPG interrupt flag.

Parameters
[in]u8ChPPG channnel
  • PPG_CHx, x=0,2,4,8,10,12,16,18,20
Return values
OkClear PPG interrupt flag successfully
ErrorInvalidParameteru8Ch != ch.0,2,4,8,10,12,16,18,20

Definition at line 844 of file ppg.c.

References ErrorInvalidParameter, Ok, PPG_CH0, PPG_CH10, PPG_CH12, PPG_CH16, PPG_CH18, PPG_CH2, PPG_CH20, PPG_CH4, and PPG_CH8.

en_result_t Ppg_ConfigUpCnt0 ( stc_ppg_upcnt0_config_t *  pstcConfig)

Configure the up counter of Timing Generator 0.

Parameters
[in]pstcConfigPointer to up counter 0 configuration structure
Return values
OkConfigure the up counter successfully
ErrorInvalidParameterpstcConfig != NULL pstcConfig->enClk > PpgUpCntPclkDiv64

Definition at line 441 of file ppg.c.

References stc_ppg_upcnt0_config::enClk, ErrorInvalidParameter, Ok, PpgUpCntPclkDiv64, stc_ppg_upcnt0_config::u8CmpValue0, stc_ppg_upcnt0_config::u8CmpValue2, stc_ppg_upcnt0_config::u8CmpValue4, and stc_ppg_upcnt0_config::u8CmpValue6.

en_result_t Ppg_ConfigUpCnt1 ( stc_ppg_upcnt1_config_t *  pstcConfig)

Configure the up counter of Timing Generator 1.

Parameters
[in]pstcConfigPointer to up counter 1 configuration structure
Return values
OkConfigure the up counter successfully
ErrorInvalidParameterpstcConfig != NULL pstcConfig->enClk > PpgUpCntPclkDiv64

Definition at line 520 of file ppg.c.

References stc_ppg_upcnt1_config::enClk, ErrorInvalidParameter, Ok, PpgUpCntPclkDiv64, stc_ppg_upcnt1_config::u8CmpValue10, stc_ppg_upcnt1_config::u8CmpValue12, stc_ppg_upcnt1_config::u8CmpValue14, and stc_ppg_upcnt1_config::u8CmpValue8.

en_result_t Ppg_ConfigUpCnt2 ( stc_ppg_upcnt2_config_t *  pstcConfig)

Configure the up counter of Timing Generator 2.

Parameters
[in]pstcConfigPointer to up counter 2 configuration structure
Return values
OkConfigure the up counter successfully
ErrorInvalidParameterpstcConfig != NULL pstcConfig->enClk > PpgUpCntPclkDiv64

Definition at line 598 of file ppg.c.

References stc_ppg_upcnt2_config::enClk, ErrorInvalidParameter, Ok, PpgUpCntPclkDiv64, stc_ppg_upcnt2_config::u8CmpValue16, stc_ppg_upcnt2_config::u8CmpValue18, stc_ppg_upcnt2_config::u8CmpValue20, and stc_ppg_upcnt2_config::u8CmpValue22.

static void Ppg_DeInitNvic ( uint8_t  u8Ch)
static

Clear NVIC Interrupt depending on PPG channel.

Parameters
u8ChPPG interrupt channel

Definition at line 111 of file ppg.c.

References PDL_DEFAULT_INTERRUPT_LEVEL, PPG_CH0, PPG_CH10, PPG_CH12, PPG_CH16, PPG_CH18, PPG_CH2, PPG_CH20, PPG_CH4, and PPG_CH8.

Referenced by Ppg_DisableInt().

Here is the caller graph for this function:

void Ppg_DisableIgbtMode ( void  )

Disable IGBT mode.

Note
PPG0 and PPG4 outputs normal PPG wave.

Definition at line 963 of file ppg.c.

en_result_t Ppg_DisableInt ( uint8_t  u8Ch)

Disable PPG interrupt.

Parameters
[in]u8ChPPG channnel
  • PPG_CHx, x=0,2,4,8,10,12,16,18,20
Return values
OkDisable PPG interrupt successfully
ErrorInvalidParameteru8Ch != ch.0,2,4,8,10,12,16,18,20

Definition at line 744 of file ppg.c.

References ErrorInvalidParameter, Ok, pfnPpgCallback, PPG_CH0, PPG_CH10, PPG_CH12, PPG_CH16, PPG_CH18, PPG_CH2, PPG_CH20, PPG_CH4, PPG_CH8, and Ppg_DeInitNvic().

Here is the call graph for this function:

en_result_t Ppg_DisableTimerGen0StartTrig ( stc_timer0_gen_ch_t *  pstcTimer0GenCh)

Disable start trigger of Timing Generator 0.

Parameters
pstcTimer0GenChPointer to the structure of selected channels (ch.0,2,4,6)
Return values
OkDisable start trigger
ErrorInvalidParameterpstcTimer0GenCh->bPpgChx isn't bool type

Definition at line 492 of file ppg.c.

References stc_timer0_gen_ch::bPpgCh0, stc_timer0_gen_ch::bPpgCh2, stc_timer0_gen_ch::bPpgCh4, stc_timer0_gen_ch::bPpgCh6, ErrorInvalidParameter, and Ok.

en_result_t Ppg_DisableTimerGen1StartTrig ( stc_timer1_gen_ch_t *  pstcTimer1GenCh)

Disable start trigger of Timing Generator 1.

Parameters
pstcTimer1GenChPointer to the structure of selected channels (ch.8,10,12,14)
Return values
OkDisable start trigger
ErrorInvalidParameterpstcTimer0GenCh->bPpgChx isn't bool type

Definition at line 570 of file ppg.c.

References stc_timer1_gen_ch::bPpgCh10, stc_timer1_gen_ch::bPpgCh12, stc_timer1_gen_ch::bPpgCh14, stc_timer1_gen_ch::bPpgCh8, ErrorInvalidParameter, and Ok.

en_result_t Ppg_DisableTimerGen2StartTrig ( stc_timer2_gen_ch_t *  pstcTimer2GenCh)

Disable start trigger of Timing Generator 2.

Parameters
pstcTimer2GenChPointer to the structure of selected channels (ch.16,18,20,22)
Return values
OkDisable start trigger
ErrorInvalidParameterpstcTimer0GenCh->bPpgChx isn't bool type

Definition at line 648 of file ppg.c.

References stc_timer2_gen_ch::bPpgCh16, stc_timer2_gen_ch::bPpgCh18, stc_timer2_gen_ch::bPpgCh20, stc_timer2_gen_ch::bPpgCh22, ErrorInvalidParameter, and Ok.

void Ppg_EnableIgbtMode ( void  )

Enable IGBT mode.

Note
Only PPG0 and PP4 supports IGBT mode.

Definition at line 952 of file ppg.c.

en_result_t Ppg_EnableInt ( uint8_t  u8Ch,
en_ppg_int_mode_t  enIntMode,
func_ptr_t  pfnCallback 
)

Enable PPG interrupt.

Parameters
[in]u8ChPPG channnel
  • PPG_CHx, x=0,2,4,8,10,12,16,18,20
[in]enIntModeInterrupt mode
  • PpgHighUnderflow Generate interrupt when high width count underflows
  • PpgHighAndLowUnderflow Generate interrupt when high or low width count underflows
[in]pfnCallbackPointer to interrupt callback function
Return values
OkEnable PPG interrupt successfully
ErrorInvalidParameteru8Ch != ch.0,2,4,8,10,12,16,18,20 enIntMode > PpgHighAndLowUnderflow pfnCallback == NULL

Definition at line 685 of file ppg.c.

References ErrorInvalidParameter, Ok, pfnPpgCallback, PPG_CH0, PPG_CH10, PPG_CH12, PPG_CH16, PPG_CH18, PPG_CH2, PPG_CH20, PPG_CH4, PPG_CH8, Ppg_InitNvic(), and PpgHighAndLowUnderflow.

Here is the call graph for this function:

en_int_flag_t Ppg_GetIntFlag ( uint8_t  u8Ch)

Get the interrupt flag of PPG.

Parameters
[in]u8ChPPG channnel
  • PPG_CHx, x=0,2,4,8,10,12,16,18,20
Return values
PdlSetInterrupt flag set
PdlClrInterrupt flag clear

Definition at line 798 of file ppg.c.

References PdlClr, PdlSet, PPG_CH0, PPG_CH10, PPG_CH12, PPG_CH16, PPG_CH18, PPG_CH2, PPG_CH20, PPG_CH4, and PPG_CH8.

en_stat_flag_t Ppg_GetUpCnt0Status ( void  )

Get the work status of up counter of Timing Generator 0.

Return values
PdlSetUp counter is counting
PdlClrUp counter stops

Definition at line 476 of file ppg.c.

en_stat_flag_t Ppg_GetUpCnt1Status ( void  )

Get the work status of up counter of Timing Generator 1.

Return values
PdlSetUp counter is counting
PdlClrUp counter stops

Definition at line 554 of file ppg.c.

en_stat_flag_t Ppg_GetUpCnt2Status ( void  )

Get the work status of up counter of Timing Generator 2.

Return values
PdlSetUp counter is counting
PdlClrUp counter stops

Definition at line 632 of file ppg.c.

en_result_t Ppg_Init ( uint8_t  u8CoupleCh,
stc_ppg_config_t *  pstcConfig 
)

Initialize PPG.

Parameters
[in]u8CoupleCha couple PPG channel
  • PPG_COUPLE_CH01 ~ PPG_COUPLE_CH2223
[in]pstcConfigpointer to PPG configuration structure
Return values
OkConfigure the PPG successfully
ErrorInvalidParameteru8CoupleCh%2 !=0 u8CoupleCh > PPG_COUPLE_CH2223 Parameter error of PPG configuration structure

Definition at line 241 of file ppg.c.

References stc_ppg_config::enEvenClock, stc_ppg_config::enEvenLevel, stc_ppg_config::enMode, stc_ppg_config::enOddClock, stc_ppg_config::enOddLevel, stc_ppg_config::enTrig, ErrorInvalidParameter, Ok, Ppg16Bit16Pres, PPG_CH16, PPG_COUPLE_CH2223, PpgMftGateTrig, PpgPclkDiv64, PpgReverseLevel, PpgSoftwareTrig, and PpgTimingGenTrig.

en_result_t Ppg_InitIgbt ( stc_ppg_igbt_config_t *  pstcPpgIgbt)

Initialize IGBT mode.

Parameters
[in]pstcPpgIgbtpointer to IBGT configuration structure
Return values
ErrorInvalidParameterpstcPpgIgbt == NULL Other error configuration

Definition at line 916 of file ppg.c.

References stc_ppg_igbt_config::enIgbt0OutputLevel, stc_ppg_igbt_config::enIgbt1OutputLevel, stc_ppg_igbt_config::enMode, stc_ppg_igbt_config::enTrigInputLevel, stc_ppg_igbt_config::enWidth, ErrorInvalidParameter, IgbtFilter32Pclk, IgbtLevelInvert, IgbtStopProhibitionMode, and Ok.

static void Ppg_InitNvic ( uint8_t  u8Ch)
static

Set NVIC Interrupt depending on PPG channel.

Parameters
u8ChPPG interrupt channel

Definition at line 80 of file ppg.c.

References PDL_IRQ_LEVEL_PPG00_02_04, PDL_IRQ_LEVEL_PPG08_10_12, PPG_CH0, PPG_CH10, PPG_CH12, PPG_CH16, PPG_CH18, PPG_CH2, PPG_CH20, PPG_CH4, and PPG_CH8.

Referenced by Ppg_EnableInt().

Here is the caller graph for this function:

void Ppg_IrqHandler ( en_ppg_irq_ch_t  u8Ch)

PPG interrupt service routine.

Parameters
u8ChIrq channel of PPG

Definition at line 151 of file ppg.c.

References pfnPpgCallback, PpgCh024, PpgCh161820, and PpgCh81012.

en_result_t Ppg_SelGateLevel ( uint8_t  u8EvenCh,
en_ppg_gate_level_t  enLevel 
)

Set the valid level of GATE signal.

Parameters
[in]u8EvenChan even channel of PPG
  • PPG_CH0~PPG_CH22
[in]enLevelGate level
Return values
OkSet the valid level of GATE signal successfully
ErrorInvalidParameteru8Ch > PPG_CH22 u8EvenCh%2 != 0 enLevel > PpgGateLowActive

Definition at line 404 of file ppg.c.

References ErrorInvalidParameter, Ok, PPG_CH22, and PpgGateLowActive.

en_result_t Ppg_SetLevelWidth ( uint8_t  u8Ch,
uint8_t  u8LowWidth,
uint8_t  u8HighWidth 
)

Set the pulse width of PPG.

Parameters
[in]u8ChPPG channnel
  • PPG_CH0~PPG_CH23
[in]u8LowWidthLow level width of PPG
[in]u8HighWidthHigh level width of PPG
Return values
OkSet the pulse width of PPG successfully
ErrorInvalidParameteru8Ch > PPG_CH23

Definition at line 887 of file ppg.c.

References ErrorInvalidParameter, Ok, and PPG_CH23.

en_result_t Ppg_StartSoftwareTrig ( uint8_t  u8Ch)

Start PPG by software trigger.

Parameters
[in]u8ChPPG channel
  • PPG_CH0~PPG_CH23
Return values
OkConfigure the PPG successfully
ErrorInvalidParameteru8Ch > PPG_CH23

Definition at line 341 of file ppg.c.

References ErrorInvalidParameter, Ok, PPG_CH16, and PPG_CH23.

void Ppg_StartUpCnt0 ( void  )

Start the up counter of Timing Generator 0.

Definition at line 463 of file ppg.c.

void Ppg_StartUpCnt1 ( void  )

Start the up counter of Timing Generator 1.

Definition at line 541 of file ppg.c.

void Ppg_StartUpCnt2 ( void  )

Start the up counter of Timing Generator 2.

Definition at line 619 of file ppg.c.

en_result_t Ppg_StopSoftwareTrig ( uint8_t  u8Ch)

Stop PPG software trigger.

Parameters
[in]u8ChPPG channel
  • PPG_CH0~PPG_CH23
Return values
OkConfigure the PPG successfully
ErrorInvalidParameteru8Ch > PPG_CH23

Definition at line 371 of file ppg.c.

References ErrorInvalidParameter, Ok, PPG_CH16, and PPG_CH23.

Variable Documentation

func_ptr_t pfnPpgCallback[9]
static

Callback function pointer of PPG interrupt.

Definition at line 71 of file ppg.c.

Referenced by Ppg_DisableInt(), Ppg_EnableInt(), and Ppg_IrqHandler().