/* Reads and returns the last word of data received by a SPI peripheral. This method must be called after a successful SPI_Write call.  */
unsigned short SPI_Read(AT91S_SPI *spi)
/* Reads and returns the last word of data received by a SPI peripheral. This method must be called after a successful SPI_Write call.  */
unsigned short SPI_Read(AT91S_SPI *spi)
{
    while ((spi->SPI_SR & AT91C_SPI_RDRF) == 0);
    return spi->SPI_RDR & 0xFFFF;
}