Ejemplo n.º 1
0
/*FUNCTION**********************************************************************
 *
 * Function Name : CLOCK_SYS_GetLptmrFreq
 * Description   : Gets LPTMRx pre-scaler/glitch filter clock frequency.
 * This function gets the LPTMRx pre-scaler/glitch filter clock frequency.
 *
 *END**************************************************************************/
uint32_t CLOCK_SYS_GetLptmrFreq(uint32_t instance, clock_lptmr_src_t lptmrSrc)
{
    uint32_t freq;

    switch (lptmrSrc)
    {
        case kClockLptmrSrcMcgIrClk:            /* MCG out clock  */
            freq = CLOCK_HAL_GetInternalRefClk(MCG);
            break;
        case kClockLptmrSrcLpoClk:              /* LPO clock     */
            freq = CLOCK_SYS_GetLpoClockFreq();
            break;
        case kClockLptmrSrcEr32kClk:            /* ERCLK32K clock */
            freq = CLOCK_SYS_GetExternalRefClock32kFreq();
            break;
        case kClockLptmrSrcOsc0erClkUndiv:      /* OSC0ERCLKUDIV clock */
            freq = CLOCK_SYS_GetOsc0ExternalRefClockUndivFreq();
            break;
        default:
            freq = 0U;
            break;
    }

    return freq;
}
Ejemplo n.º 2
0
/*FUNCTION**********************************************************************
*
* Function Name : CLOCK_SYS_GetLpuartFreq
* Description	 : Gets the clock frequency for LPUART module.
* This function gets the clock frequency for LPUART moudle.
*
*END**************************************************************************/
uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance)
{
    clock_lpuart_src_t src;
    uint32_t freq;

    src = CLOCK_HAL_GetLpuartSrc(SIM, instance);

    switch (src)
    {
        case kClockLpuartSrcIrc48M:	  /* IRC48M */
            freq = kMcgliteConst48M;
            break;
        case kClockLpuartSrcOsc0erClk:		/* OSCER clock */
            freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq();
            break;
        case kClockLpuartSrcMcgIrClk:		/* MCGIR clock */
            freq = CLOCK_HAL_GetInternalRefClk(MCG);
            break;
        default:
            freq = 0U;
            break;
    }

    return freq;
}
Ejemplo n.º 3
0
/*FUNCTION**********************************************************************
*
* Function Name : CLOCK_SYS_GetCopFreq
* Description   : Gets the clock frequency for COP module.
* This function gets the clock frequency for COP moudle.
*
*END**************************************************************************/
uint32_t CLOCK_SYS_GetCopFreq(void)
{
    clock_cop_src_t src;
    uint32_t freq;

    src = CLOCK_HAL_GetCopSrc(SIM);

    switch (src)
    {
        case kClockCopSrcLpoClk:
            freq = CLOCK_SYS_GetLpoClockFreq();
            break;
        case kClockCopSrcMcgIrClk:
            freq = CLOCK_HAL_GetInternalRefClk(MCG);
            break;
        case kClockCopSrcOsc0erClk:
            freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq();
            break;
        case kClockCopSrcBusClk:
            freq = CLOCK_SYS_GetBusClockFreq();
            break;
        default:
            freq = 0U;
            break;
    }

    return freq;
}
clock_manager_error_code_t CLOCK_SYS_GetFreq(clock_names_t clockName,
                                                 uint32_t *frequency)
{
    clock_manager_error_code_t returnCode = kClockManagerSuccess;

    switch (clockName)
    {
        case kCoreClock:
        case kSystemClock:
            *frequency = CLOCK_SYS_GetCoreClockFreq();
            break;
        case kPlatformClock:
            *frequency = CLOCK_SYS_GetSystemClockFreq();
            break;
        case kBusClock:
            *frequency = CLOCK_SYS_GetBusClockFreq();
            break;
        case kFlexBusClock:
            *frequency = CLOCK_SYS_GetFlexbusFreq();
            break;
        case kFlashClock:
            *frequency = CLOCK_SYS_GetFlashClockFreq();
            break;
        case kOsc32kClock:
            *frequency = CLOCK_SYS_GetExternalRefClock32kFreq();
            break;
        case kOsc0ErClock:
            *frequency = CLOCK_SYS_GetOsc0ExternalRefClockFreq();
            break;
        case kRtcoutClock:
            *frequency = CLOCK_SYS_GetRtcOutFreq();
            break;
        case kMcgFfClock:
            *frequency = CLOCK_SYS_GetFixedFreqClockFreq();
            break;
        case kMcgFllClock:
            *frequency = CLOCK_HAL_GetFllClk(MCG_BASE);
            break;
        case kMcgPll0Clock:
            *frequency = CLOCK_HAL_GetPll0Clk(MCG_BASE);
            break;
        case kMcgOutClock:
            *frequency = CLOCK_HAL_GetOutClk(MCG_BASE);
            break;
        case kMcgIrClock:
            *frequency = CLOCK_HAL_GetInternalRefClk(MCG_BASE);
            break;
        case kLpoClock:
            *frequency = CLOCK_SYS_GetLpoClockFreq();
            break;
        default:
            *frequency = 0U;
            returnCode = kClockManagerNoSuchClockName;
            break;
    }

    return returnCode;
}
Ejemplo n.º 5
0
/*FUNCTION**********************************************************************
 *
 * Function Name : CLOCK_SYS_GetWdogFreq
 * Description   : Gets watch dog clock frequency.
 * This function gets the watch dog clock frequency.
 *
 *END**************************************************************************/
