SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
PmicBQ25896.hpp
Go to the documentation of this file.
1
61#pragma once
62
63#include "../../../SensorBuildOpt.h"
64#if !SENSORLIB_EXCLUDE_PMIC_BQ25896
65
66#include "../../PmicBase.hpp"
67#include "../../PmicPowerBase.hpp"
68#include "../../PmicAdcBase.hpp"
69
70#include "BQ25896Core.hpp"
71#include "BQ25896Charger.hpp"
72#include "BQ25896Power.hpp"
73#include "BQ25896Adc.hpp"
74#include "BQ25896Led.hpp"
75
82static constexpr uint8_t BQ25896_SLAVE_ADDRESS = 0x6B;
83
84class PmicBQ25896 : public PmicBase
85{
86public:
94 PmicBQ25896() : _core(), _charger(_core), _power(_core), _adc(_core), _led(_core) {}
95
96#if defined(ARDUINO)
107 bool begin(TwoWire &wire, uint8_t addr, int sda = -1, int scl = -1)
108 {
109 return _core.begin(wire, addr, sda, scl);
110 }
111#elif defined(ESP_PLATFORM)
112#if defined(SENSORLIB_USE_I2C_LEGACY)
123 bool begin(i2c_port_t port_num, uint8_t addr, int sda = -1, int scl = -1)
124 {
125 return _core.begin(port_num, addr, sda, scl);
126 }
127#else
136 bool begin(i2c_master_bus_handle_t handle, uint8_t addr)
137 {
138 return _core.begin(handle, addr);
139 }
140#endif
141#endif
142
155 uint8_t addr)
156 {
157 return _core.begin(callback, hal_cb, addr);
158 }
159
165 void end()
166 {
167 _core.end();
168 }
169
180
194 {
195 return _charger;
196 }
197
203 {
204 return &_charger;
205 }
206
219 {
220 return _power;
221 }
222
239 PmicAdcBase &getAdc() override
240 {
241 return _adc;
242 }
243
260 PmicLedBase &getLed() override
261 {
262 return _led;
263 }
264
265 // ---- Chip-specific module accessors ----
266
268 {
269 return _power;
270 }
271
273 {
274 return _led;
275 }
276
278 {
279 return _adc;
280 }
281
286 const PmicConfig &getConfig() const override
287 {
288 static const PmicConfig config = {
289 .chipName = "BQ25896",
290 .i2cAddress = 0x6B,
291 .chipIdReg = 0x14,
292 .chipIdValue = 0x02,
293 .channelCount = 0,
297 // REG04[6:0]: ICHG = 64*N mA, N=0..47, clamped at 3008mA
298 .chargeCurrentMin = 0,
299 .chargeCurrentMax = 3008,
300 .chargeCurrentStep = 64,
301 .chargeCurrentSteps = 48,
302 };
303 return config;
304 }
305
306 const char *getChipName() const override
307 {
308 return "BQ25896";
309 }
310
324 {
325 return _core;
326 }
327
332 const BQ25896Core &core() const
333 {
334 return _core;
335 }
336
337private:
338 BQ25896Core _core;
339 BQ25896Charger _charger;
340 BQ25896Power _power;
341 BQ25896Adc _adc;
342 BQ25896Led _led;
343};
344
345#endif
@license MIT License
@license MIT License
@license MIT License
@license MIT License
@license MIT License
void end()
Deinitialize and release resources.
BQ25896 LED/STAT Pin Control.
bool begin(SensorCommCustom::CustomCallback cb, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialize the sensor using custom callback interface.
void end()
Deinitialize and release resources.
PmicBQ25896()
Construct BQ25896 PMIC interface.
const char * getChipName() const override
Get PMIC device name.
BQ25896Adc & adc()
const PmicConfig & getConfig() const override
Get device name.
BQ25896Core & core()
Get core interface (mutable)
PmicCapability::Capability getCapabilities() const override
Get supported PMIC capabilities.
PmicLedBase & getLed() override
Get LED interface.
PmicChargerBase * getCharger() override
Get charger interface (base class pointer)
BQ25896Led & led()
BQ25896Power & power()
bool begin(SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialize using custom I2C callback.
BQ25896Charger & charger()
Get charger interface.
PmicPowerBase & getPower() override
Get power management interface.
const BQ25896Core & core() const
Get core interface (const)
PmicAdcBase & getAdc() override
Get ADC interface.
PMIC Base Abstract Class.
Definition PmicBase.hpp:130
PMIC charger capability interface.
uint32_t(*)(Operation op, void *param1, void *param2) CustomHalCallback
bool(*)(uint8_t addr, uint8_t reg, uint8_t *buf, size_t len, bool writeReg, bool isWrite) CustomCallback
@ PmicSupportCharger
Battery charger support.
@ PmicSupportPower
Power management (input limits, boost, etc.)
@ PmicSupportAdc
Analog-to-Digital converter for monitoring.
PMIC static configuration data.
Definition PmicBase.hpp:108
const char * chipName
e.g. "AXP2101"
Definition PmicBase.hpp:109