esp_lcd_panel_rgb.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdbool.h>
  8. #include "esp_err.h"
  9. #include "esp_lcd_types.h"
  10. #include "soc/soc_caps.h"
  11. #include "hal/lcd_types.h"
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #if SOC_LCD_RGB_SUPPORTED
  16. /**
  17. * @brief LCD RGB timing structure
  18. *
  19. * Total Width
  20. * <--------------------------------------------------->
  21. * Hsync width HBP Active Width HFP
  22. * <---><--><--------------------------------------><--->
  23. * ____ ____|_______________________________________|____|
  24. * |___| | | |
  25. * | | |
  26. * __| | | |
  27. * /|\ /|\ | | | |
  28. * | VSYNC| | | | |
  29. * |Width\|/ |__ | | |
  30. * | /|\ | | | |
  31. * | VBP | | | | |
  32. * | \|/_____|_________|_______________________________________| |
  33. * | /|\ | | / / / / / / / / / / / / / / / / / / / | |
  34. * | | | |/ / / / / / / / / / / / / / / / / / / /| |
  35. * Total | | | |/ / / / / / / / / / / / / / / / / / / /| |
  36. * Heigh | | | |/ / / / / / / / / / / / / / / / / / / /| |
  37. * |Active| | |/ / / / / / / / / / / / / / / / / / / /| |
  38. * |Heigh | | |/ / / / / / Active Display Area / / / /| |
  39. * | | | |/ / / / / / / / / / / / / / / / / / / /| |
  40. * | | | |/ / / / / / / / / / / / / / / / / / / /| |
  41. * | | | |/ / / / / / / / / / / / / / / / / / / /| |
  42. * | | | |/ / / / / / / / / / / / / / / / / / / /| |
  43. * | | | |/ / / / / / / / / / / / / / / / / / / /| |
  44. * | \|/_____|_________|_______________________________________| |
  45. * | /|\ | |
  46. * | VFP | | |
  47. * \|/ \|/_____|______________________________________________________|
  48. *
  49. */
  50. typedef struct {
  51. unsigned int pclk_hz; /*!< Frequency of pixel clock */
  52. unsigned int h_res; /*!< Horizontal resolution, i.e. the number of pixels in a line */
  53. unsigned int v_res; /*!< Vertical resolution, i.e. the number of lines in the frame */
  54. unsigned int hsync_pulse_width; /*!< Horizontal sync width, unit: PCLK period */
  55. unsigned int hsync_back_porch; /*!< Horizontal back porch, number of PCLK between hsync and start of line active data */
  56. unsigned int hsync_front_porch; /*!< Horizontal front porch, number of PCLK between the end of active data and the next hsync */
  57. unsigned int vsync_pulse_width; /*!< Vertical sync width, unit: number of lines */
  58. unsigned int vsync_back_porch; /*!< Vertical back porch, number of invalid lines between vsync and start of frame */
  59. unsigned int vsync_front_porch; /*!< Vertical front porch, number of invalid lines between then end of frame and the next vsync */
  60. struct {
  61. unsigned int hsync_idle_low: 1; /*!< The hsync signal is low in IDLE state */
  62. unsigned int vsync_idle_low: 1; /*!< The vsync signal is low in IDLE state */
  63. unsigned int de_idle_high: 1; /*!< The de signal is high in IDLE state */
  64. unsigned int pclk_active_neg: 1; /*!< The display will write data lines when there's a falling edge on PCLK */
  65. unsigned int pclk_idle_low: 1; /*!< The PCLK stays at low level in IDLE phase */
  66. } flags;
  67. } esp_lcd_rgb_timing_t;
  68. /**
  69. * @brief Type of RGB LCD panel event data
  70. */
  71. typedef struct {
  72. } esp_lcd_rgb_panel_event_data_t;
  73. /**
  74. * @brief Declare the prototype of the function that will be invoked when panel IO finishes transferring color data
  75. *
  76. * @param[in] panel LCD panel handle, returned from `esp_lcd_new_rgb_panel`
  77. * @param[in] edata Panel event data, fed by driver
  78. * @param[in] user_ctx User data, passed from `esp_lcd_rgb_panel_config_t`
  79. * @return Whether a high priority task has been waken up by this function
  80. */
  81. typedef bool (*esp_lcd_rgb_panel_frame_trans_done_cb_t)(esp_lcd_panel_handle_t panel, esp_lcd_rgb_panel_event_data_t *edata, void *user_ctx);
  82. /**
  83. * @brief LCD RGB panel configuration structure
  84. */
  85. typedef struct {
  86. lcd_clock_source_t clk_src; /*!< Clock source for the RGB LCD peripheral */
  87. esp_lcd_rgb_timing_t timings; /*!< RGB timing parameters */
  88. size_t data_width; /*!< Number of data lines */
  89. int hsync_gpio_num; /*!< GPIO used for HSYNC signal */
  90. int vsync_gpio_num; /*!< GPIO used for VSYNC signal */
  91. int de_gpio_num; /*!< GPIO used for DE signal, set to -1 if it's not used */
  92. int pclk_gpio_num; /*!< GPIO used for PCLK signal */
  93. int data_gpio_nums[SOC_LCD_RGB_DATA_WIDTH]; /*!< GPIOs used for data lines */
  94. int disp_gpio_num; /*!< GPIO used for display control signal, set to -1 if it's not used */
  95. esp_lcd_rgb_panel_frame_trans_done_cb_t on_frame_trans_done; /*!< Callback invoked when one frame buffer has transferred done */
  96. void *user_ctx; /*!< User data which would be passed to on_frame_trans_done's user_ctx */
  97. struct {
  98. unsigned int disp_active_low: 1; /*!< If this flag is enabled, a low level of display control signal can turn the screen on; vice versa */
  99. unsigned int relax_on_idle: 1; /*!< If this flag is enabled, the host won't refresh the LCD if nothing changed in host's frame buffer (this is usefull for LCD with built-in GRAM) */
  100. unsigned int fb_in_psram: 1; /*!< If this flag is enabled, the frame buffer will be allocated from PSRAM preferentially */
  101. } flags;
  102. } esp_lcd_rgb_panel_config_t;
  103. /**
  104. * @brief Create RGB LCD panel
  105. *
  106. * @param rgb_panel_config RGB panel configuration
  107. * @param ret_panel Returned LCD panel handle
  108. * @return
  109. * - ESP_ERR_INVALID_ARG if parameter is invalid
  110. * - ESP_ERR_NO_MEM if out of memory
  111. * - ESP_ERR_NOT_FOUND if no free RGB panel is available
  112. * - ESP_OK on success
  113. */
  114. esp_err_t esp_lcd_new_rgb_panel(const esp_lcd_rgb_panel_config_t *rgb_panel_config, esp_lcd_panel_handle_t *ret_panel);
  115. #endif // SOC_LCD_RGB_SUPPORTED
  116. #ifdef __cplusplus
  117. }
  118. #endif