/* SPI Data Write and Read Exchange. 
Data is written to the SPI interface, then a read is done after the incoming transfer has finished. */
uint16_t spi_xfer(uint32_t spi, uint16_t data)
/* SPI Data Write and Read Exchange. 
Data is written to the SPI interface, then a read is done after the incoming transfer has finished. */
uint16_t spi_xfer(uint32_t spi, uint16_t data)
{
	spi_write(spi, data);
	while (!(SPI_SR(spi) & SPI_SR_RXNE));
	return SPI_DR(spi);
}