PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
ppg.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2013 Spansion LLC. All Rights Reserved.
3 *
4 * This software is owned and published by:
5 * Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA 94088-3453 ("Spansion").
6 *
7 * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
8 * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
9 *
10 * This software contains source code for use with Spansion
11 * components. This software is licensed by Spansion to be adapted only
12 * for use in systems utilizing Spansion components. Spansion shall not be
13 * responsible for misuse or illegal use of this software for devices not
14 * supported herein. Spansion is providing this software "AS IS" and will
15 * not be responsible for issues arising from incorrect user implementation
16 * of the software.
17 *
18 * SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
19 * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
20 * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
21 * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
22 * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
23 * WARRANTY OF NONINFRINGEMENT.
24 * SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
25 * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
26 * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
27 * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
28 * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
30 * SAVINGS OR PROFITS,
31 * EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
33 * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
34 * FROM, THE SOFTWARE.
35 *
36 * This software may be replicated in part or whole for the licensed use,
37 * with the restriction that this Disclaimer and Copyright notice must be
38 * included with each copy of this software, whether used in part or whole,
39 * at all times.
40 */
41 /******************************************************************************/
52 #ifndef __PPG_H__
53 #define __PPG_H__
54 
55 #include "pdl.h"
56 
57 #if (defined(PDL_PERIPHERAL_PPG_ACTIVE))
58 
138 /******************************************************************************
139  * Global type definitions
140  ******************************************************************************/
141 #define PPG_CH0 0
142 #define PPG_CH1 1
143 #define PPG_CH2 2
144 #define PPG_CH3 3
145 #define PPG_CH4 4
146 #define PPG_CH5 5
147 #define PPG_CH6 6
148 #define PPG_CH7 7
149 #define PPG_CH8 8
150 #define PPG_CH9 9
151 #define PPG_CH10 10
152 #define PPG_CH11 11
153 #define PPG_CH12 12
154 #define PPG_CH13 13
155 #define PPG_CH14 14
156 #define PPG_CH15 15
157 #define PPG_CH16 16
158 #define PPG_CH17 17
159 #define PPG_CH18 18
160 #define PPG_CH19 19
161 #define PPG_CH20 20
162 #define PPG_CH21 21
163 #define PPG_CH22 22
164 #define PPG_CH23 23
165 
166 #define PPG_COUPLE_CH01 0
167 #define PPG_COUPLE_CH23 2
168 #define PPG_COUPLE_CH45 4
169 #define PPG_COUPLE_CH67 6
170 #define PPG_COUPLE_CH89 8
171 #define PPG_COUPLE_CH1011 10
172 #define PPG_COUPLE_CH1213 12
173 #define PPG_COUPLE_CH1415 14
174 #define PPG_COUPLE_CH1617 16
175 #define PPG_COUPLE_CH1819 18
176 #define PPG_COUPLE_CH2021 20
177 #define PPG_COUPLE_CH2223 22
178 
179 #define PPG_INT_MAX_CH 9 // Including channel.0,2,4,8,10,12,16,18,20
180 
181 #define PPG_UP_COUNTER_CH0 0
182 #define PPG_UP_COUNTER_CH1 1
183 #define PPG_UP_COUNTER_CH2 2
184 
202 typedef enum en_ppg_opt_mode
203 {
208 
210 
215 typedef enum en_ppg_clock
216 {
221 
223 
228 typedef enum en_ppg_trig
229 {
233 
235 
240 typedef enum en_ppg_level
241 {
244 
246 
251 typedef struct stc_ppg_config
252 {
259 
261 
266 typedef enum en_ppg_gate_level
267 {
270 
272 
278 typedef enum en_ppg_upcnt_clk
279 {
284 
286 
291 typedef struct stc_ppg_upcnt0_config
292 {
294  uint8_t u8CmpValue0;
295  uint8_t u8CmpValue2;
296  uint8_t u8CmpValue4;
297  uint8_t u8CmpValue6;
298 
300 
305 typedef struct stc_timer0_gen_ch
306 {
311 
313 
318 typedef struct stc_ppg_upcnt1_config
319 {
321  uint8_t u8CmpValue8;
322  uint8_t u8CmpValue10;
323  uint8_t u8CmpValue12;
324  uint8_t u8CmpValue14;
325 
327 
332 typedef struct stc_timer1_gen_ch
333 {
338 
340 
345 typedef struct stc_ppg_upcnt2_config
346 {
348  uint8_t u8CmpValue16;
349  uint8_t u8CmpValue18;
350  uint8_t u8CmpValue20;
351  uint8_t u8CmpValue22;
352 
354 
359 typedef struct stc_timer2_gen_ch
360 {
365 
367 
372 typedef enum en_ppg_int_mode
373 {
376 
378 
384 {
387 
389 
395 {
401 
403 
408 typedef enum en_igbt_level
409 {
412 
414 
419 typedef struct stc_ppg_igbt_config
420 {
426 
428 
433 typedef enum en_ppg_irq_ch
434 {
438 
440 
441 /* C binding of definitions if building with C++ compiler */
442 #ifdef __cplusplus
443 extern "C"
444 {
445 #endif
446 /* 1. Init */
447 en_result_t Ppg_Init( uint8_t u8CoupleCh, stc_ppg_config_t *pstcConfig);
448 /* 2. Trigger configuration */
449 /* software */
450 en_result_t Ppg_StartSoftwareTrig(uint8_t u8Ch);
451 en_result_t Ppg_StopSoftwareTrig(uint8_t u8Ch);
452 /* MFT gate signal */
453 en_result_t Ppg_SelGateLevel(uint8_t u8EvenCh, en_ppg_gate_level_t enLevel);
454 /* Timing generator configuration */
456 void Ppg_StartUpCnt0(void);
459 
461 void Ppg_StartUpCnt1(void);
464 
466 void Ppg_StartUpCnt2(void);
469 /* 3. Int */
470 #if (PDL_INTERRUPT_ENABLE_PPG00_02_04 == PDL_ON) || \
471  (PDL_INTERRUPT_ENABLE_PPG08_10_12 == PDL_ON) || \
472  (PDL_INTERRUPT_ENABLE_PPG16_18_20 == PDL_ON)
473 en_result_t Ppg_EnableInt(uint8_t u8Ch, en_ppg_int_mode_t enIntMode, func_ptr_t pfnCallback);
474 en_result_t Ppg_DisableInt(uint8_t u8Ch);
475 #endif
476 en_int_flag_t Ppg_GetIntFlag(uint8_t u8Ch);
477 en_result_t Ppg_ClrIntFlag(uint8_t u8Ch);
478 /* 4. H/L width set */
479 en_result_t Ppg_SetLevelWidth(uint8_t u8Ch, uint8_t u8LowWidth, uint8_t u8HighWidth);
480 /* 5. IGBT mode */
482 void Ppg_EnableIgbtMode(void);
483 void Ppg_DisableIgbtMode(void);
484 /* 6. IRQ handler */
485 void Ppg_IrqHandler(en_ppg_irq_ch_t u8Ch) ;
486 
487 #ifdef __cplusplus
488 }
489 #endif
490 
492 
493 #endif
494 
495 #endif