T-Beam Supreme: added PMU config, enabled pwr button. Repeater env verified working.

This commit is contained in:
cod3doomy
2025-04-09 18:28:46 -07:00
parent 3eded4581a
commit c4c175cab8
3 changed files with 131 additions and 49 deletions

View File

@@ -6,9 +6,6 @@
#include <Arduino.h>
#include "XPowersLib.h"
// Define using AXP2102
#define XPOWERS_CHIP_AXP2101
// LoRa radio module pins for TBeam S3 Supreme
#define P_LORA_DIO_1 1 //SX1262 IRQ pin
#define P_LORA_NSS 10 //SX1262 SS pin
@@ -18,8 +15,12 @@
#define P_LORA_MISO 13 //SX1262 MISO pin
#define P_LORA_MOSI 11 //SX1262 MOSI pin
#define PIN_BOARD_SDA 17 //SDA for OLED, BME280, and QMC6310U (0x1C)
#define PIN_BOARD_SCL 18 //SCL for OLED, BME280, and QMC6310U (0x1C)
#define PIN_BOARD_SDA_1 42 //SDA for PMU and PFC8563 (RTC)
#define PIN_BOARD_SCL_1 41 //SCL for PMU and PFC8563 (RTC)
#define PIN_PMU_IRQ 40 //IRQ pin for PMU
#define PIN_USER_BTN 0
@@ -39,52 +40,13 @@
class TBeamS3SupremeBoard : public ESP32Board {
XPowersAXP2101 PMU;
public:
void begin() {
ESP32Board::begin();
//Manually set voltage rails
//GPS
PMU.setALDO4Voltage(3300);
PMU.disableALDO3(); //disable to save power
//Lora
PMU.setALDO3Voltage(3300);
PMU.enableALDO3();
//BME280 and OLED
PMU.setALDO1Voltage(3300);
PMU.enableALDO1();
//QMC6310U
PMU.setALDO2Voltage(3300);
PMU.disableALDO2(); //disable to save power
//SD card
PMU.setBLDO1Voltage(3300);
PMU.enableBLDO1();
//Out to header pins
PMU.setBLDO2Voltage(3300);
PMU.enableBLDO2();
PMU.setDC4Voltage(XPOWERS_AXP2101_DCDC4_VOL2_MAX); //1.8V
PMU.enableDC4();
PMU.setDC5Voltage(3300);
PMU.enableDC5();
//Other power rails
PMU.setDC3Voltage(3300); //doesn't go anywhere in the schematic??
PMU.enableDC3();
//Unused power rails
PMU.disableDC2();
PMU.disableDLDO1();
PMU.disableDLDO2();
bool power_init();
ESP32Board::begin();
esp_reset_reason_t reason = esp_reset_reason();
if (reason == ESP_RST_DEEPSLEEP) {
@@ -122,9 +84,12 @@ public:
}
uint16_t getBattMilliVolts() override {
return 0;
}
uint16_t getBattPercent();
const char* getManufacturerName() const override {
return "LilyGo T-Beam S3 Supreme SX1262";
}

View File

@@ -34,4 +34,26 @@ build_src_filter = ${T_Beam_S3_Supreme_SX1262.build_src_filter}
+<../examples/simple_repeater>
lib_deps =
${T_Beam_S3_Supreme_SX1262.lib_deps}
${esp32_ota.lib_deps}
${esp32_ota.lib_deps}
[env:T_Beam_S3_Supreme_SX1262_companion_radio_ble]
extends = T_Beam_S3_Supreme_SX1262
build_flags =
${T_Beam_S3_Supreme_SX1262.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-D BLE_PIN_CODE=123456
-D BLE_DEBUG_LOGGING=1
; -D ENABLE_PRIVATE_KEY_IMPORT=1
; -D ENABLE_PRIVATE_KEY_EXPORT=1
-D MESH_PACKET_LOGGING=1
-D MESH_DEBUG=1
build_src_filter = ${T_Beam_S3_Supreme_SX1262.build_src_filter}
+<helpers/esp32/*.cpp>
+<helpers/ui/*.cpp>
+<../examples/companion_radio>
lib_deps =
${T_Beam_S3_Supreme_SX1262.lib_deps}
densaugeo/base64 @ ~1.4.0

View File

@@ -3,6 +3,15 @@
TBeamS3SupremeBoard board;
// Using PMU AXP2102
XPowersAXP2101 PMU;
bool pmuIntFlag;
#ifndef LORA_CR
#define LORA_CR 5
#endif
#if defined(P_LORA_SCLK)
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
@@ -15,9 +24,88 @@ WRAPPER_CLASS radio_driver(radio, board);
ESP32RTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#ifndef LORA_CR
#define LORA_CR 5
#endif
static void setPMUIntFlag(){
pmuIntFlag = true;
}
bool power_init() {
//Set LED to indicate charge state
PMU.setChargingLedMode(XPOWERS_CHG_LED_CTRL_CHG);
//Set up PMU interrupts
pinMode(PIN_PMU_IRQ,INPUT_PULLUP);
attachInterrupt(PIN_PMU_IRQ,setPMUIntFlag,FALLING);
//GPS
PMU.setALDO4Voltage(3300);
PMU.enableALDO3(); //disable to save power
//Lora
PMU.setALDO3Voltage(3300);
PMU.enableALDO3();
//To avoid SPI bus issues during power up, reset OLED, sensor, and SD card supplies
if(ESP_SLEEP_WAKEUP_UNDEFINED == esp_sleep_get_wakeup_cause()){
PMU.enableALDO1();
PMU.enableALDO2();
PMU.enableBLDO1();
delay(250);
}
//BME280 and OLED
PMU.setALDO1Voltage(3300);
PMU.enableALDO1();
//QMC6310U
PMU.setALDO2Voltage(3300);
PMU.enableALDO2(); //disable to save power
//SD card
PMU.setBLDO1Voltage(3300);
PMU.enableBLDO1();
//Out to header pins
PMU.setBLDO2Voltage(3300);
PMU.enableBLDO2();
PMU.setDC4Voltage(XPOWERS_AXP2101_DCDC4_VOL2_MAX); //1.8V
PMU.enableDC4();
PMU.setDC5Voltage(3300);
PMU.enableDC5();
//Other power rails
PMU.setDC3Voltage(3300); //doesn't go anywhere in the schematic??
PMU.enableDC3();
//Unused power rails
PMU.disableDC2();
PMU.disableDLDO1();
PMU.disableDLDO2();
//Set charge current to 300mA
PMU.setChargerConstantCurr(XPOWERS_AXP2101_CHG_CUR_300MA);
PMU.setChargeTargetVoltage(XPOWERS_AXP2101_CHG_VOL_4V2);
//enable battery voltage measurement
PMU.enableBattVoltageMeasure();
//Reset and re-enable PMU interrupts
PMU.disableIRQ(XPOWERS_AXP2101_ALL_IRQ);
PMU.clearIrqStatus();
PMU.enableIRQ(
XPOWERS_AXP2101_BAT_INSERT_IRQ | XPOWERS_AXP2101_BAT_REMOVE_IRQ | //Battery interrupts
XPOWERS_AXP2101_VBUS_INSERT_IRQ | XPOWERS_AXP2101_VBUS_REMOVE_IRQ | //VBUS interrupts
XPOWERS_AXP2101_PKEY_SHORT_IRQ | XPOWERS_AXP2101_PKEY_LONG_IRQ | //Power Key interrupts
XPOWERS_AXP2101_BAT_CHG_DONE_IRQ | XPOWERS_AXP2101_BAT_CHG_START_IRQ //Charging interrupts
);
//Set the power key off press time
PMU.setPowerKeyPressOffTime(XPOWERS_POWEROFF_4S);
}
bool radio_init() {
fallback_clock.begin();
@@ -44,6 +132,13 @@ bool radio_init() {
return true; // success
}
uint16_t getBattPercent() {
//Read the PMU fuel guage for battery %
uint16_t battPercent = PMU.getBatteryPercent();
return battPercent;
}
uint32_t radio_get_rng_seed() {
return radio.random(0x7FFFFFFF);
}