/* Calculate prescaler value used to determine ADC clock. 
The ADC clock is given by: HFPERCLK / (prescale + 1). */
uint8_t ADC_PrescaleCalc(uint32_t adcFreq, uint32_t hfperFreq)
/* Calculate prescaler value used to determine ADC clock. 
The ADC clock is given by: HFPERCLK / (prescale + 1). */
uint8_t ADC_PrescaleCalc(uint32_t adcFreq, uint32_t hfperFreq)
{
  uint32_t ret;
  if (adcFreq > ADC_MAX_CLOCK)
  {
    adcFreq = ADC_MAX_CLOCK;
  }
  else if (adcFreq < ADC_MIN_CLOCK)
  {
    adcFreq = ADC_MIN_CLOCK;
  }
  if (!hfperFreq)
  {
    hfperFreq = CMU_ClockFreqGet(cmuClock_HFPER);
  }
  ret = (hfperFreq + adcFreq - 1) / adcFreq;
  if (ret)
  {
    ret--;
  }
  return (uint8_t)ret;
}