Skip to content

Commit 88ea318

Browse files
Lzw655MacChu0315-Espressif
authored and
MacChu0315-Espressif
committed
feat(board): add new board M5CORE2
1 parent 9cdc53e commit 88ea318

File tree

13 files changed

+300
-6
lines changed

13 files changed

+300
-6
lines changed

ESP_Panel_Board_Supported.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
*/
5757
// #define BOARD_ESP32_4848S040C_I_Y_3
5858

59+
/*
60+
* m5stack (https://m5stack.com/):
61+
*
62+
* - M5STACK_M5CORE2: https://docs.m5stack.com/zh_CN/core/core2
63+
*
64+
*/
65+
// #define BOARD_M5STACK_M5CORE2
66+
5967
/**
6068
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
6169
* the current version of `ESP_Panel_Board_Supported.h` in the library. The detailed rules are as follows:

examples/LVGL/v8/Porting/ESP_Panel_Board_Supported.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
*/
5757
// #define BOARD_ESP32_4848S040C_I_Y_3
5858

59+
/*
60+
* m5stack (https://m5stack.com/):
61+
*
62+
* - M5STACK_M5CORE2: https://docs.m5stack.com/zh_CN/core/core2
63+
*
64+
*/
65+
// #define BOARD_M5STACK_M5CORE2
66+
5967
/**
6068
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
6169
* the current version of `ESP_Panel_Board_Supported.h` in the library. The detailed rules are as follows:

examples/LVGL/v8/Porting/lvgl_port_v8.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* - The number of buffers should be 1 or 2.
3737
*
3838
*/
39-
#define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_INTERNAL) // Allocate LVGL buffer in SRAM
39+
#define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) // Allocate LVGL buffer in SRAM
4040
// #define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_SPIRAM) // Allocate LVGL buffer in PSRAM
4141
#define LVGL_PORT_BUFFER_SIZE (LVGL_PORT_DISP_WIDTH * 20)
4242
#define LVGL_PORT_BUFFER_NUM (2)

examples/LVGL/v8/Rotation/ESP_Panel_Board_Supported.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
*/
5757
// #define BOARD_ESP32_4848S040C_I_Y_3
5858

59+
/*
60+
* m5stack (https://m5stack.com/):
61+
*
62+
* - M5STACK_M5CORE2: https://docs.m5stack.com/zh_CN/core/core2
63+
*
64+
*/
65+
// #define BOARD_M5STACK_M5CORE2
66+
5967
/**
6068
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
6169
* the current version of `ESP_Panel_Board_Supported.h` in the library. The detailed rules are as follows:

examples/LVGL/v8/Rotation/lvgl_port_v8.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* - The number of buffers should be 1 or 2.
3737
*
3838
*/
39-
#define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_INTERNAL) // Allocate LVGL buffer in SRAM
39+
#define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) // Allocate LVGL buffer in SRAM
4040
// #define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_SPIRAM) // Allocate LVGL buffer in PSRAM
4141
#define LVGL_PORT_BUFFER_SIZE (LVGL_PORT_DISP_WIDTH * 20)
4242
#define LVGL_PORT_BUFFER_NUM (2)

examples/Panel/PanelTest/ESP_Panel_Board_Supported.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
*/
5757
// #define BOARD_ESP32_4848S040C_I_Y_3
5858

59+
/*
60+
* m5stack (https://m5stack.com/):
61+
*
62+
* - M5STACK_M5CORE2: https://docs.m5stack.com/zh_CN/core/core2
63+
*
64+
*/
65+
// #define BOARD_M5STACK_M5CORE2
66+
5967
/**
6068
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
6169
* the current version of `ESP_Panel_Board_Supported.h` in the library. The detailed rules are as follows:

examples/SquareLine/v8/Porting/ESP_Panel_Board_Supported.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
*/
5757
// #define BOARD_ESP32_4848S040C_I_Y_3
5858

