PDL for FM0+  Version1.0
Peripheral Driverl Library for FM0+
C:/pdl_v10/library/driver/mft/mft_frt.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2013 Spansion LLC. All Rights Reserved.
00003 *
00004 * This software is owned and published by:
00005 * Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA  94088-3453 ("Spansion").
00006 *
00007 * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
00008 * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
00009 *
00010 * This software contains source code for use with Spansion
00011 * components. This software is licensed by Spansion to be adapted only
00012 * for use in systems utilizing Spansion components. Spansion shall not be
00013 * responsible for misuse or illegal use of this software for devices not
00014 * supported herein.  Spansion is providing this software "AS IS" and will
00015 * not be responsible for issues arising from incorrect user implementation
00016 * of the software.
00017 *
00018 * SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
00019 * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
00020 * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
00021 * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
00022 * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
00023 * WARRANTY OF NONINFRINGEMENT.
00024 * SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
00025 * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
00026 * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
00027 * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
00028 * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
00029 * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
00030 * SAVINGS OR PROFITS,
00031 * EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
00032 * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
00033 * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
00034 * FROM, THE SOFTWARE.
00035 *
00036 * This software may be replicated in part or whole for the licensed use,
00037 * with the restriction that this Disclaimer and Copyright notice must be
00038 * included with each copy of this software, whether used in part or whole,
00039 * at all times.
00040 */
00041 /******************************************************************************/
00052 #ifndef __MFT_FRT_H__
00053 #define __MFT_FRT_H__
00054 
00055 /******************************************************************************/
00056 /* Include files                                                              */
00057 /******************************************************************************/
00058 #include "mcu.h"
00059 #include "pdl_user.h"
00060 
00061 #if (defined(PDL_PERIPHERAL_MFT_FRT_ACTIVE))
00062 
00120 /******************************************************************************
00121  * Global definitions
00122  ******************************************************************************/
00123 #define stc_mftn_frt_t FM0P_MFT_FRT_TypeDef
00124 #define MFT0_FRT       (*((volatile stc_mftn_frt_t *) FM0P_MFT0_FRT_BASE))
00125 #define MFT1_FRT       (*((volatile stc_mftn_frt_t *) FM0P_MFT1_FRT_BASE))
00126 #define MFT2_FRT       (*((volatile stc_mftn_frt_t *) FM0P_MFT2_FRT_BASE))
00127 
00128 #define FRT_INSTANCE_COUNT (PDL_PERIPHERAL_ENABLE_MFT0_FRT == PDL_ON ? 1 : 0) + \
00129                            (PDL_PERIPHERAL_ENABLE_MFT1_FRT == PDL_ON ? 1 : 0) + \
00130                            (PDL_PERIPHERAL_ENABLE_MFT2_FRT == PDL_ON ? 1 : 0)  
00131 
00132 #define  MFT_FRT_CH0             0
00133 #define  MFT_FRT_CH1             1
00134 #define  MFT_FRT_CH2             2
00135 
00136 #define  MFT_FRT_MAX_CH          3
00137 
00141 typedef enum en_frt_instance_index
00142 {
00143 #if (PDL_PERIPHERAL_ENABLE_MFT0_FRT == PDL_ON)  
00144     FrtInstanceIndexFrt0,      
00145 #endif    
00146 #if (PDL_PERIPHERAL_ENABLE_MFT1_FRT == PDL_ON) 
00147     FrtInstanceIndexFrt1,      
00148 #endif
00149 #if (PDL_PERIPHERAL_ENABLE_MFT2_FRT == PDL_ON) 
00150     FrtInstanceIndexFrt2,      
00151 #endif
00152 } en_frt_instance_index_t;
00153 
00158 typedef enum en_mft_frt_clock
00159 {
00160     FrtPclkDiv1   = 0,    
00161     FrtPclkDiv2   = 1,    
00162     FrtPclkDiv4   = 2,    
00163     FrtPclkDiv8   = 3,    
00164     FrtPclkDiv16  = 4,    
00165     FrtPclkDiv32  = 5,    
00166     FrtPclkDiv64  = 6,    
00167     FrtPclkDiv128 = 7,    
00168     FrtPclkDiv256 = 8,    
00169     FrtPclkDiv512 = 9,    
00170     FrtPclkDiv1024 = 10,    
00171 } en_mft_frt_clock_t;
00172 
00177 typedef enum en_mft_frt_mode
00178 {
00179     FrtUpCount     = 0,    
00180     FrtUpDownCount = 1     
00181 } en_mft_frt_mode_t;
00182 
00187 typedef struct stc_mft_frt_config
00188 {
00189     en_mft_frt_clock_t  enFrtClockDiv;  
00190     en_mft_frt_mode_t   enFrtMode;      
00191     boolean_t           bEnBuffer;      
00192     boolean_t           bEnExtClock;    
00193 
00194 }stc_mft_frt_config_t;
00195 
00200 typedef struct stc_frt_int_sel
00201 {
00202     boolean_t bFrtZeroMatchInt;       
00203     boolean_t bFrtPeakMatchInt;       
00204 
00205 }stc_frt_int_sel_t;
00206 
00211 typedef enum   en_mft_frt_int
00212 {
00213     enFrtZeroMatchInt = 0,           
00214     enFrtPeakMatchInt,               
00215 
00216 }en_mft_frt_int_t;
00217 
00222 typedef struct stc_frt_int_cb
00223 {
00224     func_ptr_t  pfnFrtZeroCallback; 
00225     func_ptr_t  pfnFrtPeakCallback; 
00226 
00227 }stc_frt_int_cb_t;
00228 
00234 typedef struct stc_mft_frt_intern_data
00235 {
00236     func_ptr_t  pfnFrt0PeakCallback;  
00237     func_ptr_t  pfnFrt1PeakCallback;  
00238     func_ptr_t  pfnFrt2PeakCallback;  
00239     func_ptr_t  pfnFrt0ZeroCallback;  
00240     func_ptr_t  pfnFrt1ZeroCallback;  
00241     func_ptr_t  pfnFrt2ZeroCallback;  
00242 }stc_mft_frt_intern_data_t;
00243 
00248 typedef struct stc_mft_frt_instance_data
00249 {
00250     volatile stc_mftn_frt_t*  pstcInstance;  
00251     stc_mft_frt_intern_data_t stcInternData; 
00252 } stc_mft_frt_instance_data_t;
00253 
00254 /******************************************************************************/
00255 /* Global variable declarations ('extern', definition in C source)            */
00256 /******************************************************************************/
00258 extern stc_mft_frt_instance_data_t m_astcMftFrtInstanceDataLut[FRT_INSTANCE_COUNT];
00259 
00260 /* C binding of definitions if building with C++ compiler */
00261 #ifdef __cplusplus
00262 extern "C"
00263 {
00264 #endif
00265 /******************************************************************************/
00266 /* Global function prototypes ('extern', definition in C source)              */
00267 /******************************************************************************/
00268 /* Init */
00269 en_result_t Mft_Frt_Init(volatile stc_mftn_frt_t* pstcFrt,
00270                          uint8_t u8Ch, stc_mft_frt_config_t*  pstcFrtConfig);
00271 /* Mask zero/peak write/read */
00272 en_result_t Mft_Frt_SetMaskZeroTimes(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch, 
00273                                      uint8_t u8Times);
00274 uint8_t Mft_Frt_GetMaskZeroTimes(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch);
00275 en_result_t Mft_Frt_SetMaskPeakTimes(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch, 
00276                                      uint8_t u8Times);
00277 uint8_t Mft_Frt_GetMaskPeakTimes(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch);
00278 /* Func/Int enable/disable */
00279 en_result_t Mft_Frt_Start(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch);
00280 en_result_t Mft_Frt_Stop(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch);
00281 #if (PDL_INTERRUPT_ENABLE_MFT0_FRT == PDL_ON) || \
00282     (PDL_INTERRUPT_ENABLE_MFT1_FRT == PDL_ON) || \
00283     (PDL_INTERRUPT_ENABLE_MFT2_FRT == PDL_ON)
00284 en_result_t Mft_Frt_EnableInt(volatile stc_mftn_frt_t* pstcFrt,
00285                               uint8_t u8Ch,
00286                               stc_frt_int_sel_t* pstcIntSel,
00287                               stc_frt_int_cb_t* pstcFrtIntCallback);
00288 en_result_t Mft_Frt_DisableInt(volatile stc_mftn_frt_t* pstcFrt,uint8_t u8Ch,
00289                                stc_frt_int_sel_t* pstcIntSel);
00290 #endif
00291 
00292 /* Status get/clear */
00293 en_int_flag_t Mft_Frt_GetIntFlag(volatile stc_mftn_frt_t* pstcFrt,
00294                                  uint8_t u8Ch,
00295                                  en_mft_frt_int_t enIntType);
00296 en_result_t Mft_Frt_ClrIntFlag(volatile stc_mftn_frt_t* pstcFrt,
00297                                uint8_t u8Ch,
00298                                en_mft_frt_int_t enIntType);
00299 
00300 /* Count write/read */
00301 en_result_t Mft_Frt_SetCountCycle(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch, 
00302                                   uint16_t u16Cycle);
00303 en_result_t Mft_Frt_SetCountVal(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch,
00304                                 uint16_t u16Count);
00305 uint16_t Mft_Frt_GetCurCount(volatile stc_mftn_frt_t*pstcFrt, 
00306                              uint8_t u8Ch);
00307 
00308 /* IRQ handler */
00309 void Mft_Frt_IrqHandler(volatile stc_mftn_frt_t* pstcFrt, 
00310                         stc_mft_frt_intern_data_t* pstcMftFrtInternData) ;
00311 
00312 #ifdef __cplusplus
00313 }
00314 #endif
00315 
00317 
00318 #endif // #if (defined(PDL_PERIPHERAL_ADC_ACTIVE))
00319 
00320 #endif /* __MFT_H__ */
00321 
00322 
00323 
00324 
00325 
00326 
00327 
00328 
00329