/* This API configures ADC module to be ready for convert the input from selected channel.  */
void ADC_Open(ADC_T *adc, uint32_t u32InputMode, uint32_t u32OpMode, uint32_t u32ChMask)
/* This API configures ADC module to be ready for convert the input from selected channel.  */
void ADC_Open(ADC_T *adc, uint32_t u32InputMode, uint32_t u32OpMode, uint32_t u32ChMask)
{
    if ((adc->ADCALSTSR & ADC_ADCALSTSR_CALIF_Msk) == 0)
    {
        adc->ADCR |= ADC_ADCR_RESET_Msk;
        while((adc->ADCR & ADC_ADCR_RESET_Msk) == ADC_ADCR_RESET_Msk);
        adc->ADCALSTSR |= ADC_ADCALSTSR_CALIF_Msk;
        adc->ADCALR |= ADC_ADCALR_CALEN_Msk;
        ADC_START_CONV(adc);
        while((adc->ADCALSTSR & ADC_ADCALSTSR_CALIF_Msk) != ADC_ADCALSTSR_CALIF_Msk);
    }
    adc->ADCR = (adc->ADCR & (~(ADC_ADCR_DIFFEN_Msk | ADC_ADCR_ADMD_Msk))) | \
                (u32InputMode) | \
                (u32OpMode);
    adc->ADCHER = (adc->ADCHER & ~ADC_ADCHER_CHEN_Msk) | (u32ChMask);
    return;
}