59+
/*
60+
* m5stack (https://m5stack.com/):
61+
*
62+
* - M5STACK_M5CORE2: https://docs.m5stack.com/zh_CN/core/core2
63+
*
64+
*/
65+
// #define BOARD_M5STACK_M5CORE2
66+
5967
/**
6068
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
6169
* the current version of `ESP_Panel_Board_Supported.h` in the library. The detailed rules are as follows:

examples/SquareLine/v8/Porting/lvgl_port_v8.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* - The number of buffers should be 1 or 2.
3737
*
3838
*/
39-
#define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_INTERNAL) // Allocate LVGL buffer in SRAM
39+
#define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) // Allocate LVGL buffer in SRAM
4040
// #define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_SPIRAM) // Allocate LVGL buffer in PSRAM
4141
#define LVGL_PORT_BUFFER_SIZE (LVGL_PORT_DISP_WIDTH * 20)
4242
#define LVGL_PORT_BUFFER_NUM (2)

examples/SquareLine/v8/WiFiClock/ESP_Panel_Board_Supported.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
*/
5757
// #define BOARD_ESP32_4848S040C_I_Y_3
5858

59+
/*
60+
* m5stack (https://m5stack.com/):
61+
*
62+
* - M5STACK_M5CORE2: https://docs.m5stack.com/zh_CN/core/core2
63+
*
64+
*/
65+
// #define BOARD_M5STACK_M5CORE2
66+
5967
/**
6068
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
6169
* the current version of `ESP_Panel_Board_Supported.h` in the library. The detailed rules are as follows:

examples/SquareLine/v8/WiFiClock/lvgl_port_v8.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* - The number of buffers should be 1 or 2.
3737
*
3838
*/
39-
#define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_INTERNAL) // Allocate LVGL buffer in SRAM
39+
#define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) // Allocate LVGL buffer in SRAM
4040
// #define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_SPIRAM) // Allocate LVGL buffer in PSRAM
4141
#define LVGL_PORT_BUFFER_SIZE (LVGL_PORT_DISP_WIDTH * 20)
4242
#define LVGL_PORT_BUFFER_NUM (2)

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ESP32_Display_Panel
2-
version=0.1.2
2+
version=0.1.3
33
author=espressif
44
maintainer=espressif
55
sentence=ESP32_Display_Panel is an Arduino library designed for ESP SoCs to drive display panels and facilitate rapid GUI development.

src/board/ESP_PanelBoard.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
defined(BOARD_ESP32_S3_KORVO_2) + defined(BOARD_ESP32_S3_LCD_EV_BOARD) + \
1515
defined(BOARD_ESP32_S3_LCD_EV_BOARD_V1_5) + defined(BOARD_ESP32_S3_LCD_EV_BOARD_2) + \
1616
defined(BOARD_ESP32_S3_LCD_EV_BOARD_2_V1_5) + defined(BOARD_ESP32_S3_USB_OTG) + \
17-
defined(BOARD_ESP32_4848S040C_I_Y_3) \
17+
defined(BOARD_ESP32_4848S040C_I_Y_3) + defined(BOARD_M5STACK_M5CORE2) \
1818
> 1
1919
#error "Multiple boards enabled! Please check file `ESP_Panel_Board_Supported.h` and make sure only one board is enabled."
2020
#endif
@@ -48,6 +48,8 @@
4848
/* Jingcai */
4949
#elif defined(BOARD_ESP32_4848S040C_I_Y_3) || CONFIG_BOARD_ESP32_4848S040C_I_Y_3
5050
#include "board/jingcai/ESP32_4848S040C_I_Y_3.h"
51+
#elif defined(BOARD_M5STACK_M5CORE2) || CONFIG_BOARD_M5STACK_M5CORE2
52+
#include "board/m5stack/M5CORE2.h"
5153
#else
5254
#error "Unkonw board selected! Please check file `ESP_Panel_Board_Supported.h` and make sure only one board is enabled."
5355
#endif

