1============================= 2ILI9341 LCD Controller driver 3============================= 4 5Overview 6-------- 7 8The `ILI9341 <https://www.buydisplay.com/download/ic/ILI9341.pdf>`__ is a 262,144-color single-chip SOC driver for a-TFT liquid crystal display with resolution of 240RGBx320 9dots, comprising a 720-channel source driver, a 320-channel gate driver, 172,800 bytes GRAM for graphic 10display data of 240RGBx320 dots, and power supply circuit. 11ILI9341 supports parallel 8-/9-/16-/18-bit data bus MCU interface, 6-/16-/18-bit data bus RGB interface and 123-/4-line serial peripheral interface (SPI). 13 14The ILI9341 LCD controller `driver <https://github.com/lvgl/lvgl/src/drivers/display/ili9341>`__ is a platform-agnostic driver, based on the `generic MIPI driver <https://github.com/lvgl/lvgl/doc/integration/drivers/display/gen_mipi.rst>`__. 15It implements display initialization, supports display rotation and implements the display flush callback. The user needs to implement only two platform-specific functions to send 16a command or pixel data to the controller via SPI or parallel bus. Typically these are implemented by calling the appropriate SDK library functions on the given platform. 17 18Prerequisites 19------------- 20 21There are no prerequisites. 22 23Configuring the driver 24---------------------- 25 26Enable the ILI9341 driver support in lv_conf.h, by cmake compiler define or by KConfig 27 28.. code-block:: c 29 30 #define LV_USE_ILI9341 1 31 32Usage 33----- 34 35You need to implement two platform-dependent functions: 36 37.. code-block:: c 38 39 /* Send short command to the LCD. This function shall wait until the transaction finishes. */ 40 int32_t my_lcd_send_cmd(lv_display_t *disp, const uint8_t *cmd, size_t cmd_size, const uint8_t *param, size_t param_size) 41 { 42 ... 43 } 44 45 /* Send large array of pixel data to the LCD. If necessary, this function has to do the byte-swapping. This function can do the transfer in the background. */ 46 int32_t my_lcd_send_color(lv_display_t *disp, const uint8_t *cmd, size_t cmd_size, uint8_t *param, size_t param_size) 47 { 48 ... 49 } 50 51To create an ILI9341-based display use the function 52 53.. code-block:: c 54 55 /** 56 * Create an LCD display with ILI9341 driver 57 * @param hor_res horizontal resolution 58 * @param ver_res vertical resolution 59 * @param flags default configuration settings (mirror, RGB ordering, etc.) 60 * @param send_cmd platform-dependent function to send a command to the LCD controller (usually uses polling transfer) 61 * @param send_color platform-dependent function to send pixel data to the LCD controller (usually uses DMA transfer: must implement a 'ready' callback) 62 * @return pointer to the created display 63 */ 64 lv_display_t * lv_ili9341_create(uint32_t hor_res, uint32_t ver_res, lv_lcd_flag_t flags, 65 lv_ili9341_send_cmd_cb_t send_cmd_cb, lv_ili9341_send_color_cb_t send_color_cb); 66 67 68For additional details and a working example see the `generic MIPI driver documentation <https://github.com/lvgl/lvgl/doc/integration/drivers/display/gen_mipi.rst>`__. 69 70.. note:: 71 72 You can find a step-by-step guide and the actual implementation of the callbacks on an STM32F746 using STM32CubeIDE and the ST HAL libraries here: :ref:`lcd_stm32_guide` 73 74