| PDL for FM0+ Version1.0 Peripheral Driverl Library for FM0+

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

C:/pdl_v10/library/driver/mft/mft_frt.c
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 /******************************************************************************/
    00053 /******************************************************************************/
    00054 /* Include files                                                              */
    00055 /******************************************************************************/
    00056 #include "mft_frt.h"
    00057
    00058 #if (defined(PDL_PERIPHERAL_MFT_FRT_ACTIVE))
    00059
    00065
    00066 /******************************************************************************/
    00067 /* Local pre-processor symbols/macros ('#define')                             */
    00068 /******************************************************************************/
    00069
    00070 /******************************************************************************/
    00071 /* Global variable definitions (declared in header file with 'extern')        */
    00072 /******************************************************************************/
    00074 stc_mft_frt_instance_data_t m_astcMftFrtInstanceDataLut[] =
    00075 {
    00076 #if (PDL_PERIPHERAL_ENABLE_MFT0_FRT == PDL_ON)
    00077     {
    00078         &MFT0_FRT,  // pstcInstance
    00079         {NULL,NULL,NULL,NULL,NULL,NULL}  // stcInternData (not initialized yet)
    00080     },
    00081 #endif
    00082 #if (PDL_PERIPHERAL_ENABLE_MFT1_FRT == PDL_ON)
    00083     {
    00084         &MFT1_FRT,  // pstcInstance
    00085         {NULL,NULL,NULL,NULL,NULL,NULL}  // stcInternData (not initialized yet)
    00086     },
    00087 #endif
    00088 #if (PDL_PERIPHERAL_ENABLE_MFT2_FRT == PDL_ON)
    00089     {
    00090         &MFT2_FRT,  // pstcInstance
    00091         {NULL,NULL,NULL,NULL,NULL,NULL}  // stcInternData (not initialized yet)
    00092     },
    00093 #endif
    00094 };
    00095
    00096 /******************************************************************************/
    00097 /* Local type definitions ('typedef')                                         */
    00098 /******************************************************************************/
    00099 /******************************************************************************/
    00100 /* Local function prototypes ('static')                                       */
    00101 /******************************************************************************/
    00102 /******************************************************************************/
    00103 /* Local variable definitions ('static')                                      */
    00104 /******************************************************************************/
    00105 /******************************************************************************/
    00106 /* Function implementation - global ('extern') and local ('static')           */
    00107 /******************************************************************************/
    00118 static stc_mft_frt_intern_data_t* MftGetInternDataPtr(volatile stc_mftn_frt_t* pstcFrt)
    00119 {
    00120     uint8_t u8Instance;
    00121
    00122     for (u8Instance = 0; u8Instance < FRT_INSTANCE_COUNT; u8Instance++)
    00123     {
    00124         if (pstcFrt == m_astcMftFrtInstanceDataLut[u8Instance].pstcInstance)
    00125         {
    00126             return &m_astcMftFrtInstanceDataLut[u8Instance].stcInternData;
    00127         }
    00128     }
    00129
    00130     return NULL;
    00131 }
    00132
    00133 #if (PDL_INTERRUPT_ENABLE_MFT0_FRT == PDL_ON) || \
    00134     (PDL_INTERRUPT_ENABLE_MFT1_FRT == PDL_ON) || \
    00135     (PDL_INTERRUPT_ENABLE_MFT2_FRT == PDL_ON)
    00136
    00145 void Mft_Frt_IrqHandler( volatile stc_mftn_frt_t* pstcFrt,
    00146                          stc_mft_frt_intern_data_t* pstcMftFrtInternData)
    00147 {
    00148     static func_ptr_t funCallBack;
    00149     static uint32_t* ptemp;
    00150     uint8_t ch;
    00151
    00152     /* Peak match Interrupt */
    00153     for(ch=0;ch<3;ch++)
    00154     {
    00155         if(PdlSet == Mft_Frt_GetIntFlag(pstcFrt,ch,enFrtPeakMatchInt))
    00156         {
    00157             /* Clear Interrupt */
    00158             Mft_Frt_ClrIntFlag(pstcFrt,ch,enFrtPeakMatchInt);
    00159
    00160             //get peak match callback address of each channel
    00161             ptemp = (uint32_t*)&(pstcMftFrtInternData->pfnFrt0PeakCallback);
    00162             funCallBack = (func_ptr_t)(*(ptemp + ch));
    00163
    00164             if(funCallBack != NULL)
    00165             {
    00166                funCallBack();
    00167             }
    00168         }
    00169     }
    00170
    00171     /* Zero match Interrupt */
    00172     for(ch=0;ch<3;ch++)
    00173     {
    00174         if(PdlSet == Mft_Frt_GetIntFlag(pstcFrt,ch,enFrtZeroMatchInt))
    00175         {
    00176             /* Clear Interrupt */
    00177             Mft_Frt_ClrIntFlag(pstcFrt,ch,enFrtZeroMatchInt);
    00178
    00179             //get Zero match callback address of each channel
    00180             ptemp = (uint32_t*)&(pstcMftFrtInternData->pfnFrt0ZeroCallback);
    00181             funCallBack = (func_ptr_t)(*(ptemp +  ch));
    00182
    00183             if(funCallBack != NULL)
    00184             {
    00185                funCallBack();
    00186             }
    00187         }
    00188     }
    00189
    00190 }
    00191
    00200 static void Mft_Frt_InitIrq( volatile stc_mftn_frt_t* pstcFrt,
    00201                              stc_frt_int_sel_t* pstcIntSel )
    00202 {
    00203     if ((pstcFrt == (volatile stc_mftn_frt_t*)(&MFT0_FRT)) ||
    00204         (pstcFrt == (volatile stc_mftn_frt_t*)(&MFT1_FRT)) ||
    00205         (pstcFrt == (volatile stc_mftn_frt_t*)(&MFT2_FRT)))
    00206     {
    00207         if((pstcIntSel->bFrtZeroMatchInt == 1) ||
    00208            (pstcIntSel->bFrtPeakMatchInt == 1))
    00209         {
    00210             NVIC_ClearPendingIRQ(FRTIM_IRQn);
    00211             NVIC_EnableIRQ(FRTIM_IRQn);
    00212             NVIC_SetPriority(FRTIM_IRQn, PDL_IRQ_LEVEL_MFT_FRT);
    00213         }
    00214     }
    00215
    00216     return;
    00217 }
    00218
    00219
    00228 static void Mft_Frt_DeInitIrq( volatile stc_mftn_frt_t* pstcFrt,
    00229                                stc_frt_int_sel_t* pstcIntSel )
    00230 {
    00231     if ((pstcFrt == (volatile stc_mftn_frt_t*)(&MFT0_FRT)) ||
    00232         (pstcFrt == (volatile stc_mftn_frt_t*)(&MFT1_FRT)) ||
    00233         (pstcFrt == (volatile stc_mftn_frt_t*)(&MFT2_FRT)))
    00234     {
    00235         if((pstcIntSel->bFrtZeroMatchInt == 1) || (pstcIntSel->bFrtPeakMatchInt == 1))
    00236         {
    00237             if(pstcFrt->TCSA0_f.IRQZE == 1)
    00238             {
    00239                 return;
    00240             }
    00241
    00242             if(pstcFrt->TCSA0_f.ICRE == 1)
    00243             {
    00244                 return;
    00245             }
    00246             if(pstcFrt->TCSA1_f.IRQZE == 1)
    00247             {
    00248                 return;
    00249             }
    00250
    00251             if(pstcFrt->TCSA1_f.ICRE == 1)
    00252             {
    00253                 return;
    00254             }
    00255             if(pstcFrt->TCSA2_f.IRQZE == 1)
    00256             {
    00257                 return;
    00258             }
    00259
    00260             if(pstcFrt->TCSA2_f.ICRE == 1)
    00261             {
    00262                 return;
    00263             }
    00264
    00265             NVIC_ClearPendingIRQ(FRTIM_IRQn);
    00266             NVIC_DisableIRQ(FRTIM_IRQn);
    00267             NVIC_SetPriority(FRTIM_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
    00268
    00269         }
    00270     }
    00271
    00272     return;
    00273 }
    00274
    00275 #endif
    00276
    00277 /******************************************************************************/
    00278 /* Local Functions                                                            */
    00279 /******************************************************************************/
    00280
    00298 en_result_t Mft_Frt_Init(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch,
    00299                          stc_mft_frt_config_t*  pstcFrtConfig)
    00300 {
    00301     // Pointer to internal data
    00302     stc_mft_frt_intern_data_t* pstcFrtInternData ;
    00303     volatile stc_mft_frt_tcsa0_field_t* pstcTCSA;
    00304
    00305     // Check for NULL pointer and configuration parameter
    00306     if ((pstcFrt == NULL) ||
    00307         (pstcFrtConfig == NULL) ||
    00308         (u8Ch >= MFT_FRT_MAX_CH) ||
    00309         (pstcFrtConfig->enFrtMode > FrtUpDownCount) ||
    00310         (pstcFrtConfig->enFrtClockDiv > FrtPclkDiv1024) ||
    00311         (pstcFrtConfig->bEnBuffer > 1) ||
    00312         (pstcFrtConfig->bEnExtClock > 1) )
    00313     {
    00314         return ErrorInvalidParameter ;
    00315     }
    00316
    00317     // Get pointer to internal data structure ...
    00318     pstcFrtInternData = MftGetInternDataPtr( pstcFrt ) ;
    00319     // ... and check for NULL
    00320     if ( pstcFrtInternData != NULL )
    00321     {
    00322         pstcFrtInternData->pfnFrt0PeakCallback = NULL;
    00323         pstcFrtInternData->pfnFrt0ZeroCallback = NULL;
    00324         pstcFrtInternData->pfnFrt1PeakCallback = NULL;
    00325         pstcFrtInternData->pfnFrt1ZeroCallback = NULL;
    00326         pstcFrtInternData->pfnFrt2PeakCallback = NULL;
    00327         pstcFrtInternData->pfnFrt2ZeroCallback = NULL;
    00328     }
    00329
    00330     //Get pointer of current channel frt register address
    00331     pstcTCSA = (volatile stc_mft_frt_tcsa0_field_t*)((volatile uint8_t*)&pstcFrt->TCSA0 + u8Ch*0x0Cu);
    00332
    00333     //set count clock cycle of FRT counter
    00334     pstcTCSA->CLK = (uint8_t)pstcFrtConfig->enFrtClockDiv;
    00335
    00336     //set frt mode
    00337     pstcTCSA->MODE = pstcFrtConfig->enFrtMode;
    00338
    00339     //set buffer enable bit
    00340     pstcTCSA->BFE = pstcFrtConfig->bEnBuffer;
    00341
    00342     //set external clock enable bit
    00343     pstcTCSA->ECKE = pstcFrtConfig->bEnExtClock;
    00344
    00345     return Ok;
    00346 }
    00365 en_result_t Mft_Frt_SetMaskZeroTimes(volatile stc_mftn_frt_t* pstcFrt,
    00366                                      uint8_t u8Ch, uint8_t u8Times)
    00367 {
    00368       volatile uint16_t* pu16TCSC;
    00369
    00370       // Check for NULL pointer
    00371       if ( (pstcFrt == NULL) ||
    00372            (u8Ch >= MFT_FRT_MAX_CH) ||
    00373            (u8Times > 15) )
    00374       {
    00375           return ErrorInvalidParameter ;
    00376       }
    00377
    00378       //Get pointer of current channel frt register address
    00379       pu16TCSC=(volatile uint16_t*)((volatile uint8_t*)pstcFrt+0x4AUL+u8Ch*0x0C);
    00380
    00381       *pu16TCSC &= 0xFFF0u;
    00382       *pu16TCSC |= u8Times;
    00383
    00384       return Ok;
    00385 }
    00386
    00399 uint8_t Mft_Frt_GetMaskZeroTimes(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch)
    00400 {
    00401     volatile uint16_t* pu16TCSC;
    00402     uint8_t u8Times;
    00403
    00404     // Check for NULL pointer
    00405     if ( (pstcFrt == NULL)
    00406          || (u8Ch >= MFT_FRT_MAX_CH))
    00407     {
    00408         return 0 ;
    00409     }
    00410
    00411     //Get pointer of current channel frt register address
    00412     pu16TCSC=(volatile uint16_t*)((volatile uint8_t*)pstcFrt+0x4AUL+u8Ch*0x0C);
    00413
    00414     u8Times = (*pu16TCSC & 0x0F00u) >> 8;
    00415
    00416     return u8Times;
    00417 }
    00436 en_result_t Mft_Frt_SetMaskPeakTimes(volatile stc_mftn_frt_t* pstcFrt,
    00437                                      uint8_t u8Ch, uint8_t u8Times)
    00438 {
    00439     volatile uint16_t* pu16TCSC;
    00440
    00441     // Check for NULL pointer
    00442       if ( (pstcFrt == NULL) ||
    00443            (u8Ch >= MFT_FRT_MAX_CH) ||
    00444            (u8Times > 15) )
    00445       {
    00446           return ErrorInvalidParameter ;
    00447       }
    00448
    00449     //Get pointer of current channel frt register address
    00450     pu16TCSC=(volatile uint16_t*)((volatile uint8_t*)pstcFrt+0x4AUL+u8Ch*0x0C);
    00451
    00452     *pu16TCSC &= 0x00F0u;
    00453     *pu16TCSC |= (uint16_t)((uint16_t)u8Times<<4u);
    00454
    00455     return Ok;
    00456 }
    00457
    00470 uint8_t Mft_Frt_GetMaskPeakTimes(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch)
    00471 {
    00472     volatile uint16_t* pu16TCSC;
    00473     uint8_t u8Times;
    00474
    00475     // Check for NULL pointer
    00476     if ( (pstcFrt == NULL)
    00477          || (u8Ch >= MFT_FRT_MAX_CH))
    00478     {
    00479         return 0 ;
    00480     }
    00481
    00482     //Get pointer of current channel frt register address
    00483     pu16TCSC=(volatile uint16_t*)((volatile uint8_t*)pstcFrt+0x4AUL+u8Ch*0x0C);
    00484
    00485     u8Times = (*pu16TCSC & 0xF000u) >> 12;
    00486
    00487     return u8Times;
    00488 }
    00489
    00506 en_result_t Mft_Frt_Start(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch)
    00507 {
    00508     volatile stc_mft_frt_tcsa0_field_t* pstcTCSA;
    00509
    00510     // Check for NULL pointer
    00511     if ( (pstcFrt == NULL)
    00512          || (u8Ch >= MFT_FRT_MAX_CH))
    00513     {
    00514         return ErrorInvalidParameter ;
    00515     }
    00516
    00517     //Get pointer of current channel frt register address
    00518     pstcTCSA = (volatile stc_mft_frt_tcsa0_field_t*)((volatile uint8_t*)pstcFrt+0x48UL+u8Ch*0x0C);
    00519     pstcTCSA->STOP = 0;
    00520     pstcTCSA->SCLR = 0;
    00521     return Ok;
    00522 }
    00523
    00540 en_result_t Mft_Frt_Stop(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch)
    00541 {
    00542     volatile stc_mft_frt_tcsa0_field_t* pstcTCSA;
    00543
    00544     // Check for NULL pointer
    00545     if ( (pstcFrt == NULL)
    00546          || (u8Ch >= MFT_FRT_MAX_CH))
    00547     {
    00548         return ErrorInvalidParameter ;
    00549     }
    00550
    00551     //Get pointer of current channel frt register address
    00552     pstcTCSA = (volatile stc_mft_frt_tcsa0_field_t*)((volatile uint8_t*)pstcFrt+0x48UL+u8Ch*0x0C);
    00553
    00554     pstcTCSA->STOP = 1;
    00555     pstcTCSA->SCLR = 1;
    00556     return Ok;
    00557 }
    00558
    00559 #if (PDL_INTERRUPT_ENABLE_MFT0_FRT == PDL_ON) || \
    00560     (PDL_INTERRUPT_ENABLE_MFT1_FRT == PDL_ON) || \
    00561     (PDL_INTERRUPT_ENABLE_MFT2_FRT == PDL_ON)
    00562
    00582 en_result_t Mft_Frt_EnableInt(volatile stc_mftn_frt_t* pstcFrt,
    00583                               uint8_t u8Ch,
    00584                               stc_frt_int_sel_t* pstcIntSel,
    00585                               stc_frt_int_cb_t* pstcFrtIntCallback)
    00586 {
    00587      volatile stc_mft_frt_tcsa0_field_t* pstcTCSA;
    00588      stc_mft_frt_intern_data_t* pstcFrtInternData ;
    00589
    00590     // Check for NULL pointer
    00591     if ( (pstcFrt == NULL)
    00592          || (u8Ch >= MFT_FRT_MAX_CH)
    00593          || (pstcIntSel->bFrtPeakMatchInt > 1)
    00594          || (pstcIntSel->bFrtZeroMatchInt > 1) )
    00595     {
    00596         return ErrorInvalidParameter ;
    00597     }
    00598
    00599     // Get pointer to internal data structure ...
    00600     pstcFrtInternData = MftGetInternDataPtr( pstcFrt ) ;
    00601
    00602     //Get pointer of current channel frt register address
    00603     pstcTCSA = (volatile stc_mft_frt_tcsa0_field_t*)((volatile uint8_t*)pstcFrt+0x48UL+u8Ch*0x0C);
    00604
    00605     if(pstcIntSel->bFrtZeroMatchInt == 1) //zero detect interrupt
    00606     {
    00607         pstcTCSA->IRQZE = 1;
    00608     }
    00609     if(pstcIntSel->bFrtPeakMatchInt == 1) //peak detect interrupt
    00610     {
    00611         pstcTCSA->ICRE = 1;
    00612     }
    00613
    00614     //set callback function
    00615     switch(u8Ch)
    00616     {
    00617         case MFT_FRT_CH0: //channel 0
    00618             if(pstcIntSel->bFrtZeroMatchInt == 1) //zero detect interrupt
    00619             {
    00620                 pstcFrtInternData->pfnFrt0ZeroCallback = pstcFrtIntCallback->pfnFrtZeroCallback;
    00621             }
    00622             if(pstcIntSel->bFrtPeakMatchInt == 1) //peak detect interrupt
    00623             {
    00624                 pstcFrtInternData->pfnFrt0PeakCallback = pstcFrtIntCallback->pfnFrtPeakCallback;
    00625             }
    00626             break;
    00627
    00628         case MFT_FRT_CH1: //channel 1
    00629             if(pstcIntSel->bFrtZeroMatchInt == 1) //zero detect interrupt
    00630             {
    00631                 pstcFrtInternData->pfnFrt1ZeroCallback = pstcFrtIntCallback->pfnFrtZeroCallback;
    00632             }
    00633             if(pstcIntSel->bFrtPeakMatchInt == 1)  //peak detect interrupt
    00634             {
    00635                 pstcFrtInternData->pfnFrt1PeakCallback = pstcFrtIntCallback->pfnFrtPeakCallback;
    00636             }
    00637             break;
    00638         case MFT_FRT_CH2: //channel 2
    00639             if(pstcIntSel->bFrtZeroMatchInt == 1)  //zero detect interrupt
    00640             {
    00641                 pstcFrtInternData->pfnFrt2ZeroCallback = pstcFrtIntCallback->pfnFrtZeroCallback;
    00642             }
    00643             if(pstcIntSel->bFrtPeakMatchInt == 1)  //peak detect interrupt
    00644             {
    00645                 pstcFrtInternData->pfnFrt2PeakCallback = pstcFrtIntCallback->pfnFrtPeakCallback;
    00646             }
    00647             break;
    00648         default :
    00649             return ErrorInvalidParameter;
    00650     }
    00651     Mft_Frt_InitIrq(pstcFrt,pstcIntSel);
    00652
    00653     return Ok;
    00654 }
    00655
    00674 en_result_t Mft_Frt_DisableInt(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch,
    00675                                stc_frt_int_sel_t* pstcIntSel)
    00676 {
    00677     volatile stc_mft_frt_tcsa0_field_t* pstcTCSA;
    00678
    00679     // Check for NULL pointer
    00680     if ( (pstcFrt == NULL)
    00681          || (u8Ch >= MFT_FRT_MAX_CH)
    00682          || (pstcIntSel->bFrtPeakMatchInt > 1)
    00683          || (pstcIntSel->bFrtZeroMatchInt > 1))
    00684     {
    00685         return ErrorInvalidParameter ;
    00686     }
    00687
    00688     //Get pointer of current channel frt register address
    00689     pstcTCSA = (volatile stc_mft_frt_tcsa0_field_t*)((volatile uint8_t*)pstcFrt+0x48UL+u8Ch*0x0C);
    00690
    00691     if(pstcIntSel->bFrtZeroMatchInt == 1) //zero detect interrupt
    00692     {
    00693         pstcTCSA->IRQZE = 0;
    00694     }
    00695     if(pstcIntSel->bFrtPeakMatchInt == 1) //peak detect interrupt
    00696     {
    00697         pstcTCSA->ICRE = 0;
    00698     }
    00699     Mft_Frt_DeInitIrq(pstcFrt, pstcIntSel);
    00700     return Ok;
    00701 }
    00702
    00703 #endif
    00704
    00725 en_int_flag_t Mft_Frt_GetIntFlag(volatile stc_mftn_frt_t* pstcFrt,
    00726                                  uint8_t u8Ch,
    00727                                  en_mft_frt_int_t enIntType)
    00728 {
    00729     volatile stc_mft_frt_tcsa0_field_t* pstcTCSA;
    00730     en_int_flag_t retval;
    00731
    00732     //Get pointer of current channel frt register address
    00733     pstcTCSA = (volatile stc_mft_frt_tcsa0_field_t*)((volatile uint8_t*)pstcFrt+0x48UL+u8Ch*0x0C);
    00734
    00735     if(enFrtZeroMatchInt == enIntType) //zero detect interrupt
    00736     {
    00737         (pstcTCSA->IRQZF == 1) ? (retval = PdlSet) : (retval = PdlClr);
    00738     }
    00739     else //peak detect interrupt
    00740     {
    00741         (pstcTCSA->ICLR == 1) ? (retval = PdlSet) : (retval = PdlClr);
    00742     }
    00743
    00744     return retval;
    00745 }
    00746
    00766 en_result_t Mft_Frt_ClrIntFlag(volatile stc_mftn_frt_t* pstcFrt,
    00767                                uint8_t u8Ch,
    00768                                en_mft_frt_int_t enIntType)
    00769 {
    00770     volatile stc_mft_frt_tcsa0_field_t* pstcTCSA;
    00771
    00772     // Check for NULL pointer
    00773     if ( (pstcFrt == NULL)
    00774          || (u8Ch >= MFT_FRT_MAX_CH))
    00775     {
    00776         return ErrorInvalidParameter ;
    00777     }
    00778
    00779     //Get pointer of current channel frt register address
    00780     pstcTCSA = (volatile stc_mft_frt_tcsa0_field_t*)((volatile uint8_t*)pstcFrt+0x48UL+u8Ch*0x0C);
    00781
    00782     if(enFrtZeroMatchInt == enIntType) //zero detect interrupt
    00783     {
    00784         pstcTCSA->IRQZF = 0;
    00785     }
    00786     else //peak detect interrupt
    00787     {
    00788         pstcTCSA->ICLR = 0;
    00789     }
    00790
    00791     return Ok;
    00792 }
    00793
    00812 en_result_t Mft_Frt_SetCountCycle(volatile stc_mftn_frt_t* pstcFrt,
    00813                                   uint8_t u8Ch, uint16_t u16Cycle)
    00814 {
    00815     volatile uint16_t* pu16TCCP;
    00816
    00817     // Check for NULL pointer
    00818     if ( (pstcFrt == NULL)
    00819          || (u8Ch >= MFT_FRT_MAX_CH))
    00820     {
    00821         return ErrorInvalidParameter ;
    00822     }
    00823
    00824     //Get pointer of current channel frt register address
    00825     pu16TCCP = (volatile uint16_t*)( (volatile uint8_t*)pstcFrt + 0x42UL + u8Ch*0x0C);
    00826
    00827     *pu16TCCP = u16Cycle;
    00828
    00829     return Ok;
    00830 }
    00831
    00850 en_result_t Mft_Frt_SetCountVal(volatile stc_mftn_frt_t* pstcFrt,
    00851                                 uint8_t u8Ch,uint16_t u16Count)
    00852 {
    00853     volatile uint16_t* pu16TCDT;
    00854
    00855     // Check for NULL pointer
    00856     if ( (pstcFrt == NULL)
    00857          || (u8Ch >= MFT_FRT_MAX_CH))
    00858     {
    00859         return ErrorInvalidParameter ;
    00860     }
    00861
    00862     //Get pointer of current channel frt register address
    00863     pu16TCDT = (volatile uint16_t*)( (volatile uint8_t*)pstcFrt + 0x46UL + u8Ch*0x0C);
    00864
    00865     *pu16TCDT = u16Count;
    00866
    00867     return Ok;
    00868 }
    00869
    00882 uint16_t Mft_Frt_GetCurCount(volatile stc_mftn_frt_t* pstcFrt, uint8_t u8Ch)
    00883 {
    00884     uint16_t retTCDT;
    00885     volatile  uint16_t* pstcTCDT;
    00886
    00887     // Check for NULL pointer
    00888     if ( (pstcFrt == NULL)
    00889          || (u8Ch >= MFT_FRT_MAX_CH))
    00890     {
    00891         return ErrorInvalidParameter ;
    00892     }
    00893
    00894     //Get pointer of current channel frt register address
    00895     pstcTCDT = (volatile uint16_t*)( (volatile uint8_t*)pstcFrt + 0x46UL + u8Ch*0x0C);
    00896
    00897     retTCDT = *pstcTCDT;
    00898
    00899     return retTCDT;
    00900 }
    00901
    00903
    00904 #endif // #if (defined(PDL_PERIPHERAL_$$X_ACTIVE))
    00905
    00906 /******************************************************************************/
    00907 /* EOF (not truncated)                                                        */
    00908 /******************************************************************************/