/* param config Pointer to the OSC0 configuration structure.  */
void CLOCK_InitOsc0(osc_config_t const *config)
/* param config Pointer to the OSC0 configuration structure.  */
void CLOCK_InitOsc0(osc_config_t const *config)
{
    uint8_t range = CLOCK_GetOscRangeFromFreq(config->freq);
    OSC_SetCapLoad(OSC0, config->capLoad);
    OSC_SetExtRefClkConfig(OSC0, &config->oscerConfig);
    MCG->C2 = ((MCG->C2 & MCG_C2_IRCS_MASK) | MCG_C2_RANGE0(range) | (uint8_t)config->workMode);
    if ((kOSC_ModeExt != config->workMode) && (OSC0->CR & OSC_CR_ERCLKEN_MASK))
    {
        while (!(MCG->S & MCG_S_OSCINIT0_MASK))
        {
        }
    }
}