+ Fixup: Bq27220

* Give credit
 * Fixed scope of byte functions
 * Remove debug log
 * Update README.md
This commit is contained in:
Dominic Höglinger 2025-07-03 18:22:06 +02:00
parent baa4ed96df
commit 61b0fd84ee
3 changed files with 16 additions and 8 deletions

View File

@ -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)

View File

@ -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.");
}
}

View File

@ -20,6 +20,11 @@ private:
template<typename T>
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
{