SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
AXP202Coulomb.hpp
Go to the documentation of this file.
1
13#pragma once
14#include "AXP202Core.hpp"
15#include "AXP202Regs.hpp"
16
18{
19public:
20 explicit AXP202Coulomb(AXP202Core &core) : _core(core) {}
21
32
33 bool isEnabled()
34 {
36 }
37
42 bool pause()
43 {
45 }
46
51 bool resume()
52 {
54 }
55
60 bool clear()
61 {
63 }
64
70 {
71 return readCoulomb32(axp202_regs::coulomb::BAT_CHGCOULOMB3);
72 }
73
79 {
80 return readCoulomb32(axp202_regs::coulomb::BAT_DISCHGCOULOMB3);
81 }
82
83private:
84 uint32_t readCoulomb32(uint8_t regH)
85 {
86 uint8_t buf[4];
87 if (_core.readRegBuff(regH, buf, 4) < 0) return 0;
88 return (static_cast<uint32_t>(buf[0]) << 24) |
89 (static_cast<uint32_t>(buf[1]) << 16) |
90 (static_cast<uint32_t>(buf[2]) << 8) |
91 static_cast<uint32_t>(buf[3]);
92 }
93
94 AXP202Core &_core;
95};
@license MIT License
@license MIT License
uint32_t getDischargeCoulomb()
Read discharge coulomb counter (REG B4H-B7H, 32-bit big-endian)
uint32_t getChargeCoulomb()
Read charge coulomb counter (REG B0H-B3H, 32-bit big-endian)
bool pause()
Pause coulomb counter (REG B8H bit 6)
bool enable(bool enable)
Enable coulomb counter (REG B8H bit 7)
AXP202Coulomb(AXP202Core &core)
bool clear()
Clear/reset coulomb counter (REG B8H bit 5)
bool resume()
Resume coulomb counter (REG B8H bit 6 clear)
bool clrRegBit(uint8_t reg, uint8_t bit)
bool getRegBit(uint8_t reg, uint8_t bit)
int readRegBuff(uint8_t reg, uint8_t *buf, size_t len) const
bool setRegBit(uint8_t reg, uint8_t bit)
char buf[64]
static constexpr uint8_t COULOMB_CTL
static constexpr uint8_t BAT_CHGCOULOMB3
static constexpr uint8_t BAT_DISCHGCOULOMB3