Merge pull request #1609 from meshtastic/AXP192-CLEANUP

Axp192 cleanup
This commit is contained in:
Thomas Göttgens 2022-08-08 16:50:57 +02:00 committed by GitHub
commit 8490bdd14e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 16 deletions

View File

@ -132,7 +132,7 @@ class ButtonThread : public concurrency::OSThread
#endif
// If user button is held down for 5 seconds, shutdown the device.
if ((millis() - longPressTime > 5 * 1000) && (longPressTime > 0)) {
#ifdef TBEAM_V10
#ifdef HAS_AXP192
if (axp192_found == true) {
setLed(false);
power->shutdown();

View File

@ -7,9 +7,7 @@
#include "utils.h"
#include "buzz/buzz.h"
#ifdef TBEAM_V10
// FIXME. nasty hack cleanup how we load axp192
#undef AXP192_SLAVE_ADDRESS
#ifdef HAS_AXP192
#include "axp20x.h"
AXP20X_Class axp;
@ -221,7 +219,7 @@ bool Power::setup()
void Power::shutdown()
{
#ifdef TBEAM_V10
#ifdef HAS_AXP192
DEBUG_MSG("Shutting down\n");
axp.setChgLEDMode(AXP20X_LED_OFF);
axp.shutdown();
@ -293,7 +291,7 @@ int32_t Power::runOnce()
{
readPowerStatus();
#ifdef TBEAM_V10
#ifdef HAS_AXP192
// WE no longer use the IRQ line to wake the CPU (due to false wakes from sleep), but we do poll
// the IRQ status by reading the registers over I2C
axp.readIRQ();
@ -343,7 +341,7 @@ int32_t Power::runOnce()
*/
bool Power::axp192Init()
{
#ifdef TBEAM_V10
#ifdef HAS_AXP192
if (axp192_found) {
if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) {
batteryLevel = &axp;

View File

@ -12,7 +12,7 @@
static bool isPowered()
{
// Circumvent the battery sensing logic and assumes constant power if no battery pin or power mgmt IC
#if !defined(BATTERY_PIN) && !defined(AXP192_SLAVE_ADDRESS)
#if !defined(BATTERY_PIN) && !defined(HAS_AXP192)
return true;
#endif

View File

@ -3,6 +3,10 @@
#include <Wire.h>
#include "mesh/generated/telemetry.pb.h"
#ifdef HAS_AXP192
#include "axp20x.h"
#endif
#if HAS_WIRE
uint16_t getRegisterValue(uint8_t address, uint8_t reg, uint8_t length) {
uint16_t value = 0x00;
@ -110,7 +114,7 @@ void scanI2Cdevice(void)
screen_found = addr;
DEBUG_MSG("st7567 display found\n");
}
#ifdef AXP192_SLAVE_ADDRESS
#ifdef HAS_AXP192
if (addr == AXP192_SLAVE_ADDRESS) {
axp192_found = true;
DEBUG_MSG("axp192 PMU found\n");

View File

@ -307,7 +307,7 @@ void setup()
setupModules();
// Do this after service.init (because that clears error_code)
#ifdef AXP192_SLAVE_ADDRESS
#ifdef HAS_AXP192
if (!axp192_found)
RECORD_CRITICALERROR(CriticalErrorCode_NoAXP192); // Record a hardware fault for missing hardware
#endif

View File

@ -35,7 +35,7 @@ void powerCommandsCheck()
if (shutdownAtMsec && millis() > shutdownAtMsec) {
DEBUG_MSG("Shutting down from admin command\n");
#ifdef TBEAM_V10
#ifdef HAS_AXP192
if (axp192_found == true) {
playShutdownMelody();
power->shutdown();

View File

@ -21,7 +21,7 @@
esp_sleep_source_t wakeCause; // the reason we booted this time
#endif
#ifdef TBEAM_V10
#ifdef HAS_AXP192
#include "axp20x.h"
extern AXP20X_Class axp;
#endif
@ -80,7 +80,7 @@ void setLed(bool ledOn)
digitalWrite(LED_PIN, ledOn ^ LED_INVERTED);
#endif
#ifdef TBEAM_V10
#ifdef HAS_AXP192
if (axp192_found) {
// blink the axp led
axp.setChgLEDMode(ledOn ? AXP20X_LED_LOW_LEVEL : AXP20X_LED_OFF);
@ -92,7 +92,7 @@ void setGPSPower(bool on)
{
DEBUG_MSG("Setting GPS power=%d\n", on);
#ifdef TBEAM_V10
#ifdef HAS_AXP192
if (axp192_found)
axp.setPowerOutPut(AXP192_LDO3, on ? AXP202_ON : AXP202_OFF); // GPS main power
#endif
@ -187,7 +187,7 @@ void doDeepSleep(uint64_t msecToWake)
digitalWrite(VEXT_ENABLE, 1); // turn off the display power
#endif
#ifdef TBEAM_V10
#ifdef HAS_AXP192
if (axp192_found) {
// Obsolete comment: from back when we we used to receive lora packets while CPU was in deep sleep.
// We no longer do that, because our light-sleep current draws are low enough and it provides fast start/low cost

View File

@ -34,4 +34,4 @@
// Leave undefined to disable our PMU IRQ handler. DO NOT ENABLE THIS because the pmuirq can cause sperious interrupts
// and waking from light sleep
// #define PMU_IRQ 35
#define AXP192_SLAVE_ADDRESS 0x34
#define HAS_AXP192