|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
#include <SY6970Core.hpp>
Public Member Functions | |
| SY6970Core ()=default | |
| ~SY6970Core ()=default | |
| void | end () |
| Deinitialize and release resources. | |
| bool | isValid () const |
| Check if device is valid/present. | |
| uint8_t | getDeviceRevision () const |
| Get device revision. | |
| 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 | getFaultStatus (uint8_t &fault) |
| Get fault status. | |
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 95 of file SY6970Core.hpp.
|
default |
|
default |
| void SY6970Core::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 SY6970Core.cpp.
Referenced by PmicSY6970::end().
| uint8_t SY6970Core::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 63 of file SY6970Core.cpp.
References SensorCommWrapper::readReg().
Referenced by isOtg().
| uint8_t SY6970Core::getChargeStatus | ( | ) |
Get charging status.
Returns the current charging state from REG_STATUS (0x0B).
Definition at line 69 of file SY6970Core.cpp.
References SensorCommWrapper::readReg().
Referenced by SY6970Charger::getStatus(), isChargeDone(), and isCharging().
| uint8_t SY6970Core::getDeviceRevision | ( | ) | const |
Get device revision.
Reads the device revision from REG_DEVICE_REV (0x14). The SY6970 returns 0x00 for the base revision.
Definition at line 46 of file SY6970Core.cpp.
References SensorCommWrapper::readReg().
Referenced by isValid().
| bool SY6970Core::getFaultStatus | ( | uint8_t & | fault | ) |
Get fault status.
Reads the fault register REG_FAULT (0x0C) and returns the raw fault byte for detailed fault analysis.
| fault | Reference to store fault byte |
Definition at line 96 of file SY6970Core.cpp.
References SensorCommWrapper::readReg().
Referenced by SY6970Charger::getStatus().
| bool SY6970Core::isChargeDone | ( | ) |
Check if charging is complete.
Returns true when charge status is DONE (3). Indicates the battery has reached full charge.
Definition at line 86 of file SY6970Core.cpp.
References getChargeStatus().
Referenced by SY6970Charger::getStatus().
| bool SY6970Core::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 81 of file SY6970Core.cpp.
References getChargeStatus().
Referenced by SY6970Charger::getStatus(), SY6970Charger::isCharging(), and SY6970Adc::read().
| bool SY6970Core::isOtg | ( | ) |
Check if in OTG (boost) mode.
Returns true when bus status is OTG (7). Indicates the SY6970 is supplying power to VBUS.
Definition at line 91 of file SY6970Core.cpp.
References getBusStatus().
| bool SY6970Core::isPowerGood | ( | ) |
Check if power is good.
Reads the PG_STAT bit from REG_STATUS (0x0B). Indicates valid input power (VBUS > VBUS_VALID).
Definition at line 75 of file SY6970Core.cpp.
References SensorCommWrapper::readReg().
| bool SY6970Core::isValid | ( | ) | const |
Check if device is valid/present.
Verifies communication by reading the device revision register and comparing against expected value (0x00).
Definition at line 40 of file SY6970Core.cpp.
References getDeviceRevision().
Referenced by SY6970Charger::getStatus().
| bool SY6970Core::isVbusPresent | ( | ) |
Check if VBUS (USB power) is present.
Reads the BUS_GD bit from the VBUS ADC register. Returns true when VBUS voltage is above the valid threshold.
Definition at line 57 of file SY6970Core.cpp.
References SensorCommWrapper::readReg().
Referenced by SY6970Power::enableBoost(), SY6970Charger::getStatus(), and SY6970Adc::read().
| void SY6970Core::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.
Definition at line 52 of file SY6970Core.cpp.
References SensorCommWrapper::setRegBit().