/* Get the captured data for the ADC sample channel.  */
unsigned long ADCDataGet(unsigned long ulBase, unsigned long ulChannel)
/* Get the captured data for the ADC sample channel.  */
unsigned long ADCDataGet(unsigned long ulBase, unsigned long ulChannel)
{
    unsigned long ulData;
    unsigned long ulCRReg;
    xASSERT(ulBase == ADC0_BASE);
    xASSERT((ulChannel >= 0) && (ulChannel < 8));
    ulData = xHWREG(ulBase + ADC_DR0 + (ulChannel * 4));
    ulCRReg = xHWREG(ulBase + ADC_CR);
    if(ulCRReg & ADC_CR_DIFFEN)
    {
        if(ulCRReg & ADC_CR_DMOF)    
        {
            if (ulData & 0x8000)    
            {
                return (ulData | 0xFFFF0000);
            }
            else
            {
                return (ulData & 0xFFF);
            }
        }
        else
        {
            return (ulData & 0xFFF);
        }
    }
    else
    {
        return (ulData & 0xFFF);
    }
}