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

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Functions | Variables
C:/pdl_v10/library/driver/ppg/ppg.c File Reference
`#include "ppg.h"`
Include dependency graph for ppg.c:

Go to the source code of this file.

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

## Detailed Description

A detailed description is available at PPG Module description

History:

- 2014-01-08 0.1 Edison Zhang First version.

Definition in file ppg.c.

## Function Documentation

en_result_t Ppg_ClrIntFlag | ( | uint8_t | u8Ch | ) |

Clear PPG interrupt flag.

Parameters:

  [in] | u8Ch | PPG channel PPG_CHx, x=0,2,4,8,10,12,16,18,20

Return values:

  Ok | Clear PPG interrupt flag successfully
  ErrorInvalidParameter | If one of following conditions are met: u8Ch != ch.0,2,4,8,10,12,16,18,20

Definition at line 855 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] | pstcConfig | Pointer to up counter 0 configuration structure

Return values:

  Ok | Configure the up counter successfully
  ErrorInvalidParameter | If one of following conditions are met: pstcConfig != NULL pstcConfig->enClk > PpgUpCntPclkDiv64

Definition at line 439 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] | pstcConfig | Pointer to up counter 1 configuration structure

Return values:

  Ok | Configure the up counter successfully
  ErrorInvalidParameter | If one of following conditions are met: pstcConfig != NULL pstcConfig->enClk > PpgUpCntPclkDiv64

Definition at line 523 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] | pstcConfig | Pointer to up counter 2 configuration structure

Return values:

  Ok | Configure the up counter successfully
  ErrorInvalidParameter | If one of following conditions are met: pstcConfig != NULL pstcConfig->enClk > PpgUpCntPclkDiv64

Definition at line 606 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:

  u8Ch | PPG interrupt channel

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

Definition at line 974 of file ppg.c.

en_result_t Ppg_DisableInt | ( | uint8_t | u8Ch | ) |

Disable PPG interrupt.

Parameters:

  [in] | u8Ch | PPG channel PPG_CHx, x=0,2,4,8,10,12,16,18,20

Return values:

  Ok | Disable PPG interrupt successfully
  ErrorInvalidParameter | If one of following conditions are met: u8Ch != ch.0,2,4,8,10,12,16,18,20

Definition at line 754 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:

  pstcTimer0GenCh | Pointer to the structure of selected channels (ch.0,2,4,6)

Return values:

  Ok | Disable start trigger
  ErrorInvalidParameter | If one of following conditions are met: pstcTimer0GenCh->bPpgChx isn't bool type

Definition at line 494 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:

  pstcTimer1GenCh | Pointer to the structure of selected channels (ch.8,10,12,14)

Return values:

  Ok | Disable start trigger
  ErrorInvalidParameter | If one of following conditions are met: pstcTimer0GenCh->bPpgChx isn't bool type

Definition at line 577 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:

  pstcTimer2GenCh | Pointer to the structure of selected channels (ch.16,18,20,22)

Return values:

  Ok | Disable start trigger
  ErrorInvalidParameter | If one of following conditions are met: pstcTimer0GenCh->bPpgChx isn't bool type

Definition at line 658 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 965 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] | u8Ch | PPG channel PPG_CHx, x=0,2,4,8,10,12,16,18,20
  [in] | enIntMode | Interrupt mode PpgHighUnderflow Generate interrupt when high width count underflows PpgHighAndLowUnderflow Generate interrupt when high or low width count underflows
  [in] | pfnCallback | Pointer to interrupt callback function

Return values:

  Ok | Enable PPG interrupt successfully
  ErrorInvalidParameter | If one of following conditions are met: u8Ch != ch.0,2,4,8,10,12,16,18,20 enIntMode > PpgHighAndLowUnderflow pfnCallback == NULL

Definition at line 694 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] | u8Ch | PPG channel PPG_CHx, x=0,2,4,8,10,12,16,18,20

Return values:

  PdlSet | Interrupt flag set
  PdlClr | Interrupt flag clear

