/**
 * \internal
 * \brief Helper function to send a byte over an arbitrary interface
 *
 * This function is used to hide what interface is used by the driver, e.g.
 * the driver does not need to know if USART in SPI mode is used or the native
 * SPI module.
 *
 * \param data the byte to be transfered
 */
__always_inline static void hx8347a_send_byte(uint8_t data)
{
#if defined(CONF_HX8347A_USART_SPI)

	/* A workaround for optimizing data transfer had to be done for the
	 * XMEGA in order for the display to work correctly at all SPI clock
	 * clock speeds */

#  if UC3
	usart_spi_write_packet(CONF_HX8347A_USART_SPI, &data, 1);

#  elif XMEGA
	usart_spi_write_single(CONF_HX8347A_USART_SPI, data);

#  endif

#elif defined(CONF_HX8347A_SPI)
	spi_write_single(CONF_HX8347A_SPI, data);

	/* Wait for TX to complete */
	while (!spi_is_tx_ok(CONF_HX8347A_SPI)) {
		/* Do nothing */
	}
#endif
}
Example #2
0
char SPI_L(char TX_Data) 
{	
/* Send pattern. */
	spi_put(&NRF24L01_L_SPI,TX_Data);

	/* Wait for transmission complete. */
	while(!(spi_is_tx_ok(&NRF24L01_L_SPI)));
	/* Read received data. */
	uint8_t result = spi_get(&NRF24L01_L_SPI);

	return(result);
}