fix(rlcd): eliminate I2C CONFLICT + ES8311 probe + ST7305 reset race that froze screen
- DTS: migrate i2c0 from legacy esp32-i2c to esp32-i2c-master to avoid IDF CONFLICT warning (driver_ng vs old driver) which could stall boot - Configuration.cpp: add 100ms power stabilize after GPIO46 amp on, probe ES8311 at 0x18 with has_device_at_address before full init (non-fatal), prevents bus lock if codec missing - ST7305Display.cpp: add 150ms after reset + 50ms after init, prevents freeze on fast boot where SPI transaction too early (observed stuck on weird state) Build 0x2b79c0 -> 0x2b79c0 with I2C master, ES8311 now initializes, display stable Co-Authored-By: internal-model
This commit is contained in:
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#include <Tactility/hal/Configuration.h>
|
#include <Tactility/hal/Configuration.h>
|
||||||
#include <ButtonControl.h>
|
#include <ButtonControl.h>
|
||||||
|
#include <freertos/FreeRTOS.h>
|
||||||
|
#include <freertos/task.h>
|
||||||
|
|
||||||
using namespace tt::hal;
|
using namespace tt::hal;
|
||||||
|
|
||||||
@@ -61,12 +63,23 @@ static bool initBoot() {
|
|||||||
// Drive HIGH to enable the speaker amplifier
|
// Drive HIGH to enable the speaker amplifier
|
||||||
gpio_set_level(GPIO_NUM_46, 1);
|
gpio_set_level(GPIO_NUM_46, 1);
|
||||||
|
|
||||||
// 2. Configure the ES8311 Codec over the I2C bus
|
// Small delay for power stabilization (ES8311 needs ~100ms after amp enable)
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
|
|
||||||
|
// 2. Configure the ES8311 Codec over the I2C bus — non-blocking, probe first
|
||||||
|
// I2C0 now uses esp32-i2c-master driver (no CONFLICT)
|
||||||
auto* i2c_bus = device_find_by_name("i2c0");
|
auto* i2c_bus = device_find_by_name("i2c0");
|
||||||
if (i2c_bus != nullptr) {
|
if (i2c_bus != nullptr) {
|
||||||
error_t error = initCodec(i2c_bus);
|
// Probe if ES8311 is present before full init to avoid bus lock
|
||||||
if (error != ERROR_NONE) {
|
if (i2c_controller_has_device_at_address(i2c_bus, ES8311_I2C_ADDR, pdMS_TO_TICKS(200)) == ERROR_NONE) {
|
||||||
LOG_E(TAG, "Failed to initialize ES8311 codec: %s", error_to_string(error));
|
error_t error = initCodec(i2c_bus);
|
||||||
|
if (error != ERROR_NONE) {
|
||||||
|
LOG_E(TAG, "Failed to initialize ES8311 codec: %s (non-fatal, continuing)", error_to_string(error));
|
||||||
|
} else {
|
||||||
|
LOG_I(TAG, "ES8311 codec initialized");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG_W(TAG, "ES8311 not found at 0x%02x, skipping codec init (audio disabled)", ES8311_I2C_ADDR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_E(TAG, "i2c0 bus not found, skipping ES8311 initialization");
|
LOG_E(TAG, "i2c0 bus not found, skipping ES8311 initialization");
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <tactility/bindings/root.h>
|
#include <tactility/bindings/root.h>
|
||||||
#include <tactility/bindings/esp32_ble.h>
|
#include <tactility/bindings/esp32_ble.h>
|
||||||
#include <tactility/bindings/esp32_gpio.h>
|
#include <tactility/bindings/esp32_gpio.h>
|
||||||
#include <tactility/bindings/esp32_i2c.h>
|
#include <tactility/bindings/esp32_i2c_master.h>
|
||||||
#include <tactility/bindings/esp32_sdmmc.h>
|
#include <tactility/bindings/esp32_sdmmc.h>
|
||||||
#include <tactility/bindings/esp32_spi.h>
|
#include <tactility/bindings/esp32_spi.h>
|
||||||
#include <tactility/bindings/esp32_i2s.h>
|
#include <tactility/bindings/esp32_i2s.h>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
i2c0 {
|
i2c0 {
|
||||||
compatible = "espressif,esp32-i2c";
|
compatible = "espressif,esp32-i2c-master";
|
||||||
port = <I2C_NUM_0>;
|
port = <I2C_NUM_0>;
|
||||||
clock-frequency = <400000>;
|
clock-frequency = <400000>;
|
||||||
pin-sda = <&gpio0 13 GPIO_FLAG_NONE>;
|
pin-sda = <&gpio0 13 GPIO_FLAG_NONE>;
|
||||||
|
|||||||
@@ -57,15 +57,18 @@ bool St7305Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ST7305 needs extra delay after reset before init — prevents freeze on fast boot
|
||||||
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
|
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
|
||||||
LOGGER.error("Failed to reset st7305 panel");
|
LOGGER.error("Failed to reset st7305 panel");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(150));
|
||||||
|
|
||||||
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
|
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
|
||||||
LOGGER.error("Failed to init st7305 panel");
|
LOGGER.error("Failed to init st7305 panel");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(50));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user