/* Calculate prescaler value used to determine DAC clock. 
The DAC clock is given by: HFPERCLK / (prescale ^ 2). */
uint8_t DAC_PrescaleCalc(uint32_t dacFreq, uint32_t hfperFreq)
/* Calculate prescaler value used to determine DAC clock. 
The DAC clock is given by: HFPERCLK / (prescale ^ 2). */
uint8_t DAC_PrescaleCalc(uint32_t dacFreq, uint32_t hfperFreq)
{
  uint32_t ret;
  if (dacFreq > DAC_MAX_CLOCK)
  {
    dacFreq = DAC_MAX_CLOCK;
  }
  if (!hfperFreq)
  {
    hfperFreq = CMU_ClockFreqGet(cmuClock_HFPER);
  }
  for (ret = 0; ret <= (_DAC_CTRL_PRESC_MASK >> _DAC_CTRL_PRESC_SHIFT); ret++)
  {
    if ((hfperFreq >> ret) <= dacFreq)
      break;
  }
  return((uint8_t)ret);
}