/* Configure the mode and trigger source of a sample sequence.  */
void xADCConfigure(unsigned long ulBase, unsigned long ulMode, unsigned long ulTrigger)
/* Configure the mode and trigger source of a sample sequence.  */
void xADCConfigure(unsigned long ulBase, unsigned long ulMode, unsigned long ulTrigger)
{
    xASSERT(ulBase == xADC1_BASE || ulBase == xADC2_BASE);
    xASSERT((ulMode == xADC_MODE_SCAN_SINGLE_CYCLE) ||
            (ulMode == xADC_MODE_SCAN_CONTINUOUS)
           );
    xASSERT((ulTrigger == xADC_TRIGGER_PROCESSOR) || 
            (ulTrigger == xADC_TRIGGER_EXT_INT11)             
           );
    if(ulMode == xADC_MODE_SCAN_SINGLE_CYCLE)
    {
        xHWREG(ulBase + ADC_CR1) |= xADC_MODE_SCAN_SINGLE_CYCLE;
    }
    else
    {
        xHWREG(ulBase + ADC_CR2) &= ~xADC_MODE_SCAN_CONTINUOUS; 
        xHWREG(ulBase + ADC_CR2) |= xADC_MODE_SCAN_CONTINUOUS;        
    }
    xHWREG(ulBase + ADC_CR2) &= ~xADC_TRIGGER_PROCESSOR;
    xHWREG(ulBase + ADC_CR2) |= ulTrigger;
}