From 15f5477ae0b4dd73f0e82fb761b651c869317661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Izzo?= Date: Mon, 21 Aug 2023 19:59:50 +0200 Subject: [PATCH] ttwrplus: add battery voltage readout Add battery voltage readout through the XPowersLib library. TG-553 --- platform/targets/ttwrplus/platform.c | 2 +- platform/targets/ttwrplus/pmu.cpp | 5 +++++ platform/targets/ttwrplus/pmu.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/platform/targets/ttwrplus/platform.c b/platform/targets/ttwrplus/platform.c index df155b08..5b0ba545 100644 --- a/platform/targets/ttwrplus/platform.c +++ b/platform/targets/ttwrplus/platform.c @@ -82,7 +82,7 @@ void platform_terminate() uint16_t platform_getVbat() { - return 0; + return pmu_getVbat(); } uint8_t platform_getMicLevel() diff --git a/platform/targets/ttwrplus/pmu.cpp b/platform/targets/ttwrplus/pmu.cpp index a6eb94f3..cc7801ff 100644 --- a/platform/targets/ttwrplus/pmu.cpp +++ b/platform/targets/ttwrplus/pmu.cpp @@ -292,3 +292,8 @@ void pmu_init() val = PMU.getChargeTargetVoltage(); printk("Setting Charge Target Voltage : %d\n", tableVoltage[val]); } + +uint16_t pmu_getVbat() +{ + return PMU.isBatteryConnect() ? PMU.getBattVoltage() : 0; +} diff --git a/platform/targets/ttwrplus/pmu.h b/platform/targets/ttwrplus/pmu.h index 1b70c080..71755b57 100644 --- a/platform/targets/ttwrplus/pmu.h +++ b/platform/targets/ttwrplus/pmu.h @@ -25,7 +25,7 @@ extern "C" { #endif void pmu_init(); - +uint16_t pmu_getVbat(); #ifdef __cplusplus }