| 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_icu.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 /******************************************************************************/
    00055 /******************************************************************************/
    00056 /* Include files                                                              */
    00057 /******************************************************************************/
    00058 #include "mft_icu.h"
    00059
    00060 #if (defined(PDL_PERIPHERAL_MFT_ICU_ACTIVE))
    00061
    00067 /******************************************************************************/
    00068 /* Local pre-processor symbols/macros ('#define')                             */
    00069 /******************************************************************************/
    00070
    00071 /******************************************************************************/
    00072 /* Global variable definitions (declared in header file with 'extern')        */
    00073 /******************************************************************************/
    00074 stc_mft_icu_instance_data_t m_astcMftIcuInstanceDataLut[MFT_ICU_INSTANCE_COUNT] =
    00075 {
    00076 #if (PDL_PERIPHERAL_ENABLE_MFT0_ICU == PDL_ON)
    00077     {
    00078         &MFT0_ICU,    // pstcInstance
    00079         {NULL,NULL,NULL,NULL}          // stcInternData (not initialized yet)
    00080     },
    00081 #endif
    00082 #if (PDL_PERIPHERAL_ENABLE_MFT1_ICU == PDL_ON)
    00083     {
    00084         &MFT1_ICU,    // pstcInstance
    00085         {NULL,NULL,NULL,NULL}          // stcInternData (not initialized yet)
    00086     },
    00087 #endif
    00088 #if (PDL_PERIPHERAL_ENABLE_MFT2_ICU == PDL_ON)
    00089     {
    00090         &MFT2_ICU,    // pstcInstance
    00091         {NULL,NULL,NULL,NULL}          // stcInternData (not initialized yet)
    00092     },
    00093 #endif
    00094 };
    00095
    00096 /******************************************************************************/
    00097 /* Local type definitions ('typedef')                                         */
    00098 /******************************************************************************/
    00099
    00100 /******************************************************************************/
    00101 /* Local function prototypes ('static')                                       */
    00102 /******************************************************************************/
    00103 #if (PDL_INTERRUPT_ENABLE_MFT0_ICU == PDL_ON) || \
    00104     (PDL_INTERRUPT_ENABLE_MFT1_ICU == PDL_ON) || \
    00105     (PDL_INTERRUPT_ENABLE_MFT2_ICU == PDL_ON)
    00106 static stc_mft_icu_intern_data_t* MftIcuGetInternDataPtr(volatile stc_mftn_icu_t *pstcMftIcu);
    00107 static void Mft_Icu_InitIrq( volatile stc_mftn_icu_t* pstcMftIcu );
    00108 static void Mft_Icu_DeInitIrq( volatile stc_mftn_icu_t* pstcMftIcu );
    00109 #endif
    00110 /******************************************************************************/
    00111 /* Local variable definitions ('static')                                      */
    00112 /******************************************************************************/
    00113
    00114 /******************************************************************************/
    00115 /* Function implementation - global ('extern') and local ('static')           */
    00116 /******************************************************************************/
    00117
    00118 #if (PDL_INTERRUPT_ENABLE_MFT0_ICU == PDL_ON) || \
    00119     (PDL_INTERRUPT_ENABLE_MFT1_ICU == PDL_ON) || \
    00120     (PDL_INTERRUPT_ENABLE_MFT2_ICU == PDL_ON)
    00121
    00130 static stc_mft_icu_intern_data_t* MftIcuGetInternDataPtr(volatile stc_mftn_icu_t *pstcMftIcu)
    00131 {
    00132     uint8_t u8Instance;
    00133
    00134     for (u8Instance = 0u; u8Instance < MFT_ICU_INSTANCE_COUNT; u8Instance++)
    00135     {
    00136         if (pstcMftIcu == m_astcMftIcuInstanceDataLut[u8Instance].pstcInstance)
    00137         {
    00138             return &m_astcMftIcuInstanceDataLut[u8Instance].stcInternData;
    00139         }
    00140     }
    00141
    00142     return NULL;
    00143 }
    00144
    00154 void Mft_Icu_IrqHandler( volatile stc_mftn_icu_t* pstcMftIcu,
    00155                          stc_mft_icu_intern_data_t* pstcMftIcuInternData)
    00156 {
    00157     // ICU interrupt 0
    00158     if(TRUE == pstcMftIcu->ICSA10_f.ICP0)
    00159     {
    00160         pstcMftIcu->ICSA10_f.ICP0 = 0u;
    00161         if (pstcMftIcuInternData->pfnIcu0Callback != NULL)
    00162         {
    00163              pstcMftIcuInternData->pfnIcu0Callback();
    00164         }
    00165     }
    00166     // ICU interrupt 1
    00167     if(TRUE == pstcMftIcu->ICSA10_f.ICP1)
    00168     {
    00169         pstcMftIcu->ICSA10_f.ICP1 = 0u;
    00170         if (pstcMftIcuInternData->pfnIcu1Callback != NULL)
    00171         {
    00172              pstcMftIcuInternData->pfnIcu1Callback();
    00173         }
    00174     }
    00175     // ICU interrupt 2
    00176     if(TRUE == pstcMftIcu->ICSA32_f.ICP0)
    00177     {
    00178         pstcMftIcu->ICSA32_f.ICP0 = 0u;
    00179         if (pstcMftIcuInternData->pfnIcu2Callback != NULL)
    00180         {
    00181              pstcMftIcuInternData->pfnIcu2Callback();
    00182         }
    00183     }
    00184     // ICU interrupt 3
    00185     if(TRUE == pstcMftIcu->ICSA32_f.ICP1)
    00186     {
    00187         pstcMftIcu->ICSA32_f.ICP1 = 0u;
    00188         if (pstcMftIcuInternData->pfnIcu3Callback != NULL)
    00189         {
    00190              pstcMftIcuInternData->pfnIcu3Callback();
    00191         }
    00192     }
    00193 }
    00194
    00202 static void Mft_Icu_InitIrq( volatile stc_mftn_icu_t* pstcMftIcu )
    00203 {
    00204     if ((pstcMftIcu == (volatile stc_mftn_icu_t*)(&MFT0_ICU)) ||
    00205         (pstcMftIcu == (volatile stc_mftn_icu_t*)(&MFT1_ICU)) ||
    00206         (pstcMftIcu == (volatile stc_mftn_icu_t*)(&MFT2_ICU)))
    00207     {
    00208         NVIC_ClearPendingIRQ(INCAP_IRQn);
    00209         NVIC_EnableIRQ(INCAP_IRQn);
    00210         NVIC_SetPriority(INCAP_IRQn, PDL_IRQ_LEVEL_MFT_ICU);
    00211     }
    00212     return;
    00213 }
    00214
    00221 static void Mft_Icu_DeInitIrq( volatile stc_mftn_icu_t* pstcMftIcu )
    00222 {
    00223     if ((pstcMftIcu == (volatile stc_mftn_icu_t*)(&MFT0_ICU)) ||
    00224         (pstcMftIcu == (volatile stc_mftn_icu_t*)(&MFT1_ICU)) ||
    00225         (pstcMftIcu == (volatile stc_mftn_icu_t*)(&MFT2_ICU)))
    00226     {
    00227         if(pstcMftIcu->ICSA10_f.ICE0 == 1u)
    00228         {
    00229             return;
    00230         }
    00231         if(pstcMftIcu->ICSA10_f.ICE1 == 1u)
    00232         {
    00233             return;
    00234         }
    00235         if(pstcMftIcu->ICSA32_f.ICE0 == 1u)
    00236         {
    00237             return;
    00238         }
    00239         if(pstcMftIcu->ICSA32_f.ICE1 == 0u)
    00240         {
    00241             return;
    00242         }
    00243         NVIC_ClearPendingIRQ(INCAP_IRQn);
    00244         NVIC_DisableIRQ(INCAP_IRQn);
    00245         NVIC_SetPriority(INCAP_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
    00246     }
    00247
    00248     return;
    00249 }
    00250
    00251 #endif
    00252
    00272 en_result_t Mft_Icu_SelFrt( volatile stc_mftn_icu_t* pstcMftIcu, uint8_t u8Ch,
    00273                             en_mft_icu_frt_t enFrt)
    00274 {
    00275     volatile stc_mft_icu_icfs10_field_t* stcICFS10;
    00276     volatile stc_mft_icu_icfs32_field_t* stcICFS32;
    00277
    00278     // Check for NULL pointer and channel parameter
    00279     boolean_t bAvoidSideEffects  = ((NULL == pstcMftIcu) ? 1u : 0u);
    00280               bAvoidSideEffects |= ((u8Ch > MFT_ICU_CHx_MAX) ? 1u : 0u);
    00281     if (TRUE == bAvoidSideEffects)
    00282     {
    00283         return ErrorInvalidParameter ;
    00284     }
    00285
    00286     // Get actual address of register list of current channel
    00287     stcICFS10 = (volatile stc_mft_icu_icfs10_field_t*)(&(pstcMftIcu->ICFS10));
    00288     stcICFS32 = (volatile stc_mft_icu_icfs32_field_t*)(&(pstcMftIcu->ICFS32));
    00289
    00290     // FRT channel select: FRTx -> ICUx
    00291     if(enFrt > IcuFrtToExt1)
    00292     {
    00293         return ErrorInvalidParameter;
    00294     }
    00295     // configure the Frt channel to connect to Icu
    00296     switch(u8Ch)
    00297     {
    00298         // ICU channel 0
    00299         case MFT_ICU_CH0:
    00300             stcICFS10->FSI0 = (uint8_t)enFrt;
    00301             break;
    00302         // ICU channel 1
    00303         case MFT_ICU_CH1:
    00304             stcICFS10->FSI1 = (uint8_t)enFrt;
    00305             break;
    00306         // ICU channel 2
    00307         case MFT_ICU_CH2:
    00308             stcICFS32->FSI0 = (uint8_t)enFrt;
    00309             break;
    00310         // ICU channel 3
    00311         case MFT_ICU_CH3:
    00312             stcICFS32->FSI1 = (uint8_t)enFrt;
    00313             break;
    00314         default:
    00315             return ErrorInvalidParameter;
    00316     }
    00317
    00318     return Ok;
    00319 }
    00320
    00340 en_result_t Mft_Icu_ConfigDetectMode( volatile stc_mftn_icu_t* pstcMftIcu, uint8_t u8Ch,
    00341                                       en_mft_icu_mode_t enMode)
    00342 {
    00343     // Check for NULL pointer and channel parameter
    00344     boolean_t bAvoidSideEffects  = ((NULL == pstcMftIcu) ? 1u : 0u);
    00345     bAvoidSideEffects |= ((u8Ch > MFT_ICU_CHx_MAX) ? 1u : 0u);
    00346     if (bAvoidSideEffects)
    00347     {
    00348         return ErrorInvalidParameter ;
    00349     }
    00350
    00351     // Check configuration of Mft Icu mode
    00352     if(enMode > IcuBothDetect)
    00353     {
    00354         return ErrorInvalidParameter;
    00355     }
    00356     // Configure Icu detection mode
    00357     switch (u8Ch)
    00358     {
    00359         // ICU channel 0
    00360         case MFT_ICU_CH0:
    00361             pstcMftIcu->ICSA10_f.EG0 = (uint8_t)enMode;
    00362             break;
    00363         // ICU channel 1
    00364         case MFT_ICU_CH1:
    00365             pstcMftIcu->ICSA10_f.EG1 = (uint8_t)enMode;
    00366             break;
    00367         // ICU channel 2
    00368         case MFT_ICU_CH2:
    00369             pstcMftIcu->ICSA32_f.EG0 = (uint8_t)enMode;
    00370             break;
    00371         // ICU channel 3
    00372         case MFT_ICU_CH3:
    00373             pstcMftIcu->ICSA32_f.EG1 = (uint8_t)enMode;
    00374             break;
    00375         // ICU channel number error
    00376         default:
    00377             return ErrorInvalidParameter;
    00378     }
    00379     return Ok;
    00380 }
    00381
    00382 #if (PDL_INTERRUPT_ENABLE_MFT0_ICU == PDL_ON) || \
    00383     (PDL_INTERRUPT_ENABLE_MFT1_ICU == PDL_ON) || \
    00384     (PDL_INTERRUPT_ENABLE_MFT2_ICU == PDL_ON)
    00385
    00401 en_result_t Mft_Icu_EnableInt( volatile stc_mftn_icu_t*pstcMftIcu, uint8_t u8Ch,
    00402                                func_ptr_t pfnCallback)
    00403 {
    00404     // Pointer to internal data
    00405     stc_mft_icu_intern_data_t* pstcMftIcuInternData ;
    00406     volatile stc_mftn_icu_t* pstcOrgMftIcu = pstcMftIcu;
    00407
    00408     // Check for NULL pointer and channel parameter
    00409     boolean_t bAvoidSideEffects  = ((NULL == pstcMftIcu) ? 1u : 0u);
    00410     bAvoidSideEffects |= ((u8Ch > MFT_ICU_CHx_MAX) ? 1u : 0u);
    00411     bAvoidSideEffects |= ((NULL == pfnCallback) ? 1u : 0u);
    00412     if (bAvoidSideEffects)
    00413     {
    00414         return ErrorInvalidParameter ;
    00415     }
    00416
    00417     // Get pointer to internal data structure
    00418     pstcMftIcuInternData = MftIcuGetInternDataPtr( pstcOrgMftIcu );
    00419
    00420     switch (u8Ch)
    00421     {
    00422         // ICU channel 0
    00423         case MFT_ICU_CH0:
    00424             pstcMftIcuInternData->pfnIcu0Callback = pfnCallback;
    00425             pstcMftIcu->ICSA10_f.ICE0 = 1u;
    00426             break;
    00427         // ICU channel 1
    00428         case MFT_ICU_CH1:
    00429             pstcMftIcuInternData->pfnIcu1Callback = pfnCallback;
    00430             pstcMftIcu->ICSA10_f.ICE1 = 1u;
    00431             break;
    00432         // ICU channel 2
    00433         case MFT_ICU_CH2:
    00434             pstcMftIcuInternData->pfnIcu2Callback = pfnCallback;
    00435             pstcMftIcu->ICSA32_f.ICE0 = 1u;
    00436             break;
    00437         // ICU channel 3
    00438         case MFT_ICU_CH3:
    00439             pstcMftIcuInternData->pfnIcu3Callback = pfnCallback;
    00440             pstcMftIcu->ICSA32_f.ICE1 = 1u;
    00441             break;
    00442         // ICU channel number error
    00443         default:
    00444             return ErrorInvalidParameter;
    00445     }
    00446
    00447     // initialize interrupt
    00448     Mft_Icu_InitIrq(pstcOrgMftIcu);
    00449     return Ok;
    00450 }
    00451
    00467 en_result_t Mft_Icu_DisableInt( volatile stc_mftn_icu_t*pstcMftIcu, uint8_t u8Ch)
    00468 {
    00469     // Pointer to internal data
    00470     stc_mft_icu_intern_data_t* pstcMftIcuInternData ;
    00471     volatile stc_mftn_icu_t* pstcOrgMftIcu = pstcMftIcu;
    00472
    00473     // Check for NULL pointer and channel parameter
    00474     boolean_t bAvoidSideEffects  = ((NULL == pstcMftIcu) ? 1u : 0u);
    00475               bAvoidSideEffects |= ((u8Ch > MFT_ICU_CHx_MAX) ? 1u : 0u);
    00476     if (bAvoidSideEffects)
    00477     {
    00478         return ErrorInvalidParameter ;
    00479     }
    00480
    00481     // Get pointer to internal data structure
    00482     pstcMftIcuInternData = MftIcuGetInternDataPtr( pstcOrgMftIcu );
    00483     // Dis-register callback function and disable interrupt operation
    00484     switch (u8Ch)
    00485     {
    00486         // ICU channel 0
    00487         case MFT_ICU_CH0:
    00488             pstcMftIcuInternData->pfnIcu0Callback = NULL;
    00489             pstcMftIcu->ICSA10_f.ICE0 = 0u;
    00490             break;
    00491         // ICU channel 1
    00492         case MFT_ICU_CH1:
    00493             pstcMftIcuInternData->pfnIcu1Callback = NULL;
    00494             pstcMftIcu->ICSA10_f.ICE1 = 0u;
    00495             break;
    00496         // ICU channel 2
    00497         case MFT_ICU_CH2:
    00498             pstcMftIcuInternData->pfnIcu2Callback = NULL;
    00499             pstcMftIcu->ICSA32_f.ICE0 = 0u;
    00500             break;
    00501         // ICU channel 3
    00502         case MFT_ICU_CH3:
    00503             pstcMftIcuInternData->pfnIcu3Callback = NULL;
    00504             pstcMftIcu->ICSA32_f.ICE1 = 0u;
    00505             break;
    00506         // ICU channel number error
    00507         default:
    00508             return ErrorInvalidParameter;
    00509     }
    00510
    00511     Mft_Icu_DeInitIrq(pstcOrgMftIcu);
    00512     return Ok;
    00513 }
    00514
    00515 #endif
    00516
    00529 en_int_flag_t Mft_Icu_GetIntFlag(volatile stc_mftn_icu_t *pstcMftIcu, uint8_t u8Ch)
    00530 {
    00531     en_int_flag_t enIntFlagBuf;
    00532
    00533     // Read interrupt flag
    00534     switch (u8Ch)
    00535     {
    00536         // ICU channel 0
    00537         case MFT_ICU_CH0:
    00538             (pstcMftIcu->ICSA10_f.ICP0 == 1) ? (enIntFlagBuf = PdlSet) : (enIntFlagBuf = PdlClr);
    00539             break;
    00540         // ICU channel 1
    00541         case MFT_ICU_CH1:
    00542             (pstcMftIcu->ICSA10_f.ICP1 == 1) ? (enIntFlagBuf = PdlSet) : (enIntFlagBuf = PdlClr);
    00543             break;
    00544         // ICU channel 2
    00545         case MFT_ICU_CH2:
    00546             (pstcMftIcu->ICSA32_f.ICP0 == 1) ? (enIntFlagBuf = PdlSet) : (enIntFlagBuf = PdlClr);
    00547             break;
    00548         // ICU channel 3
    00549         case MFT_ICU_CH3:
    00550             (pstcMftIcu->ICSA32_f.ICP1 == 1) ? (enIntFlagBuf = PdlSet) : (enIntFlagBuf = PdlClr);
    00551             break;
    00552         // ICU channel number error
    00553         default:
    00554             break;
    00555     }
    00556     // return interrupt flag
    00557     return enIntFlagBuf;
    00558 }
    00574 en_result_t Mft_Icu_ClrIntFlag( volatile stc_mftn_icu_t *pstcMftIcu, uint8_t u8Ch)
    00575 {
    00576     // Check for NULL pointer and channel parameter
    00577     boolean_t bAvoidSideEffects  = ((NULL == pstcMftIcu) ? 1u : 0u);
    00578               bAvoidSideEffects |= ((u8Ch > MFT_ICU_CHx_MAX) ? 1u : 0u);
    00579     if (bAvoidSideEffects)
    00580     {
    00581         return ErrorInvalidParameter ;
    00582     }
    00583
    00584     // Clear interrupt flag
    00585     switch (u8Ch)
    00586     {
    00587         // ICU channel 0
    00588         case MFT_ICU_CH0:
    00589             pstcMftIcu->ICSA10_f.ICP0 = 0u;
    00590             break;
    00591         // ICU channel 1
    00592         case MFT_ICU_CH1:
    00593             pstcMftIcu->ICSA10_f.ICP1 = 0u;
    00594             break;
    00595         // ICU channel 2
    00596         case MFT_ICU_CH2:
    00597             pstcMftIcu->ICSA32_f.ICP0 = 0u;
    00598             break;
    00599         // ICU channel 3
    00600         case MFT_ICU_CH3:
    00601             pstcMftIcu->ICSA32_f.ICP1 = 0u;
    00602             break;
    00603         // ICU channel number error
    00604         default:
    00605             return ErrorInvalidParameter;
    00606     }
    00607
    00608     return Ok;
    00609 }
    00620 en_mft_icu_edge_t Mft_Icu_GetLastEdge( volatile stc_mftn_icu_t *pstcMftIcu, uint8_t u8Ch)
    00621 {
    00622     en_mft_icu_edge_t enEdgeTypeBuf;
    00623
    00624     // Read last Edge type
    00625     switch (u8Ch)
    00626     {
    00627         // ICU channel 0
    00628         case MFT_ICU_CH0:
    00629             (pstcMftIcu->ICSB10_f.IEI0 == 1) ? (enEdgeTypeBuf = IcuRisingEdge) : (enEdgeTypeBuf = IcuFallingEdge);
    00630             break;
    00631         // ICU channel 1
    00632         case MFT_ICU_CH1:
    00633             (pstcMftIcu->ICSB10_f.IEI1 == 1) ? (enEdgeTypeBuf = IcuRisingEdge) : (enEdgeTypeBuf = IcuFallingEdge);
    00634             break;
    00635         // ICU channel 2
    00636         case MFT_ICU_CH2:
    00637             (pstcMftIcu->ICSB32_f.IEI0 == 1) ? (enEdgeTypeBuf = IcuRisingEdge) : (enEdgeTypeBuf = IcuFallingEdge);
    00638             break;
    00639         // ICU channel 3
    00640         case MFT_ICU_CH3:
    00641             (pstcMftIcu->ICSB32_f.IEI1 == 1) ? (enEdgeTypeBuf = IcuRisingEdge) : (enEdgeTypeBuf = IcuFallingEdge);
    00642             break;
    00643         // ICU channel number error
    00644         default:
    00645             break;
    00646     }
    00647     // return last edge type
    00648     return enEdgeTypeBuf;
    00649 }
    00660 uint16_t Mft_Icu_GetCaptureData(volatile stc_mftn_icu_t *pstcMftIcu, uint8_t u8Ch)
    00661 {
    00662     uint16_t u16CaptureVal;
    00663
    00664     // Read captured value
    00665     switch (u8Ch)
    00666     {
    00667         // ICU channel 0
    00668         case MFT_ICU_CH0:
    00669             u16CaptureVal = (uint16_t)(pstcMftIcu->ICCP0);
    00670             break;
    00671         // ICU channel 1
    00672         case MFT_ICU_CH1:
    00673             u16CaptureVal = (uint16_t)(pstcMftIcu->ICCP1);
    00674             break;
    00675         // ICU channel 2
    00676         case MFT_ICU_CH2:
    00677             u16CaptureVal = (uint16_t)(pstcMftIcu->ICCP2);
    00678             break;
    00679         // ICU channel 3
    00680         case MFT_ICU_CH3:
    00681             u16CaptureVal = (uint16_t)(pstcMftIcu->ICCP3);
    00682             break;
    00683         // ICU channel number error
    00684         default:
    00685             break;
    00686     }
    00687
    00688     return (uint16_t)u16CaptureVal;
    00689 }
    00690
    00692
    00693 #endif // #if (defined(PDL_PERIPHERAL_MFT_ICU_ACTIVE))