/* Reads last received SPI character. 
This function will return the last SPI character shifted into the receive register by the  */
enum status_code spi_read(struct spi_module *const module, uint8_t *rx_data)
/* Reads last received SPI character. 
This function will return the last SPI character shifted into the receive register by the  */
enum status_code spi_read(struct spi_module *const module, uint8_t *rx_data)
{
	Assert(module);
	Assert(module->hw);
	Spi *const spi_module = (module->hw);
	if (!_spi_is_ready_to_read(spi_module)) {
		return STATUS_ERR_IO;
	}
	enum status_code retval = STATUS_OK;
	if (spi_module->RECEIVE_STATUS.bit.FIFO_OVERRUN) {
		retval = STATUS_ERR_OVERFLOW;
	}
	*rx_data = ((uint8_t)spi_module->RECEIVE_DATA.reg & SPI_RECEIVE_DATA_MASK);
	return retval;
}