src/board/m5stack/M5CORE2.h

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
// *INDENT-OFF*
10+
11+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
12+
//////////////////////////// Please update the following macros to configure the LCD panel /////////////////////////////
13+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
14+
/* Set to 1 when using an LCD panel */
15+
#define ESP_PANEL_USE_LCD (1) // 0/1
16+
17+
#if ESP_PANEL_USE_LCD
18+
/**
19+
* LCD Controller Name.
20+
* LCD Controller of M5Core2 is ILI9342C, but the driver is compatible with ILI9341.
21+
*/
22+
#define ESP_PANEL_LCD_NAME ILI9341
23+
24+
/* LCD resolution in pixels */
25+
#define ESP_PANEL_LCD_WIDTH (320)
26+
#define ESP_PANEL_LCD_HEIGHT (240)
27+
28+
/* LCD Bus Settings */
29+
/**
30+
* If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance.
31+
* It is useful if other devices use the same host. Please ensure that the host is initialized only once.
32+
*/
33+
#define ESP_PANEL_LCD_BUS_SKIP_INIT_HOST (0) // 0/1
34+
/**
35+
* LCD Bus Type.
36+
*/
37+
#define ESP_PANEL_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_SPI)
38+
/**
39+
* LCD Bus Parameters.
40+
*
41+
* Please refer to https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/lcd.html and
42+
* https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/lcd/index.html for more details.
43+
*
44+
*/
45+
#if ESP_PANEL_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI
46+
47+
#define ESP_PANEL_LCD_BUS_HOST_ID (1) // Typically set to 1
48+
#define ESP_PANEL_LCD_SPI_IO_CS (5)
49+
#if !ESP_PANEL_LCD_BUS_SKIP_INIT_HOST
50+
#define ESP_PANEL_LCD_SPI_IO_SCK (18)
51+
#define ESP_PANEL_LCD_SPI_IO_MOSI (23)
52+
#define ESP_PANEL_LCD_SPI_IO_MISO (38) // -1 if not used
53+
#endif
54+
#define ESP_PANEL_LCD_SPI_IO_DC (15)
55+
#define ESP_PANEL_LCD_SPI_MODE (0) // 0/1/2/3, typically set to 0
56+
#define ESP_PANEL_LCD_SPI_CLK_HZ (40 * 1000 * 1000)
57+
// Should be an integer divisor of 80M, typically set to 40M
58+
#define ESP_PANEL_LCD_SPI_TRANS_QUEUE_SZ (10) // Typically set to 10
59+
#define ESP_PANEL_LCD_SPI_CMD_BITS (8) // Typically set to 8
60+
#define ESP_PANEL_LCD_SPI_PARAM_BITS (8) // Typically set to 8
61+
62+
#endif /* ESP_PANEL_LCD_BUS_TYPE */
63+
64+
/**
65+
* LCD Venbdor Initialization Commands.
66+
*
67+
* Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for
68+
* initialization sequence code. Please uncomment and change the following macro definitions. Otherwise, the LCD driver
69+
* will use the default initialization sequence code.
70+
*
71+
* There are two formats for the sequence code:
72+
* 1. Raw data: {command, (uint8_t []){ data0, data1, ... }, data_size, delay_ms}
73+
* 2. Formater: ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(delay_ms, command, { data0, data1, ... }) and
74+
* ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(delay_ms, command)
75+
*/
76+
// #define ESP_PANEL_LCD_VENDOR_INIT_CMD \
77+
// { \
78+
// {0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0}, \
79+
// {0xC0, (uint8_t []){0x3B, 0x00}, 2, 0}, \
80+
// {0xC1, (uint8_t []){0x0D, 0x02}, 2, 0}, \
81+
// {0x29, (uint8_t []){0x00}, 0, 120}, \
82+
// or \
83+
// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xFF, {0x77, 0x01, 0x00, 0x00, 0x10}), \
84+
// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC0, {0x3B, 0x00}), \
85+
// ESP_PANEL_LCD_CMD_WITH_8BIT_PARAM(0, 0xC1, {0x0D, 0x02}), \
86+
// ESP_PANEL_LCD_CMD_WITH_NONE_PARAM(120, 0x29), \
87+
// }
88+
89+
/* LCD Color Settings */
90+
/* LCD color depth in bits */
91+
#define ESP_PANEL_LCD_COLOR_BITS (16) // 8/16/18/24
92+
/*
93+
* LCD RGB Element Order. Choose one of the following:
94+
* - 0: RGB
95+
* - 1: BGR
96+
*/
97+
#define ESP_PANEL_LCD_BGR_ORDER (1) // 0/1
98+
#define ESP_PANEL_LCD_INEVRT_COLOR (1) // 0/1
99+
100+
/* LCD Transformation Flags */
101+
#define ESP_PANEL_LCD_SWAP_XY (0) // 0/1
102+
#define ESP_PANEL_LCD_MIRROR_X (0) // 0/1
103+
#define ESP_PANEL_LCD_MIRROR_Y (0) // 0/1
104+
105+
/* LCD Other Settings */
106+
/* IO num of RESET pin, set to -1 if not use */
107+
#define ESP_PANEL_LCD_IO_RST (-1)
108+
#define ESP_PANEL_LCD_RST_LEVEL (0) // 0: low level, 1: high level
109+
110+
#endif /* ESP_PANEL_USE_LCD */
111+
112+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
113+
//////////////////////////// Please update the following macros to configure the touch panel ///////////////////////////
114+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
115+
/* Set to 1 when using an touch panel */
116+
#define ESP_PANEL_USE_TOUCH (1) // 0/1
117+
#if ESP_PANEL_USE_TOUCH
118+
/**
119+
* Touch controller name.
120+
*/
121+
#define ESP_PANEL_TOUCH_NAME FT5x06
122+
123+
/* Touch resolution in pixels */
124+
#define ESP_PANEL_TOUCH_H_RES (ESP_PANEL_LCD_WIDTH) // Typically set to the same value as the width of LCD
125+
#define ESP_PANEL_TOUCH_V_RES (ESP_PANEL_LCD_HEIGHT) // Typically set to the same value as the height of LCD
126+
127+
/* Touch Panel Bus Settings */
128+
/**
129+
* If set to 1, the bus will skip to initialize the corresponding host. Users need to initialize the host in advance.
130+
* It is useful if other devices use the same host. Please ensure that the host is initialized only once.
131+
*/
132+
#define ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1
133+
/**
134+
* Touch panel bus type.
135+
*/
136+
#define ESP_PANEL_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C)
137+
/* Touch panel bus parameters */
138+
#if ESP_PANEL_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_I2C
139+
140+
#define ESP_PANEL_TOUCH_BUS_HOST_ID (0) // Typically set to 0
141+
#define ESP_PANEL_TOUCH_I2C_ADDRESS (0) // Typically set to 0 to use default address
142+
#if !ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST
143+
#define ESP_PANEL_TOUCH_I2C_CLK_HZ (400 * 1000)
144+
// Typically set to 400K
145+
#define ESP_PANEL_TOUCH_I2C_SCL_PULLUP (0) // 0/1
146+
#define ESP_PANEL_TOUCH_I2C_SDA_PULLUP (0) // 0/1
147+
#define ESP_PANEL_TOUCH_I2C_IO_SCL (22)
148+
#define ESP_PANEL_TOUCH_I2C_IO_SDA (21)
149+
#endif
150+
151+
#endif
152+
153+
/* Touch Transformation Flags */
154+
#define ESP_PANEL_TOUCH_SWAP_XY (0) // 0/1
155+
#define ESP_PANEL_TOUCH_MIRROR_X (0) // 0/1
156+
#define ESP_PANEL_TOUCH_MIRROR_Y (0) // 0/1
157+
158+
/* Touch Other Settings */
159+
/* IO num of RESET pin, set to -1 if not use */
160+
#define ESP_PANEL_TOUCH_IO_RST (-1)
161+
#define ESP_PANEL_TOUCH_RST_LEVEL (0) // 0: low level, 1: high level
162+
/* IO num of INT pin, set to -1 if not use */
163+
#define ESP_PANEL_TOUCH_IO_INT (39)
164+
#define ESP_PANEL_TOUCH_INT_LEVEL (0) // 0: low level, 1: high level
165+
166+
#endif /* ESP_PANEL_USE_TOUCH */
167+
168+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
169+
///////////////////////////// Please update the following macros to configure the backlight ////////////////////////////
170+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
171+
#define ESP_PANEL_USE_BACKLIGHT (0) // 0/1
172+
173+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
174+
///////////////////////////// Please update the following macros to configure the IO expander //////////////////////////
175+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
176+
/* Set to 0 if not using IO Expander */
177+
#define ESP_PANEL_USE_EXPANDER (0) // 0/1
178+
179+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
180+
///////////////////////////// Please utilize the following macros to execute any additional code if required. //////////
181+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
182+
// #define ESP_PANEL_BEGIN_START_FUNCTION( panel )
183+
// #define ESP_PANEL_BEGIN_EXPANDER_START_FUNCTION( panel )
184+
// #define ESP_PANEL_BEGIN_EXPANDER_END_FUNCTION( panel )
185+
// #define ESP_PANEL_BEGIN_LCD_START_FUNCTION( panel )
186+
// #define ESP_PANEL_BEGIN_LCD_END_FUNCTION( panel )
187+
// #define ESP_PANEL_BEGIN_TOUCH_START_FUNCTION( panel )
188+
// #define ESP_PANEL_BEGIN_TOUCH_END_FUNCTION( panel )
189+
// #define ESP_PANEL_BEGIN_BACKLIGHT_START_FUNCTION( panel )
190+
// #define ESP_PANEL_BEGIN_BACKLIGHT_END_FUNCTION( panel )
191+
#define ESP_PANEL_BEGIN_END_FUNCTION( panel ) \
192+
{ \
193+
static const char *TAG = "DEBUG"; \
194+
static const uint8_t AXP_ADDR = 0x34; \
195+
static const uint8_t I2C_MASTER_TIMEOUT_MS = 1000; \
196+
static i2c_port_t i2c_master_port = I2C_NUM_0; \
197+
\
198+
uint8_t device_id = 0; \
199+
uint8_t read_value = 0; \
200+
uint8_t write_value = 0; \
201+
uint8_t reg_addr = 0; \
202+
uint8_t write_buf[2] = {0}; \
203+
\
204+
reg_addr = 0x03; \
205+
i2c_master_write_read_device(i2c_master_port, AXP_ADDR, &reg_addr, 1, &device_id, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
206+
if (device_id == 0x03) { \
207+
reg_addr = 0x28; \
208+
i2c_master_write_read_device(i2c_master_port, AXP_ADDR, &reg_addr, 1, &read_value, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
209+
write_value = (read_value & 0x0F) | ((((3300 - 1800) / 100) & 0x0F) << 4); \
210+
write_buf[0] = 0x28; \
211+
write_buf[1] = write_value; \
212+
i2c_master_write_to_device(i2c_master_port, AXP_ADDR, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
213+
\
214+
reg_addr = 0x12; \
215+
i2c_master_write_read_device(i2c_master_port, AXP_ADDR, &reg_addr, 1, &read_value, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
216+
write_value = (read_value | (0x01 << 2)); \
217+
write_buf[0] = 0x12; \
218+
write_buf[1] = write_value; \
219+
i2c_master_write_to_device(i2c_master_port, AXP_ADDR, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
220+
\
221+
reg_addr = 0x12; \
222+
i2c_master_write_read_device(i2c_master_port, AXP_ADDR, &reg_addr, 1, &read_value, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
223+
write_value = (read_value | (0x01 << 1)); \
224+
write_buf[0] = 0x12; \
225+
write_buf[1] = write_value; \
226+
i2c_master_write_to_device(i2c_master_port, AXP_ADDR, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
227+
} else if (device_id == 0x4A) { \
228+
reg_addr = 0x90; \
229+
read_value = device_id; \
230+
i2c_master_write_read_device(i2c_master_port, AXP_ADDR, &reg_addr, 1, &read_value, 1, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
231+
write_value = (read_value | (1 << 4)); \
232+
write_buf[0] = 0x90; \
233+
write_buf[1] = write_value; \
234+
i2c_master_write_to_device(i2c_master_port, AXP_ADDR, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
235+
\
236+
write_value = (3000 - 500) / 100; \
237+
write_buf[0] = 0x94; \
238+
write_buf[1] = write_value; \
239+
i2c_master_write_to_device(i2c_master_port, AXP_ADDR, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
240+
} else { \
241+
\
242+
} \
243+
}
244+
// *INDENT-OFF*

0 commit comments

Comments
 (0)