/* Calculate the RANGE value base on crystal frequency. 
To setup external crystal oscillator, must set the register bits RANGE base on the crystal frequency. This function returns the RANGE base on the input frequency. This is an internal function. */
static uint8_t CLOCK_GetOscRangeFromFreq(uint32_t freq)
/* Calculate the RANGE value base on crystal frequency. 
To setup external crystal oscillator, must set the register bits RANGE base on the crystal frequency. This function returns the RANGE base on the input frequency. This is an internal function. */
static uint8_t CLOCK_GetOscRangeFromFreq(uint32_t freq)
{
    uint8_t range;
    if (freq <= 39063U)
    {
        range = 0U;
    }
    else if (freq <= 8000000U)
    {
        range = 1U;
    }
    else
    {
        range = 2U;
    }
    return range;
}