Added missing define
This commit is contained in:
parent
262d45b440
commit
93953cb565
15 changed files with 615 additions and 151 deletions
|
|
@ -12,76 +12,274 @@ U8G2_SSD1306_128X64_NONAME_F_HW_I2C *u8g2 = nullptr;
|
|||
#endif
|
||||
|
||||
#if defined(LILYGO_TBeam_V1_X)
|
||||
#include <axp20x.h>
|
||||
AXP20X_Class PMU;
|
||||
#include "XPowersLib.h"
|
||||
XPowersLibInterface *PMU = NULL;
|
||||
|
||||
#ifndef PMU_WIRE_PORT
|
||||
#define PMU_WIRE_PORT Wire
|
||||
#endif
|
||||
|
||||
|
||||
bool pmuInterrupt;
|
||||
|
||||
void setPmuFlag()
|
||||
{
|
||||
pmuInterrupt = true;
|
||||
}
|
||||
|
||||
|
||||
bool initPMU()
|
||||
{
|
||||
if (PMU.begin(Wire, AXP192_SLAVE_ADDRESS) == AXP_FAIL) {
|
||||
if (!PMU) {
|
||||
PMU = new XPowersAXP2101(PMU_WIRE_PORT);
|
||||
if (!PMU->init()) {
|
||||
Serial.println("Warning: Failed to find AXP2101 power management");
|
||||
delete PMU;
|
||||
PMU = NULL;
|
||||
} else {
|
||||
Serial.println("AXP2101 PMU init succeeded, using AXP2101 PMU");
|
||||
}
|
||||
}
|
||||
|
||||
if (!PMU) {
|
||||
PMU = new XPowersAXP192(PMU_WIRE_PORT);
|
||||
if (!PMU->init()) {
|
||||
Serial.println("Warning: Failed to find AXP192 power management");
|
||||
delete PMU;
|
||||
PMU = NULL;
|
||||
} else {
|
||||
Serial.println("AXP192 PMU init succeeded, using AXP192 PMU");
|
||||
}
|
||||
}
|
||||
|
||||
if (!PMU) {
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* The charging indicator can be turned on or off
|
||||
* * * */
|
||||
// PMU.setChgLEDMode(LED_BLINK_4HZ);
|
||||
|
||||
/*
|
||||
* The default ESP32 power supply has been turned on,
|
||||
* no need to set, please do not set it, if it is turned off,
|
||||
* it will not be able to program
|
||||
*
|
||||
* PMU.setDCDC3Voltage(3300);
|
||||
* PMU.setPowerOutPut(AXP192_DCDC3, AXP202_ON);
|
||||
*
|
||||
* * * */
|
||||
|
||||
/*
|
||||
* Turn off unused power sources to save power
|
||||
* **/
|
||||
|
||||
PMU.setPowerOutPut(AXP192_DCDC1, AXP202_OFF);
|
||||
PMU.setPowerOutPut(AXP192_DCDC2, AXP202_OFF);
|
||||
PMU.setPowerOutPut(AXP192_LDO2, AXP202_OFF);
|
||||
PMU.setPowerOutPut(AXP192_LDO3, AXP202_OFF);
|
||||
PMU.setPowerOutPut(AXP192_EXTEN, AXP202_OFF);
|
||||
|
||||
/*
|
||||
* Set the power of LoRa and GPS module to 3.3V
|
||||
**/
|
||||
PMU.setLDO2Voltage(3300); //LoRa VDD
|
||||
PMU.setLDO3Voltage(3300); //GPS VDD
|
||||
PMU.setDCDC1Voltage(3300); //3.3V Pin next to 21 and 22 is controlled by DCDC1
|
||||
|
||||
PMU.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
|
||||
PMU.setPowerOutPut(AXP192_LDO2, AXP202_ON);
|
||||
PMU.setPowerOutPut(AXP192_LDO3, AXP202_ON);
|
||||
PMU->setChargingLedMode(XPOWERS_CHG_LED_BLINK_1HZ);
|
||||
|
||||
pinMode(PMU_IRQ, INPUT_PULLUP);
|
||||
attachInterrupt(PMU_IRQ, [] {
|
||||
// pmu_irq = true;
|
||||
}, FALLING);
|
||||
attachInterrupt(PMU_IRQ, setPmuFlag, FALLING);
|
||||
|
||||
PMU.adc1Enable(AXP202_VBUS_VOL_ADC1 |
|
||||
AXP202_VBUS_CUR_ADC1 |
|
||||
AXP202_BATT_CUR_ADC1 |
|
||||
AXP202_BATT_VOL_ADC1,
|
||||
AXP202_ON);
|
||||
if (PMU->getChipModel() == XPOWERS_AXP192) {
|
||||
|
||||
PMU.enableIRQ(AXP202_VBUS_REMOVED_IRQ |
|
||||
AXP202_VBUS_CONNECT_IRQ |
|
||||
AXP202_BATT_REMOVED_IRQ |
|
||||
AXP202_BATT_CONNECT_IRQ,
|
||||
AXP202_ON);
|
||||
PMU.clearIRQ();
|
||||
PMU->setProtectedChannel(XPOWERS_DCDC3);
|
||||
|
||||
// lora
|
||||
PMU->setPowerChannelVoltage(XPOWERS_LDO2, 3300);
|
||||
// gps
|
||||
PMU->setPowerChannelVoltage(XPOWERS_LDO3, 3300);
|
||||
// oled
|
||||
PMU->setPowerChannelVoltage(XPOWERS_DCDC1, 3300);
|
||||
|
||||
PMU->enablePowerOutput(XPOWERS_LDO2);
|
||||
PMU->enablePowerOutput(XPOWERS_LDO3);
|
||||
|
||||
//protected oled power source
|
||||
PMU->setProtectedChannel(XPOWERS_DCDC1);
|
||||
//protected esp32 power source
|
||||
PMU->setProtectedChannel(XPOWERS_DCDC3);
|
||||
// enable oled power
|
||||
PMU->enablePowerOutput(XPOWERS_DCDC1);
|
||||
|
||||
//disable not use channel
|
||||
PMU->disablePowerOutput(XPOWERS_DCDC2);
|
||||
|
||||
PMU->disableIRQ(XPOWERS_AXP192_ALL_IRQ);
|
||||
|
||||
PMU->enableIRQ(XPOWERS_AXP192_VBUS_REMOVE_IRQ |
|
||||
XPOWERS_AXP192_VBUS_INSERT_IRQ |
|
||||
XPOWERS_AXP192_BAT_CHG_DONE_IRQ |
|
||||
XPOWERS_AXP192_BAT_CHG_START_IRQ |
|
||||
XPOWERS_AXP192_BAT_REMOVE_IRQ |
|
||||
XPOWERS_AXP192_BAT_INSERT_IRQ |
|
||||
XPOWERS_AXP192_PKEY_SHORT_IRQ
|
||||
);
|
||||
|
||||
} else if (PMU->getChipModel() == XPOWERS_AXP2101) {
|
||||
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32)
|
||||
//Unuse power channel
|
||||
PMU->disablePowerOutput(XPOWERS_DCDC2);
|
||||
PMU->disablePowerOutput(XPOWERS_DCDC3);
|
||||
PMU->disablePowerOutput(XPOWERS_DCDC4);
|
||||
PMU->disablePowerOutput(XPOWERS_DCDC5);
|
||||
PMU->disablePowerOutput(XPOWERS_ALDO1);
|
||||
PMU->disablePowerOutput(XPOWERS_ALDO4);
|
||||
PMU->disablePowerOutput(XPOWERS_BLDO1);
|
||||
PMU->disablePowerOutput(XPOWERS_BLDO2);
|
||||
PMU->disablePowerOutput(XPOWERS_DLDO1);
|
||||
PMU->disablePowerOutput(XPOWERS_DLDO2);
|
||||
|
||||
// GNSS RTC PowerVDD 3300mV
|
||||
PMU->setPowerChannelVoltage(XPOWERS_VBACKUP, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_VBACKUP);
|
||||
|
||||
//ESP32 VDD 3300mV
|
||||
// ! No need to set, automatically open , Don't close it
|
||||
// PMU->setPowerChannelVoltage(XPOWERS_DCDC1, 3300);
|
||||
// PMU->setProtectedChannel(XPOWERS_DCDC1);
|
||||
PMU->setProtectedChannel(XPOWERS_DCDC1);
|
||||
|
||||
// LoRa VDD 3300mV
|
||||
PMU->setPowerChannelVoltage(XPOWERS_ALDO2, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_ALDO2);
|
||||
|
||||
//GNSS VDD 3300mV
|
||||
PMU->setPowerChannelVoltage(XPOWERS_ALDO3, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_ALDO3);
|
||||
|
||||
#endif /*CONFIG_IDF_TARGET_ESP32*/
|
||||
|
||||
|
||||
#if defined(LILYGO_TBeamS3_SUPREME_V3_0)
|
||||
|
||||
//t-beam m.2 inface
|
||||
//gps
|
||||
PMU->setPowerChannelVoltage(XPOWERS_ALDO4, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_ALDO4);
|
||||
|
||||
// lora
|
||||
PMU->setPowerChannelVoltage(XPOWERS_ALDO3, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_ALDO3);
|
||||
|
||||
// In order to avoid bus occupation, during initialization, the SD card and QMC sensor are powered off and restarted
|
||||
if (ESP_SLEEP_WAKEUP_UNDEFINED == esp_sleep_get_wakeup_cause()) {
|
||||
Serial.println("Power off and restart ALDO BLDO..");
|
||||
PMU->disablePowerOutput(XPOWERS_ALDO1);
|
||||
PMU->disablePowerOutput(XPOWERS_ALDO2);
|
||||
PMU->disablePowerOutput(XPOWERS_BLDO1);
|
||||
delay(250);
|
||||
}
|
||||
|
||||
// Sensor
|
||||
PMU->setPowerChannelVoltage(XPOWERS_ALDO1, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_ALDO1);
|
||||
|
||||
PMU->setPowerChannelVoltage(XPOWERS_ALDO2, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_ALDO2);
|
||||
|
||||
//Sdcard
|
||||
|
||||
PMU->setPowerChannelVoltage(XPOWERS_BLDO1, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_BLDO1);
|
||||
|
||||
PMU->setPowerChannelVoltage(XPOWERS_BLDO2, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_BLDO2);
|
||||
|
||||
//face m.2
|
||||
PMU->setPowerChannelVoltage(XPOWERS_DCDC3, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_DCDC3);
|
||||
|
||||
PMU->setPowerChannelVoltage(XPOWERS_DCDC4, XPOWERS_AXP2101_DCDC4_VOL2_MAX);
|
||||
PMU->enablePowerOutput(XPOWERS_DCDC4);
|
||||
|
||||
PMU->setPowerChannelVoltage(XPOWERS_DCDC5, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_DCDC5);
|
||||
|
||||
|
||||
//not use channel
|
||||
PMU->disablePowerOutput(XPOWERS_DCDC2);
|
||||
// PMU->disablePowerOutput(XPOWERS_DCDC4);
|
||||
// PMU->disablePowerOutput(XPOWERS_DCDC5);
|
||||
PMU->disablePowerOutput(XPOWERS_DLDO1);
|
||||
PMU->disablePowerOutput(XPOWERS_DLDO2);
|
||||
PMU->disablePowerOutput(XPOWERS_VBACKUP);
|
||||
|
||||
// Set constant current charge current limit
|
||||
PMU->setChargerConstantCurr(XPOWERS_AXP2101_CHG_CUR_500MA);
|
||||
|
||||
// Set charge cut-off voltage
|
||||
PMU->setChargeTargetVoltage(XPOWERS_AXP2101_CHG_VOL_4V2);
|
||||
|
||||
// Disable all interrupts
|
||||
PMU->disableIRQ(XPOWERS_AXP2101_ALL_IRQ);
|
||||
// Clear all interrupt flags
|
||||
PMU->clearIrqStatus();
|
||||
// Enable the required interrupt function
|
||||
PMU->enableIRQ(
|
||||
XPOWERS_AXP2101_BAT_INSERT_IRQ | XPOWERS_AXP2101_BAT_REMOVE_IRQ | //BATTERY
|
||||
XPOWERS_AXP2101_VBUS_INSERT_IRQ | XPOWERS_AXP2101_VBUS_REMOVE_IRQ | //VBUS
|
||||
XPOWERS_AXP2101_PKEY_SHORT_IRQ | XPOWERS_AXP2101_PKEY_LONG_IRQ | //POWER KEY
|
||||
XPOWERS_AXP2101_BAT_CHG_DONE_IRQ | XPOWERS_AXP2101_BAT_CHG_START_IRQ //CHARGE
|
||||
// XPOWERS_AXP2101_PKEY_NEGATIVE_IRQ | XPOWERS_AXP2101_PKEY_POSITIVE_IRQ | //POWER KEY
|
||||
);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
PMU->enableSystemVoltageMeasure();
|
||||
PMU->enableVbusVoltageMeasure();
|
||||
PMU->enableBattVoltageMeasure();
|
||||
// It is necessary to disable the detection function of the TS pin on the board
|
||||
// without the battery temperature detection function, otherwise it will cause abnormal charging
|
||||
PMU->disableTSPinMeasure();
|
||||
|
||||
Serial.printf("=========================================\n");
|
||||
if (PMU->isChannelAvailable(XPOWERS_DCDC1)) {
|
||||
Serial.printf("DC1 : %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC1) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_DCDC1));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_DCDC2)) {
|
||||
Serial.printf("DC2 : %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC2) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_DCDC2));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_DCDC3)) {
|
||||
Serial.printf("DC3 : %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC3) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_DCDC3));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_DCDC4)) {
|
||||
Serial.printf("DC4 : %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC4) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_DCDC4));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_DCDC5)) {
|
||||
Serial.printf("DC5 : %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC5) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_DCDC5));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_LDO2)) {
|
||||
Serial.printf("LDO2 : %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_LDO2) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_LDO2));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_LDO3)) {
|
||||
Serial.printf("LDO3 : %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_LDO3) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_LDO3));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_ALDO1)) {
|
||||
Serial.printf("ALDO1: %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO1) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_ALDO1));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_ALDO2)) {
|
||||
Serial.printf("ALDO2: %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO2) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_ALDO2));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_ALDO3)) {
|
||||
Serial.printf("ALDO3: %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO3) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_ALDO3));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_ALDO4)) {
|
||||
Serial.printf("ALDO4: %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO4) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_ALDO4));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_BLDO1)) {
|
||||
Serial.printf("BLDO1: %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_BLDO1) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_BLDO1));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_BLDO2)) {
|
||||
Serial.printf("BLDO2: %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_BLDO2) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_BLDO2));
|
||||
}
|
||||
Serial.printf("=========================================\n");
|
||||
|
||||
|
||||
// Set the time of pressing the button to turn off
|
||||
PMU->setPowerKeyPressOffTime(XPOWERS_POWEROFF_4S);
|
||||
uint8_t opt = PMU->getPowerKeyPressOffTime();
|
||||
Serial.print("PowerKeyPressOffTime:");
|
||||
switch (opt) {
|
||||
case XPOWERS_POWEROFF_4S: Serial.println("4 Second");
|
||||
break;
|
||||
case XPOWERS_POWEROFF_6S: Serial.println("6 Second");
|
||||
break;
|
||||
case XPOWERS_POWEROFF_8S: Serial.println("8 Second");
|
||||
break;
|
||||
case XPOWERS_POWEROFF_10S: Serial.println("10 Second");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void disablePeripherals()
|
||||
{
|
||||
PMU.setPowerOutPut(AXP192_DCDC1, AXP202_OFF);
|
||||
PMU.setPowerOutPut(AXP192_LDO2, AXP202_OFF);
|
||||
PMU.setPowerOutPut(AXP192_LDO3, AXP202_OFF);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@
|
|||
#define GPS_BAUD_RATE 9600
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
|
||||
|
||||
#define HAS_PMU
|
||||
#elif defined(LILYGO_T3_V1_0)
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@
|
|||
#define GPS_BAUD_RATE 9600
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
|
||||
|
||||
#define HAS_PMU
|
||||
#elif defined(LILYGO_T3_V1_0)
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@
|
|||
#define GPS_BAUD_RATE 9600
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
|
||||
|
||||
#define HAS_PMU
|
||||
#elif defined(LILYGO_T3_V1_0)
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@
|
|||
#define GPS_BAUD_RATE 9600
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
|
||||
|
||||
#define HAS_PMU
|
||||
#elif defined(LILYGO_T3_V1_0)
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
#define GPS_BAUD_RATE 9600
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
|
||||
|
||||
#define HAS_PMU
|
||||
#elif defined(LILYGO_T3_V1_0)
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
#define GPS_BAUD_RATE 9600
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
|
||||
|
||||
#define HAS_PMU
|
||||
#elif defined(LILYGO_T3_V1_0)
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
#define GPS_BAUD_RATE 9600
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
|
||||
|
||||
#define HAS_PMU
|
||||
#elif defined(LILYGO_T3_V1_0)
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
#define GPS_BAUD_RATE 9600
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
|
||||
|
||||
#define HAS_PMU
|
||||
#elif defined(LILYGO_T3_V1_0)
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
#define GPS_BAUD_RATE 9600
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
|
||||
|
||||
#define HAS_PMU
|
||||
#elif defined(LILYGO_T3_V1_0)
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@
|
|||
#define GPS_BAUD_RATE 9600
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
|
||||
|
||||
#define HAS_PMU
|
||||
#elif defined(LILYGO_T3_V1_0)
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@
|
|||
#define GPS_BAUD_RATE 9600
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
|
||||
|
||||
#define HAS_PMU
|
||||
#elif defined(LILYGO_T3_V1_0)
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@
|
|||
#define GPS_BAUD_RATE 9600
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
|
||||
|
||||
#define HAS_PMU
|
||||
#elif defined(LILYGO_T3_V1_0)
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
|
|
|
|||
|
|
@ -8,93 +8,292 @@
|
|||
#include <FS.h>
|
||||
#endif
|
||||
|
||||
#if defined(LILYGO_TBeam_V1_X)
|
||||
#include <axp20x.h>
|
||||
AXP20X_Class PMU;
|
||||
#ifdef HAS_DISPLAY
|
||||
#include <U8g2lib.h>
|
||||
|
||||
#ifndef DISPLAY_MODEL
|
||||
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
|
||||
#endif
|
||||
|
||||
DISPLAY_MODEL *u8g2 = nullptr;
|
||||
#endif
|
||||
|
||||
#ifndef OLED_WIRE_PORT
|
||||
#define OLED_WIRE_PORT Wire
|
||||
#endif
|
||||
|
||||
#if defined(HAS_PMU)
|
||||
#include "XPowersLib.h"
|
||||
|
||||
|
||||
XPowersLibInterface *PMU = NULL;
|
||||
|
||||
#ifndef PMU_WIRE_PORT
|
||||
#define PMU_WIRE_PORT Wire
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
bool pmuInterrupt;
|
||||
|
||||
void setPmuFlag()
|
||||
{
|
||||
pmuInterrupt = true;
|
||||
}
|
||||
|
||||
|
||||
bool initPMU()
|
||||
{
|
||||
if (PMU.begin(Wire, AXP192_SLAVE_ADDRESS) == AXP_FAIL) {
|
||||
if (!PMU) {
|
||||
PMU = new XPowersAXP2101(PMU_WIRE_PORT);
|
||||
if (!PMU->init()) {
|
||||
Serial.println("Warning: Failed to find AXP2101 power management");
|
||||
delete PMU;
|
||||
PMU = NULL;
|
||||
} else {
|
||||
Serial.println("AXP2101 PMU init succeeded, using AXP2101 PMU");
|
||||
}
|
||||
}
|
||||
|
||||
if (!PMU) {
|
||||
PMU = new XPowersAXP192(PMU_WIRE_PORT);
|
||||
if (!PMU->init()) {
|
||||
Serial.println("Warning: Failed to find AXP192 power management");
|
||||
delete PMU;
|
||||
PMU = NULL;
|
||||
} else {
|
||||
Serial.println("AXP192 PMU init succeeded, using AXP192 PMU");
|
||||
}
|
||||
}
|
||||
|
||||
if (!PMU) {
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* The charging indicator can be turned on or off
|
||||
* * * */
|
||||
// PMU.setChgLEDMode(LED_BLINK_4HZ);
|
||||
|
||||
/*
|
||||
* The default ESP32 power supply has been turned on,
|
||||
* no need to set, please do not set it, if it is turned off,
|
||||
* it will not be able to program
|
||||
*
|
||||
* PMU.setDCDC3Voltage(3300);
|
||||
* PMU.setPowerOutPut(AXP192_DCDC3, AXP202_ON);
|
||||
*
|
||||
* * * */
|
||||
|
||||
|
||||
/*
|
||||
* Warning:
|
||||
* Disable it will cause abnormal communication between boot and AXP power supply,
|
||||
* do not turn it off
|
||||
*
|
||||
* PMU.setPowerOutPut(AXP192_DCDC1, AXP202_OFF);
|
||||
*
|
||||
*****/
|
||||
|
||||
/*
|
||||
* Turn off unused power sources to save power
|
||||
* **/
|
||||
|
||||
// PMU.setPowerOutPut(AXP192_LDO2, AXP202_OFF);
|
||||
// PMU.setPowerOutPut(AXP192_LDO3, AXP202_OFF);
|
||||
PMU.setPowerOutPut(AXP192_DCDC2, AXP202_OFF);
|
||||
PMU.setPowerOutPut(AXP192_EXTEN, AXP202_OFF);
|
||||
|
||||
/*
|
||||
* Set the power of LoRa and GPS module to 3.3V
|
||||
**/
|
||||
PMU.setLDO2Voltage(3300); //LoRa VDD
|
||||
PMU.setLDO3Voltage(3300); //GPS VDD
|
||||
PMU.setDCDC1Voltage(3300); //3.3V Pin next to 21 and 22 is controlled by DCDC1
|
||||
|
||||
PMU.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
|
||||
PMU.setPowerOutPut(AXP192_LDO2, AXP202_ON);
|
||||
PMU.setPowerOutPut(AXP192_LDO3, AXP202_ON);
|
||||
PMU->setChargingLedMode(XPOWERS_CHG_LED_BLINK_1HZ);
|
||||
|
||||
pinMode(PMU_IRQ, INPUT_PULLUP);
|
||||
attachInterrupt(PMU_IRQ, [] {
|
||||
// pmu_irq = true;
|
||||
}, FALLING);
|
||||
attachInterrupt(PMU_IRQ, setPmuFlag, FALLING);
|
||||
|
||||
PMU.adc1Enable(AXP202_VBUS_VOL_ADC1 |
|
||||
AXP202_VBUS_CUR_ADC1 |
|
||||
AXP202_BATT_CUR_ADC1 |
|
||||
AXP202_BATT_VOL_ADC1,
|
||||
AXP202_ON);
|
||||
if (PMU->getChipModel() == XPOWERS_AXP192) {
|
||||
|
||||
PMU.enableIRQ(AXP202_VBUS_REMOVED_IRQ |
|
||||
AXP202_VBUS_CONNECT_IRQ |
|
||||
AXP202_BATT_REMOVED_IRQ |
|
||||
AXP202_BATT_CONNECT_IRQ,
|
||||
AXP202_ON);
|
||||
PMU.clearIRQ();
|
||||
PMU->setProtectedChannel(XPOWERS_DCDC3);
|
||||
|
||||
// lora
|
||||
PMU->setPowerChannelVoltage(XPOWERS_LDO2, 3300);
|
||||
// gps
|
||||
PMU->setPowerChannelVoltage(XPOWERS_LDO3, 3300);
|
||||
// oled
|
||||
PMU->setPowerChannelVoltage(XPOWERS_DCDC1, 3300);
|
||||
|
||||
PMU->enablePowerOutput(XPOWERS_LDO2);
|
||||
PMU->enablePowerOutput(XPOWERS_LDO3);
|
||||
|
||||
//protected oled power source
|
||||
PMU->setProtectedChannel(XPOWERS_DCDC1);
|
||||
//protected esp32 power source
|
||||
PMU->setProtectedChannel(XPOWERS_DCDC3);
|
||||
// enable oled power
|
||||
PMU->enablePowerOutput(XPOWERS_DCDC1);
|
||||
|
||||
//disable not use channel
|
||||
PMU->disablePowerOutput(XPOWERS_DCDC2);
|
||||
|
||||
PMU->disableIRQ(XPOWERS_AXP192_ALL_IRQ);
|
||||
|
||||
PMU->enableIRQ(XPOWERS_AXP192_VBUS_REMOVE_IRQ |
|
||||
XPOWERS_AXP192_VBUS_INSERT_IRQ |
|
||||
XPOWERS_AXP192_BAT_CHG_DONE_IRQ |
|
||||
XPOWERS_AXP192_BAT_CHG_START_IRQ |
|
||||
XPOWERS_AXP192_BAT_REMOVE_IRQ |
|
||||
XPOWERS_AXP192_BAT_INSERT_IRQ |
|
||||
XPOWERS_AXP192_PKEY_SHORT_IRQ
|
||||
);
|
||||
|
||||
} else if (PMU->getChipModel() == XPOWERS_AXP2101) {
|
||||
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32)
|
||||
//Unuse power channel
|
||||
PMU->disablePowerOutput(XPOWERS_DCDC2);
|
||||
PMU->disablePowerOutput(XPOWERS_DCDC3);
|
||||
PMU->disablePowerOutput(XPOWERS_DCDC4);
|
||||
PMU->disablePowerOutput(XPOWERS_DCDC5);
|
||||
PMU->disablePowerOutput(XPOWERS_ALDO1);
|
||||
PMU->disablePowerOutput(XPOWERS_ALDO4);
|
||||
PMU->disablePowerOutput(XPOWERS_BLDO1);
|
||||
PMU->disablePowerOutput(XPOWERS_BLDO2);
|
||||
PMU->disablePowerOutput(XPOWERS_DLDO1);
|
||||
PMU->disablePowerOutput(XPOWERS_DLDO2);
|
||||
|
||||
// GNSS RTC PowerVDD 3300mV
|
||||
PMU->setPowerChannelVoltage(XPOWERS_VBACKUP, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_VBACKUP);
|
||||
|
||||
//ESP32 VDD 3300mV
|
||||
// ! No need to set, automatically open , Don't close it
|
||||
// PMU->setPowerChannelVoltage(XPOWERS_DCDC1, 3300);
|
||||
// PMU->setProtectedChannel(XPOWERS_DCDC1);
|
||||
PMU->setProtectedChannel(XPOWERS_DCDC1);
|
||||
|
||||
// LoRa VDD 3300mV
|
||||
PMU->setPowerChannelVoltage(XPOWERS_ALDO2, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_ALDO2);
|
||||
|
||||
//GNSS VDD 3300mV
|
||||
PMU->setPowerChannelVoltage(XPOWERS_ALDO3, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_ALDO3);
|
||||
|
||||
#endif /*CONFIG_IDF_TARGET_ESP32*/
|
||||
|
||||
|
||||
#if defined(LILYGO_TBeamS3_SUPREME_V3_0)
|
||||
|
||||
//t-beam m.2 inface
|
||||
//gps
|
||||
PMU->setPowerChannelVoltage(XPOWERS_ALDO4, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_ALDO4);
|
||||
|
||||
// lora
|
||||
PMU->setPowerChannelVoltage(XPOWERS_ALDO3, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_ALDO3);
|
||||
|
||||
// In order to avoid bus occupation, during initialization, the SD card and QMC sensor are powered off and restarted
|
||||
if (ESP_SLEEP_WAKEUP_UNDEFINED == esp_sleep_get_wakeup_cause()) {
|
||||
Serial.println("Power off and restart ALDO BLDO..");
|
||||
PMU->disablePowerOutput(XPOWERS_ALDO1);
|
||||
PMU->disablePowerOutput(XPOWERS_ALDO2);
|
||||
PMU->disablePowerOutput(XPOWERS_BLDO1);
|
||||
delay(250);
|
||||
}
|
||||
|
||||
// Sensor
|
||||
PMU->setPowerChannelVoltage(XPOWERS_ALDO1, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_ALDO1);
|
||||
|
||||
PMU->setPowerChannelVoltage(XPOWERS_ALDO2, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_ALDO2);
|
||||
|
||||
//Sdcard
|
||||
|
||||
PMU->setPowerChannelVoltage(XPOWERS_BLDO1, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_BLDO1);
|
||||
|
||||
PMU->setPowerChannelVoltage(XPOWERS_BLDO2, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_BLDO2);
|
||||
|
||||
//face m.2
|
||||
PMU->setPowerChannelVoltage(XPOWERS_DCDC3, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_DCDC3);
|
||||
|
||||
PMU->setPowerChannelVoltage(XPOWERS_DCDC4, XPOWERS_AXP2101_DCDC4_VOL2_MAX);
|
||||
PMU->enablePowerOutput(XPOWERS_DCDC4);
|
||||
|
||||
PMU->setPowerChannelVoltage(XPOWERS_DCDC5, 3300);
|
||||
PMU->enablePowerOutput(XPOWERS_DCDC5);
|
||||
|
||||
|
||||
//not use channel
|
||||
PMU->disablePowerOutput(XPOWERS_DCDC2);
|
||||
// PMU->disablePowerOutput(XPOWERS_DCDC4);
|
||||
// PMU->disablePowerOutput(XPOWERS_DCDC5);
|
||||
PMU->disablePowerOutput(XPOWERS_DLDO1);
|
||||
PMU->disablePowerOutput(XPOWERS_DLDO2);
|
||||
PMU->disablePowerOutput(XPOWERS_VBACKUP);
|
||||
|
||||
// Set constant current charge current limit
|
||||
PMU->setChargerConstantCurr(XPOWERS_AXP2101_CHG_CUR_500MA);
|
||||
|
||||
// Set charge cut-off voltage
|
||||
PMU->setChargeTargetVoltage(XPOWERS_AXP2101_CHG_VOL_4V2);
|
||||
|
||||
// Disable all interrupts
|
||||
PMU->disableIRQ(XPOWERS_AXP2101_ALL_IRQ);
|
||||
// Clear all interrupt flags
|
||||
PMU->clearIrqStatus();
|
||||
// Enable the required interrupt function
|
||||
PMU->enableIRQ(
|
||||
XPOWERS_AXP2101_BAT_INSERT_IRQ | XPOWERS_AXP2101_BAT_REMOVE_IRQ | //BATTERY
|
||||
XPOWERS_AXP2101_VBUS_INSERT_IRQ | XPOWERS_AXP2101_VBUS_REMOVE_IRQ | //VBUS
|
||||
XPOWERS_AXP2101_PKEY_SHORT_IRQ | XPOWERS_AXP2101_PKEY_LONG_IRQ | //POWER KEY
|
||||
XPOWERS_AXP2101_BAT_CHG_DONE_IRQ | XPOWERS_AXP2101_BAT_CHG_START_IRQ //CHARGE
|
||||
// XPOWERS_AXP2101_PKEY_NEGATIVE_IRQ | XPOWERS_AXP2101_PKEY_POSITIVE_IRQ | //POWER KEY
|
||||
);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
PMU->enableSystemVoltageMeasure();
|
||||
PMU->enableVbusVoltageMeasure();
|
||||
PMU->enableBattVoltageMeasure();
|
||||
// It is necessary to disable the detection function of the TS pin on the board
|
||||
// without the battery temperature detection function, otherwise it will cause abnormal charging
|
||||
PMU->disableTSPinMeasure();
|
||||
|
||||
Serial.printf("=========================================\n");
|
||||
if (PMU->isChannelAvailable(XPOWERS_DCDC1)) {
|
||||
Serial.printf("DC1 : %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC1) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_DCDC1));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_DCDC2)) {
|
||||
Serial.printf("DC2 : %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC2) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_DCDC2));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_DCDC3)) {
|
||||
Serial.printf("DC3 : %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC3) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_DCDC3));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_DCDC4)) {
|
||||
Serial.printf("DC4 : %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC4) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_DCDC4));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_DCDC5)) {
|
||||
Serial.printf("DC5 : %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC5) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_DCDC5));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_LDO2)) {
|
||||
Serial.printf("LDO2 : %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_LDO2) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_LDO2));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_LDO3)) {
|
||||
Serial.printf("LDO3 : %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_LDO3) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_LDO3));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_ALDO1)) {
|
||||
Serial.printf("ALDO1: %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO1) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_ALDO1));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_ALDO2)) {
|
||||
Serial.printf("ALDO2: %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO2) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_ALDO2));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_ALDO3)) {
|
||||
Serial.printf("ALDO3: %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO3) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_ALDO3));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_ALDO4)) {
|
||||
Serial.printf("ALDO4: %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO4) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_ALDO4));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_BLDO1)) {
|
||||
Serial.printf("BLDO1: %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_BLDO1) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_BLDO1));
|
||||
}
|
||||
if (PMU->isChannelAvailable(XPOWERS_BLDO2)) {
|
||||
Serial.printf("BLDO2: %s Voltage: %04u mV \n", PMU->isPowerChannelEnable(XPOWERS_BLDO2) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_BLDO2));
|
||||
}
|
||||
Serial.printf("=========================================\n");
|
||||
|
||||
|
||||
// Set the time of pressing the button to turn off
|
||||
PMU->setPowerKeyPressOffTime(XPOWERS_POWEROFF_4S);
|
||||
uint8_t opt = PMU->getPowerKeyPressOffTime();
|
||||
Serial.print("PowerKeyPressOffTime:");
|
||||
switch (opt) {
|
||||
case XPOWERS_POWEROFF_4S: Serial.println("4 Second");
|
||||
break;
|
||||
case XPOWERS_POWEROFF_6S: Serial.println("6 Second");
|
||||
break;
|
||||
case XPOWERS_POWEROFF_8S: Serial.println("8 Second");
|
||||
break;
|
||||
case XPOWERS_POWEROFF_10S: Serial.println("10 Second");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void disablePeripherals()
|
||||
{
|
||||
/*
|
||||
* Warning:
|
||||
* Disable it will cause abnormal communication between boot and AXP power supply,
|
||||
* do not turn it off
|
||||
*
|
||||
* PMU.setPowerOutPut(AXP192_DCDC1, AXP202_OFF);
|
||||
*
|
||||
*****/
|
||||
PMU.setPowerOutPut(AXP192_LDO2, AXP202_OFF);
|
||||
PMU.setPowerOutPut(AXP192_LDO3, AXP202_OFF);
|
||||
}
|
||||
#else
|
||||
#define initPMU()
|
||||
|
|
@ -109,8 +308,16 @@ void initBoard()
|
|||
Serial.begin(115200);
|
||||
Serial.println("initBoard");
|
||||
SPI.begin(RADIO_SCLK_PIN, RADIO_MISO_PIN, RADIO_MOSI_PIN);
|
||||
|
||||
|
||||
Wire.begin(I2C_SDA, I2C_SCL);
|
||||
|
||||
|
||||
#ifdef I2C1_SDA
|
||||
Wire1.begin(I2C1_SDA, I2C1_SCL);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAS_GPS
|
||||
Serial1.begin(GPS_BAUD_RATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
||||
#endif
|
||||
|
|
@ -124,19 +331,6 @@ void initBoard()
|
|||
|
||||
initPMU();
|
||||
|
||||
#ifdef HAS_SDCARD
|
||||
pinMode(SDCARD_MISO, INPUT_PULLUP);
|
||||
|
||||
SDSPI.begin(SDCARD_SCLK, SDCARD_MISO, SDCARD_MOSI, SDCARD_CS);
|
||||
if (!SD.begin(SDCARD_CS, SDSPI)) {
|
||||
Serial.println("setupSDCard FAIL");
|
||||
} else {
|
||||
uint32_t cardSize = SD.cardSize() / (1024 * 1024);
|
||||
Serial.print("setupSDCard PASS . SIZE = ");
|
||||
Serial.print(cardSize);
|
||||
Serial.println(" MB");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_LED
|
||||
/*
|
||||
|
|
@ -150,6 +344,78 @@ void initBoard()
|
|||
digitalWrite(BOARD_LED, LED_ON);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAS_DISPLAY
|
||||
Wire.beginTransmission(0x3C);
|
||||
if (Wire.endTransmission() == 0) {
|
||||
Serial.println("Started OLED");
|
||||
u8g2 = new DISPLAY_MODEL(U8G2_R0, U8X8_PIN_NONE);
|
||||
u8g2->begin();
|
||||
u8g2->clearBuffer();
|
||||
u8g2->setFlipMode(0);
|
||||
u8g2->setFontMode(1); // Transparent
|
||||
u8g2->setDrawColor(1);
|
||||
u8g2->setFontDirection(0);
|
||||
u8g2->firstPage();
|
||||
do {
|
||||
u8g2->setFont(u8g2_font_inb19_mr);
|
||||
u8g2->drawStr(0, 30, "LilyGo");
|
||||
u8g2->drawHLine(2, 35, 47);
|
||||
u8g2->drawHLine(3, 36, 47);
|
||||
u8g2->drawVLine(45, 32, 12);
|
||||
u8g2->drawVLine(46, 33, 12);
|
||||
u8g2->setFont(u8g2_font_inb19_mf);
|
||||
u8g2->drawStr(58, 60, "LoRa");
|
||||
} while ( u8g2->nextPage() );
|
||||
u8g2->sendBuffer();
|
||||
u8g2->setFont(u8g2_font_fur11_tf);
|
||||
delay(3000);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAS_SDCARD
|
||||
if (u8g2) {
|
||||
u8g2->setFont(u8g2_font_ncenB08_tr);
|
||||
}
|
||||
pinMode(SDCARD_MISO, INPUT_PULLUP);
|
||||
SDSPI.begin(SDCARD_SCLK, SDCARD_MISO, SDCARD_MOSI, SDCARD_CS);
|
||||
if (u8g2) {
|
||||
u8g2->clearBuffer();
|
||||
}
|
||||
|
||||
if (!SD.begin(SDCARD_CS, SDSPI)) {
|
||||
|
||||
Serial.println("setupSDCard FAIL");
|
||||
if (u8g2) {
|
||||
do {
|
||||
u8g2->setCursor(0, 16);
|
||||
u8g2->println( "SDCard FAILED");;
|
||||
} while ( u8g2->nextPage() );
|
||||
}
|
||||
|
||||
} else {
|
||||
uint32_t cardSize = SD.cardSize() / (1024 * 1024);
|
||||
if (u8g2) {
|
||||
do {
|
||||
u8g2->setCursor(0, 16);
|
||||
u8g2->print( "SDCard:");;
|
||||
u8g2->print(cardSize / 1024.0);;
|
||||
u8g2->println(" GB");;
|
||||
} while ( u8g2->nextPage() );
|
||||
}
|
||||
|
||||
Serial.print("setupSDCard PASS . SIZE = ");
|
||||
Serial.print(cardSize / 1024.0);
|
||||
Serial.println(" GB");
|
||||
}
|
||||
if (u8g2) {
|
||||
u8g2->sendBuffer();
|
||||
}
|
||||
delay(3000);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ RADIO_TYPE option:
|
|||
#define GPS_BAUD_RATE 9600
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY //Optional, bring your own board, no OLED !!
|
||||
|
||||
#define HAS_PMU
|
||||
#elif defined(LILYGO_T3_V1_0)
|
||||
#define I2C_SDA 4
|
||||
#define I2C_SCL 15
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue