Skip to content

Commit c4c175c

Browse files
committed
T-Beam Supreme: added PMU config, enabled pwr button. Repeater env verified working.
1 parent 3eded45 commit c4c175c

File tree

3 files changed

+131
-49
lines changed

3 files changed

+131
-49
lines changed

src/helpers/TBeamS3SupremeBoard.h

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
#include <Arduino.h>
77
#include "XPowersLib.h"
88

9-
// Define using AXP2102
10-
#define XPOWERS_CHIP_AXP2101
11-
129
// LoRa radio module pins for TBeam S3 Supreme
1310
#define P_LORA_DIO_1 1 //SX1262 IRQ pin
1411
#define P_LORA_NSS 10 //SX1262 SS pin
@@ -18,8 +15,12 @@
1815
#define P_LORA_MISO 13 //SX1262 MISO pin
1916
#define P_LORA_MOSI 11 //SX1262 MOSI pin
2017

18+
#define PIN_BOARD_SDA 17 //SDA for OLED, BME280, and QMC6310U (0x1C)
19+
#define PIN_BOARD_SCL 18 //SCL for OLED, BME280, and QMC6310U (0x1C)
20+
2121
#define PIN_BOARD_SDA_1 42 //SDA for PMU and PFC8563 (RTC)
2222
#define PIN_BOARD_SCL_1 41 //SCL for PMU and PFC8563 (RTC)
23+
#define PIN_PMU_IRQ 40 //IRQ pin for PMU
2324

2425
#define PIN_USER_BTN 0
2526

@@ -39,52 +40,13 @@
3940

4041

