/* Get the captured data for a sample sequence.  */
unsigned long xADCDataGet(unsigned long ulBase, unsigned long *pulBuffer)
/* Get the captured data for a sample sequence.  */
unsigned long xADCDataGet(unsigned long ulBase, unsigned long *pulBuffer)
{
    unsigned long i;
    unsigned long ulEnableChannels;
    unsigned long ulValid;
    unsigned long ulWrite;
    xASSERT(ulBase == ADC_BASE);
    xASSERT(pulBuffer != 0);
    ulEnableChannels = (xHWREG(ulBase + ADC_CHER) & ADC_CHER_CHEN_M) >> 
                       ADC_CHER_CHEN_S;
    ulValid = (xHWREG(ulBase + ADC_SR) & ADC_SR_VALID) >> 8;
    if(ulValid == 0)
    {
        return 0;
    }
    ulWrite = 0;
    for(i = 0; i < 8; i++)
    {
        if(ulEnableChannels & (1 << i))
        {
            pulBuffer[ulWrite++] = xHWREG(ulBase + ADC_DR0 + (4 * i));
            break;
        }
    }
    return ulWrite;
}