PDL for FM0+  Version1.0
Peripheral Driverl Library for FM0+
C:/pdl_v10/library/driver/qprc/qprc.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 /******************************************************************************/
00051 #ifndef __QPRC_H__
00052 #define __QPRC_H__
00053 
00054 /******************************************************************************/
00055 /* Include files                                                              */
00056 /******************************************************************************/
00057 #include "mcu.h"
00058 #include "pdl_user.h"
00059 
00060 #if (defined(PDL_PERIPHERAL_QPRC_ACTIVE))
00061 
00148 
00149 /******************************************************************************
00150  * Global definitions
00151  ******************************************************************************/
00152 #define stc_qprcn_t     FM0P_QPRC_TypeDef
00153 #define stc_qprc_nfn_t  FM0P_QPRC_NF_TypeDef
00154 
00155 #define QPRC0       (*((volatile stc_qprcn_t *) FM0P_QPRC0_BASE))
00156 #define QPRC1       (*((volatile stc_qprcn_t *) FM0P_QPRC1_BASE))
00157 #define QPRC2       (*((volatile stc_qprcn_t *) FM0P_QPRC2_BASE))
00158 #define QPRC3       (*((volatile stc_qprcn_t *) FM0P_QPRC3_BASE))
00159 
00160 #define QPRCNF0       (*((volatile stc_qprc_nfn_t *) FM0P_QPRC0_NF_BASE))
00161 #define QPRCNF1       (*((volatile stc_qprc_nfn_t *) FM0P_QPRC1_NF_BASE))
00162 #define QPRCNF2       (*((volatile stc_qprc_nfn_t *) FM0P_QPRC2_NF_BASE))
00163 #define QPRCNF3       (*((volatile stc_qprc_nfn_t *) FM0P_QPRC3_NF_BASE))
00164 
00165 #define QPRC_INSTANCE_COUNT     (PDL_PERIPHERAL_ENABLE_QPRC0 == PDL_ON ? 1 : 0) + \
00166                                 (PDL_PERIPHERAL_ENABLE_QPRC1 == PDL_ON ? 1 : 0) + \
00167                                 (PDL_PERIPHERAL_ENABLE_QPRC2 == PDL_ON ? 1 : 0)  
00168 
00169 #define QPRC_PC_OVERFLOW_INT       0
00170 #define QPRC_PC_UNDERFLOW_INT      1
00171 #define QPRC_PC_ZERO_INDEX_INT     2
00172    
00177 typedef enum en_qprc_instance_index
00178 {
00179 #if (PDL_PERIPHERAL_ENABLE_QPRC0 == PDL_ON)  
00180     QprcInstanceIndexQprc0 = 0,  
00181 #endif
00182 #if (PDL_PERIPHERAL_ENABLE_QPRC1 == PDL_ON) 
00183     QprcInstanceIndexQprc1,      
00184 #endif
00185 #if (PDL_PERIPHERAL_ENABLE_QPRC2 == PDL_ON) 
00186     QprcInstanceIndexQprc2,      
00187 #endif
00188 } en_qprc_instance_index_t;
00189 
00194 typedef enum en_qprc_pcmode
00195 {
00196     QprcPcMode0 = 0,  
00197     QprcPcMode1 = 1,  
00198     QprcPcMode2 = 2,  
00199     QprcPcMode3 = 3   
00200 } en_qprc_pcmode_t;
00201 
00206 typedef enum en_qprc_rcmode
00207 {
00208     QprcRcMode0 = 0,  
00209     QprcRcMode1 = 1,  
00210     QprcRcMode2 = 2,  
00211     QprcRcMode3 = 3   
00212 } en_qprc_rcmode_t;
00213 
00218 typedef enum en_qprc_zinedge
00219 {
00220     QprcZinDisable     = 0,  
00221     QprcZinFallingEdge = 1,  
00222     QprcZinRisingEdge  = 2,  
00223     QprcZinBothEdges   = 3,  
00224     QprcZinLowLevel    = 4,  
00225     QprcZinHighLevel   = 5   
00226 } en_qprc_zinedge_t;
00227 
00232 typedef enum en_qprc_binedge
00233 {
00234     QprcBinDisable     = 0,  
00235     QprcBinFallingEdge = 1,  
00236     QprcBinRisingEdge  = 2,  
00237     QprcBinBothEdges   = 3   
00238 } en_qprc_binedge_t;
00239 
00244 typedef enum en_qprc_ainedge
00245 {
00246     QprcAinDisable     = 0,  
00247     QprcAinFallingEdge = 1,  
00248     QprcAinRisingEdge  = 2,  
00249     QprcAinBothEdges   = 3   
00250 } en_qprc_ainedge_t;
00251 
00256 typedef enum en_qprc_pcresetmask
00257 {
00258     QprcResetMaskDisable  = 0,  
00259     QprcResetMask2Times   = 1,  
00260     QprcResetMask4Times   = 2,  
00261     QprcResetMask8Times   = 3   
00262 } en_qprc_pcresetmask_t;
00263 
00268 typedef enum en_qprc_compmode
00269 {
00270     QprcComapreWithPosition   = 0,  
00271     QprcComapreWithRevolution = 1   
00272 } en_qprc_compmode_t;
00273 
00278 typedef enum en_qprc_int
00279 {
00280     QprcPcOfUfZeroInt = 0,    
00281     QprcPcMatchInt,           
00282     QprcPcRcMatchInt,         
00283     QprcPcMatchRcMatchInt,    
00284     QprcPcCountInvertInt,     
00285     QprcRcOutrangeInt,        
00286 
00287 }en_qprc_int_t;
00288 
00293 typedef struct stc_qprc_int_sel
00294 {
00295     boolean_t    bQprcPcOfUfZeroInt;      
00296     boolean_t    bQprcPcMatchInt;         
00297     boolean_t    bQprcPcRcMatchInt;       
00298     boolean_t    bQprcPcMatchRcMatchInt;  
00299     boolean_t    bQprcPcCountInvertInt;   
00300     boolean_t    bQprcRcOutrangeInt;      
00301 
00302 }stc_qprc_int_sel_t;
00303 
00308 typedef struct stc_qprc_int_cb
00309 {
00310     func_ptr_arg1_t   pfnPcOfUfZeroIntCallback;      
00311     func_ptr_t        pfnPcMatchIntCallback;         
00312     func_ptr_t        pfnPcRcMatchIntCallback;       
00313     func_ptr_t        pfnPcMatchRcMatchIntCallback;  
00314     func_ptr_t        pfnPcCountInvertIntCallback;   
00315     func_ptr_t        pfnRcOutrangeIntCallback;      
00316 
00317 }stc_qprc_int_cb_t;
00318 
00323 typedef enum en_qprc_filter_width
00324 {
00325     QprcNoFilter = 0,           
00326     QprcFilterWidth4Pclk,       
00327     QprcFilterWidth8Pclk,       
00328     QprcFilterWidth16Pclk,      
00329     QprcFilterWidth32Pclk,      
00330     QprcFilterWidth64Pclk,      
00331     QprcFilterWidth128Pclk,     
00332     QprcFilterWidth256Pclk,     
00333 
00334 }en_qprc_filter_width_t;
00335 
00340 typedef struct stc_qprc_filter
00341 {
00342     boolean_t               bInputMask;     
00343     boolean_t               bInputInvert;   
00344     en_qprc_filter_width_t  enWidth;        
00345 
00346 }stc_qprc_filter_t;
00347 
00352 typedef struct stc_qprc_config
00353 {
00354     boolean_t             bSwapAinBin;                    
00355     en_qprc_compmode_t    enComapreMode;                  
00356     en_qprc_zinedge_t     enZinEdge;                      
00357     en_qprc_binedge_t     enBinEdge;                      
00358     en_qprc_ainedge_t     enAinEdge;                      
00359     en_qprc_pcresetmask_t enPcResetMask;                  
00360     boolean_t             b8KValue;                       
00361     stc_qprc_filter_t     stcAinFilter;                   
00362     stc_qprc_filter_t     stcBinFilter;                   
00363     stc_qprc_filter_t     stcCinFilter;                   
00364 
00365 } stc_qprc_config_t;
00366 
00371 typedef struct stc_qprc_intern_data
00372 {
00373     func_ptr_arg1_t  pfnPcUfOfZeroCallback;      
00374     func_ptr_t       pfnPcMatchCallback;         
00375     func_ptr_t       pfnPcRcMatchCallback;       
00376     func_ptr_t       pfnPcMatchRcMatchCallback;  
00377     func_ptr_t       pfnPcCountInvertCallback;   
00378     func_ptr_t       pfnRcOutrangeCallback;      
00379 
00380 } stc_qprc_intern_data_t;
00381 
00386 typedef struct stc_qprc_instance_data
00387 {
00388     volatile stc_qprcn_t*  pstcInstance;       
00389     volatile stc_qprc_nfn_t* pstcInstanceNf;   
00390     stc_qprc_intern_data_t stcInternData;      
00391 } stc_qprc_instance_data_t;
00392 
00393 /******************************************************************************/
00394 /* Global variable definitions ('extern')                                     */
00395 /******************************************************************************/
00396 
00398 extern stc_qprc_instance_data_t m_astcQprcInstanceDataLut[QPRC_INSTANCE_COUNT];
00399 
00400 /******************************************************************************/
00401 /* Global function prototypes (definition in C source)                        */
00402 /******************************************************************************/
00403 /* C binding of definitions if building with C++ compiler */
00404 #ifdef __cplusplus
00405 extern "C"
00406 {
00407 #endif
00408 
00409 /* QPRC init */
00410 en_result_t Qprc_Init( volatile stc_qprcn_t* pstcQprc, stc_qprc_config_t*  pstcConfig );
00411 /* Stop/Restart Pc Count */
00412 en_result_t Qprc_StopPcCount(volatile stc_qprcn_t *pstcQprc);
00413 en_result_t Qprc_RestartPcCount(volatile stc_qprcn_t *pstcQprc);
00414 /* Count write/read */
00415 en_result_t Qprc_SetPcCount ( volatile stc_qprcn_t* pstcQprc, uint16_t u16PcValue ) ;
00416 uint16_t Qprc_GetPcCount ( volatile stc_qprcn_t* pstcQprc );
00417 en_result_t Qprc_SetRcCount ( volatile stc_qprcn_t* pstcQprc, uint16_t u16RcValue );
00418 uint16_t Qprc_GetRcCount ( volatile stc_qprcn_t* pstcQprc );
00419 en_result_t Qprc_SetPcMaxValue( volatile stc_qprcn_t* pstcQprc, uint16_t u16PcMaxValue ) ;
00420 uint16_t Qprc_GetPcMaxValue(volatile stc_qprcn_t *pstcQprc);
00421 en_result_t Qprc_SetPcCompareValue( volatile stc_qprcn_t* pstcQprc, uint16_t u16PcValue ) ;
00422 uint16_t Qprc_GetPcCompareValue( volatile stc_qprcn_t *pstcQprc);
00423 en_result_t Qprc_SetPcRcCompareValue( volatile stc_qprcn_t* pstcQprc, uint16_t u16PcRcValue ) ;
00424 uint16_t Qprc_GetPcRcCompareValue(volatile stc_qprcn_t *pstcQprc);
00425 /* Mode configuration */
00426 en_result_t Qprc_ConfigPcMode( volatile stc_qprcn_t* pstcQprc, en_qprc_pcmode_t enMode );
00427 en_result_t Qprc_ConfigRcMode( volatile stc_qprcn_t* pstcQprc, en_qprc_rcmode_t enMode );
00428 /* Interrupt configuration */
00429 #if (PDL_INTERRUPT_ENABLE_QPRC0 == PDL_ON) || \
00430     (PDL_INTERRUPT_ENABLE_QPRC1 == PDL_ON) || \
00431     (PDL_INTERRUPT_ENABLE_QPRC2 == PDL_ON) || \
00432     (PDL_INTERRUPT_ENABLE_QPRC3 == PDL_ON)
00433 en_result_t Qprc_EnableInt( volatile stc_qprcn_t* pstcQprc, stc_qprc_int_sel_t* pstcIntSel,
00434                             stc_qprc_int_cb_t*  pstcIntCallback );
00435 en_result_t Qprc_DisableInt( volatile stc_qprcn_t* pstcQprc, stc_qprc_int_sel_t* pstcIntSel );
00436 #endif
00437 en_int_flag_t Qprc_GetIntFlag( volatile stc_qprcn_t* pstcQprc, en_qprc_int_t enIntType );
00438 en_result_t Qprc_ClrIntFlag( volatile stc_qprcn_t *pstcQprc, en_qprc_int_t enIntType );
00439 /* status */
00440 en_stat_flag_t Qprc_GetPcOfUfDir( volatile stc_qprcn_t* pstcQprc );
00441 en_stat_flag_t Qprc_GetPcDir( volatile stc_qprcn_t* pstcQprc );
00442 /* IRQ handler */
00443 void Qprc_IrqHandler ( volatile stc_qprcn_t* pstcQprc,
00444                        stc_qprc_intern_data_t* pstcQprcInternData );
00445 #ifdef __cplusplus
00446 }
00447 #endif
00448 
00450 
00451 #endif // #if (defined(PDL_PERIPHERAL_QPRC_ACTIVE))
00452 
00453 #endif /* __QPRC_H__ */
00454 /******************************************************************************/
00455 /* EOF (not truncated)                                                        */
00456 /******************************************************************************/