/* 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 == ADC0_BASE);
    xASSERT(pulBuffer != 0);
    ulEnableChannels = (xHWREG(ulBase + ADC_CHEN) & ADC_CHEN_CHEN_M) >>
                       ADC_CHEN_CHEN_S;
    ulValid = (xHWREG(ulBase + ADC_STATUS1) & ADC_STATUS1_VALID_M) >> ADC_STATUS1_VALID_S;
    if(ulEnableChannels ^ ulValid)
    {
        return 0;
    }
    ulWrite = 0;
    for(i = 0; i < 8; i++)
    {
        if(ulEnableChannels & (1 << i))
        {
            pulBuffer[ulWrite++] = xHWREG(ulBase + ADC_DR0 + (4 * i));
        }
    }
    return ulWrite;
}