| 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_wfg.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_wfg.h"
    00057
    00058
    00059 #if (defined(PDL_PERIPHERAL_MFT_WFG_ACTIVE))
    00060
    00066
    00067 /******************************************************************************/
    00068 /* Local pre-processor symbols/macros ('#define')                             */
    00069 /******************************************************************************/
    00070 /******************************************************************************/
    00071 /* Global variable definitions (declared in header file with 'extern')        */
    00072 /******************************************************************************/
    00074 stc_mft_wfg_instance_data_t m_astcMftWfgInstanceDataLut[WFG_INSTANCE_COUNT] =
    00075 {
    00076 #if (PDL_PERIPHERAL_ENABLE_MFT0_WFG == PDL_ON)
    00077     {
    00078         &MFT0_WFG,  // pstcInstance
    00079         {NULL,NULL,NULL,NULL,NULL}    // stcInternData (not initialized yet)
    00080     },
    00081 #endif
    00082 #if (PDL_PERIPHERAL_ENABLE_MFT1_WFG == PDL_ON)
    00083     {
    00084         &MFT1_WFG,  // pstcInstance
    00085         {NULL,NULL,NULL,NULL,NULL}    // stcInternData (not initialized yet)
    00086     },
    00087 #endif
    00088 #if (PDL_PERIPHERAL_ENABLE_MFT2_WFG == PDL_ON)
    00089     {
    00090         &MFT2_WFG,  // pstcInstance
    00091         {NULL,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
    00104 /******************************************************************************/
    00105 /* Local variable definitions ('static')                                      */
    00106 /******************************************************************************/
    00107
    00108 /******************************************************************************/
    00109 /* Function implementation - global ('extern') and local ('static')           */
    00110 /******************************************************************************/
    00121 static stc_mft_wfg_intern_data_t* MftGetInternDataPtr(volatile stc_mftn_wfg_t* pstcWfg)
    00122 {
    00123     uint32_t u32Instance;
    00124
    00125     for (u32Instance = 0; u32Instance < WFG_INSTANCE_COUNT; u32Instance++)
    00126     {
    00127         if (pstcWfg == m_astcMftWfgInstanceDataLut[u32Instance].pstcInstance)
    00128         {
    00129             return &m_astcMftWfgInstanceDataLut[u32Instance].stcInternData;
    00130         }
    00131     }
    00132
    00133     return NULL;
    00134 }
    00135
    00136 #if (PDL_INTERRUPT_ENABLE_MFT0_WFG == PDL_ON) || \
    00137     (PDL_INTERRUPT_ENABLE_MFT1_WFG == PDL_ON) || \
    00138     (PDL_INTERRUPT_ENABLE_MFT2_WFG == PDL_ON)
    00139
    00149 void Mft_Wfg_IrqHandler( volatile  stc_mftn_wfg_t* pstcWfg,
    00150                  stc_mft_wfg_intern_data_t* pstcMftWfgInternData)
    00151 {
    00152     func_ptr_t funCallBack;
    00153     uint32_t* ptemp;
    00154     uint8_t ch;
    00155
    00156     /* timer interrupt*/
    00157     for(ch=0;ch<3;ch++)
    00158     {
    00159         if(PdlSet == Mft_Wfg_GetTimerIntFlag(pstcWfg,ch))
    00160         {
    00161             /* Clear Interrupt */
    00162             Mft_Wfg_ClrTimerIntFlag(pstcWfg,ch);
    00163
    00164             //get peak timer interrupt callback address of each channel
    00165             ptemp = (uint32_t*)&(pstcMftWfgInternData->pfnWfg10TimerCallback);
    00166             funCallBack = (func_ptr_t)(*(ptemp + ch));
    00167
    00168             if(funCallBack != NULL)
    00169             {
    00170                funCallBack();
    00171             }
    00172         }
    00173     }
    00174
    00175     /* DTIF Interrupt */
    00176     //Digital filter interrupt
    00177     if(PdlSet == Mft_Wfg_GetDigitalFilterIntFlag(pstcWfg))
    00178     {
    00179         //Mft_Wfg_ClrDigitalFilterIntFlag(pstcMft);
    00180         funCallBack = pstcMftWfgInternData->pfnWfgDigtalFilterCallback;
    00181         if(funCallBack != NULL)
    00182         {
    00183            funCallBack();
    00184         }
    00185     }
    00186
    00187     //analog filter interrupt
    00188     if(PdlSet == Mft_Wfg_GetAnalogFilterIntFlag(pstcWfg))
    00189     {
    00190         //Mft_Wfg_ClrAnalogFilterIntFlag(pstcMft);
    00191         funCallBack = pstcMftWfgInternData->pfnWfgAnalogFilterCallback;
    00192         if(funCallBack != NULL)
    00193         {
    00194            funCallBack();
    00195         }
    00196     }
    00197 }
    00198
    00209 static void Mft_Wfg_InitIrq( volatile stc_mftn_wfg_t* pstcWfg )
    00210 {
    00211     if ((pstcWfg == (volatile stc_mftn_wfg_t*)(&MFT0_WFG)) ||
    00212         (pstcWfg == (volatile stc_mftn_wfg_t*)(&MFT1_WFG)) ||
    00213         (pstcWfg == (volatile stc_mftn_wfg_t*)(&MFT2_WFG)))
    00214     {
    00215         NVIC_ClearPendingIRQ(WFG_DTIF_IRQn);
    00216         NVIC_EnableIRQ(WFG_DTIF_IRQn);
    00217         NVIC_SetPriority(WFG_DTIF_IRQn, PDL_IRQ_LEVEL_MFT_WFG);
    00218     }
    00219
    00220     return;
    00221 }
    00222
    00232 static void Mft_Wfg_DeInitIrq( volatile stc_mftn_wfg_t* pstcWfg )
    00233 {
    00234     if ((pstcWfg == (volatile stc_mftn_wfg_t*)(&MFT0_WFG)) ||
    00235         (pstcWfg == (volatile stc_mftn_wfg_t*)(&MFT1_WFG)) ||
    00236         (pstcWfg == (volatile stc_mftn_wfg_t*)(&MFT2_WFG)))
    00237     {
    00238         if((pstcWfg->NZCL & 0x7300) != 0x7300) // DIMA=DIMB=WIM10=WIM32=WIM54=1 ?
    00239         {
    00240             return;
    00241         }
    00242
    00243         NVIC_ClearPendingIRQ(WFG_DTIF_IRQn);
    00244         NVIC_DisableIRQ(WFG_DTIF_IRQn);
    00245         NVIC_SetPriority(WFG_DTIF_IRQn, PDL_DEFAULT_INTERRUPT_LEVEL);
    00246     }
    00247
    00248
    00249     return;
    00250 }
    00251
    00252 #endif
    00253
    00272 en_result_t Mft_Wfg_ConfigMode( volatile stc_mftn_wfg_t* pstcWfg,
    00273                                uint8_t u8CoupleCh, en_mft_wfg_mode_t enMode)
    00274 {
    00275     volatile stc_mft_wfg_wfsa10_field_t* pstcWFSA;
    00276     stc_mft_wfg_intern_data_t* pstcWfgInternData;
    00277
    00278     // Check for NULL pointer
    00279     if ( (pstcWfg == NULL)
    00280          || (u8CoupleCh >= MFT_WFG_MAXCH))
    00281     {
    00282         return ErrorInvalidParameter ;
    00283     }
    00284     // Get pointer to internal data structure ...
    00285     pstcWfgInternData = MftGetInternDataPtr( pstcWfg ) ;
    00286
    00287     // ... and check for NULL
    00288     if ( pstcWfgInternData != NULL )
    00289     {
    00290         pstcWfgInternData->pfnWfg10TimerCallback = NULL;
    00291         pstcWfgInternData->pfnWfg32TimerCallback = NULL;
    00292         pstcWfgInternData->pfnWfg54TimerCallback = NULL;
    00293     }
    00294
    00295     //Get pointer of current channel WFG register address
    00296     pstcWFSA = (volatile stc_mft_wfg_wfsa10_field_t*)((volatile uint8_t*)pstcWfg + 0xA4UL + u8CoupleCh*4);
    00297
    00298     switch(enMode)
    00299     {
    00300         case WfgThroughMode:
    00301             pstcWFSA->TMD = 0u;
    00302             break;
    00303         case WfgRtPpgMode:
    00304             pstcWFSA->TMD = 1u;
    00305             break;
    00306         case WfgTimerPpgMode:
    00307             pstcWFSA->TMD = 2u;
    00308             break;
    00309         case WfgRtDeadTimerMode:
    00310             pstcWFSA->TMD = 4u;
    00311             break;
    00312         case WfgRtDeadTimerFilterMode:
    00313             pstcWFSA->TMD = 5u;
    00314             break;
    00315         case WfgPpgDeadTimerFilterMode:
    00316             pstcWFSA->TMD = 6u;
    00317             break;
    00318         case WfgPpgDeadTimerMode:
    00319             pstcWFSA->TMD = 7u;
    00320             break;
    00321         default:
    00322             return ErrorInvalidParameter;
    00323     }
    00324
    00325     return Ok;
    00326 }
    00327
    00345 en_result_t Mft_Wfg_ConfigCtrlBits( volatile stc_mftn_wfg_t* pstcWfg,uint8_t u8CoupleCh,
    00346                                     stc_wfg_ctrl_bits_t* pstcCtrlBits)
    00347 {
    00348     volatile stc_mft_wfg_wfsa10_field_t* pstcWFSA;
    00349
    00350     // Check for NULL pointer
    00351     if ( (pstcWfg == NULL)
    00352          || (u8CoupleCh >= MFT_WFG_MAXCH))
    00353     {
    00354         return ErrorInvalidParameter ;
    00355     }
    00356
    00357     //Get pointer of current channel WFG register address
    00358     pstcWFSA = (volatile stc_mft_wfg_wfsa10_field_t*)((volatile uint8_t*)pstcWfg + 0xA4UL + u8CoupleCh*4);
    00359
    00360     //set register
    00361     if(pstcCtrlBits->enDmodBit == DmodBit0B)
    00362     {
    00363         pstcWFSA->DMOD = 0u;
    00364     }
    00365     else
    00366     {;
    00367         pstcWFSA->DMOD = 1u;
    00368     }
    00369
    00370     pstcWFSA->PGEN = (uint8_t)pstcCtrlBits->enPgenBits;
    00371     pstcWFSA->PSEL = (uint8_t)pstcCtrlBits->enPselBits;
    00372     pstcWFSA->GTEN = (uint8_t)pstcCtrlBits->enGtenBits;
    00373
    00374     return Ok;
    00375 }
    00376
    00394 en_result_t Mft_Wfg_InitTimerClock( volatile stc_mftn_wfg_t* pstcWfg,uint8_t u8CoupleCh,
    00395                                    en_wfg_timer_clock_t enClk)
    00396 {
    00397     volatile stc_mft_wfg_wfsa10_field_t* pstcWFSA;
    00398
    00399     // Check for NULL pointer
    00400     if ( (pstcWfg == NULL)
    00401          || (u8CoupleCh >= MFT_WFG_MAXCH))
    00402     {
    00403         return ErrorInvalidParameter ;
    00404     }
    00405
    00406     //Get pointer of current channel WFG register address
    00407     pstcWFSA = (volatile stc_mft_wfg_wfsa10_field_t*)((volatile uint8_t*)pstcWfg + 0xA4UL + u8CoupleCh*4);
    00408
    00409     //set count clock
    00410     pstcWFSA->DCK = (uint16_t)enClk;
    00411
    00412     return Ok;
    00413 }
    00414
    00415 #if (PDL_INTERRUPT_ENABLE_MFT0_WFG == PDL_ON) || \
    00416     (PDL_INTERRUPT_ENABLE_MFT1_WFG == PDL_ON) || \
    00417     (PDL_INTERRUPT_ENABLE_MFT2_WFG == PDL_ON)
    00418
    00435 en_result_t Mft_Wfg_EnableTimerInt( volatile stc_mftn_wfg_t* pstcWfg,
    00436                                    uint8_t u8CoupleCh, func_ptr_t pfnCallback)
    00437 {
    00438     stc_mft_wfg_intern_data_t* pstcWfgInternData;
    00439
    00440     // Check for NULL pointer
    00441     if ( (pstcWfg == NULL)
    00442          || (u8CoupleCh >= MFT_WFG_MAXCH))
    00443     {
    00444         return ErrorInvalidParameter ;
    00445     }
    00446
    00447     // Get pointer to internal data structure ...
    00448     pstcWfgInternData = MftGetInternDataPtr( pstcWfg ) ;
    00449
    00450     switch(u8CoupleCh)
    00451     {
    00452         case MFT_WFG_CH10:
    00453             pstcWfgInternData->pfnWfg10TimerCallback = pfnCallback;
    00454             pstcWfg->NZCL_f.WIM10 = 0;
    00455             break;
    00456         case MFT_WFG_CH32:
    00457             pstcWfgInternData->pfnWfg32TimerCallback = pfnCallback;
    00458             pstcWfg->NZCL_f.WIM32 = 0;
    00459             break;
    00460         case MFT_WFG_CH54:
    00461             pstcWfgInternData->pfnWfg54TimerCallback = pfnCallback;
    00462             pstcWfg->NZCL_f.WIM54 = 0;
    00463             break;
    00464         default:
    00465             break;
    00466     }
    00467
    00468     Mft_Wfg_InitIrq(pstcWfg);
    00469
    00470     return Ok;
    00471 }
    00472
    00488 en_result_t Mft_Wfg_DisableTimerInt( volatile stc_mftn_wfg_t* pstcWfg, uint8_t u8CoupleCh)
    00489 {
    00490     stc_mft_wfg_intern_data_t* pstcWfgInternData;
    00491
    00492     // Check for NULL pointer
    00493     if ( (pstcWfg == NULL)
    00494          || (u8CoupleCh >= MFT_WFG_MAXCH))
    00495     {
    00496         return ErrorInvalidParameter ;
    00497     }
    00498
    00499     // Get pointer to internal data structure ...
    00500     pstcWfgInternData = MftGetInternDataPtr( pstcWfg ) ;
    00501
    00502     switch(u8CoupleCh)
    00503     {
    00504         case MFT_WFG_CH10:
    00505             pstcWfgInternData->pfnWfg10TimerCallback = NULL;
    00506             pstcWfg->NZCL_f.WIM10 = 1;
    00507             break;
    00508         case MFT_WFG_CH32:
    00509             pstcWfgInternData->pfnWfg32TimerCallback = NULL;
    00510             pstcWfg->NZCL_f.WIM32 = 1;
    00511             break;
    00512         case MFT_WFG_CH54:
    00513             pstcWfgInternData->pfnWfg54TimerCallback = NULL;
    00514             pstcWfg->NZCL_f.WIM54 = 1;
    00515             break;
    00516         default:
    00517             break;
    00518     }
    00519
    00520     Mft_Wfg_DeInitIrq(pstcWfg);
    00521
    00522     return Ok;
    00523 }
    00524
    00525 #endif
    00526
    00542 en_result_t Mft_Wfg_StartTimer(volatile stc_mftn_wfg_t* pstcWfg, uint8_t u8CoupleCh)
    00543 {
    00544     if ( (pstcWfg == NULL)
    00545          || (u8CoupleCh >= MFT_WFG_MAXCH))
    00546     {
    00547         return ErrorInvalidParameter ;
    00548     }
    00549
    00550     switch(u8CoupleCh)
    00551     {
    00552         case MFT_WFG_CH10:
    00553             pstcWfg->WFIR_f.TMIE10 = 1;
    00554             break;
    00555         case MFT_WFG_CH32:
    00556             pstcWfg->WFIR_f.TMIE32 = 1;
    00557             break;
    00558         case MFT_WFG_CH54:
    00559             pstcWfg->WFIR_f.TMIE54 = 1;
    00560             break;
    00561         default:
    00562             break;
    00563     }
    00564
    00565     return Ok;
    00566 }
    00567
    00583 en_result_t Mft_Wfg_StopTimer(volatile stc_mftn_wfg_t* pstcWfg, uint8_t u8CoupleCh)
    00584 {
    00585     if ( (pstcWfg == NULL)
    00586          || (u8CoupleCh >= MFT_WFG_MAXCH))
    00587     {
    00588         return ErrorInvalidParameter ;
    00589     }
    00590
    00591     switch(u8CoupleCh)
    00592     {
    00593         case MFT_WFG_CH10:
    00594             pstcWfg->WFIR_f.TMIS10 = 1;
    00595             break;
    00596         case MFT_WFG_CH32:
    00597             pstcWfg->WFIR_f.TMIS32 = 1;
    00598             break;
    00599         case MFT_WFG_CH54:
    00600             pstcWfg->WFIR_f.TMIS54 = 1;
    00601             break;
    00602         default:
    00603             break;
    00604     }
    00605
    00606     return Ok;
    00607 }
    00608
    00609
    00623 en_int_flag_t Mft_Wfg_GetTimerIntFlag( volatile stc_mftn_wfg_t* pstcWfg,
    00624                                        uint8_t u8CoupleCh)
    00625 {
    00626     en_int_flag_t retval = PdlClr;
    00627
    00628     switch(u8CoupleCh)
    00629     {
    00630         case MFT_WFG_CH10:
    00631             (pstcWfg->WFIR_f.TMIF10 == 1) ? (retval = PdlSet) : (retval = PdlClr);
    00632             break;
    00633         case MFT_WFG_CH32:
    00634             (pstcWfg->WFIR_f.TMIF32 == 1) ? (retval = PdlSet) : (retval = PdlClr);
    00635             break;
    00636         case MFT_WFG_CH54:
    00637             (pstcWfg->WFIR_f.TMIF54 == 1) ? (retval = PdlSet) : (retval = PdlClr);
    00638             break;
    00639         default:
    00640             break;
    00641     }
    00642
    00643     return retval;
    00644 }
    00645
    00661 en_result_t Mft_Wfg_ClrTimerIntFlag( volatile stc_mftn_wfg_t* pstcWfg, uint8_t u8CoupleCh)
    00662 {
    00663     // Check for NULL pointer
    00664     if ( (pstcWfg == NULL)
    00665          || (u8CoupleCh >= MFT_WFG_MAXCH))
    00666     {
    00667         return ErrorInvalidParameter ;
    00668     }
    00669
    00670     //set register value
    00671     switch(u8CoupleCh)
    00672     {
    00673         case MFT_WFG_CH10:
    00674             pstcWfg->WFIR_f.TMIC10 = 1;
    00675             break;
    00676         case MFT_WFG_CH32:
    00677             pstcWfg->WFIR_f.TMIC32 = 1;
    00678             break;
    00679         case MFT_WFG_CH54:
    00680             pstcWfg->WFIR_f.TMIC54 = 1;
    00681             break;
    00682         default:
    00683             break;
    00684     }
    00685
    00686     return Ok;
    00687 }
    00688
    00708 en_result_t Mft_Wfg_WriteTimerCountCycle( volatile stc_mftn_wfg_t* pstcWfg,
    00709                                          uint8_t u8CoupleCh,
    00710                                          uint16_t u16CycleA,
    00711                                          uint16_t u16CycleB)
    00712 {
    00713     volatile uint16_t* pWFTA;
    00714     volatile uint16_t* pWFTB;
    00715
    00716     // Check for NULL pointer
    00717     if ( (pstcWfg == NULL)
    00718          || (u8CoupleCh >= MFT_WFG_MAXCH))
    00719     {
    00720         return ErrorInvalidParameter ;
    00721     }
    00722
    00723     //Get pointer of current channel WFG register address
    00724     pWFTA = (volatile uint16_t*)((volatile uint8_t*)pstcWfg + 0x90UL + u8CoupleCh*8);
    00725     pWFTB = (volatile uint16_t*)((volatile uint8_t*)pstcWfg + 0x92UL + u8CoupleCh*8);
    00726
    00727     //set the register
    00728     *pWFTA = u16CycleA;
    00729     *pWFTB = u16CycleB;
    00730
    00731     return Ok;
    00732
    00733 }
    00734
    00752 en_result_t Mft_Wfg_SetTimerCycle( volatile stc_mftn_wfg_t* pstcWfg,
    00753                                       uint8_t u8CoupleCh, uint16_t u16Count)
    00754 {
    00755     volatile uint16_t* pWFTF;
    00756
    00757     //Get pointer of current channel WFG register address
    00758     pWFTF = (volatile uint16_t*)((volatile uint8_t*)pstcWfg + 0x8EUL + u8CoupleCh*8);
    00759
    00760     *pWFTF =u16Count;
    00761     return Ok;
    00762 }
    00775 uint16_t Mft_Wfg_GetTimerCurCycle( volatile stc_mftn_wfg_t* pstcWfg, uint8_t u8CoupleCh)
    00776 {
    00777     uint16_t retval;
    00778     volatile uint16_t* pWFTF;
    00779
    00780     //Get pointer of current channel WFG register address
    00781     pWFTF = (volatile uint16_t*)((volatile uint8_t*)pstcWfg + 0x8EUL + u8CoupleCh*8);
    00782
    00783     retval = *pWFTF;
    00784     return retval;
    00785 }
    00786
    00801 en_result_t Mft_Wfg_ConfigNzcl( volatile stc_mftn_wfg_t* pstcWfg,
    00802                                stc_wfg_nzcl_config_t* pstcNzclConfig)
    00803 {
    00804     // Check for NULL pointer
    00805     if ( pstcWfg == NULL)
    00806     {
    00807         return ErrorInvalidParameter ;
    00808     }
    00809
    00810     //set register value
    00811     pstcWfg->NZCL_f.DTIEA = pstcNzclConfig->bEnDigitalFilter;
    00812     pstcWfg->NZCL_f.DTIEB = pstcNzclConfig->bEnAnalogFilter;
    00813     pstcWfg->NZCL &= ~(7ul<<1);
    00814     pstcWfg->NZCL |= (uint16_t)((uint16_t)pstcNzclConfig->enDigitalFilterWidth <<1 );
    00815     if(pstcWfg == &MFT0_WFG)
    00816     {
    00817         bFM0P_GPIO_EPFR01_DTTI0C = pstcNzclConfig->bSwitchToGpio;
    00818     }
    00819     else if (pstcWfg == &MFT1_WFG)
    00820     {
    00821         bFM0P_GPIO_EPFR02_DTTI1C = pstcNzclConfig->bSwitchToGpio;
    00822     }
    00823     else if(pstcWfg == &MFT2_WFG)
    00824     {
    00825         bFM0P_GPIO_EPFR03_DTTI2C = pstcNzclConfig->bSwitchToGpio;
    00826     }
    00827     return Ok;
    00828 }
    00829
    00830 #if (PDL_INTERRUPT_ENABLE_MFT0_WFG == PDL_ON) || \
    00831     (PDL_INTERRUPT_ENABLE_MFT1_WFG == PDL_ON) || \
    00832     (PDL_INTERRUPT_ENABLE_MFT2_WFG == PDL_ON)
    00833
    00850 en_result_t Mft_Wfg_EnableDtifInt( volatile stc_mftn_wfg_t* pstcWfg,
    00851                                    stc_dtif_int_sel_t* pstcIntSel,
    00852                                    stc_dtif_int_cb_t* pstcCallback)
    00853 {
    00854     stc_mft_wfg_intern_data_t* pstcWfgInternData;
    00855     // Check for NULL pointer
    00856     if ((pstcWfg == NULL ) ||
    00857         (pstcIntSel->bDtifAnalogFilterInt > 1) ||
    00858         (pstcIntSel->bDtifDigitalFilterInt > 1))
    00859     {
    00860         return ErrorInvalidParameter ;
    00861     }
    00862
    00863     // Get pointer to internal data structure ...
    00864     pstcWfgInternData = MftGetInternDataPtr( pstcWfg ) ;
    00865
    00866     if(TRUE == pstcIntSel->bDtifDigitalFilterInt)
    00867     {
    00868         pstcWfg->NZCL_f.DIMA = 0;
    00869         pstcWfgInternData->pfnWfgDigtalFilterCallback = pstcCallback->pfnWfgDigtalFilterCallback;
    00870
    00871     }
    00872     if(TRUE == pstcIntSel->bDtifAnalogFilterInt)
    00873     {
    00874         pstcWfg->NZCL_f.DIMB = 0;
    00875         pstcWfgInternData->pfnWfgAnalogFilterCallback = pstcCallback->pfnWfgAnalogFilterCallback;
    00876     }
    00877
    00878     Mft_Wfg_InitIrq(pstcWfg);
    00879
    00880     return Ok;
    00881 }
    00882
    00897 en_result_t Mft_Wfg_DisableDtifInt( volatile stc_mftn_wfg_t* pstcWfg,
    00898                                     stc_dtif_int_sel_t* pstcIntSel)
    00899 {
    00900     stc_mft_wfg_intern_data_t* pstcWfgInternData;
    00901     // Check for NULL pointer
    00902     if ( (pstcWfg == NULL) ||
    00903          (pstcIntSel->bDtifAnalogFilterInt > 1) ||
    00904          (pstcIntSel->bDtifDigitalFilterInt > 1)
    00905        )
    00906     {
    00907         return ErrorInvalidParameter ;
    00908     }
    00909
    00910     // Get pointer to internal data structure ...
    00911     pstcWfgInternData = MftGetInternDataPtr( pstcWfg ) ;
    00912
    00913     if(TRUE == pstcIntSel->bDtifDigitalFilterInt)
    00914     {
    00915         pstcWfg->NZCL_f.DIMA = 1;
    00916         pstcWfgInternData->pfnWfgDigtalFilterCallback = NULL;
    00917
    00918     }
    00919     if(TRUE == pstcIntSel->bDtifAnalogFilterInt)
    00920     {
    00921         pstcWfg->NZCL_f.DIMB = 1;
    00922         pstcWfgInternData->pfnWfgAnalogFilterCallback = NULL;
    00923     }
    00924
    00925     Mft_Wfg_DeInitIrq(pstcWfg);
    00926
    00927     return Ok;
    00928 }
    00929
    00930 #endif
    00931
    00945 en_result_t Mft_Wfg_SwTiggerDtif( volatile stc_mftn_wfg_t* pstcWfg)
    00946 {
    00947     // Check for NULL pointer
    00948     if ( (pstcWfg == NULL))
    00949     {
    00950         return ErrorInvalidParameter ;
    00951     }
    00952
    00953     pstcWfg->NZCL_f.SDTI = 1;
    00954     return Ok;
    00955 }
    00956
    00968 en_int_flag_t Mft_Wfg_GetDigitalFilterIntFlag( volatile stc_mftn_wfg_t* pstcWfg)
    00969 {
    00970     en_int_flag_t retval = PdlClr;
    00971
    00972     //get interrupt flag via digital noise-canceler
    00973     (pstcWfg->WFIR_f.DTIFA == 1) ? (retval = PdlSet) : (retval = PdlClr);
    00974
    00975     return retval;
    00976 }
    00977
    00991 en_result_t Mft_Wfg_ClrDigitalFilterIntFlag( volatile stc_mftn_wfg_t* pstcWfg)
    00992 {
    00993     // Check for NULL pointer
    00994     if ( pstcWfg == NULL)
    00995     {
    00996         return ErrorInvalidParameter ;
    00997     }
    00998
    00999     pstcWfg->WFIR_f.DTICA = 1;
    01000     return Ok;
    01001 }
    01002
    01014 en_int_flag_t Mft_Wfg_GetAnalogFilterIntFlag( volatile stc_mftn_wfg_t* pstcWfg)
    01015 {
    01016     en_int_flag_t retval;
    01017
    01018     //get interrupt flag via analog noise filter
    01019     (pstcWfg->WFIR_f.DTIFB == 1) ? (retval = PdlSet) : (retval = PdlClr);
    01020
    01021     return retval;
    01022 }
    01036 en_result_t Mft_Wfg_ClrAnalogFilterIntFlag( volatile stc_mftn_wfg_t* pstcWfg)
    01037 {
    01038     // Check for NULL pointer
    01039     if ( pstcWfg == NULL)
    01040     {
    01041         return ErrorInvalidParameter ;
    01042     }
    01043
    01044     pstcWfg->WFIR_f.DTICB = 1;
    01045     return Ok;
    01046 }
    01047
    01049
    01050 #endif // #if (defined(PDL_PERIPHERAL_$$X_ACTIVE))
    01051
    01052 /******************************************************************************/
    01053 /* EOF (not truncated)                                                        */
    01054 /******************************************************************************/