Skip to content

Commit faa6887

Browse files
committed
Use faster bus & remove final delay
this pushes the LCD initialization down to about 1.3s.
1 parent 5a60b8d commit faa6887

File tree

1 file changed

+10
-7
lines changed
  • ports/espressif/boards/espressif_esp32s3_lcd_ev

1 file changed

+10
-7
lines changed

ports/espressif/boards/espressif_esp32s3_lcd_ev/board.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static const uint8_t display_init_sequence[] = {
8080
0x3a, 1, 0x66,
8181
0x3a, 1, 0x66,
8282
0x11, 0x80, 120,
83-
0x29, 0x80, 20
83+
0x29, 0x0
8484
};
8585

8686
static const mcu_pin_obj_t *red_pins[] = {
@@ -122,25 +122,27 @@ void board_init(void) {
122122
true
123123
);
124124

125-
busio_i2c_obj_t *i2c = common_hal_board_create_i2c(0);
125+
busio_i2c_obj_t i2c;
126+
i2c.base.type = &busio_i2c_type;
127+
common_hal_busio_i2c_construct(&i2c, DEFAULT_I2C_BUS_SCL, DEFAULT_I2C_BUS_SDA, 400000, 255);
126128
const int i2c_device_address = 32;
127129

128-
common_hal_busio_i2c_try_lock(i2c);
130+
common_hal_busio_i2c_try_lock(&i2c);
129131

130132
{
131133
uint8_t buf[2] = {3, 0xf1}; // set GPIO direction
132-
common_hal_busio_i2c_write(i2c, i2c_device_address, buf, sizeof(buf));
134+
common_hal_busio_i2c_write(&i2c, i2c_device_address, buf, sizeof(buf));
133135
}
134136

135137
{
136138
uint8_t buf[2] = {2, 0}; // set all output pins low initially
137-
common_hal_busio_i2c_write(i2c, i2c_device_address, buf, sizeof(buf));
139+
common_hal_busio_i2c_write(&i2c, i2c_device_address, buf, sizeof(buf));
138140
}
139141

140-
common_hal_busio_i2c_unlock(i2c);
142+
common_hal_busio_i2c_unlock(&i2c);
141143

142144
dotclockframebuffer_ioexpander_spi_bus spibus = {
143-
.bus = i2c,
145+
.bus = &i2c,
144146
.i2c_device_address = i2c_device_address,
145147
.i2c_write_size = 2,
146148
.addr_reg_shadow = { .u32 = 1 }, // GPIO data at register 1
@@ -151,6 +153,7 @@ void board_init(void) {
151153

152154
dotclockframebuffer_ioexpander_send_init_sequence(&spibus, display_init_sequence, sizeof(display_init_sequence));
153155

156+
common_hal_busio_i2c_deinit(&i2c);
154157
}
155158

156159
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

0 commit comments

Comments
 (0)