PDL for FM0+  Version1.0
Peripheral Driverl Library for FM0+
C:/pdl_v10/library/driver/mft/mft_ocu.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_OCU_H__
00053 #define __MFT_OCU_H__
00054 /******************************************************************************/
00055 /* Include files                                                              */
00056 /******************************************************************************/
00057 #include "mcu.h"
00058 #include "pdl_user.h"
00059 
00060 #if (defined(PDL_PERIPHERAL_MFT_OCU_ACTIVE))
00061   
00116 /******************************************************************************
00117  * Global definitions
00118  ******************************************************************************/
00119 #define stc_mftn_ocu_t FM0P_MFT_OCU_TypeDef
00120 
00121 #define MFT0_OCU       (*((volatile stc_mftn_ocu_t *) FM0P_MFT0_OCU_BASE))
00122 #define MFT1_OCU       (*((volatile stc_mftn_ocu_t *) FM0P_MFT1_OCU_BASE))
00123 #define MFT2_OCU       (*((volatile stc_mftn_ocu_t *) FM0P_MFT1_OCU_BASE))
00124 
00125 #define  MFT_OCU_CH0             0
00126 #define  MFT_OCU_CH1             1
00127 #define  MFT_OCU_CH2             2
00128 #define  MFT_OCU_CH3             3  
00129 #define  MFT_OCU_CH4             4
00130 #define  MFT_OCU_CH5             5
00131 #define  MFT_OCU_MAXCH           6
00132 
00133 #define  MFT_OCU_CH10            0
00134 #define  MFT_OCU_CH32            1
00135 #define  MFT_OCU_CH54            2
00136 
00137 #define  OCU_INSTANCE_COUNT       (PDL_PERIPHERAL_ENABLE_MFT0_OCU == PDL_ON ? 1 :0) + \
00138                                   (PDL_PERIPHERAL_ENABLE_MFT1_OCU == PDL_ON ? 1 :0) + \
00139                                   (PDL_PERIPHERAL_ENABLE_MFT2_OCU == PDL_ON ? 1 :0)  
00140 
00145 typedef enum en_ocu_instance_index
00146 {
00147 #if (PDL_PERIPHERAL_ENABLE_MFT0_OCU == PDL_ON)  
00148     OcuInstanceIndexOcu0 = 0,  
00149 #endif
00150 #if (PDL_PERIPHERAL_ENABLE_MFT1_OCU == PDL_ON) 
00151     OcuInstanceIndexOcu1,      
00152 #endif 
00153 #if (PDL_PERIPHERAL_ENABLE_MFT2_OCU == PDL_ON) 
00154     OcuInstanceIndexOcu2,      
00155 #endif    
00156 
00157 } en_ocu_instance_index_t;  
00158   
00163 typedef enum en_mft_ocu_frt
00164 {
00165     Frt0ToOcu = 0u,       
00166     Frt1ToOcu,       
00167     Frt2ToOcu,       
00168     OcuFrtToExt,     
00169 }en_mft_ocu_frt_t;
00170 
00175 typedef enum en_ocu_rt_out_state
00176 {
00177     RtLowLevel = 0,         
00178     RtHighLevel             
00179 }en_ocu_rt_out_state_t;
00180 
00185 typedef enum en_ocu_occp_buf
00186 {
00187     OccpBufDisable = 0,         
00188     OccpBufTrsfByFrtZero,       
00189     OccpBufTrsfByFrtPeak,       
00190     OccpBufTrsfByFrtZeroPeak,   
00191 }en_ocu_occp_buf_t;
00192 
00193 
00198 typedef enum en_ocu_ocse_buf
00199 {
00200     OcseBufDisable = 0,         
00201     OcseBufTrsfByFrtZero,       
00202     OcseBufTrsfByFrtPeak,       
00203     OcseBufTrsfByFrtZeroPeak,   
00204 
00205 }en_ocu_ocse_buf_t;
00206 
00211 typedef struct stc_mft_ocu_config
00212 {
00213     en_mft_ocu_frt_t    enFrtConnect;  
00214     boolean_t           bFm4;          
00215     boolean_t           bCmod;         
00216     uint8_t             u8Mod;         
00217     en_ocu_occp_buf_t   enOccpBufMode; 
00218     en_ocu_ocse_buf_t   enOcseBufMode; 
00219     en_ocu_rt_out_state_t enStatePin;  
00220 }stc_mft_ocu_config_t;
00221 
00226 typedef enum en_rt_status
00227 {
00228     RtOutputHold = 0,              
00229     RtOutputHigh,                  
00230     RtOutputLow,                   
00231     RtOutputReverse,               
00232   
00233 }en_rt_even_status_t, en_rt_odd_status_t;
00234 
00239 typedef enum en_iop_flag_set_condition
00240 {
00241     IopFlagHold = 0,           
00242     IopFlagSet,                
00243   
00244 }en_iop_flag_even_t, en_iop_flag_odd_t;
00245 
00250 typedef struct stc_even_compare_config
00251 {
00252     en_rt_even_status_t enFrtZeroEvenMatchEvenChRtStatus;    
00253     en_rt_even_status_t enFrtZeroEvenNotMatchEvenChRtStatus; 
00254     
00255     en_rt_even_status_t enFrtUpCntEvenMatchEvenChRtStatus;   
00256     
00257     en_rt_even_status_t enFrtPeakEvenMatchEvenChRtStatus;  
00258     en_rt_even_status_t enFrtPeakEvenNotMatchEvenChStatus; 
00259     
00260     en_rt_even_status_t enFrtDownCntEvenMatchEvenChRtStatus;    
00261     
00262     en_iop_flag_even_t enIopFlagWhenFrtZeroEvenMatch;    
00263     en_iop_flag_even_t enIopFlagWhenFrtUpCntEvenMatch;   
00264     en_iop_flag_even_t enIopFlagWhenFrtPeakEvenMatch;    
00265     en_iop_flag_even_t enIopFlagWhenFrtDownCntEvenMatch; 
00266     
00267 }stc_even_compare_config_t;
00268 
00273 typedef struct stc_odd_compare_config
00274 {
00275     en_rt_odd_status_t enFrtZeroOddMatchEvenMatchOddChRtStatus;       
00276     en_rt_odd_status_t enFrtZeroOddMatchEvenNotMatchOddChRtStatus;    
00277     en_rt_odd_status_t enFrtZeroOddNotMatchEvenMatchOddChRtStatus;    
00278     en_rt_odd_status_t enFrtZeroOddNotMatchEvenNotMatchOddChRtStatus; 
00279     
00280     en_rt_odd_status_t enFrtUpCntOddMatchEvenMatchOddChRtStatus;      
00281     en_rt_odd_status_t enFrtUpCntOddMatchEvenNotMatchOddChRtStatus;   
00282     en_rt_odd_status_t enFrtUpCntOddNotMatchEvenMatchOddChRtStatus;   
00283     
00284     en_rt_odd_status_t enFrtPeakOddMatchEvenMatchOddChRtStatus;      
00285     en_rt_odd_status_t enFrtPeakOddMatchEvenNotMatchOddChRtStatus;   
00286     en_rt_odd_status_t enFrtPeakOddNotMatchEvenMatchOddChRtStatus;   
00287     en_rt_odd_status_t enFrtPeakOddNotMatchEvenNotMatchOddChRtStatus;
00288     
00289     en_rt_odd_status_t enFrtDownOddMatchEvenMatchOddChRtStatus;      
00290     en_rt_odd_status_t enFrtDownOddMatchEvenNotMatchOddChRtStatus;   
00291     en_rt_odd_status_t enFrtDownOddNotMatchEvenMatchOddChRtStatus;   
00292     
00293     en_iop_flag_odd_t enIopFlagWhenFrtZeroOddMatch;    
00294     en_iop_flag_odd_t enIopFlagWhenFrtUpCntOddMatch;   
00295     en_iop_flag_odd_t enIopFlagWhenFrtPeakOddMatch;    
00296     en_iop_flag_odd_t enIopFlagWhenFrtDownCntOddMatch; 
00297   
00298 }stc_odd_compare_config_t;
00299 
00304 typedef struct stc_mft_ocu_intern_data
00305 {
00306     func_ptr_t  pfnOcu0Callback;      
00307     func_ptr_t  pfnOcu1Callback;      
00308     func_ptr_t  pfnOcu2Callback;      
00309     func_ptr_t  pfnOcu3Callback;      
00310     func_ptr_t  pfnOcu4Callback;      
00311     func_ptr_t  pfnOcu5Callback;      
00312 }stc_mft_ocu_intern_data_t;
00313 
00318 typedef struct stc_mft_ocu_instance_data
00319 {
00320   volatile stc_mftn_ocu_t*  pstcInstance;  
00321   stc_mft_ocu_intern_data_t stcInternData; 
00322 } stc_mft_ocu_instance_data_t;
00323 
00324 /* C binding of definitions if building with C++ compiler */
00325 #ifdef __cplusplus
00326 extern "C"
00327 {
00328 #endif
00329 /******************************************************************************/
00330 /* Global variable declarations ('extern', definition in C source)            */
00331 /******************************************************************************/
00333 extern stc_mft_ocu_instance_data_t m_astcMftOcuInstanceDataLut[OCU_INSTANCE_COUNT];
00334 
00335 /******************************************************************************/
00336 /* Global function prototypes ('extern', definition in C source)              */
00337 /******************************************************************************/
00338 /* Init */
00339 en_result_t Mft_Ocu_Init( volatile stc_mftn_ocu_t* pstcOcu, 
00340                           uint8_t u8Ch, stc_mft_ocu_config_t*  pstcOcuConfig);
00341 /* Compare configuration */
00342 en_result_t Mft_Ocu_SetEvenChCompareMode(volatile stc_mftn_ocu_t* pstcOcu,
00343                                          uint8_t EvenCh,
00344                                          stc_even_compare_config_t* pstcConfig);
00345 en_result_t Mft_Ocu_SetOddChCompareMode (volatile stc_mftn_ocu_t* pstcOcu,
00346                                          uint8_t OddCh,
00347                                          stc_odd_compare_config_t* pstcConfig);
00348                           
00349 /* Func/Int enable/disable */
00350 en_result_t Mft_Ocu_EnableOperation(volatile stc_mftn_ocu_t* pstcOcu, uint8_t u8Ch);
00351 en_result_t Mft_Ocu_DisableOperation(volatile stc_mftn_ocu_t* pstcOcu, uint8_t u8Ch);
00352 #if (PDL_INTERRUPT_ENABLE_MFT0_OCU == PDL_ON) || \
00353     (PDL_INTERRUPT_ENABLE_MFT1_OCU == PDL_ON) || \
00354     (PDL_INTERRUPT_ENABLE_MFT2_OCU == PDL_ON)
00355 en_result_t Mft_Ocu_EnableInt(volatile stc_mftn_ocu_t* pstcOcu,
00356                               uint8_t u8Ch,func_ptr_t  pfnCallback);
00357 en_result_t Mft_Ocu_DisableInt(volatile stc_mftn_ocu_t* pstcOcu,uint8_t u8Ch);
00358 #endif
00359 
00360 /* Count write/read */
00361 en_result_t Mft_Ocu_WriteOccp(volatile stc_mftn_ocu_t* pstcOcu, 
00362                               uint8_t u8Ch, uint16_t u16Occp);
00363 uint16_t Mft_Ocu_ReadOccp(volatile stc_mftn_ocu_t* pstcOcu, uint8_t u8Ch);
00364 
00365 /* Status read/clear */
00366 en_int_flag_t Mft_Ocu_GetIntFlag(volatile stc_mftn_ocu_t* pstcOcu, uint8_t u8Ch);
00367 en_result_t Mft_Ocu_ClrIntFlag(volatile stc_mftn_ocu_t* pstcOcu, uint8_t u8Ch);
00368 
00369 /* Get RT pin level */
00370 en_ocu_rt_out_state_t Mft_Ocu_GetRtPinLevel(volatile stc_mftn_ocu_t* pstcOcu, 
00371                                             uint8_t u8Ch);
00372 
00373 /* IRQ handler */
00374 void Mft_Ocu_IrqHandler( volatile stc_mftn_ocu_t* pstcOcu,
00375                          stc_mft_ocu_intern_data_t* pstcMftOcuInternData) ;
00376 
00377 
00378 #ifdef __cplusplus
00379 }
00380 #endif
00381 
00383 
00384 #endif // #if (defined(PDL_PERIPHERAL_ADC_ACTIVE))
00385 
00386 #endif