-
Notifications
You must be signed in to change notification settings - Fork 0
/
esp_lcd_axs15231b.h
197 lines (181 loc) · 8.54 KB
/
esp_lcd_axs15231b.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief ESP LCD & Touch: AXS15231B
*/
#pragma once
#include "hal/spi_ll.h"
#include "esp_lcd_touch.h"
#include "esp_lcd_panel_vendor.h"
#define ESP_LCD_AXS15231B_VER_MAJOR (1)
#define ESP_LCD_AXS15231B_VER_MINOR (0)
#define ESP_LCD_AXS15231B_VER_PATCH (0)
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief LCD panel initialization commands.
*
*/
typedef struct {
int cmd; /*<! The specific LCD command */
const void *data; /*<! Buffer that holds the command specific data */
size_t data_bytes; /*<! Size of `data` in memory, in bytes */
unsigned int delay_ms; /*<! Delay in milliseconds after this command */
} axs15231b_lcd_init_cmd_t;
/**
* @brief LCD panel vendor configuration.
*
* @note This structure needs to be passed to the `vendor_config` field in `esp_lcd_panel_dev_config_t`.
*
*/
typedef struct {
const axs15231b_lcd_init_cmd_t *init_cmds; /*!< Pointer to initialization commands array. Set to NULL if using default commands.
* The array should be declared as `static const` and positioned outside the function.
* Please refer to `vendor_specific_init_default` in source file.
*/
uint16_t init_cmds_size; /*<! Number of commands in above array */
struct {
unsigned int use_qspi_interface: 1; /*<! Set to 1 if use QSPI interface, default is SPI interface */
} flags;
} axs15231b_vendor_config_t;
/**
* @brief Create LCD panel for model AXS15231B
*
* @note Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for initialization sequence code.
*
* @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_axs15231b(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 LCD panel bus configuration structure
*
*/
#define AXS15231B_PANEL_BUS_I80_CONFIG(dc, wr, clk, d0, d1, d2, d3, d4, d5, d6, d7, b_w, max_trans_sz) \
{ \
.dc_gpio_num = dc, \
.wr_gpio_num = wr, \
.clk_src = clk, \
.data_gpio_nums = { \
d0, \
d1, \
d2, \
d3, \
d4, \
d5, \
d6, \
d7, \
}, \
.bus_width = b_w, \
.max_transfer_bytes = max_trans_sz, \
}
#define AXS15231B_PANEL_BUS_SPI_CONFIG(sclk, mosi, max_trans_sz) \
{ \
.sclk_io_num = sclk, \
.mosi_io_num = mosi, \
.miso_io_num = -1, \
.quadhd_io_num = -1, \
.quadwp_io_num = -1, \
.max_transfer_sz = max_trans_sz, \
}
#define AXS15231B_PANEL_BUS_QSPI_CONFIG(sclk, d0, d1, d2, d3, max_trans_sz) \
{ \
.sclk_io_num = sclk, \
.data0_io_num = d0, \
.data1_io_num = d1, \
.data2_io_num = d2, \
.data3_io_num = d3, \
.max_transfer_sz = max_trans_sz, \
}
/**
* @brief LCD panel IO configuration structure
*
*/
#define AXS15231B_PANEL_IO_I80_CONFIG(cs, dc, cb, cb_ctx) \
{ \
.cs_gpio_num = cs, \
.pclk_hz = 20 * 1000 * 1000, \
.on_color_trans_done = cb, \
.trans_queue_depth = 10, \
.user_ctx = cb_ctx, \
.dc_levels = { \
.dc_idle_level = 0, \
.dc_cmd_level = 0, \
.dc_dummy_level = 0, \
.dc_data_level = 1, \
}, \
.lcd_cmd_bits = 8, \
.lcd_param_bits = 8, \
}
#define AXS15231B_PANEL_IO_SPI_CONFIG(cs, dc, cb, cb_ctx) \
{ \
.cs_gpio_num = cs, \
.dc_gpio_num = dc, \
.spi_mode = 3, \
.pclk_hz = 40 * 1000 * 1000, \
.trans_queue_depth = 10, \
.on_color_trans_done = cb, \
.user_ctx = cb_ctx, \
.lcd_cmd_bits = 8, \
.lcd_param_bits = 8, \
}
#define AXS15231B_PANEL_IO_QSPI_CONFIG(cs, cb, cb_ctx) \
{ \
.cs_gpio_num = cs, \
.dc_gpio_num = -1, \
.spi_mode = 3, \
.pclk_hz = 40 * 1000 * 1000, \
.trans_queue_depth = 10, \
.on_color_trans_done = cb, \
.user_ctx = cb_ctx, \
.lcd_cmd_bits = 32, \
.lcd_param_bits = 8, \
.flags = { \
.quad_mode = true, \
}, \
}
/**
* @brief Create a new AXS15231B1B touch driver
*
* @note The I2C communication should be initialized before use this function.
*
* @param io LCD panel IO handle, it should be created by `esp_lcd_new_panel_io_i2c()`
* @param config Touch panel configuration
* @param tp Touch panel handle
* @return
* - ESP_OK: on success
*/
esp_err_t esp_lcd_touch_new_i2c_axs15231b(const esp_lcd_panel_io_handle_t io, const esp_lcd_touch_config_t *config, esp_lcd_touch_handle_t *tp);
/**
* @brief I2C address of the AXS15231B controller
*
*/
#define ESP_LCD_TOUCH_IO_I2C_AXS15231B_ADDRESS (0x3B)
/**
* @brief Touch IO configuration structure
*
*/
#define ESP_LCD_TOUCH_IO_I2C_AXS15231B_CONFIG() \
{ \
.dev_addr = ESP_LCD_TOUCH_IO_I2C_AXS15231B_ADDRESS, \
.control_phase_bytes = 1, \
.dc_bit_offset = 0, \
.lcd_cmd_bits = 8, \
.flags = \
{ \
.disable_control_phase = 1, \
} \
}
#ifdef __cplusplus
}
#endif