/* Get the captured data from a sample sequence.  */
unsigned long ADCDataGet(unsigned long ulBase, unsigned long *pulBuffer)
/* Get the captured data from a sample sequence.  */
unsigned long ADCDataGet(unsigned long ulBase, unsigned long *pulBuffer)
{
    unsigned long i, j;
    unsigned long ulSeqLen,ulChannelNo[16];
    unsigned long ulWrite;
    xASSERT(ulBase == ADC_BASE);
    xASSERT(pulBuffer != 0);
    ulSeqLen = ((xHWREG(ulBase + ADC_CONV) & ADC_CONV_SEQL_M) >> ADC_CONV_SEQL_S) + 1;
    for(i = 0; i < ulSeqLen; i++)
    {
        ulChannelNo[i] = (xHWREG(ulBase + ADC_LST0 + (i/4)*4) & (0x07<<(8*(i%4))))
                                                                      >> (8*(i%4));
    }
    ulWrite = 0;
    for(j = 0; j < ulSeqLen; j++)
    {
        while(!ADCIntStatus(ADC_BASE, ADC_INT_END_CONVERSION));
        pulBuffer[ulWrite++] = xHWREG(ulBase + ADC_DR0 + ulChannelNo[j]*4) 
                                                                & ADC_DR0_ADD0_M;
    }
    return ulWrite;
}