move axpinit and document LDO & LED usage on V1 hardware

This commit is contained in:
geeksville 2020-01-18 17:41:17 -08:00
parent 4018141a45
commit 716c355b21
2 changed files with 64 additions and 45 deletions

View File

@ -91,9 +91,9 @@ void ttn_register(void (*callback)(uint8_t message));
#define I2C_SDA 21 #define I2C_SDA 21
#define I2C_SCL 22 #define I2C_SCL 22
#define LED_PIN 14
#if defined(T_BEAM_V07) #if defined(T_BEAM_V07)
#define LED_PIN 14
#define BUTTON_PIN 39 #define BUTTON_PIN 39
#elif defined(T_BEAM_V10) #elif defined(T_BEAM_V10)
#define BUTTON_PIN 38 #define BUTTON_PIN 38

View File

@ -171,18 +171,18 @@ void scanI2Cdevice(void)
Serial.println("done\n"); Serial.println("done\n");
} }
void setup() { /**
// Debug * Init the power manager chip
#ifdef DEBUG_PORT *
DEBUG_PORT.begin(SERIAL_BAUD); * axp192 power
#endif DCDC1 0.7-3.5V @ 1200mA max -> OLED // If you turn this off you'll lose comms to the axp192 because the OLED and the axp192 share the same i2c bus, instead use ssd1306 sleep mode
DCDC2 -> unused
delay(1000); DCDC3 0.7-3.5V @ 700mA max -> ESP32 (keep this on!)
LDO1 30mA -> charges GPS backup battery // turn this off during deep sleep to force the tiny J13 battery by the GPS to power the GPS ram (for a couple of days)
#ifdef T_BEAM_V10 LDO2 200mA -> LORA
Wire.begin(I2C_SDA, I2C_SCL); LDO3 200mA -> GPS
scanI2Cdevice(); */
axp192_found = true; void axp192Init() {
if (axp192_found) { if (axp192_found) {
if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) { if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) {
Serial.println("AXP192 Begin PASS"); Serial.println("AXP192 Begin PASS");
@ -203,7 +203,7 @@ void setup() {
axp.setPowerOutPut(AXP192_DCDC2, AXP202_ON); axp.setPowerOutPut(AXP192_DCDC2, AXP202_ON);
axp.setPowerOutPut(AXP192_EXTEN, AXP202_ON); axp.setPowerOutPut(AXP192_EXTEN, AXP202_ON);
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
axp.setDCDC1Voltage(3300); axp.setDCDC1Voltage(3300); // for the OLED power
Serial.printf("DCDC1: %s\n", axp.isDCDC1Enable() ? "ENABLE" : "DISABLE"); Serial.printf("DCDC1: %s\n", axp.isDCDC1Enable() ? "ENABLE" : "DISABLE");
Serial.printf("DCDC2: %s\n", axp.isDCDC2Enable() ? "ENABLE" : "DISABLE"); Serial.printf("DCDC2: %s\n", axp.isDCDC2Enable() ? "ENABLE" : "DISABLE");
@ -227,11 +227,30 @@ void setup() {
} else { } else {
Serial.println("AXP192 not found"); Serial.println("AXP192 not found");
} }
}
void setup() {
// Debug
#ifdef DEBUG_PORT
DEBUG_PORT.begin(SERIAL_BAUD);
#endif
delay(1000);
#ifdef T_BEAM_V10
Wire.begin(I2C_SDA, I2C_SCL);
scanI2Cdevice();
axp192_found = true;
axp192Init();
#endif #endif
// Buttons & LED // Buttons & LED
pinMode(BUTTON_PIN, INPUT_PULLUP); pinMode(BUTTON_PIN, INPUT_PULLUP);
#ifdef LED_PIN
pinMode(LED_PIN, OUTPUT); pinMode(LED_PIN, OUTPUT);
#endif
// Hello // Hello
DEBUG_MSG(APP_NAME " " APP_VERSION "\n"); DEBUG_MSG(APP_NAME " " APP_VERSION "\n");