PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
mft_wfg.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 __MFT_WFG_H__
53 #define __MFT_WFG_H__
54 
55 #include "pdl.h"
56 
57 #if (defined(PDL_PERIPHERAL_MFT_WFG_ACTIVE))
58 
59 /* C binding of definitions if building with C++ compiler */
60 #ifdef __cplusplus
61 extern "C"
62 {
63 #endif
64 
271 /******************************************************************************
272  * Global definitions
273  ******************************************************************************/
274 #define stc_mftn_wfg_t FM4_MFT_WFG_TypeDef
275 
276 #define MFT0_WFG (*((volatile stc_mftn_wfg_t *) FM4_MFT0_WFG_BASE))
277 #define MFT1_WFG (*((volatile stc_mftn_wfg_t *) FM4_MFT1_WFG_BASE))
278 #define MFT2_WFG (*((volatile stc_mftn_wfg_t *) FM4_MFT2_WFG_BASE))
279 
280 #define MFT_WFG_CH0 0
281 #define MFT_WFG_CH1 1
282 #define MFT_WFG_CH2 2
283 #define MFT_WFG_CH3 3
284 #define MFT_WFG_CH4 4
285 #define MFT_WFG_CH5 5
286 
287 #define MFT_WFG_CH10 0
288 #define MFT_WFG_CH32 1
289 #define MFT_WFG_CH54 2
290 #define MFT_WFG_MAXCH 3
291 
297 {
301 
303 
304 /******************************************************************************
305  * \brief WFG operation mode
306  ******************************************************************************/
307 typedef enum en_mft_wfg_mode
308 {
316 
318 
319 /******************************************************************************
320  * \brief Enumeration of GTEN bits setting
321  ******************************************************************************/
322 typedef enum en_gten_bits
323 {
328 
330 
331 /******************************************************************************
332  * \brief Enumeration of PSEL bits setting
333  ******************************************************************************/
334 typedef enum en_psel_bits
335 {
340 
342 
343 /******************************************************************************
344  * \brief Enumeration of PGEN bits setting
345  ******************************************************************************/
346 typedef enum en_pgen_bits
347 {
352 
354 
355 /******************************************************************************
356  * \brief Enumeration of DMOD bit setting
357  ******************************************************************************/
358 typedef enum en_dmod_bit
359 {
360  DmodBit0B = 0,
362 
364 
365 /******************************************************************************
366  * \brief WFG control configure
367  ******************************************************************************/
368 typedef struct stc_wfg_ctrl_bits
369 {
374 
376 
377 /******************************************************************************
378  * \brief Enumeration to set count clock prescaler
379  ******************************************************************************/
380 typedef enum en_wfg_timer_clock
381 {
390 
392 
393 /******************************************************************************
394  * \brief WFG internal data
395  ******************************************************************************/
397 {
404 
405 /******************************************************************************
406  * brief noise canceling width for a digital noise-canceler
407  ******************************************************************************/
409 {
417 
419 
420 /******************************************************************************
421  * brief NZCL configure
422  ******************************************************************************/
423 typedef struct stc_wfg_nzcl_config
424 {
430 
431 /******************************************************************************
432  * \brief Structure of DTIF interrupt selection
433  ******************************************************************************/
434 typedef struct stc_dtif_int_sel
435 {
438 
440 
441 /******************************************************************************
442  * \brief Structure of DTIF callback function array
443  ******************************************************************************/
444 typedef struct stc_dtif_int_cb
445 {
448 
450 
451 /******************************************************************************
452  * brief structure of WFG instance data
453  ******************************************************************************/
455 {
459 
460 /******************************************************************************/
461 /* Global variable declarations ('extern', definition in C source) */
462 /******************************************************************************/
465 
466 /******************************************************************************/
467 /* Global function prototypes ('extern', definition in C source) */
468 /******************************************************************************/
469 /* 1. WFG function configuration */
471  uint8_t u8CoupleCh, en_mft_wfg_mode_t enMode);
472 en_result_t Mft_Wfg_ConfigCtrlBits(volatile stc_mftn_wfg_t*pstcMft,uint8_t u8CoupleCh,
473  stc_wfg_ctrl_bits* pstcCtrlBits);
474 
475 /* 2. WFG timer configuration */
476 en_result_t Mft_Wfg_InitTimerClock(volatile stc_mftn_wfg_t*pstcMft,uint8_t u8CoupleCh,
477  en_wfg_timer_clock_t enClk);
478 #if (PDL_INTERRUPT_ENABLE_MFT0_WFG == PDL_ON) || \
479  (PDL_INTERRUPT_ENABLE_MFT1_WFG == PDL_ON) || \
480  (PDL_INTERRUPT_ENABLE_MFT2_WFG == PDL_ON)
482  uint8_t u8CoupleCh, func_ptr_t pfnCallback);
483 en_result_t Mft_Wfg_DisableTimerInt(volatile stc_mftn_wfg_t*pstcMft, uint8_t u8CoupleCh);
484 #endif
485 en_result_t Mft_Wfg_StartTimer(volatile stc_mftn_wfg_t*pstcMft, uint8_t u8CoupleCh);
486 en_result_t Mft_Wfg_StopTimer(volatile stc_mftn_wfg_t*pstcMft, uint8_t u8CoupleCh);
487 en_int_flag_t Mft_Wfg_GetTimerIntFlag(volatile stc_mftn_wfg_t*pstcMft, uint8_t u8CoupleCh);
488 en_result_t Mft_Wfg_ClrTimerIntFlag(volatile stc_mftn_wfg_t*pstcMft, uint8_t u8CoupleCh);
490  uint8_t u8CoupleCh,
491  uint16_t u16CycleA,
492  uint16_t u16CycleB);
494  uint8_t u8CoupleCh, uint16_t u16Count);
495 uint16_t Mft_Wfg_GetTimerCurCycle(volatile stc_mftn_wfg_t*pstcMft, uint8_t u8CoupleCh);
496 
497 /* 3. WFG NZCL configuration */
499  stc_wfg_nzcl_config_t* pstcNzclConfig);
500 #if (PDL_INTERRUPT_ENABLE_MFT0_WFG == PDL_ON) || \
501  (PDL_INTERRUPT_ENABLE_MFT1_WFG == PDL_ON) || \
502  (PDL_INTERRUPT_ENABLE_MFT2_WFG == PDL_ON)
504  stc_dtif_int_cb_t* pstcCallback);
506 #endif
512 
513 /* 4. IRQ handler */
514 void Mft_Wfg_IrqHandler(volatile stc_mftn_wfg_t*pstcMft,
515  stc_mft_wfg_intern_data_t* pstcMftWfgInternData) ;
516 
517 #ifdef __cplusplus
518 }
519 #endif
520 
522 
523 #endif // #if (defined(PDL_PERIPHERAL_ADC_ACTIVE))
524 #endif