uint32_t CLOCK_SYS_GetWdogFreq(uint32_t instance, clock_wdog_src_t wdogSrc)
{
    if (kClockWdogSrcLpoClk == wdogSrc)
    {
        return CLOCK_SYS_GetLpoClockFreq();
    }
    else
    {
        return CLOCK_HAL_GetInternalRefClk(MCG); /* For KV11Z7, it's MCGIRCLK */
    }
}
Ejemplo n.º 6
0
/*FUNCTION**********************************************************************
 *
 * Function Name : CLOCK_SYS_GetFtmFixedFreq
 * Description   : Gets FTM fixed frequency clock frequency.
 * 
 * This function gets the FTM fixed frequency clock frequency.
 *END**************************************************************************/
uint32_t CLOCK_SYS_GetFtmFixedFreq(uint32_t instance)
{
    uint32_t ftmFixedFreq;
    clock_ftm_fixedfreq_src_t ftmFixedFreqSel;
    ftmFixedFreqSel = (clock_ftm_fixedfreq_src_t)CLOCK_HAL_GetFtmFixFreqClkSrc(SIM);
    switch(ftmFixedFreqSel)
    {
      case kClockFtmClkMcgFfClk:
          ftmFixedFreq = CLOCK_HAL_GetFixedFreqClk(MCG);
          break;
      case kClockFtmClkMcgIrClk:
          ftmFixedFreq = CLOCK_HAL_GetInternalRefClk(MCG);
          break;
      case kClockFtmClkOsc0erClk:
          ftmFixedFreq = CLOCK_SYS_GetOsc0ExternalRefClockFreq();
          break;
      default:
          ftmFixedFreq = 0;
          break;
    }
    return ftmFixedFreq;
}
Ejemplo n.º 7
0
/*FUNCTION**********************************************************************
 *
 * Function Name : CLOCK_SYS_GetLpuartFreq
 * Description   : Gets the clock frequency for LPUART module.
 * This function gets the clock frequency for LPUART moudle.
 *
 *END**************************************************************************/
uint32_t CLOCK_SYS_GetLpuartFreq(uint32_t instance)
{
    clock_lpuart_src_t src;
    uint32_t freq;

    src = CLOCK_HAL_GetLpuartSrc(SIM, instance);
    switch (src)
    {
        case kClockLpuartSrcPllFllSel:
            freq = CLOCK_SYS_GetPllFllClockFreq();
            break;
        case kClockLpuartSrcOsc0erClk:
            freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq();
            break;
        case kClockLpuartSrcMcgIrClk:
            freq = CLOCK_HAL_GetInternalRefClk(MCG);
            break;
        default:
            freq = 0U;
            break;
    }
    return freq;
}
Ejemplo n.º 8
0
/*FUNCTION**********************************************************************
 *
 * Function Name : CLOCK_SYS_GetFlexioFreq
 * Description   : Gets the clock frequency for FLEXIO.
 * This function gets the clock frequency for FLEXIO.
 *
 *END**************************************************************************/
uint32_t CLOCK_SYS_GetFlexioFreq(uint32_t instance)
{
    uint32_t freq;
    clock_flexio_src_t src = CLOCK_HAL_GetFlexioSrc(SIM, instance);

    switch (src)
    {
        case kClockFlexioSrcIrc48M:
            freq = kMcgliteConst48M;
            break;
        case kClockFlexioSrcOsc0erClk:
            freq = CLOCK_SYS_GetOsc0ExternalRefClockFreq();
            break;
        case kClockFlexioSrcMcgIrClk:
            freq = CLOCK_HAL_GetInternalRefClk(MCG);
            break;
        default:
            freq = 0U;
            break;
    }

    return freq;
}