SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
AXP2101Power.hpp
Go to the documentation of this file.
1
31#pragma once
32#include "AXP2101Core.hpp"
33#include "../../PmicPowerBase.hpp"
34
36{
37public:
38 // DCDC identifiers for protection control
39 static constexpr uint8_t DCDC1 = 0;
40 static constexpr uint8_t DCDC2 = 1;
41 static constexpr uint8_t DCDC3 = 2;
42 static constexpr uint8_t DCDC4 = 3;
43 static constexpr uint8_t DCDC5 = 4;
44
49 explicit AXP2101Power(AXP2101Core &core);
50 ~AXP2101Power() = default;
51
52 // ---- PmicPowerBase overrides ----
53
59 bool setMinimumSystemVoltage(uint32_t mv) override;
60
65 uint32_t getMinimumSystemVoltage() const override;
66
72 bool setInputVoltageLimit(uint32_t mv) override;
73
78 uint32_t getInputVoltageLimit() const override;
79
85 bool setInputCurrentLimit(uint32_t mA) override;
86
91 uint32_t getInputCurrentLimit() const override;
92
102 bool enableShipMode(bool enable) override;
103
108 bool isShipModeEnabled() const override;
109
110 // ---- VSYS Power Down Voltage (REG 24) ----
111
117 bool setSysPowerDownVoltage(uint16_t millivolt);
118
123 uint16_t getSysPowerDownVoltage();
124
125 // ---- Internal Discharge (REG 10 bit 5) ----
126
131
136
137 // ---- System Reset & Shutdown (REG 10) ----
138
142 void softShutdown();
143
147 void resetSoC();
148
149 // ---- Sleep / Wakeup (REG 26) ----
150
155 bool enableSleep();
156
161 bool disableSleep();
162
167 bool enableWakeup();
168
173 bool disableWakeup();
174
175 // ---- PWROK & Sequence (REG 25) ----
176
180 void enablePwrOk();
181
185 void disablePwrOk();
186
190 void enablePowerOffDelay();
191
196
200 void enablePowerSequence();
201
206
212 bool setPwrOkDelay(uint8_t opt);
213
218 uint8_t getPwrOkDelay();
219
220 // ---- Power Off Configuration (REG 22) ----
221
226
231
236
241
246 void setLongPressAction(bool restart);
247
248 // ---- DCDC Protection (REG 23-24) ----
249
254 void setDCOverVoltageProtection(bool enable);
255
261
267 void setDCLowVoltageProtection(uint8_t dc_id, bool enable);
268
274 bool isDCLowVoltageProtectionEnabled(uint8_t dc_id);
275
276 // ---- Power On/Off Source Status (REG 20-21) ----
277
282 uint8_t getPowerOnStatus();
283
288 uint8_t getPowerOffStatus();
289
290 // ---- Fuel Gauge ----
291
298 bool writeGaugeData(uint8_t *data, uint8_t len);
299
306 bool compareGaugeData(uint8_t *data, uint8_t len);
307
308 // ---- Low Battery Thresholds (REG 1A) ----
309
314 void setLowBatWarnThreshold(uint8_t percentage);
315
320 uint8_t getLowBatWarnThreshold();
321
326 void setLowBatShutdownThreshold(uint8_t percentage);
327
333
334 // ---- Die Temperature Protection (REG 13) ----
335
341 bool enableDieTempDetection(bool enable);
342
348
354 bool setDieTempLevel1Threshold(uint8_t opt);
355
361
362 // ---- DCDC PWM Mode Control (REG 81) ----
363
370 bool setDCDCForcePWM(uint8_t dc_id, bool force);
371
377 bool isDCDCForcePWM(uint8_t dc_id);
378
384 bool setDCDCForceCCM(bool enable);
385
390 bool isDCDCForceCCM();
391
397 bool setDVMRampSlow(bool slow);
398
403 bool isDVMRampSlow();
404
410 bool setFrequencySpreadEnable(bool enable);
411
417
423 bool setFrequencySpreadRange(bool wide);
424
430
436 bool setDCDCUVPDebounce(uint8_t opt);
437
442 uint8_t getDCDCUVPDebounce();
443
444 // ---- Fast Power-On Sequencing (REG 28-2B) ----
445
451 bool enableFastPowerOn(bool enable);
452
458
464 bool enableFastWakeup(bool enable);
465
470 bool isFastWakeupEnabled();
471
480 bool setFastPowerOnSequence(uint8_t channel, uint8_t seq);
481
487 uint8_t getFastPowerOnSequence(uint8_t channel);
488
489private:
490 AXP2101Core &_core;
491};
@license MIT License
Core I2C communication layer for the AXP2101 PMIC.
void enablePowerSequence()
Enable power-on sequencing (REG 0x25 bit 2).
void softShutdown()
Initiate a soft shutdown (REG 0x10 bit 0).
void setLowBatShutdownThreshold(uint8_t percentage)
Set the low-battery shutdown threshold (REG 0x1A bits 3:0).
static constexpr uint8_t DCDC4
void disableLongPressShutdown()
Disable long-press power-off (REG 0x22 bit 1).
bool setDCDCUVPDebounce(uint8_t opt)
Set DCDC UVP debounce time (REG 81 bits 1:0).
void enablePwrOk()
Enable PWROK output (REG 0x25 bit 4).
bool isFastPowerOnEnabled()
Check if fast power-on sequence is enabled (REG 2B bit 7).
void disablePwrOk()
Disable PWROK output (REG 0x25 bit 4).
~AXP2101Power()=default
void disableInternalDischarge()
Disable internal battery discharge resistor (REG 0x10 bit 5).
uint8_t getDCDCUVPDebounce()
Get DCDC UVP debounce time (REG 81 bits 1:0).
uint32_t getInputCurrentLimit() const override
Get the VBUS input current limit (REG 0x16 bits 2:0).
bool getFrequencySpreadRange()
Get the frequency spread range (REG 81 bit 6).
bool isFastWakeupEnabled()
Check if fast wakeup is enabled (REG 2B bit 6).
bool enableFastWakeup(bool enable)
Enable fast wakeup (REG 2B bit 6).
bool enableWakeup()
Enable wakeup function (REG 0x26 bit 1).
bool enableSleep()
Enable sleep mode (REG 0x26 bit 0).
bool isDCDCForcePWM(uint8_t dc_id)
Check if a DCDC converter is in forced-PWM mode (REG 81 bits 2-5).
uint16_t getSysPowerDownVoltage()
Get the VSYS power-off voltage threshold (REG 0x24 bits 2:0).
void setDCOverVoltageProtection(bool enable)
Enable or disable DC over-voltage protection (REG 0x23 bit 5).
bool compareGaugeData(uint8_t *data, uint8_t len)
Compare data against the fuel-gauge backup registers.
void setDCLowVoltageProtection(uint8_t dc_id, bool enable)
Enable or disable under-voltage protection for a DCDC (REG 0x23 bits 0-4).
void disablePowerSequence()
Disable power-on sequencing (REG 0x25 bit 2).
void enableOverTempShutdown()
Enable automatic shutdown on over-temperature (REG 0x22 bit 2).
bool isShipModeEnabled() const override
Check whether ship mode is currently active (REG 0x12 bit 3).
uint32_t getMinimumSystemVoltage() const override
Get the minimum VSYS system voltage (REG 0x14 bits 6:4).
bool setFrequencySpreadRange(bool wide)
Set frequency spread range (REG 81 bit 6).
bool enableDieTempDetection(bool enable)
Enable or disable die temperature detection.
bool setDieTempLevel1Threshold(uint8_t opt)
Set die over-temperature Level1 threshold (REG 13 bits 2:1).
static constexpr uint8_t DCDC2
void resetSoC()
Trigger a system-on-chip reset (REG 0x10 bit 1).
uint8_t getPwrOkDelay()
Get the PWROK delay time (REG 0x25 bits 1:0).
bool setInputCurrentLimit(uint32_t mA) override
Set the VBUS input current limit (REG 0x16 bits 2:0).
uint8_t getPowerOnStatus()
Read the power-on source status register (REG 0x20, read-only).
void setLowBatWarnThreshold(uint8_t percentage)
Set the low-battery warning threshold (REG 0x1A bits 7:4).
bool setDCDCForcePWM(uint8_t dc_id, bool force)
Force a DCDC converter to always-PWM mode (REG 81 bits 2-5).
void disableOverTempShutdown()
Disable automatic shutdown on over-temperature (REG 0x22 bit 2).
bool setSysPowerDownVoltage(uint16_t millivolt)
Set the VSYS power-off voltage threshold (REG 0x24 bits 2:0).
static constexpr uint8_t DCDC1
bool isFrequencySpreadEnabled()
Check if frequency spread spectrum is enabled (REG 81 bit 7).
bool writeGaugeData(uint8_t *data, uint8_t len)
Write user data to the fuel-gauge backup registers.
uint8_t getFastPowerOnSequence(uint8_t channel)
Get fast power-on start sequence for a channel (REG 28-2B).
uint32_t getInputVoltageLimit() const override
Get the VBUS input voltage limit (REG 0x15 bits 3:0).
static constexpr uint8_t DCDC5
bool disableWakeup()
Disable wakeup function (REG 0x26 bit 1).
bool isDCDCForceCCM()
Check if all DCDC1-4 are in forced CCM mode (REG 80 bit 6).
bool setDVMRampSlow(bool slow)
Set DVM voltage ramp rate (REG 80 bit 5).
bool isDVMRampSlow()
Check if DVM ramp is set to slow (REG 80 bit 5).
bool setInputVoltageLimit(uint32_t mv) override
Set the VBUS input voltage limit (REG 0x15 bits 3:0).
bool enableFastPowerOn(bool enable)
Enable fast power-on sequence (REG 2B bit 7).
bool isDieTempDetectionEnabled()
Check if die temperature detection is enabled.
bool setDCDCForceCCM(bool enable)
Force all DCDC1-4 to CCM (continuous conduction mode) (REG 80 bit 6).
uint8_t getLowBatShutdownThreshold()
Get the low-battery shutdown threshold (REG 0x1A bits 3:0).
bool disableSleep()
Disable sleep mode (REG 0x26 bit 0).
bool enableShipMode(bool enable) override
Enable or disable ship mode (REG 0x12 bit 3).
bool isDCLowVoltageProtectionEnabled(uint8_t dc_id)
Check if under-voltage protection is enabled for a DCDC (REG 0x23 bits 0-4).
bool setMinimumSystemVoltage(uint32_t mv) override
Set the minimum VSYS system voltage (REG 0x14 bits 6:4).
bool setFastPowerOnSequence(uint8_t channel, uint8_t seq)
Set fast power-on start sequence for a channel (REG 28-2B).
void enablePowerOffDelay()
Enable power-off delay (REG 0x25 bit 3).
void disablePowerOffDelay()
Disable power-off delay (REG 0x25 bit 3).
bool isDCOverVoltageProtectionEnabled()
Check if DC over-voltage protection is enabled (REG 0x23 bit 5).
uint8_t getDieTempLevel1Threshold()
Get die over-temperature Level1 threshold (REG 13 bits 2:1).
void enableLongPressShutdown()
Enable long-press power-off (REG 0x22 bit 1).
bool setFrequencySpreadEnable(bool enable)
Enable DCDC frequency spread spectrum (REG 81 bit 7).
uint8_t getLowBatWarnThreshold()
Get the low-battery warning threshold (REG 0x1A bits 7:4).
uint8_t getPowerOffStatus()
Read the power-off source status register (REG 0x21, read-only).
bool setPwrOkDelay(uint8_t opt)
Set the PWROK delay time (REG 0x25 bits 1:0).
void enableInternalDischarge()
Enable internal battery discharge resistor (REG 0x10 bit 5).
static constexpr uint8_t DCDC3
void setLongPressAction(bool restart)
Set the long-press power key action (REG 0x22 bit 0).