/* Read and write a data element from and to the SPI interface.  */
unsigned long SPISingleDataReadWrite(unsigned long ulBase, unsigned long ulWData)
/* Read and write a data element from and to the SPI interface.  */
unsigned long SPISingleDataReadWrite(unsigned long ulBase, unsigned long ulWData)
{
    unsigned long ulFlag, ulReadTemp;
    xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE));
    ulFlag = xHWREG(ulBase + SPI_FCR) & SPI_FCR_FIFOEN;
    if(ulFlag != SPI_FCR_FIFOEN)
    {
        while(!(xHWREG(ulBase + SPI_SR) & SPI_SR_TXE))
        {
        }
    }
    else
    {
        while(!(xHWREG(ulBase + SPI_SR) & SPI_SR_TXBE))
        {
        }
    }
    xHWREG(ulBase + SPI_DR) = ulWData;
    while(!(xHWREG(ulBase + SPI_SR) & SPI_SR_RXBNE))
    {
    }
    ulReadTemp = xHWREG(ulBase + SPI_DR);
    return ulReadTemp;
}