-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesp_lcd_ra8876.h
118 lines (106 loc) · 5.24 KB
/
esp_lcd_ra8876.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*-
* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 2023 Daniel Austin <me@dan.me.uk>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#pragma once
#include "esp_lcd_panel_interface.h"
#include "esp_lcd_panel_io.h"
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lcd_panel_commands.h"
#include "driver/gpio.h"
#include "ra8876_registers.h"
#include "sdkconfig.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef CONFIG_RA8876_PANEL_CUSTOM
#define RA8876_OSC_FREQ CONFIG_RA8876_OSC_FREQ /*!< crystal clock (MHz) */
#define RA8876_DRAM_FREQ CONFIG_RA8876_DRAM_FREQ /*!< SDRAM clock frequency (MHz) */
#define RA8876_CORE_FREQ CONFIG_RA8876_CORE_FREQ /*!< core (system) clock frequency (MHz) */
#define RA8876_SCAN_FREQ CONFIG_RA8876_SCAN_FREQ /*!< pixel scan clock frequency (MHz) */
#define RA8876_PANEL_HNDR CONFIG_RA8876_HNDR /*!< horizontal non-display period or back porch */
#define RA8876_PANEL_HSTR CONFIG_RA8876_HSTR /*!< horizontal start position or front porch */
#define RA8876_PANEL_HPWR CONFIG_RA8876_HPWR /*!< HSYNC pulse width */
#define RA8876_PANEL_VNDR CONFIG_RA8876_VNDR /*!< vertical non-display period */
#define RA8876_PANEL_VSTR CONFIG_RA8876_VSTR /*!< vertical start position */
#define RA8876_PANEL_VPWR CONFIG_RA8876_VPWR /*!< VSYNC pulse width */
#endif
/* pre-defined panel definitions here (also add to Kconfig file) */
#ifdef CONFIG_RA8876_PANEL_ER_TFTM070_6
#define RA8876_OSC_FREQ 10 /*!< crystal clock (MHz) */
#define RA8876_DRAM_FREQ 100 /*!< SDRAM clock frequency (MHz) */
#define RA8876_CORE_FREQ 100 /*!< core (system) clock frequency (MHz) */
#define RA8876_SCAN_FREQ 50 /*!< pixel scan clock frequency (MHz) */
#define RA8876_PANEL_HNDR 160 /*!< horizontal non-display period or back porch */
#define RA8876_PANEL_HSTR 160 /*!< horizontal start position or front porch */
#define RA8876_PANEL_HPWR 70 /*!< HSYNC pulse width */
#define RA8876_PANEL_VNDR 23 /*!< vertical non-display period */
#define RA8876_PANEL_VSTR 12 /*!< vertical start position */
#define RA8876_PANEL_VPWR 10 /*!< VSYNC pulse width */
#endif
#define RA8876_PLL_DIV_2 0x02 /*!< PLL divided by 2 */
#define RA8876_PLL_DIV_4 0x04 /*!< PLL divided by 4 */
#define RA8876_PLL_DIV_8 0x06 /*!< PLL divided by 8 */
#define RA8876_PLL_DIV_16 0x16 /*!< PLL divided by 16 */
#define RA8876_PLL_DIV_32 0x26 /*!< PLL divided by 32 */
#define RA8876_PLL_DIV_64 0x36 /*!< PLL divided by 64 */
/**
* @brief Vendor specific configuration structure for panel device
*/
typedef struct {
gpio_num_t wait_gpio_num; /*!< GPIO used to indicate busy state of the LCD panel, set to GPIO_NUM_NC if it's not used */
uint16_t lcd_width; /*!< Width of the LCD panel in pixels */
uint16_t lcd_height; /*!< Height of the LCD panel in pixels */
int mcu_bit_interface; /*!< Selection between 8-bit and 16-bit MCU interface */
} esp_lcd_panel_ra8876_config_t;
/**
* @brief Create LCD panel for model RA8876/LT768x
*
* @param[in] io LCD panel IO handle
* @param[in] panel_dev_config general panel device configuration
* @param[out] ret_panel Returned LCD panel handle
* @return
* - ESP_ERR_INVALID_ARG if parameter is invalid
* - ESP_ERR_NO_MEM if out of memory
* - ESP_OK on success
*/
esp_err_t esp_lcd_new_panel_ra8876(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);
/**
* @brief Update LCD panel backlight via RA8876/LT768x PWM
*
* @param[in] LCD panel handle
* @param[in] backlight level (%)
* @return
* - ESP_OK on success
*/
esp_err_t esp_lcd_panel_set_backlight(esp_lcd_panel_t *panel, uint8_t level);
#ifdef __cplusplus
}
#endif