47 #include <util/delay.h> 91 #if defined(CONF_ILI9341_USART_SPI) 92 while (!usart_tx_is_complete(CONF_ILI9341_USART_SPI))
96 usart_clear_tx_complete(CONF_ILI9341_USART_SPI);
97 #elif defined(CONF_ILI9341_SPI) 118 #if defined(CONF_ILI9341_USART_SPI) 119 while (!usart_data_register_is_empty(CONF_ILI9341_USART_SPI))
124 irqflags_t flags = cpu_irq_save();
125 usart_clear_tx_complete(CONF_ILI9341_USART_SPI);
126 usart_put(CONF_ILI9341_USART_SPI, data);
127 cpu_irq_restore(flags);
128 #elif defined(CONF_ILI9341_SPI) 150 #if defined(CONF_ILI9341_USART_SPI) 152 usart_rx_enable(CONF_ILI9341_USART_SPI);
154 usart_put(CONF_ILI9341_USART_SPI, 0xFF);
155 while (!usart_rx_is_complete(CONF_ILI9341_USART_SPI))
159 data = usart_get(CONF_ILI9341_USART_SPI);
162 usart_rx_disable(CONF_ILI9341_USART_SPI);
163 #elif defined(CONF_ILI9341_SPI) 216 if ( send_end_limits )
227 if ( send_end_limits )
280 limit_start_x = start_x;
281 limit_start_y = start_y;
305 uint8_t red, green, blue;
338 Assert(
sizeof(color) == 2 );
371 #if defined(ILI9341_DMA_ENABLED) 379 chunk_len = min(ILI9341_DMA_CHUNK_SIZE, count);
384 for (uint32_t i = 0; i < chunk_len; i++)
386 chunk_buf[i] = le16_to_cpu(pixel[i]);
437 color = PROGMEM_READ_WORD(pixels);
505 uint8_t red, green, blue;
540 #if defined(CONF_ILI9341_USART_SPI) || defined(CONF_ILI9341_SPI) 542 board_spi_select_id_t spi_select_id = 0;
544 #error Interface for ILI9341 has not been selected or interface not supported, please configure component driver using the ili9341.h file! 547 #if defined(CONF_ILI9341_USART_SPI) 548 struct usart_spi_device device =
553 usart_spi_init(CONF_ILI9341_USART_SPI);
556 #elif defined(CONF_ILI9341_SPI) 709 uint8_t madctl = 0x48;
static __always_inline void ili9341_select_chip(void)
Helper function to select the CS of the controller on the bus.
static bool spi_is_rx_full(SPI_t *spi)
Tests if the SPI contains a received character.
static void ili9341_reset_display(void)
Reset the display using the digital control interface.
void ili9341_write_gram(ili9341_color_t color)
Write the graphical memory with a single color pixel.
static __always_inline void ili9341_send_byte(uint8_t data)
Helper function to send a byte over an arbitrary interface.
static __always_inline void ili9341_select_data_mode(void)
Helper function to select data byte transmission mode.
Polled SPI device definition.
#define CONF_ILI9341_CS_PIN
Define what MCU pin the ILI9341 chip select pin is connected to.
#define ILI9341_SWITCH_XY
port_pin_t id
Board specific select id.
#define Assert(expr)
This macro is used to test fatal errors.
static void spi_read_single(SPI_t *spi, uint8_t *data)
Receive one byte from a SPI device.
void ili9341_set_orientation(uint8_t flags)
Sets the orientation of the display data.
void spi_master_setup_device(SPI_t *spi, struct spi_device *device, spi_flags_t flags, uint32_t baud_rate, board_spi_select_id_t sel_id)
Setup a SPI device.
void spi_master_init(SPI_t *spi)
Initializes the SPI in master mode.
void ili9341_init(void)
Initialise the controller.
static __always_inline void ili9341_select_command_mode(void)
Helper function to select command byte transmission mode.
void ili9341_set_limits(ili9341_coord_t start_x, ili9341_coord_t start_y, ili9341_coord_t end_x, ili9341_coord_t end_y)
Set the full display drawing limits.
#define SPI_MODE_0
SPI mode 0.
void IO_SetPinHigh(PORT_t *port, uint8_t pinMask)
This function sets a bit in the OUT register of an I/O port or virtual port.
#define ILI9341_DEFAULT_HEIGHT
static void ili9341_interface_init(void)
Initialize the hardware interface to the controller.
IL9341 Display Controller Register und Bitfield Definitionen aus dem ASF 3.26.0.
static void spi_enable(SPI_t *spi)
Enables the SPI.
void ili9341_copy_progmem_pixels_to_screen(ili9341_color_t PROGMEM_PTR_T pixels, uint32_t count, uint8_t swap)
Copy pixels from progmem to the screen.
static __always_inline uint8_t ili9341_read_byte(void)
Helper function to read a byte from an arbitrary interface.
void IO_SetPinLow(PORT_t *port, uint8_t pinMask)
This function clears a bit in the OUT register of an I/O port or virtual port.
#define ILI9341_DEFAULT_WIDTH
static __always_inline void ili9341_wait_for_send_done(void)
Helper function to wait for the last send operation to complete.
static __always_inline void ili9341_deselect_chip(void)
Helper function to de-select the CS of the controller on the bus.
void ili9341_set_top_left_limit(ili9341_coord_t x, ili9341_coord_t y)
Set the display top left drawing limit.
void ili9341_copy_pixels_to_screen(const ili9341_color_t *pixels, uint32_t count)
Copy pixels from SRAM to the screen.
static void ili9341_send_command(uint8_t command)
Sends a command to the controller, and prepares for parameter transfer.
#define CONF_ILI9341_CLOCK_SPEED
Select the correct hardware interface.
static __always_inline void spi_write_single(SPI_t *spi, uint8_t data)
Write one byte to a SPI device.
#define CONF_ILI9341_RESET_PIN
Define what MCU pin the ILI9341 back light pin is connected to.
ILI9341 Display Controller Component Driver aus dem ASF 3.26.0.
#define ILI9341_COLOR(r, g, b)
void ili9341_duplicate_pixel(const ili9341_color_t color, uint32_t count)
Set a given number of pixels to the same color.
ili9341_color_t ili9341_read_gram(void)
Read a single color from the graphical memory.
static void ili9341_controller_init_registers(void)
Initialize all the display registers.
static void ili9341_exit_standby(void)
Send display commands to exit standby mode.
static bool spi_is_tx_empty(SPI_t *spi)
Checks if all transmissions are complete.
static void ili9341_send_draw_limits(const bool send_end_limits)
Helper function to send the drawing limits (boundaries) to the display.
void ili9341_copy_pixels_from_screen(ili9341_color_t *pixels, uint32_t count)
Copy pixels from the screen to a pixel buffer.
#define CONF_ILI9341_DC_PIN
Define what MCU pin the ILI9341 DC pin is connected to.
void ili9341_set_bottom_right_limit(ili9341_coord_t x, ili9341_coord_t y)
Set the display bottom right drawing limit.
#define __always_inline
The function should always be inlined.