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; }
/*FUNCTION********************************************************************** * * Function Name : CLOCK_SYS_GetPllFllClockFreq * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. * *END**************************************************************************/ uint32_t CLOCK_SYS_GetPllFllClockFreq(void) { uint32_t freq; clock_pllfll_sel_t src; src = CLOCK_HAL_GetPllfllSel(SIM); switch (src) { case kClockPllFllSelFll: freq = CLOCK_HAL_GetFllClk(MCG); break; case kClockPllFllSelIrc48M: freq = CPU_INTERNAL_IRC_48M; break; default: freq = 0U; break; } return freq; }
/*FUNCTION********************************************************************** * * Function Name : CLOCK_SYS_GetPllFllClockFreq * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. * *END**************************************************************************/ uint32_t CLOCK_SYS_GetPllFllClockFreq(void) { uint32_t freq; clock_pllfll_sel_t src; src = CLOCK_HAL_GetPllfllSel(SIM_BASE); switch (src) { case kClockPllFllSelFll: freq = CLOCK_HAL_GetFllClk(MCG_BASE); break; case kClockPllFllSelPll: freq = CLOCK_HAL_GetPll0Clk(MCG_BASE); break; default: freq = 0U; break; } return freq; }
/*FUNCTION********************************************************************** * * Function Name : CLOCK_SYS_GetPllFllClockFreq * Description : Gets the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. * This function gets the frequency of the MCGPLLCLK/MCGFLLCLK/IRC48MCLK. * *END**************************************************************************/ uint32_t CLOCK_SYS_GetPllFllClockFreq(void) { uint32_t freq; clock_pllfll_sel_t src; src = CLOCK_HAL_GetPllfllSel(SIM); switch (src) { case kClockPllFllSelFll: freq = CLOCK_HAL_GetFllClk(MCG); break; case kClockPllFllSelPll: freq = CLOCK_HAL_GetPll0Clk(MCG); freq >>= 1U; /* divided by 2 for special divider */ break; default: freq = 0U; break; } return freq; }