From 1291da746b1e052793327105b7d0e6d46d37ce19 Mon Sep 17 00:00:00 2001 From: Gareth Coleman <30833824+garethhcoleman@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:30:45 +0100 Subject: [PATCH] Support for alt I2C address for LSM6DS3 sensor, identification of TCA9555 IO Expander, resolve serial hang issue (#3622) * basic identification of TCA9555 * recognise LSM6DS3 on alt address * keep variant.h changes out of this PR * 2nd attempt to keep variant.h changes out of this PR --------- Co-authored-by: Ben Meadors --- src/configuration.h | 6 +++++- src/detect/ScanI2C.h | 1 + src/detect/ScanI2CTwoWire.cpp | 9 ++++++++- variants/unphone/platformio.ini | 5 ++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/configuration.h b/src/configuration.h index 66ec607ff..37b67f666 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -138,9 +138,13 @@ along with this program. If not, see . // ----------------------------------------------------------------------------- // Security // ----------------------------------------------------------------------------- - #define ATECC608B_ADDR 0x35 +// ----------------------------------------------------------------------------- +// IO Expander +// ----------------------------------------------------------------------------- +#define TCA9555_ADDR 0x26 + // ----------------------------------------------------------------------------- // GPS // ----------------------------------------------------------------------------- diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index e87ede0a4..c8fcfee10 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -40,6 +40,7 @@ class ScanI2C BMA423, BQ24295, LSM6DS3, + TCA9555, #ifdef HAS_NCP5623 NCP5623, #endif diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index 335892131..13c2f4609 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -299,6 +299,12 @@ void ScanI2CTwoWire::scanPort(I2CPort port) if (registerValue == 0xC0) { type = BQ24295; LOG_INFO("BQ24295 PMU found\n"); + break; + } + registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0F), 1); // get ID + if (registerValue == 0x6A) { + type = LSM6DS3; + LOG_INFO("LSM6DS3 accelerometer found at address 0x%x\n", (uint8_t)addr.address); } else { type = QMI8658; LOG_INFO("QMI8658 Highrate 6-Axis inertial measurement sensor found\n"); @@ -310,7 +316,8 @@ void ScanI2CTwoWire::scanPort(I2CPort port) SCAN_SIMPLE_CASE(PMSA0031_ADDR, PMSA0031, "PMSA0031 air quality sensor found\n") SCAN_SIMPLE_CASE(MPU6050_ADDR, MPU6050, "MPU6050 accelerometer found\n"); SCAN_SIMPLE_CASE(BMA423_ADDR, BMA423, "BMA423 accelerometer found\n"); - SCAN_SIMPLE_CASE(LSM6DS3_ADDR, LSM6DS3, "LSM6DS3 accelerometer found\n"); + SCAN_SIMPLE_CASE(LSM6DS3_ADDR, LSM6DS3, "LSM6DS3 accelerometer found at address 0x%x\n", (uint8_t)addr.address); + SCAN_SIMPLE_CASE(TCA9555_ADDR, TCA9555, "TCA9555 I2C expander found\n"); default: LOG_INFO("Device found at address 0x%x was not able to be enumerated\n", addr.address); diff --git a/variants/unphone/platformio.ini b/variants/unphone/platformio.ini index 9a4a63807..06314eaa3 100644 --- a/variants/unphone/platformio.ini +++ b/variants/unphone/platformio.ini @@ -7,10 +7,13 @@ upload_speed = 921600 monitor_speed = 115200 monitor_filters = esp32_exception_decoder +build_unflags = + -D ARDUINO_USB_MODE + build_flags = ${esp32_base.build_flags} -D UNPHONE - -D BOARD_HAS_PSRAM -I variants/unphone + -D ARDUINO_USB_MODE=0 lib_deps = ${esp32s3_base.lib_deps} lovyan03/LovyanGFX@^1.1.8 \ No newline at end of file