예제 #1
0
/**
 * \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
}
/**
 * \internal
 * \brief Helper function to send a byte over an arbitrary interface
 *
 * This function is used to hide what interface is used by the component
 * driver, e.g.  the component 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 ili9341_send_byte(uint8_t data)
{
#if defined(CONF_ILI9341_USART_SPI)
#  if XMEGA
	while (!usart_data_register_is_empty(CONF_ILI9341_USART_SPI)) {
		/* Do nothing */
	}

	irqflags_t flags = cpu_irq_save();
	usart_clear_tx_complete(CONF_ILI9341_USART_SPI);
	usart_put(CONF_ILI9341_USART_SPI, data);
	cpu_irq_restore(flags);
#  else
	usart_spi_write_single(CONF_ILI9341_USART_SPI, data);
#  endif
#elif defined(CONF_ILI9341_SPI)
	/* Wait for any previously running send data */
	ili9341_wait_for_send_done();

	spi_write_single(CONF_ILI9341_SPI, data);
#endif
}