diff --git a/Drivers/BQ27220/README.md b/Drivers/BQ27220/README.md index 5ecc1181..6a9240a5 100644 --- a/Drivers/BQ27220/README.md +++ b/Drivers/BQ27220/README.md @@ -1,5 +1,6 @@ -# BQ24295 +# BQ27220 -Power management: I2C-controlled 3A single cell USB charger with narrow VDC 4.5-5.5V adjustable voltage at 1.5A synchronous boost operation. +Power management: Single-Cell CEDV Fuel Gauge -[Datasheet](https://www.ti.com/lit/ds/symlink/bq24295.pdf) +[Datasheet](https://www.ti.com/lit/gpn/bq27220) +[User Guide](https://www.ti.com/lit/pdf/sluubd4) diff --git a/Drivers/BQ27220/Source/Bq27220.cpp b/Drivers/BQ27220/Source/Bq27220.cpp index 9a67ff51..cbf31ebb 100644 --- a/Drivers/BQ27220/Source/Bq27220.cpp +++ b/Drivers/BQ27220/Source/Bq27220.cpp @@ -7,9 +7,9 @@ #define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a))) -uint8_t highByte(const uint16_t word) { return (word >> 8) & 0xFF; } -uint8_t lowByte(const uint16_t word) { return word & 0xFF; } -void swapEndianess(uint16_t &word) { word = (lowByte(word) << 8) | highByte(word); } +static uint8_t highByte(const uint16_t word) { return (word >> 8) & 0xFF; } +static uint8_t lowByte(const uint16_t word) { return word & 0xFF; } +static constexpr void swapEndianess(uint16_t &word) { word = (lowByte(word) << 8) | highByte(word); } namespace registers { static const uint16_t SUBCMD_CTRL_STATUS = 0x0000U; @@ -314,8 +314,6 @@ bool Bq27220::configPreamble(bool &isSealed) { if (!unsealFullAccess()) { TT_LOG_E(TAG, "Unsealing full access failure!"); return false; - } else { - TT_LOG_I(TAG, "Full access theoretically."); } } diff --git a/Drivers/BQ27220/Source/Bq27220.h b/Drivers/BQ27220/Source/Bq27220.h index abf5b86d..0054bf32 100644 --- a/Drivers/BQ27220/Source/Bq27220.h +++ b/Drivers/BQ27220/Source/Bq27220.h @@ -20,6 +20,11 @@ private: template bool performConfigUpdate(T configUpdateFunc) { + // Configuration routine lifted from + // https://github.com/Xinyuan-LilyGO/T-Echo/blob/main/lib/SensorLib/src/GaugeBQ27220.hpp + // Copyright (c) 2025 lewis he + // SPDX-License-Identifier: MIT + bool isSealed = false; if (!configPreamble(isSealed)) { @@ -32,6 +37,10 @@ private: } public: + // Register structures lifted from + // https://github.com/Xinyuan-LilyGO/T-Deck-Pro/blob/master/lib/BQ27220/bq27220.h + // Copyright (c) 2025 Liygo / Shenzhen Xinyuan Electronic Technology Co., Ltd + union BatteryStatus { struct {