Skip to content

Commit 52ecfef

Browse files
committed
fix(board): fix m5stack coreS3 power issue (#54)
Closes #54
1 parent 30f8360 commit 52ecfef

File tree

2 files changed

+42
-194
lines changed

2 files changed

+42
-194
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
* fix(conf): fix error when include inside file (#52)
1212
* fix(docs): switch M5Stack doc links to english by @lboue (#50)
13+
* fix(board): fix m5stack coreS3 power issue (#54)
1314

1415
## v0.1.3 - 2024-06-14
1516

src/board/m5stack/M5CORES3.h

Lines changed: 41 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@
1717

1818
#if ESP_PANEL_USE_LCD
1919
/**
20-
* LCD Controller Name. Choose one of the following:
21-
* - GC9A01, GC9B71, GC9503
22-
* - ILI9341
23-
* - NV3022B
24-
* - SH8601
25-
* - SPD2010
26-
* - ST7262, ST7701, ST7789, ST7796, ST77916, ST77922
20+
* LCD Controller Name.
2721
* LCD Controller of M5CoreS3 is ILI9342C, but the driver is compatible with ILI9341.
2822
*/
2923
#define ESP_PANEL_LCD_NAME ILI9341
@@ -41,12 +35,7 @@
4135
*/
4236
#define ESP_PANEL_LCD_BUS_SKIP_INIT_HOST (0) // 0/1
4337
/**
44-
* LCD Bus Type. Choose one of the following:
45-
* - ESP_PANEL_BUS_TYPE_I2C (not ready)
46-
* - ESP_PANEL_BUS_TYPE_SPI
47-
* - ESP_PANEL_BUS_TYPE_QSPI
48-
* - ESP_PANEL_BUS_TYPE_I80 (not ready)
49-
* - ESP_PANEL_BUS_TYPE_RGB (only supported for ESP32-S3)
38+
* LCD Bus Type.
5039
*/
5140
#define ESP_PANEL_LCD_BUS_TYPE (ESP_PANEL_BUS_TYPE_SPI)
5241
/**
@@ -73,83 +62,6 @@
7362
#define ESP_PANEL_LCD_SPI_CMD_BITS (8) // Typically set to 8
7463
#define ESP_PANEL_LCD_SPI_PARAM_BITS (8) // Typically set to 8
7564

76-
#elif ESP_PANEL_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_QSPI
77-
78-
#define ESP_PANEL_LCD_BUS_HOST_ID (1) // Typically set to 1
79-
#define ESP_PANEL_LCD_SPI_IO_CS (5)
80-
#if !ESP_PANEL_LCD_BUS_SKIP_INIT_HOST
81-
#define ESP_PANEL_LCD_SPI_IO_SCK (9)
82-
#define ESP_PANEL_LCD_SPI_IO_DATA0 (10)
83-
#define ESP_PANEL_LCD_SPI_IO_DATA1 (11)
84-
#define ESP_PANEL_LCD_SPI_IO_DATA2 (12)
85-
#define ESP_PANEL_LCD_SPI_IO_DATA3 (13)
86-
#endif
87-
#define ESP_PANEL_LCD_SPI_MODE (0) // 0/1/2/3, typically set to 0
88-
#define ESP_PANEL_LCD_SPI_CLK_HZ (40 * 1000 * 1000)
89-
// Should be an integer divisor of 80M, typically set to 40M
90-
#define ESP_PANEL_LCD_SPI_TRANS_QUEUE_SZ (10) // Typically set to 10
91-
#define ESP_PANEL_LCD_SPI_CMD_BITS (32) // Typically set to 32
92-
#define ESP_PANEL_LCD_SPI_PARAM_BITS (8) // Typically set to 8
93-
94-
#elif ESP_PANEL_LCD_BUS_TYPE == ESP_PANEL_BUS_TYPE_RGB
95-
96-
#define ESP_PANEL_LCD_RGB_CLK_HZ (16 * 1000 * 1000)
97-
#define ESP_PANEL_LCD_RGB_HPW (10)
98-
#define ESP_PANEL_LCD_RGB_HBP (10)
99-
#define ESP_PANEL_LCD_RGB_HFP (20)
100-
#define ESP_PANEL_LCD_RGB_VPW (10)
101-
#define ESP_PANEL_LCD_RGB_VBP (10)
102-
#define ESP_PANEL_LCD_RGB_VFP (10)
103-
#define ESP_PANEL_LCD_RGB_PCLK_ACTIVE_NEG (0) // 0: rising edge, 1: falling edge
104-
#define ESP_PANEL_LCD_RGB_DATA_WIDTH (16) // 8 | 16
105-
#define ESP_PANEL_LCD_RGB_PIXEL_BITS (16) // 24 | 16
106-
#define ESP_PANEL_LCD_RGB_FRAME_BUF_NUM (1) // 1/2/3
107-
#define ESP_PANEL_LCD_RGB_BOUNCE_BUF_SIZE (0) // Bounce buffer size in bytes. This function is used to avoid screen drift.
108-
// To enable the bounce buffer, set it to a non-zero value. Typically set to `ESP_PANEL_LCD_WIDTH * 10`
109-
// The size of the Bounce Buffer must satisfy `width_of_lcd * height_of_lcd = size_of_buffer * N`,
110-
// where N is an even number.
111-
#define ESP_PANEL_LCD_RGB_IO_HSYNC (46)
112-
#define ESP_PANEL_LCD_RGB_IO_VSYNC (3)
113-
#define ESP_PANEL_LCD_RGB_IO_DE (17) // -1 if not used
114-
#define ESP_PANEL_LCD_RGB_IO_PCLK (9)
115-
#define ESP_PANEL_LCD_RGB_IO_DISP (-1) // -1 if not used
116-
#define ESP_PANEL_LCD_RGB_IO_DATA0 (10)
117-
#define ESP_PANEL_LCD_RGB_IO_DATA1 (11)
118-
#define ESP_PANEL_LCD_RGB_IO_DATA2 (12)
119-
#define ESP_PANEL_LCD_RGB_IO_DATA3 (13)
120-
#define ESP_PANEL_LCD_RGB_IO_DATA4 (14)
121-
#define ESP_PANEL_LCD_RGB_IO_DATA5 (21)
122-
#define ESP_PANEL_LCD_RGB_IO_DATA6 (47)
123-
#define ESP_PANEL_LCD_RGB_IO_DATA7 (48)
124-
#if ESP_PANEL_LCD_RGB_DATA_WIDTH > 8
125-
#define ESP_PANEL_LCD_RGB_IO_DATA8 (45)
126-
#define ESP_PANEL_LCD_RGB_IO_DATA9 (38)
127-
#define ESP_PANEL_LCD_RGB_IO_DATA10 (39)
128-
#define ESP_PANEL_LCD_RGB_IO_DATA11 (40)
129-
#define ESP_PANEL_LCD_RGB_IO_DATA12 (41)
130-
#define ESP_PANEL_LCD_RGB_IO_DATA13 (42)
131-
#define ESP_PANEL_LCD_RGB_IO_DATA14 (2)
132-
#define ESP_PANEL_LCD_RGB_IO_DATA15 (1)
133-
#endif
134-
#if !ESP_PANEL_LCD_BUS_SKIP_INIT_HOST
135-
#define ESP_PANEL_LCD_3WIRE_SPI_IO_CS (0)
136-
#define ESP_PANEL_LCD_3WIRE_SPI_IO_SCK (1)
137-
#define ESP_PANEL_LCD_3WIRE_SPI_IO_SDA (2)
138-
#define ESP_PANEL_LCD_3WIRE_SPI_CS_USE_EXPNADER (0) // 0/1
139-
#define ESP_PANEL_LCD_3WIRE_SPI_SCL_USE_EXPNADER (0) // 0/1
140-
#define ESP_PANEL_LCD_3WIRE_SPI_SDA_USE_EXPNADER (0) // 0/1
141-
#define ESP_PANEL_LCD_3WIRE_SPI_SCL_ACTIVE_EDGE (0) // 0: rising edge, 1: falling edge
142-
#define ESP_PANEL_LCD_FLAGS_AUTO_DEL_PANEL_IO (0) // Delete the panel IO instance automatically if set to 1.
143-
// If the 3-wire SPI pins are sharing other pins of the RGB interface to save GPIOs,
144-
// Please set it to 1 to release the panel IO and its pins (except CS signal).
145-
#define ESP_PANEL_LCD_FLAGS_MIRROR_BY_CMD (!ESP_PANEL_LCD_FLAGS_AUTO_DEL_PANEL_IO)
146-
// The `mirror()` function will be implemented by LCD command if set to 1.
147-
#endif
148-
149-
#else
150-
151-
#error "The function is not ready and will be implemented in the future."
152-
15365
#endif /* ESP_PANEL_LCD_BUS_TYPE */
15466

15567
/**
@@ -207,13 +119,7 @@
207119
#define ESP_PANEL_USE_TOUCH (1) // 0/1
208120
#if ESP_PANEL_USE_TOUCH
209121
/**
210-
* Touch controller name. Choose one of the following:
211-
* - CST816S
212-
* - FT5x06
213-
* - GT911, GT1151
214-
* - ST1633, ST7123
215-
* - TT21100
216-
* - XPT2046
122+
* Touch controller name.
217123
* Touch Controller of M5CoreS3 is FT6336U, but the driver is compatible with FT5x06.
218124
*/
219125
#define ESP_PANEL_TOUCH_NAME FT5x06
@@ -229,9 +135,7 @@
229135
*/
230136
#define ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST (0) // 0/1
231137
/**
232-
* Touch panel bus type. Choose one of the following:
233-
* - ESP_PANEL_BUS_TYPE_I2C
234-
* - ESP_PANEL_BUS_TYPE_SPI
138+
* Touch panel bus type.
235139
*/
236140
#define ESP_PANEL_TOUCH_BUS_TYPE (ESP_PANEL_BUS_TYPE_I2C)
237141
/* Touch panel bus parameters */
@@ -248,22 +152,6 @@
248152
#define ESP_PANEL_TOUCH_I2C_IO_SDA (12)
249153
#endif
250154

251-
#elif ESP_PANEL_TOUCH_BUS_TYPE == ESP_PANEL_BUS_TYPE_SPI
252-
253-
#define ESP_PANEL_TOUCH_BUS_HOST_ID (1) // Typically set to 1
254-
#define ESP_PANEL_TOUCH_SPI_IO_CS (5)
255-
#if !ESP_PANEL_TOUCH_BUS_SKIP_INIT_HOST
256-
#define ESP_PANEL_TOUCH_SPI_IO_SCK (7)
257-
#define ESP_PANEL_TOUCH_SPI_IO_MOSI (6)
258-
#define ESP_PANEL_TOUCH_SPI_IO_MISO (9)
259-
#endif
260-
#define ESP_PANEL_TOUCH_SPI_CLK_HZ (1 * 1000 * 1000)
261-
// Should be an integer divisor of 80M, typically set to 1M
262-
263-
#else
264-
265-
#error "The function is not ready and will be implemented in the future."
266-
267155
#endif /* ESP_PANEL_TOUCH_BUS_TYPE */
268156

269157
/* Touch Transformation Flags */
@@ -285,94 +173,53 @@
285173
///////////////////////////// Please update the following macros to configure the backlight ////////////////////////////
286174
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
287175
#define ESP_PANEL_USE_BACKLIGHT (0) // 0/1
288-
#if ESP_PANEL_USE_BACKLIGHT
289-
/* IO num of backlight pin */
290-
#define ESP_PANEL_BACKLIGHT_IO (45)
291-
#define ESP_PANEL_BACKLIGHT_ON_LEVEL (1) // 0: low level, 1: high level
292-
293-
/* Set to 1 if you want to turn off the backlight after initializing the panel; otherwise, set it to turn on */
294-
#define ESP_PANEL_BACKLIGHT_IDLE_OFF (0) // 0: on, 1: off
295-
296-
/* Set to 1 if use PWM for brightness control */
297-
#define ESP_PANEL_LCD_BL_USE_PWM (1) // 0/1
298-
#endif /* ESP_PANEL_USE_BACKLIGHT */
299176

300177
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
301178
///////////////////////////// Please update the following macros to configure the IO expander //////////////////////////
302179
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
303180
/* Set to 0 if not using IO Expander */
304181
#define ESP_PANEL_USE_EXPANDER (0) // 0/1
305-
#if ESP_PANEL_USE_EXPANDER
306-
/**
307-
* IO expander name. Choose one of the following:
308-
* - CH422G
309-
* - HT8574
310-
* - TCA95xx_8bit
311-
* - TCA95xx_16bit
312-
*/
313-
#define ESP_PANEL_EXPANDER_NAME TCA95xx_8bit
314-
315-
/* IO expander Settings */
316-
/**
317-
* If set to 1, the driver will skip to initialize the corresponding host. Users need to initialize the host in advance.
318-
* It is useful if other devices use the same host. Please ensure that the host is initialized only once.
319-
*/
320-
#define ESP_PANEL_EXPANDER_SKIP_INIT_HOST (0) // 0/1
321-
/* IO expander parameters */
322-
#define ESP_PANEL_EXPANDER_I2C_ADDRESS (0x20) // The actual I2C address. Even for the same model of IC,
323-
// the I2C address may be different, and confirmation based on
324-
// the actual hardware connection is required
325-
#if !ESP_PANEL_EXPANDER_SKIP_INIT_HOST
326-
#define ESP_PANEL_EXPANDER_HOST_ID (0) // Typically set to 0
327-
#define ESP_PANEL_EXPANDER_I2C_CLK_HZ (400 * 1000)
328-
// Typically set to 400K
329-
#define ESP_PANEL_EXPANDER_I2C_SCL_PULLUP (1) // 0/1
330-
#define ESP_PANEL_EXPANDER_I2C_SDA_PULLUP (1) // 0/1
331-
#define ESP_PANEL_EXPANDER_I2C_IO_SCL (18)
332-
#define ESP_PANEL_EXPANDER_I2C_IO_SDA (8)
333-
#endif
334-
#endif /* ESP_PANEL_USE_EXPANDER */
335182

336183
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
337184
///////////////////////////// Please utilize the following macros to execute any additional code if required. //////////
338185
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
339-
#define ESP_PANEL_BEGIN_START_FUNCTION( panel ) \
340-
{ \
341-
Serial.println("in function ESP_PANEL_BEGIN_END_FUNCTION\n"); \
342-
static const uint8_t AXP_ADDR = 0x34; \
343-
static const uint8_t I2C_MASTER_TIMEOUT_MS = 0; \
344-
static i2c_port_t i2c_master_port = I2C_NUM_0; \
345-
\
346-
uint8_t read_value = 0; \
347-
uint8_t write_value = 0; \
348-
uint8_t reg_addr = 0; \
349-
uint8_t write_buf[2] = {0}; \
350-
\
351-
write_buf[0] = 0x90; \
352-
write_buf[1] = 0xBF; \
353-
i2c_master_write_to_device(i2c_master_port, AXP_ADDR, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
354-
write_buf[0] = 0x02; \
355-
write_buf[1] = 0b00000101; \
356-
i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
357-
write_buf[0] = 0x03; \
358-
write_buf[1] = 0b00000011; \
359-
i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
360-
write_buf[0] = 0x04; \
361-
write_buf[1] = 0b00011000; \
362-
i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
363-
write_buf[0] = 0x05; \
364-
write_buf[1] = 0b00001100; \
365-
i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
366-
write_buf[0] = 0x11; \
367-
write_buf[1] = 0b00010000; \
368-
i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
369-
write_buf[0] = 0x12; \
370-
write_buf[1] = 0b11111111; \
371-
i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
372-
write_buf[0] = 0x13; \
373-
write_buf[1] = 0b11111111; \
374-
i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); \
375-
\
186+
#define ESP_PANEL_BEGIN_START_FUNCTION( panel ) \
187+
{ \
188+
const uint8_t AXP_ADDR = 0x34; \
189+
const uint8_t I2C_MASTER_TIMEOUT_MS = 1000; \
190+
const i2c_port_t i2c_master_port = I2C_NUM_0; \
191+
\
192+
uint8_t read_value = 0; \
193+
uint8_t write_value = 0; \
194+
uint8_t reg_addr = 0; \
195+
uint8_t write_buf[2] = {0}; \
196+
\
197+
ESP_LOGD(TAG, "Start AXP2101 Power"); \
198+
write_buf[0] = 0x90; \
199+
write_buf[1] = 0xBF; \
200+
i2c_master_write_to_device(i2c_master_port, AXP_ADDR, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \
201+
write_buf[0] = 0x02; \
202+
write_buf[1] = 0b00000101; \
203+
i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \
204+
write_buf[0] = 0x03; \
205+
write_buf[1] = 0b00000011; \
206+
i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \
207+
write_buf[0] = 0x04; \
208+
write_buf[1] = 0b00011000; \
209+
i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \
210+
write_buf[0] = 0x05; \
211+
write_buf[1] = 0b00001100; \
212+
i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \
213+
write_buf[0] = 0x11; \
214+
write_buf[1] = 0b00010000; \
215+
i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \
216+
write_buf[0] = 0x12; \
217+
write_buf[1] = 0b11111111; \
218+
i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \
219+
write_buf[0] = 0x13; \
220+
write_buf[1] = 0b11111111; \
221+
i2c_master_write_to_device(i2c_master_port, 0x58, write_buf, sizeof(write_buf), pdMS_TO_TICKS(I2C_MASTER_TIMEOUT_MS)); \
222+
\
376223
}
377224
// #define ESP_PANEL_BEGIN_EXPANDER_START_FUNCTION( panel )
378225
// #define ESP_PANEL_BEGIN_EXPANDER_END_FUNCTION( panel )

0 commit comments

Comments
 (0)