From fd2ae61e3eaaa992c2150c23ea87f5b40663cfe6 Mon Sep 17 00:00:00 2001 From: thebentern Date: Thu, 6 Oct 2022 20:53:47 +0000 Subject: [PATCH 1/3] [create-pull-request] automated change --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 390064201..f1a44dd8a 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 1 minor = 3 -build = 42 +build = 43 From 004f6fa4d632c2a12ccff493b2851ac15ee70aaf Mon Sep 17 00:00:00 2001 From: lewis he Date: Fri, 7 Oct 2022 19:57:55 +0800 Subject: [PATCH 2/3] Add t-beam-s3-core onboard device support. (#1764) * Change t-beam-s3-core pins definitions * Add t-beam-s3-core power initialization to properly initialize the I2C device * Add 6-axis and 3-axis sensor detection --- src/Power.cpp | 38 ++++++++++++++++++++++++--- src/configuration.h | 3 ++- src/detect/i2cScan.h | 8 ++++++ src/main.cpp | 11 +++++++- variants/tbeam-s3-core/pins_arduino.h | 7 +++++ variants/tbeam-s3-core/platformio.ini | 4 ++- variants/tbeam-s3-core/variant.h | 20 ++++++++++++-- 7 files changed, 83 insertions(+), 8 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index 767c5ca0c..d3782a2a4 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -368,8 +368,21 @@ bool Power::axpChipInit() #ifdef HAS_PMU + TwoWire * w = NULL; + + // Use macro to distinguish which wire is used by PMU +#ifdef PMU_USE_WIRE1 + w = &Wire1; +#else + w = &Wire; +#endif + + /** + * It is not necessary to specify the wire pin, + * just input the wire, because the wire has been initialized in main.cpp + */ if (!PMU) { - PMU = new XPowersAXP2101(Wire, I2C_SDA, I2C_SCL); + PMU = new XPowersAXP2101(*w); if (!PMU->init()) { DEBUG_MSG("Warning: Failed to find AXP2101 power management\n"); delete PMU; @@ -380,7 +393,7 @@ bool Power::axpChipInit() } if (!PMU) { - PMU = new XPowersAXP192(Wire, I2C_SDA, I2C_SCL); + PMU = new XPowersAXP192(*w); if (!PMU->init()) { DEBUG_MSG("Warning: Failed to find AXP192 power management\n"); delete PMU; @@ -396,7 +409,9 @@ bool Power::axpChipInit() * In order not to affect other devices, if the initialization of the PMU fails, Wire needs to be re-initialized once, * if there are multiple devices sharing the bus. * * */ - Wire.begin(I2C_SDA, I2C_SCL); +#ifndef PMU_USE_WIRE1 + w->begin(I2C_SDA, I2C_SCL); +#endif return false; } @@ -456,6 +471,23 @@ bool Power::axpChipInit() PMU->setPowerChannelVoltage(XPOWERS_DCDC3, 3300); PMU->enablePowerOutput(XPOWERS_DCDC3); + /** + * ALDO2 cannot be turned off. + * It is a necessary condition for sensor communication. + * It must be turned on to properly access the sensor and screen + * It is also responsible for the power supply of PCF8563 + */ + PMU->setPowerChannelVoltage(XPOWERS_ALDO2, 3300); + PMU->enablePowerOutput(XPOWERS_ALDO2); + + // 6-axis , magnetometer ,bme280 , oled screen power channel + PMU->setPowerChannelVoltage(XPOWERS_ALDO1, 3300); + PMU->enablePowerOutput(XPOWERS_ALDO1); + + // sdcard power channle + PMU->setPowerChannelVoltage(XPOWERS_BLDO1, 3300); + PMU->enablePowerOutput(XPOWERS_BLDO1); + // PMU->setPowerChannelVoltage(XPOWERS_DCDC4, 3300); // PMU->enablePowerOutput(XPOWERS_DCDC4); diff --git a/src/configuration.h b/src/configuration.h index d91a674c2..524dbec36 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -108,7 +108,8 @@ along with this program. If not, see . #define MCP9808_ADDR 0x18 #define INA_ADDR 0x40 #define INA_ADDR_ALTERNATE 0x41 - +#define QMC6310_ADDR 0x1C +#define QMI8658_ADDR 0x6B // ----------------------------------------------------------------------------- // GPS // ----------------------------------------------------------------------------- diff --git a/src/detect/i2cScan.h b/src/detect/i2cScan.h index 3591d307b..7f62a7604 100644 --- a/src/detect/i2cScan.h +++ b/src/detect/i2cScan.h @@ -145,6 +145,14 @@ void scanI2Cdevice(void) nodeTelemetrySensorsMap[TelemetrySensorType_MCP9808] = addr; DEBUG_MSG("MCP9808 sensor found at address 0x%x\n", (uint8_t)addr); } + if(addr == QMC6310_ADDR){ + DEBUG_MSG("QMC6310 3-Axis magnetic sensor found at address 0x%x\n", (uint8_t)addr); + // nodeTelemetrySensorsMap[TelemetrySensorType_QMC6310] = addr; //Uncomment after protobufs PR is merged + } + if(addr == QMI8658_ADDR){ + DEBUG_MSG("QMI8658 6-Axis inertial measurement sensor found at address 0x%x\n", (uint8_t)addr); + // nodeTelemetrySensorsMap[TelemetrySensorType_QMI8658] = addr; //Uncomment after protobufs PR is merged + } } else if (err == 4) { DEBUG_MSG("Unknow error at address 0x%x\n", addr); } diff --git a/src/main.cpp b/src/main.cpp index 5d3d30d0c..c5df7e021 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -214,6 +214,10 @@ void setup() // router = new DSRRouter(); router = new ReliableRouter(); +#ifdef I2C_SDA1 + Wire1.begin(I2C_SDA1, I2C_SCL1); +#endif + #ifdef I2C_SDA Wire.begin(I2C_SDA, I2C_SCL); #elif HAS_WIRE @@ -229,7 +233,6 @@ void setup() delay(1); #endif - scanI2Cdevice(); #ifdef RAK4630 // scanEInkDevice(); #endif @@ -269,6 +272,12 @@ void setup() powerStatus->observe(&power->newStatus); power->setup(); // Must be after status handler is installed, so that handler gets notified of the initial configuration + /* + * Move the scanning I2C device to the back of power initialization. + * Some boards need to be powered on to correctly scan to the device address, such as t-beam-s3-core + */ + scanI2Cdevice(); + // Init our SPI controller (must be before screen and lora) initSPI(); #ifndef ARCH_ESP32 diff --git a/variants/tbeam-s3-core/pins_arduino.h b/variants/tbeam-s3-core/pins_arduino.h index 7b0193e0e..50c993f3a 100644 --- a/variants/tbeam-s3-core/pins_arduino.h +++ b/variants/tbeam-s3-core/pins_arduino.h @@ -25,5 +25,12 @@ static const uint8_t MOSI = 11; static const uint8_t MISO = 13; static const uint8_t SCK = 12; +#define SDMMC_CMD (35) +#define SDMMC_CLK (36) +#define SDMMC_DATA (37) + +#define ACCEL_INT1 (34) +#define ACCEL_INT2 (33) +#define RTC_INT (14) #endif /* Pins_Arduino_h */ diff --git a/variants/tbeam-s3-core/platformio.ini b/variants/tbeam-s3-core/platformio.ini index 9adfb90dc..99d315a69 100644 --- a/variants/tbeam-s3-core/platformio.ini +++ b/variants/tbeam-s3-core/platformio.ini @@ -5,7 +5,9 @@ board = tbeam-s3-core lib_deps = ${esp32s3_base.lib_deps} + lewisxhe/PCF8563_Library@1.0.1 + build_flags = ${esp32s3_base.build_flags} -Ivariants/tbeam-s3-core - + -DPCF8563_RTC=0x51 ;Putting definitions in variant.h does not compile correctly diff --git a/variants/tbeam-s3-core/variant.h b/variants/tbeam-s3-core/variant.h index 8fe181ad0..63387c00a 100644 --- a/variants/tbeam-s3-core/variant.h +++ b/variants/tbeam-s3-core/variant.h @@ -1,12 +1,18 @@ // #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep -#define I2C_SDA 42 -#define I2C_SCL 41 +#define I2C_SDA1 42 //Used for PMU management +#define I2C_SCL1 41 //Used for PMU management + +#define I2C_SDA 17 //For sensors and screens +#define I2C_SCL 18 //For sensors and screens #define BUTTON_PIN 0 // The middle button GPIO on the T-Beam S3 //#define BUTTON_PIN_ALT 13 // Alternate GPIO for an external button if needed. Does anyone use this? It is not documented anywhere. // #define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module. +#define BUTTON1_PIN 47 //Additional keys + + #define LED_INVERTED 1 // #define LED_PIN 4 // Newer tbeams (1.1) have an extra led on GPIO4 @@ -36,6 +42,9 @@ // #define PMU_IRQ 40 #define HAS_AXP2101 +// Specify the PMU as Wire1. In the t-beam-s3-core, the PMU enjoys a separate bus +#define PMU_USE_WIRE1 + #define RF95_SCK 12 #define RF95_MISO 13 #define RF95_MOSI 11 @@ -47,3 +56,10 @@ #define GPS_1PPS_PIN 6 +#define HAS_SDCARD //Have 3-bit SDMMC interface SD card slot + +// PCF8563 RTC Module +// #define PCF8563_RTC 0x51 //Putting definitions in variant. h does not compile correctly + +#define HAS_RTC 1 + From bf4115a80f3d48e6b168de9f1b2e1f8e6e4ab59f Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 7 Oct 2022 08:33:07 -0500 Subject: [PATCH 3/3] Telemetry sensors re-map (#1765) * Add factory erase uf2 to the release assets * Sensors map * Uncomment sensors --- protobufs | 2 +- src/detect/i2cScan.h | 4 ++-- src/main.cpp | 2 +- src/main.h | 2 +- src/mesh/generated/telemetry.pb.h | 10 +++++++--- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/protobufs b/protobufs index d3375fe59..636212824 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit d3375fe599da1dd48572354325d3186eccf6f449 +Subproject commit 636212824a446194b73b02ca5c6c15cd61d3e007 diff --git a/src/detect/i2cScan.h b/src/detect/i2cScan.h index 7f62a7604..3adb44277 100644 --- a/src/detect/i2cScan.h +++ b/src/detect/i2cScan.h @@ -147,11 +147,11 @@ void scanI2Cdevice(void) } if(addr == QMC6310_ADDR){ DEBUG_MSG("QMC6310 3-Axis magnetic sensor found at address 0x%x\n", (uint8_t)addr); - // nodeTelemetrySensorsMap[TelemetrySensorType_QMC6310] = addr; //Uncomment after protobufs PR is merged + nodeTelemetrySensorsMap[TelemetrySensorType_QMC6310] = addr; } if(addr == QMI8658_ADDR){ DEBUG_MSG("QMI8658 6-Axis inertial measurement sensor found at address 0x%x\n", (uint8_t)addr); - // nodeTelemetrySensorsMap[TelemetrySensorType_QMI8658] = addr; //Uncomment after protobufs PR is merged + nodeTelemetrySensorsMap[TelemetrySensorType_QMI8658] = addr; } } else if (err == 4) { DEBUG_MSG("Unknow error at address 0x%x\n", addr); diff --git a/src/main.cpp b/src/main.cpp index c5df7e021..95da04014 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -87,7 +87,7 @@ uint32_t serialSinceMsec; bool pmu_found; // Array map of sensor types (as array index) and i2c address as value we'll find in the i2c scan -uint8_t nodeTelemetrySensorsMap[TelemetrySensorType_LPS22+1] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint8_t nodeTelemetrySensorsMap[TelemetrySensorType_QMI8658+1] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; Router *router = NULL; // Users of router don't care what sort of subclass implements that API diff --git a/src/main.h b/src/main.h index c92379274..f3f9c62c9 100644 --- a/src/main.h +++ b/src/main.h @@ -18,7 +18,7 @@ extern bool pmu_found; extern bool isCharging; extern bool isUSBPowered; -extern uint8_t nodeTelemetrySensorsMap[TelemetrySensorType_LPS22+1]; +extern uint8_t nodeTelemetrySensorsMap[TelemetrySensorType_QMI8658+1]; extern int TCPPort; // set by Portduino diff --git a/src/mesh/generated/telemetry.pb.h b/src/mesh/generated/telemetry.pb.h index 49c6fbf9f..38f4f9ca8 100644 --- a/src/mesh/generated/telemetry.pb.h +++ b/src/mesh/generated/telemetry.pb.h @@ -29,7 +29,11 @@ typedef enum _TelemetrySensorType { /* High accuracy temperature and humidity */ TelemetrySensorType_SHTC3 = 7, /* High accuracy pressure */ - TelemetrySensorType_LPS22 = 8 + TelemetrySensorType_LPS22 = 8, + /* 3-Axis magnetic sensor */ + TelemetrySensorType_QMC6310 = 9, + /* 6-Axis inertial measurement sensor */ + TelemetrySensorType_QMI8658 = 10 } TelemetrySensorType; /* Struct definitions */ @@ -81,8 +85,8 @@ typedef struct _Telemetry { /* Helper constants for enums */ #define _TelemetrySensorType_MIN TelemetrySensorType_SENSOR_UNSET -#define _TelemetrySensorType_MAX TelemetrySensorType_LPS22 -#define _TelemetrySensorType_ARRAYSIZE ((TelemetrySensorType)(TelemetrySensorType_LPS22+1)) +#define _TelemetrySensorType_MAX TelemetrySensorType_QMI8658 +#define _TelemetrySensorType_ARRAYSIZE ((TelemetrySensorType)(TelemetrySensorType_QMI8658+1)) #ifdef __cplusplus