esp_lcd_gc9d01n.h 4.1 KB

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