esp_lcd_ili9341.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file
  8. * @brief ESP LCD: ILI9341
  9. */
  10. #pragma once
  11. #include "esp_lcd_panel_vendor.h"
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /**
  16. * @brief LCD panel initialization commands.
  17. *
  18. */
  19. typedef struct {
  20. int cmd; /*<! The specific LCD command */
  21. const void *data; /*<! Buffer that holds the command specific data */
  22. size_t data_bytes; /*<! Size of `data` in memory, in bytes */
  23. unsigned int delay_ms; /*<! Delay in milliseconds after this command */
  24. } ili9341_lcd_init_cmd_t;
  25. /**
  26. * @brief LCD panel vendor configuration.
  27. *
  28. * @note This structure needs to be passed to the `vendor_config` field in `esp_lcd_panel_dev_config_t`.
  29. *
  30. */
  31. typedef struct {
  32. const ili9341_lcd_init_cmd_t *init_cmds; /*!< Pointer to initialization commands array. Set to NULL if using default commands.
  33. * The array should be declared as `static const` and positioned outside the function.
  34. * Please refer to `vendor_specific_init_default` in source file.
  35. */
  36. uint16_t init_cmds_size; /*<! Number of commands in above array */
  37. } ili9341_vendor_config_t;
  38. /**
  39. * @brief Create LCD panel for model ILI9341
  40. *
  41. * @note Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for initialization sequence code.
  42. *
  43. * @param[in] io LCD panel IO handle
  44. * @param[in] panel_dev_config general panel device configuration
  45. * @param[out] ret_panel Returned LCD panel handle
  46. * @return
  47. * - ESP_ERR_INVALID_ARG if parameter is invalid
  48. * - ESP_ERR_NO_MEM if out of memory
  49. * - ESP_OK on success
  50. */
  51. esp_err_t esp_lcd_new_panel_ili9341(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel);
  52. /**
  53. * @brief LCD panel bus configuration structure
  54. *
  55. * @param[in] sclk SPI clock pin number
  56. * @param[in] mosi SPI MOSI pin number
  57. * @param[in] max_trans_sz Maximum transfer size in bytes
  58. *
  59. */
  60. #define ILI9341_PANEL_BUS_SPI_CONFIG(sclk, mosi, max_trans_sz) \
  61. { \
  62. .sclk_io_num = sclk, \
  63. .mosi_io_num = mosi, \
  64. .miso_io_num = -1, \
  65. .quadhd_io_num = -1, \
  66. .quadwp_io_num = -1, \
  67. .max_transfer_sz = max_trans_sz, \
  68. }
  69. /**
  70. * @brief LCD panel IO configuration structure
  71. *
  72. * @param[in] cs SPI chip select pin number
  73. * @param[in] dc SPI data/command pin number
  74. * @param[in] cb Callback function when SPI transfer is done
  75. * @param[in] cb_ctx Callback function context
  76. *
  77. */
  78. #define ILI9341_PANEL_IO_SPI_CONFIG(cs, dc, callback, callback_ctx) \
  79. { \
  80. .cs_gpio_num = cs, \
  81. .dc_gpio_num = dc, \
  82. .spi_mode = 0, \
  83. .pclk_hz = 40 * 1000 * 1000, \
  84. .trans_queue_depth = 10, \
  85. .on_color_trans_done = callback, \
  86. .user_ctx = callback_ctx, \
  87. .lcd_cmd_bits = 8, \
  88. .lcd_param_bits = 8, \
  89. }
  90. #ifdef __cplusplus
  91. }
  92. #endif