4142
class TBeamS3SupremeBoard : public ESP32Board {
42-
XPowersAXP2101 PMU;
4343

4444
public:
4545
void begin() {
46-
ESP32Board::begin();
4746

48-
//Manually set voltage rails
49-
//GPS
50-
PMU.setALDO4Voltage(3300);
51-
PMU.disableALDO3(); //disable to save power
52-
53-
//Lora
54-
PMU.setALDO3Voltage(3300);
55-
PMU.enableALDO3();
56-
57-
//BME280 and OLED
58-
PMU.setALDO1Voltage(3300);
59-
PMU.enableALDO1();
60-
61-
//QMC6310U
62-
PMU.setALDO2Voltage(3300);
63-
PMU.disableALDO2(); //disable to save power
64-
65-
//SD card
66-
PMU.setBLDO1Voltage(3300);
67-
PMU.enableBLDO1();
68-
69-
//Out to header pins
70-
PMU.setBLDO2Voltage(3300);
71-
PMU.enableBLDO2();
72-
73-
PMU.setDC4Voltage(XPOWERS_AXP2101_DCDC4_VOL2_MAX); //1.8V
74-
PMU.enableDC4();
75-
76-
PMU.setDC5Voltage(3300);
77-
PMU.enableDC5();
78-
79-
//Other power rails
80-
PMU.setDC3Voltage(3300); //doesn't go anywhere in the schematic??
81-
PMU.enableDC3();
82-
83-
//Unused power rails
84-
PMU.disableDC2();
85-
PMU.disableDLDO1();
86-
PMU.disableDLDO2();
87-
47+
bool power_init();
48+
49+
ESP32Board::begin();
8850

8951
esp_reset_reason_t reason = esp_reset_reason();
9052
if (reason == ESP_RST_DEEPSLEEP) {
@@ -122,9 +84,12 @@ class TBeamS3SupremeBoard : public ESP32Board {
12284
}
12385

12486
uint16_t getBattMilliVolts() override {
87+
12588
return 0;
12689
}
12790

91+
uint16_t getBattPercent();
92+
12893
const char* getManufacturerName() const override {
12994
return "LilyGo T-Beam S3 Supreme SX1262";
13095
}

variants/lilygo_tbeam_supreme_SX1262/platformio.ini

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,26 @@ build_src_filter = ${T_Beam_S3_Supreme_SX1262.build_src_filter}
3434
+<../examples/simple_repeater>
3535
lib_deps =
3636
${T_Beam_S3_Supreme_SX1262.lib_deps}
37-
${esp32_ota.lib_deps}
37+
${esp32_ota.lib_deps}
38+
39+
40+
[env:T_Beam_S3_Supreme_SX1262_companion_radio_ble]
41+
extends = T_Beam_S3_Supreme_SX1262
42+
build_flags =
43+
${T_Beam_S3_Supreme_SX1262.build_flags}
44+
-D DISPLAY_CLASS=SSD1306Display
45+
-D MAX_CONTACTS=100
46+
-D MAX_GROUP_CHANNELS=8
47+
-D BLE_PIN_CODE=123456
48+
-D BLE_DEBUG_LOGGING=1
49+
; -D ENABLE_PRIVATE_KEY_IMPORT=1
50+
; -D ENABLE_PRIVATE_KEY_EXPORT=1
51+
-D MESH_PACKET_LOGGING=1
52+
-D MESH_DEBUG=1
53+
build_src_filter = ${T_Beam_S3_Supreme_SX1262.build_src_filter}
54+
+<helpers/esp32/*.cpp>
55+
+<helpers/ui/*.cpp>
56+
+<../examples/companion_radio>
57+
lib_deps =
58+
${T_Beam_S3_Supreme_SX1262.lib_deps}
59+
densaugeo/base64 @ ~1.4.0

variants/lilygo_tbeam_supreme_SX1262/target.cpp

Lines changed: 98 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33

44
TBeamS3SupremeBoard board;
55

6+
// Using PMU AXP2102
7+
XPowersAXP2101 PMU;
8+
9+
bool pmuIntFlag;
10+
11+
#ifndef LORA_CR
12+
#define LORA_CR 5
13+
#endif
14+
615
#if defined(P_LORA_SCLK)
716
static SPIClass spi;
817
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);
1524
ESP32RTCClock fallback_clock;
1625
AutoDiscoverRTCClock rtc_clock(fallback_clock);
1726

18-
#ifndef LORA_CR
19-
#define LORA_CR 5
20-
#endif
27+
28+
static void setPMUIntFlag(){
29+
pmuIntFlag = true;
30+
}
31+
32+
bool power_init() {
33+
34+
//Set LED to indicate charge state
35+
PMU.setChargingLedMode(XPOWERS_CHG_LED_CTRL_CHG);
36+
37+
//Set up PMU interrupts
38+
pinMode(PIN_PMU_IRQ,INPUT_PULLUP);
39+
attachInterrupt(PIN_PMU_IRQ,setPMUIntFlag,FALLING);
40+
41+
//GPS
42+
PMU.setALDO4Voltage(3300);
43+
PMU.enableALDO3(); //disable to save power
44+
45+
//Lora
46+
PMU.setALDO3Voltage(3300);
47+
PMU.enableALDO3();
48+
49+
//To avoid SPI bus issues during power up, reset OLED, sensor, and SD card supplies
50+
if(ESP_SLEEP_WAKEUP_UNDEFINED == esp_sleep_get_wakeup_cause()){
51+
PMU.enableALDO1();
52+
PMU.enableALDO2();
53+
PMU.enableBLDO1();
54+
delay(250);
55+
}
56+
57+
//BME280 and OLED
58+
PMU.setALDO1Voltage(3300);
59+
PMU.enableALDO1();
60+
61+
//QMC6310U
62+
PMU.setALDO2Voltage(3300);
63+
PMU.enableALDO2(); //disable to save power
64+
65+
//SD card
66+
PMU.setBLDO1Voltage(3300);
67+
PMU.enableBLDO1();
68+
69+
//Out to header pins
70+
PMU.setBLDO2Voltage(3300);
71+
PMU.enableBLDO2();
72+
73+
PMU.setDC4Voltage(XPOWERS_AXP2101_DCDC4_VOL2_MAX); //1.8V
74+
PMU.enableDC4();
75+
76+
PMU.setDC5Voltage(3300);
77+
PMU.enableDC5();
78+
79+
//Other power rails
80+
PMU.setDC3Voltage(3300); //doesn't go anywhere in the schematic??
81+
PMU.enableDC3();
82+
83+
//Unused power rails
84+
PMU.disableDC2();
85+
PMU.disableDLDO1();
86+
PMU.disableDLDO2();
87+
88+
//Set charge current to 300mA
89+
PMU.setChargerConstantCurr(XPOWERS_AXP2101_CHG_CUR_300MA);
90+
PMU.setChargeTargetVoltage(XPOWERS_AXP2101_CHG_VOL_4V2);
91+
92+
//enable battery voltage measurement
93+
PMU.enableBattVoltageMeasure();
94+
95+
//Reset and re-enable PMU interrupts
96+
PMU.disableIRQ(XPOWERS_AXP2101_ALL_IRQ);
97+
PMU.clearIrqStatus();
98+
PMU.enableIRQ(
99+
XPOWERS_AXP2101_BAT_INSERT_IRQ | XPOWERS_AXP2101_BAT_REMOVE_IRQ | //Battery interrupts
100+
XPOWERS_AXP2101_VBUS_INSERT_IRQ | XPOWERS_AXP2101_VBUS_REMOVE_IRQ | //VBUS interrupts
101+
XPOWERS_AXP2101_PKEY_SHORT_IRQ | XPOWERS_AXP2101_PKEY_LONG_IRQ | //Power Key interrupts
102+
XPOWERS_AXP2101_BAT_CHG_DONE_IRQ | XPOWERS_AXP2101_BAT_CHG_START_IRQ //Charging interrupts
103+
);
104+
105+
//Set the power key off press time
106+
PMU.setPowerKeyPressOffTime(XPOWERS_POWEROFF_4S);
107+
108+
}
21109

22110
bool radio_init() {
23111
fallback_clock.begin();
@@ -44,6 +132,13 @@ bool radio_init() {
44132
return true; // success
45133
}
46134

135+
uint16_t getBattPercent() {
136+
//Read the PMU fuel guage for battery %
137+
uint16_t battPercent = PMU.getBatteryPercent();
138+
139+
return battPercent;
140+
}
141+
47142
uint32_t radio_get_rng_seed() {
48143
return radio.random(0x7FFFFFFF);
49144
}

0 commit comments

Comments
 (0)