/* 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 == xADC0_BASE);
    xASSERT((ulMode == xADC_MODE_SCAN_SINGLE_CYCLE) ||
            (ulMode == xADC_MODE_SCAN_CONTINUOUS)
           );
    xASSERT((ulTrigger == xADC_TRIGGER_PROCESSOR) || 
            (ulTrigger == xADC_TRIGGER_EXT_PIN));
    xHWREG(ulBase + ADC0_SC3) &= ~ADC0_SC3_ADCO;  
    xHWREG(ulBase + ADC0_SC3) |= ulMode;
    if(ulTrigger == xADC_TRIGGER_EXT_PIN)
    {
        xHWREG(SIM_SOPT7) &= ~SIM_SOPT7_ADC0TRGSEL_M;   
    }
    else
    {
        xHWREG(ulBase + ADC0_SC2) &= ~ADC0_SC2_ADTRG_HARD;
    } 
}