Grove driver, I2C migrations, bugfixes and docs (#532)

This commit is contained in:
Ken Van Hoeylandt
2026-06-19 00:52:31 +02:00
committed by GitHub
parent 8dabda2b5b
commit a35c88c8fd
74 changed files with 937 additions and 483 deletions
+3 -2
View File
@@ -146,8 +146,9 @@ bool initPowerControl() {
bool initBoot() {
LOGGER.info("initBoot()");
axp2101 = std::make_shared<Axp2101>(I2C_NUM_0);
aw9523 = std::make_shared<Aw9523>(I2C_NUM_0);
auto controller = device_find_by_name("i2c_internal");
axp2101 = std::make_shared<Axp2101>(controller);
aw9523 = std::make_shared<Aw9523>(controller);
return initPowerControl() && initGpioExpander();
}
@@ -4,14 +4,17 @@
#include <Ft5x06Touch.h>
#include <Ili934xDisplay.h>
#include <Tactility/Logger.h>
#include <Tactility/hal/i2c/I2c.h>
#include <tactility/check.h>
static const auto LOGGER = tt::Logger("CoreS3Display");
static void setBacklightDuty(uint8_t backlightDuty) {
const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100] - under 20 is too dark
// TODO: Refactor to use Axp2102 driver subproject. Reference: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/AXP2101_Class.cpp#L42
if (!tt::hal::i2c::masterWriteRegister(I2C_NUM_0, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000)) { // Sets DLD01
auto controller = device_find_by_name("i2c_internal");
check(controller);
if (i2c_controller_write_register(controller, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000) != ERROR_NONE) { // Sets DLD01
LOGGER.error("Failed to set display backlight voltage");
}
}
+25 -28
View File
@@ -3,6 +3,7 @@
#include <tactility/bindings/root.h>
#include <tactility/bindings/esp32_ble.h>
#include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_grove.h>
#include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_i2s.h>
#include <tactility/bindings/esp32_spi.h>
@@ -42,30 +43,34 @@
};
};
i2c_port_a {
compatible = "espressif,esp32-i2c";
port = <I2C_NUM_1>;
clock-frequency = <400000>;
pin-sda = <&gpio0 2 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 1 GPIO_FLAG_NONE>;
port_a: grove0 {
compatible = "espressif,esp32-grove";
defaultMode = <GROVE_MODE_I2C>;
pinSdaRx = <&gpio0 2 GPIO_FLAG_NONE>;
pinSclTx = <&gpio0 1 GPIO_FLAG_NONE>;
uartPort = <UART_NUM_1>;
i2cPort = <I2C_NUM_1>;
i2cClockFrequency = <400000>;
};
i2c_port_b {
compatible = "espressif,esp32-i2c";
status = "disabled";
port = <I2C_NUM_1>;
clock-frequency = <400000>;
pin-sda = <&gpio0 9 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 8 GPIO_FLAG_NONE>;
port_b: grove1 {
compatible = "espressif,esp32-grove";
defaultMode = <GROVE_MODE_UART>;
pinSdaRx = <&gpio0 9 GPIO_FLAG_NONE>;
pinSclTx = <&gpio0 8 GPIO_FLAG_NONE>;
uartPort = <UART_NUM_1>;
i2cPort = <I2C_NUM_1>;
i2cClockFrequency = <400000>;
};
i2c_port_c {
compatible = "espressif,esp32-i2c";
status = "disabled";
port = <I2C_NUM_1>;
clock-frequency = <400000>;
pin-sda = <&gpio0 18 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 17 GPIO_FLAG_NONE>;
port_c: grove2 {
compatible = "espressif,esp32-grove";
defaultMode = <GROVE_MODE_UART>;
pinSdaRx = <&gpio0 17 GPIO_FLAG_NONE>;
pinSclTx = <&gpio0 18 GPIO_FLAG_NONE>;
uartPort = <UART_NUM_2>;
i2cPort = <I2C_NUM_1>;
i2cClockFrequency = <400000>;
};
spi0 {
@@ -89,12 +94,4 @@
pin-data-in = <&gpio0 14 GPIO_FLAG_NONE>;
pin-mclk = <&gpio0 0 GPIO_FLAG_NONE>;
};
uart_port_a: uart1 {
compatible = "espressif,esp32-uart";
status = "disabled";
port = <UART_NUM_1>;
pin-tx = <&gpio0 1 GPIO_FLAG_NONE>;
pin-rx = <&gpio0 2 GPIO_FLAG_NONE>;
};
};