/* Initialize ADC. 
Initializes common parts for both single conversion and scan sequence. In addition, single and/or scan control configuration must be done, please refer to  */
void ADC_Init(ADC_TypeDef *adc, const ADC_Init_TypeDef *init)
/* Initialize ADC. 
Initializes common parts for both single conversion and scan sequence. In addition, single and/or scan control configuration must be done, please refer to  */
void ADC_Init(ADC_TypeDef *adc, const ADC_Init_TypeDef *init)
{
  uint32_t tmp;
  EFM_ASSERT(ADC_REF_VALID(adc));
  adc->CMD = ADC_CMD_SINGLESTOP | ADC_CMD_SCANSTOP;
  tmp = ((uint32_t)(init->ovsRateSel) << _ADC_CTRL_OVSRSEL_SHIFT) |
        (((uint32_t)(init->timebase) << _ADC_CTRL_TIMEBASE_SHIFT) & _ADC_CTRL_TIMEBASE_MASK) |
        (((uint32_t)(init->prescale) << _ADC_CTRL_PRESC_SHIFT) & _ADC_CTRL_PRESC_MASK) |
        ((uint32_t)(init->lpfMode) << _ADC_CTRL_LPFMODE_SHIFT) |
        ((uint32_t)(init->warmUpMode) << _ADC_CTRL_WARMUPMODE_SHIFT);
  if (init->tailgate)
  {
    tmp |= ADC_CTRL_TAILGATE;
  }
  adc->CTRL = tmp;
}