Definition at line 808 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:

  PdlSet | Up counter is counting
  PdlClr | Up counter stops

Definition at line 473 of file ppg.c.

References PdlClr, and PdlSet.

en_stat_flag_t Ppg_GetUpCnt1Status | ( | void |  | ) |

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

Return values:

  PdlSet | Up counter is counting
  PdlClr | Up counter stops

Definition at line 556 of file ppg.c.

References PdlClr, and PdlSet.

en_stat_flag_t Ppg_GetUpCnt2Status | ( | void |  | ) |

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

Return values:

  PdlSet | Up counter is counting
  PdlClr | Up counter stops

Definition at line 639 of file ppg.c.

References PdlClr, and PdlSet.

en_result_t Ppg_Init | ( | uint8_t | u8CoupleCh,
|  | stc_ppg_config_t * | pstcConfig
| ) |  |

Initialize PPG.

Parameters:

  [in] | u8CoupleCh | a couple PPG channel PPG_COUPLE_CH01 ~ PPG_COUPLE_CH2223
  [in] | pstcConfig | pointer to PPG configuration structure

Return values:

  Ok | Configure the PPG successfully
  ErrorInvalidParameter | If one of following conditions are met: u8CoupleCh%2 !=0 u8CoupleCh > PPG_COUPLE_CH2223 Parameter error of PPG configuration structure

Definition at line 235 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] | pstcPpgIgbt | pointer to IBGT configuration structure

Return values:

  ErrorInvalidParameter | If one of following conditions are met: pstcPpgIgbt == NULL Other error configuration

Definition at line 929 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:

  u8Ch | PPG interrupt channel

Definition at line 72 of file ppg.c.

References PDL_IRQ_LEVEL_PPG, 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 | ( | void |  | ) |

PPG interrupt service routine.

Definition at line 152 of file ppg.c.

References pfnPpgCallback.

Referenced by PPG_IRQHandler().

Here is the caller graph for this function:

en_result_t Ppg_SelGateLevel | ( | uint8_t | u8EvenCh,
|  | en_ppg_gate_level_t | enLevel
| ) |  |

Set the valid level of GATE signal.

Parameters:

  [in] | u8EvenCh | an even channel of PPG PPG_CH0~PPG_CH22
  [in] | enLevel | Valid level

Return values:

  Ok | Set the valid level of GATE signal successfully
  ErrorInvalidParameter | If one of following conditions are met: u8Ch > PPG_CH22 u8EvenCh%2 != 0 enLevel > PpgGateLowActive

Definition at line 401 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] | u8Ch | PPG channel PPG_CH0~PPG_CH23
  [in] | u8LowWidth | Low level width of PPG
  [in] | u8HighWidth | High level width of PPG

Return values:

  Ok | Set the pulse width of PPG successfully
  ErrorInvalidParameter | If one of following conditions are met: u8Ch > PPG_CH23

Definition at line 899 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] | u8Ch | PPG channel PPG_CH0~PPG_CH23

Return values:

  Ok | Configure the PPG successfully
  ErrorInvalidParameter | If one of following conditions are met: u8Ch > PPG_CH23

Definition at line 336 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 460 of file ppg.c.

void Ppg_StartUpCnt1 | ( | void |  | ) |

Start the up counter of Timing Generator 1.

Definition at line 543 of file ppg.c.

void Ppg_StartUpCnt2 | ( | void |  | ) |

Start the up counter of Timing Generator 2.

Definition at line 626 of file ppg.c.

en_result_t Ppg_StopSoftwareTrig | ( | uint8_t | u8Ch | ) |

Stop PPG software trigger.

Parameters:

  [in] | u8Ch | PPG channel PPG_CH0~PPG_CH23

Return values:

  Ok | Configure the PPG successfully
  ErrorInvalidParameter | If one of following conditions are met: u8Ch > PPG_CH23

Definition at line 367 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 63 of file ppg.c.

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