|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
#include <BQ25896Core.hpp>
Public Member Functions | |
| BQ25896Core ()=default | |
| ~BQ25896Core ()=default | |
| void | end () |
| Deinitialize and release resources. | |
| bool | isValid () const |
| Check if device is valid/present. | |
| uint8_t | getDeviceRevision () const |
| Get device revision. | |
| uint8_t | getDeviceConfig () |
| Get device configuration/part number. | |
| void | reset () |
| Reset device to default state. | |
| bool | isVbusPresent () |
| Check if VBUS (USB power) is present. | |
| uint8_t | getBusStatus () |
| Get USB port type status. | |
| uint8_t | getChargeStatus () |
| Get charging status. | |
| bool | isPowerGood () |
| Check if power is good. | |
| bool | isCharging () |
| Check if actively charging. | |
| bool | isChargeDone () |
| Check if charging is complete. | |
| bool | isOtg () |
| Check if in OTG (boost) mode. | |
| bool | isVsysInRegulation () |
| Check if VSYS is in regulation. | |
| bool | isVindpmActive () |
| Get fault status. | |
| bool | isIindpmActive () |
| Check if IINDPM is active (input current limiting) | |
| bool | getFaultStatus (uint8_t &fault) |
| Get fault status. | |
| bool | isInputCurrentOptimizerOptimized () |
| Check if Input Current Optimizer has optimized. | |
Public Member Functions inherited from I2CDeviceWithHal | |
| bool | begin (SensorCommCustom::CustomCallback cb, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr) |
| Initialize the sensor using custom callback interface. | |
Public Member Functions inherited from DeviceBeginCommon | |
| virtual | ~DeviceBeginCommon () |
| uint8_t | getAddress () const |
| uint8_t | getInterface () const |
Public Member Functions inherited from SensorCommWrapper | |
| SensorCommWrapper ()=default | |
| int | readReg (uint8_t reg) const |
| int | readRegBuff (uint8_t reg, uint8_t *buf, size_t len) const |
| int | readBuff (uint8_t *buf, size_t len) const |
| int | writeReg (uint8_t reg, uint8_t val) |
| int | writeRegBuff (uint8_t reg, uint8_t *buf, size_t len) |
| int | writeBuff (uint8_t *buf, size_t len) |
| int | writeThenRead (const uint8_t *write_buffer, size_t write_len, uint8_t *read_buffer, size_t read_len) |
| bool | setRegBit (uint8_t reg, uint8_t bit) |
| bool | clrRegBit (uint8_t reg, uint8_t bit) |
| bool | getRegBit (uint8_t reg, uint8_t bit) |
| int | updateBits (uint8_t reg, uint8_t mask, uint8_t value_shifted) |
| void | setAddress (uint8_t address) |
| void | setAck (bool enable) |
Public Member Functions inherited from SensorCommInterface | |
| virtual | ~SensorCommInterface ()=default |
Additional Inherited Members | |
Protected Member Functions inherited from I2CDeviceWithHal | |
| bool | ensureValid () const override |
| Ensure the communication interface is valid. | |
Protected Member Functions inherited from DeviceBeginCommon | |
| DeviceBeginCommon ()=default | |
| virtual SensorCommBase * | getComm () const override |
| virtual void | beforeBegin () |
| virtual void | afterCommReady () |
| virtual void | afterInitSuccess (uint8_t param) |
| virtual void | onBeginFail () |
| bool | fail () |
| void | clearCommState () |
| template<typename CreateComm > | |
| bool | beginLifecycle (uint8_t addr, uint8_t iface, uint8_t initParam, CreateComm createComm) |
Protected Attributes inherited from DeviceBeginCommon | |
| std::unique_ptr< SensorCommBase > | comm |
| std::unique_ptr< SensorHal > | hal |
| std::unique_ptr< SensorCommStatic > | staticComm |
| uint8_t | _addr = 0 |
| uint8_t | _iface = COMM_CUSTOM |
Definition at line 120 of file BQ25896Core.hpp.
|
default |
|
default |
| void BQ25896Core::end | ( | ) |
Deinitialize and release resources.
Called when shutting down the device. Currently a no-op but may be used for cleanup in derived implementations.
Definition at line 38 of file BQ25896Core.cpp.
Referenced by PmicBQ25896::end().
| uint8_t BQ25896Core::getBusStatus | ( | ) |
Get USB port type status.
Returns the detected USB port type from REG_STATUS (0x0B). This is updated after BC1.2/HVDCP detection.
Definition at line 69 of file BQ25896Core.cpp.
References SensorCommWrapper::readReg().
Referenced by isOtg().
| uint8_t BQ25896Core::getChargeStatus | ( | ) |
Get charging status.
Returns the current charging state from REG_STATUS (0x0B).
Definition at line 75 of file BQ25896Core.cpp.
References SensorCommWrapper::readReg().
Referenced by BQ25896Charger::getStatus(), isChargeDone(), and isCharging().
| uint8_t BQ25896Core::getDeviceConfig | ( | ) |
Get device configuration/part number.
Reads the PN bits from REG_DEVICE_REV (0x14).
Definition at line 52 of file BQ25896Core.cpp.
References SensorCommWrapper::readReg().
| uint8_t BQ25896Core::getDeviceRevision | ( | ) | const |
Get device revision.
Reads the device revision from REG_DEVICE_REV (0x14). The BQ25896 returns 0x02 for the revision.
Definition at line 46 of file BQ25896Core.cpp.
References SensorCommWrapper::readReg().
Referenced by isValid().
| bool BQ25896Core::getFaultStatus | ( | uint8_t & | fault | ) |
Get fault status.
Reads the fault register REG0C (0x0C) and returns the raw fault byte for detailed fault analysis.
| fault | Reference to store fault byte |
Definition at line 120 of file BQ25896Core.cpp.
References SensorCommWrapper::readReg().
Referenced by BQ25896Charger::getStatus().
| bool BQ25896Core::isChargeDone | ( | ) |
Check if charging is complete.
Returns true when charge status is DONE (3). Indicates the battery has reached full charge and terminated.
Definition at line 92 of file BQ25896Core.cpp.
References getChargeStatus().
Referenced by BQ25896Charger::getStatus().
| bool BQ25896Core::isCharging | ( | ) |
Check if actively charging.
Returns true when charge status is not NO_CHARGE. This includes both pre-charge and fast-charge phases.
Definition at line 87 of file BQ25896Core.cpp.
References getChargeStatus().
Referenced by BQ25896Charger::getStatus(), BQ25896Charger::isCharging(), and BQ25896Adc::read().
| bool BQ25896Core::isIindpmActive | ( | ) |
Check if IINDPM is active (input current limiting)
Reads the IDPM_STAT bit from REG13 (0x13). Returns true when input current has reached the IINDPM limit.
Definition at line 114 of file BQ25896Core.cpp.
References SensorCommWrapper::readReg().
Referenced by loop().
| bool BQ25896Core::isInputCurrentOptimizerOptimized | ( | ) |
Check if Input Current Optimizer has optimized.
Reads the ICO_OPTIMIZED bit from REG_DEVICE_REV (0x14). Returns true when ICO has determined the maximum input current.
Definition at line 128 of file BQ25896Core.cpp.
References SensorCommWrapper::readReg().
Referenced by loop().
| bool BQ25896Core::isOtg | ( | ) |
Check if in OTG (boost) mode.
Returns true when bus status is OTG (7). Indicates the BQ25896 is supplying power to VBUS (5V/1A-2A).
Definition at line 97 of file BQ25896Core.cpp.
References getBusStatus().
| bool BQ25896Core::isPowerGood | ( | ) |
Check if power is good.
Reads the PG_STAT bit from REG_STATUS (0x0B). Indicates valid input power (VBUS > VBUS_VALID and within spec).
Definition at line 81 of file BQ25896Core.cpp.
References SensorCommWrapper::readReg().
| bool BQ25896Core::isValid | ( | ) | const |
Check if device is valid/present.
Verifies communication by reading the device revision register and comparing against expected value (0x02).
Definition at line 40 of file BQ25896Core.cpp.
References getDeviceRevision().
Referenced by BQ25896Charger::getStatus().
| bool BQ25896Core::isVbusPresent | ( | ) |
Check if VBUS (USB power) is present.
Reads the VBUS_GD bit from the VBUS ADC register (REG11). Returns true when VBUS voltage is above the valid threshold (≥3.8V).
Definition at line 63 of file BQ25896Core.cpp.
References SensorCommWrapper::readReg().
Referenced by BQ25896Power::enableBoost(), BQ25896Charger::getStatus(), and BQ25896Adc::read().
| bool BQ25896Core::isVindpmActive | ( | ) |
Get fault status.
Reads the VDPM_STAT bit from REG13 (0x13). Returns true when input voltage has dropped to the VINDPM threshold.
Definition at line 108 of file BQ25896Core.cpp.
References SensorCommWrapper::readReg().
Referenced by loop().
| bool BQ25896Core::isVsysInRegulation | ( | ) |
Check if VSYS is in regulation.
Reads the VSYS_STAT bit from REG_STATUS (0x0B). Returns true when system voltage is being regulated to SYS_MIN. This happens when battery voltage drops below the minimum system voltage.
Definition at line 102 of file BQ25896Core.cpp.
References SensorCommWrapper::readReg().
Referenced by loop().
| void BQ25896Core::reset | ( | ) |
Reset device to default state.
Performs a register reset by setting the REG_RST bit in REG_DEVICE_REV (0x14). This resets all registers to their default values and resets the safety timer.
Definition at line 58 of file BQ25896Core.cpp.
References SensorCommWrapper::setRegBit().