|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
#include <BQ25896Power.hpp>
Public Member Functions | |
| BQ25896Power (BQ25896Core &core) | |
| Construct power management interface. | |
| ~BQ25896Power ()=default | |
| bool | setMinimumSystemVoltage (uint32_t mv) override |
| Set minimum system voltage. | |
| uint32_t | getMinimumSystemVoltage () const override |
| Get minimum system voltage. | |
| bool | setInputVoltageLimit (uint32_t mv) override |
| Set input voltage limit (VINDPM) | |
| uint32_t | getInputVoltageLimit () const override |
| Get input voltage limit. | |
| bool | setInputCurrentLimit (uint32_t mA) override |
| Set input current limit. | |
| uint32_t | getInputCurrentLimit () const override |
| Get input current limit. | |
| bool | enableBoost (bool enable) override |
| Enable or disable OTG (boost) mode. | |
| bool | isBoostEnabled () const override |
| Check if boost mode is enabled. | |
| bool | setBoostVoltage (uint16_t mv) override |
| Set boost output voltage. | |
| uint16_t | getBoostVoltage () const override |
| Get boost output voltage. | |
| bool | enableShipMode (bool enable) override |
| Enable or disable ship mode. | |
| bool | isShipModeEnabled () const override |
| Check if ship mode is enabled. | |
| bool | enableWatchdog (bool enable) override |
| Enable or disable the I2C watchdog timer. | |
| bool | isWatchdogEnabled () const override |
| Check if watchdog is enabled. | |
| bool | setWatchdogTimeout (uint16_t timeout_s) override |
| Set the watchdog timeout duration. | |
| uint16_t | getWatchdogTimeout () const override |
| Get the current watchdog timeout setting. | |
| bool | resetWatchdog () override |
| Reset the watchdog timer (feed the watchdog) | |
Public Member Functions inherited from PmicPowerBase | |
| virtual | ~PmicPowerBase ()=default |
| Virtual destructor. | |
Public Member Functions inherited from PmicWatchdogBase | |
| virtual | ~PmicWatchdogBase ()=default |
| Virtual destructor. | |
Definition at line 85 of file BQ25896Power.hpp.
|
explicit |
Construct power management interface.
| core | Reference to BQ25896 core communication |
Definition at line 38 of file BQ25896Power.cpp.
|
default |
|
overridevirtual |
Enable or disable OTG (boost) mode.
Enables or disables the boost (OTG) mode. When enabled, the BQ25896 operates as a power source, converting battery voltage to 5V on VBUS to power external USB devices (phones, tablets, accessories).
| enable | true to enable boost/OTG mode, false to disable |
Reimplemented from PmicPowerBase.
Definition at line 103 of file BQ25896Power.cpp.
References BQ25896Core::isVbusPresent(), and SensorCommWrapper::updateBits().
|
overridevirtual |
Enable or disable ship mode.
Ship mode disconnects the battery from the system by turning off the BATFET. This is used for:
When ship mode is enabled and no VBUS is present, the system is completely powered down (only the charger IC remains in low-power mode).
| enable | true to enter ship mode (battery disconnected), false to exit |
Reimplemented from PmicPowerBase.
Definition at line 142 of file BQ25896Power.cpp.
References SensorCommWrapper::updateBits().
|
overridevirtual |
Enable or disable the I2C watchdog timer.
When enabled, the watchdog monitors I2C communication. If no I2C access occurs within the timeout period, the PMIC will reset and restore default register values.
| enable | true to enable watchdog (default 40s timeout), false to disable |
Implements PmicWatchdogBase.
Definition at line 154 of file BQ25896Power.cpp.
References SensorCommWrapper::updateBits().
|
overridevirtual |
Get boost output voltage.
Reads the configured boost voltage.
Reimplemented from PmicPowerBase.
Definition at line 134 of file BQ25896Power.cpp.
References SensorCommWrapper::readReg().
Referenced by loop().
|
overridevirtual |
Get input current limit.
Reads the configured input current limit.
Implements PmicPowerBase.
Definition at line 96 of file BQ25896Power.cpp.
References SensorCommWrapper::readReg().
Referenced by setup().
|
overridevirtual |
Get input voltage limit.
Reads the configured VINDPM threshold.
Implements PmicPowerBase.
Definition at line 74 of file BQ25896Power.cpp.
References SensorCommWrapper::readReg().
Referenced by setup().
|
overridevirtual |
Get minimum system voltage.
Reads the configured minimum system voltage.
Implements PmicPowerBase.
Definition at line 53 of file BQ25896Power.cpp.
References SensorCommWrapper::readReg().
Referenced by setup().
|
overridevirtual |
Get the current watchdog timeout setting.
Implements PmicWatchdogBase.
Definition at line 185 of file BQ25896Power.cpp.
References SensorCommWrapper::readReg().
|
overridevirtual |
Check if boost mode is enabled.
Returns the current boost/OTG mode status.
Reimplemented from PmicPowerBase.
Definition at line 115 of file BQ25896Power.cpp.
References SensorCommWrapper::readReg().
Referenced by loop().
|
overridevirtual |
Check if ship mode is enabled.
Reads the BATFET_DIS bit from REG09 to determine if ship mode is active.
Reimplemented from PmicPowerBase.
Definition at line 148 of file BQ25896Power.cpp.
References SensorCommWrapper::readReg().
|
overridevirtual |
Check if watchdog is enabled.
Implements PmicWatchdogBase.
Definition at line 163 of file BQ25896Power.cpp.
References SensorCommWrapper::readReg().
|
overridevirtual |
Reset the watchdog timer (feed the watchdog)
This must be called regularly before the watchdog timeout expires to prevent the PMIC from resetting due to I2C communication timeout.
Implements PmicWatchdogBase.
Definition at line 194 of file BQ25896Power.cpp.
References SensorCommWrapper::updateBits().
|
overridevirtual |
Set boost output voltage.
Sets the output voltage when in OTG boost mode. This is the voltage that appears on VBUS when operating as a power source.
| mv | Boost voltage in millivolts (4550-5510mV) Value will be quantized to nearest valid step (64mV). |
Reimplemented from PmicPowerBase.
Definition at line 121 of file BQ25896Power.cpp.
References SensorCommWrapper::updateBits().
|
overridevirtual |
Set input current limit.
Sets the maximum input current drawn from VBUS. This prevents the charger from drawing more current than the adapter can provide.
The actual limit is the lower of this setting and the ILIM pin (if EN_ILIM is enabled).
| mA | Input current limit in milliamps (100-3250mA) Value will be quantized to nearest valid step (50mA). |
Implements PmicPowerBase.
Definition at line 83 of file BQ25896Power.cpp.
References SensorCommWrapper::updateBits().
Referenced by setup().
|
overridevirtual |
Set input voltage limit (VINDPM)
Sets the VINDPM threshold - the minimum voltage the input source is allowed to be pulled down to. This protects weak or low-quality adapters from being overloaded.
When VBUS voltage drops to this threshold, the charger automatically reduces input current to prevent the adapter from collapsing.
| mv | Input voltage limit in millivolts (3900-15300mV) Value will be quantized to nearest valid step (100mV). |
Implements PmicPowerBase.
Definition at line 61 of file BQ25896Power.cpp.
References SensorCommWrapper::updateBits().
Referenced by setup().
|
overridevirtual |
Set minimum system voltage.
Sets the minimum VSYS voltage threshold. VSYS is the charger output that powers the system load. During high load or low battery conditions, VSYS may drop but will not go below this value.
| mv | Minimum system voltage in millivolts (3000-3700mV) Value will be quantized to nearest valid step (100mV). |
Implements PmicPowerBase.
Definition at line 40 of file BQ25896Power.cpp.
References SensorCommWrapper::updateBits().
Referenced by setup().
|
overridevirtual |
Set the watchdog timeout duration.
Sets how long the watchdog will wait before triggering a fault. Must be called after enableWatchdog(true).
| timeout_s | Timeout in seconds (0=disabled, values >0 enable watchdog) Valid chip values: 0, 40, 80, 160 seconds. Other values will be clamped. |
Implements PmicWatchdogBase.
Definition at line 170 of file BQ25896Power.cpp.
References SensorCommWrapper::updateBits().