SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
PmicSY6970.hpp
Go to the documentation of this file.
1
40#pragma once
41
42#include "../../../SensorBuildOpt.h"
43#if !SENSORLIB_EXCLUDE_PMIC_SY6970
44
45#include "../../PmicBase.hpp"
46#include "../../PmicPowerBase.hpp"
47#include "../../PmicAdcBase.hpp"
48
49#include "SY6970Core.hpp"
50#include "SY6970Charger.hpp"
51#include "SY6970Power.hpp"
52#include "SY6970Adc.hpp"
53#include "SY6970Led.hpp"
54
60static constexpr uint8_t SY6970_SLAVE_ADDRESS = 0x6A;
61
62class PmicSY6970 : public PmicBase
63{
64public:
72 PmicSY6970() : _core(), _charger(_core), _power(_core), _adc(_core), _led(_core) {}
73
74#if defined(ARDUINO)
83 bool begin(TwoWire &wire, uint8_t addr, int sda = -1, int scl = -1)
84 {
85 return _core.begin(wire, addr, sda, scl);
86 }
87#elif defined(ESP_PLATFORM)
88#if defined(SENSORLIB_USE_I2C_LEGACY)
97 bool begin(i2c_port_t port_num, uint8_t addr, int sda = -1, int scl = -1)
98 {
99 return _core.begin(port_num, addr, sda, scl);
100 }
101#else
110 bool begin(i2c_master_bus_handle_t handle, uint8_t addr)
111 {
112 return _core.begin(handle, addr);
113 }
114#endif
115#endif
116
129 uint8_t addr)
130 {
131 return _core.begin(callback, hal_cb, addr);
132 }
133
139 void end()
140 {
141 _core.end();
142 }
143
154
168 {
169 return _charger;
170 }
171
177 {
178 return &_charger;
179 }
180
193 {
194 return _power;
195 }
196
209 PmicAdcBase &getAdc() override
210 {
211 return _adc;
212 }
213
230 PmicLedBase &getLed() override
231 {
232 return _led;
233 }
234
235 // ---- Chip-specific module accessors ----
236
238 {
239 return _power;
240 }
241
243 {
244 return _led;
245 }
246
248 {
249 return _adc;
250 }
251
256 const PmicConfig &getConfig() const override
257 {
258 static const PmicConfig config = {
259 .chipName = "SY6970",
260 .i2cAddress = 0x6A,
261 .chipIdReg = 0x14,
262 .chipIdValue = 0x00,
263 .channelCount = 0,
267 // REG04[6:0]: ICHG = 64*N mA, N=0..79
268 .chargeCurrentMin = 0,
269 .chargeCurrentMax = 5056,
270 .chargeCurrentStep = 64,
271 .chargeCurrentSteps = 80,
272 };
273 return config;
274 }
275
276 const char *getChipName() const override
277 {
278 return "SY6970";
279 }
280
288 {
289 return _core;
290 }
291
296 const SY6970Core &core() const
297 {
298 return _core;
299 }
300
301private:
302 SY6970Core _core;
303 SY6970Charger _charger;
304 SY6970Power _power;
305 SY6970Adc _adc;
306 SY6970Led _led;
307};
308
309#endif
@license MIT License
@license MIT License
@license MIT License
@license MIT License
@license MIT License
bool begin(SensorCommCustom::CustomCallback cb, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialize the sensor using custom callback interface.
PMIC Base Abstract Class.
Definition PmicBase.hpp:130
PMIC charger capability interface.
PmicChargerBase * getCharger() override
Get charger interface (base class pointer)
bool begin(SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialize using custom I2C callback.
const PmicConfig & getConfig() const override
Get device name.
PmicCapability::Capability getCapabilities() const override
Get supported PMIC capabilities.
PmicSY6970()
Construct SY6970 PMIC interface.
SY6970Power & power()
SY6970Adc & adc()
SY6970Charger & charger()
Get charger interface.
PmicPowerBase & getPower() override
Get power management interface.
SY6970Led & led()
SY6970Core & core()
Get core interface (mutable)
const SY6970Core & core() const
Get core interface (const)
PmicAdcBase & getAdc() override
Get ADC interface.
void end()
Deinitialize and release resources.
PmicLedBase & getLed() override
Get LED interface.
const char * getChipName() const override
Get PMIC device name.
void end()
Deinitialize and release resources.
SY6970 LED/STAT Pin Control.
Definition SY6970Led.hpp:56
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