|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
#include <SY6970Power.hpp>
Public Member Functions | |
| SY6970Power (SY6970Core &core) | |
| Construct power management interface. | |
| ~SY6970Power ()=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/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 62 of file SY6970Power.hpp.
|
explicit |
Construct power management interface.
| core | Reference to SY6970 core communication |
Definition at line 38 of file SY6970Power.cpp.
|
default |
|
overridevirtual |
Enable/disable OTG (boost) mode.
Enables or disables OTG (On-The-Go) boost mode. When enabled, the SY6970 converts battery power to 5V/2A on VBUS to power external USB devices.
| enable | true to enable OTG, false to disable |
Reimplemented from PmicPowerBase.
Definition at line 103 of file SY6970Power.cpp.
References SY6970Core::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 SY6970Power.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 SY6970Power.cpp.
References SensorCommWrapper::updateBits().
|
overridevirtual |
Get boost output voltage.
Reimplemented from PmicPowerBase.
Definition at line 134 of file SY6970Power.cpp.
References SensorCommWrapper::readReg().
Referenced by loop().
|
overridevirtual |
Get input current limit.
Implements PmicPowerBase.
Definition at line 96 of file SY6970Power.cpp.
References SensorCommWrapper::readReg().
Referenced by setup().
|
overridevirtual |
Get input voltage limit.
Implements PmicPowerBase.
Definition at line 74 of file SY6970Power.cpp.
References SensorCommWrapper::readReg().
Referenced by setup().
|
overridevirtual |
Get minimum system voltage.
Implements PmicPowerBase.
Definition at line 53 of file SY6970Power.cpp.
References SensorCommWrapper::readReg().
Referenced by setup().
|
overridevirtual |
Get the current watchdog timeout setting.
Implements PmicWatchdogBase.
Definition at line 185 of file SY6970Power.cpp.
References SensorCommWrapper::readReg().
|
overridevirtual |
Check if boost mode is enabled.
Reimplemented from PmicPowerBase.
Definition at line 115 of file SY6970Power.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 SY6970Power.cpp.
References SensorCommWrapper::readReg().
|
overridevirtual |
Check if watchdog is enabled.
Implements PmicWatchdogBase.
Definition at line 163 of file SY6970Power.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 SY6970Power.cpp.
References SensorCommWrapper::updateBits().
|
overridevirtual |
Set boost output voltage.
Sets the output voltage when in OTG boost mode. Value is quantized to nearest 64mV step.
| mv | Boost voltage in millivolts (4550-5510mV) |
Reimplemented from PmicPowerBase.
Definition at line 121 of file SY6970Power.cpp.
References SensorCommWrapper::updateBits().
|
overridevirtual |
Set input current limit.
Sets the maximum input current drawn from VBUS. Value is quantized to nearest 50mA step.
| mA | Input current limit in milliamps (100-3250mA) |
Implements PmicPowerBase.
Definition at line 83 of file SY6970Power.cpp.
References SensorCommWrapper::updateBits().
Referenced by setup().
|
overridevirtual |
Set input voltage limit (VINDPM)
Sets the VINDPM threshold - the minimum voltage the adapter/input is allowed to be pulled down to. This protects weak adapters from being overloaded. Value is quantized to nearest 100mV step.
| mv | Input voltage limit in millivolts (3900-15300mV) |
Implements PmicPowerBase.
Definition at line 61 of file SY6970Power.cpp.
References SensorCommWrapper::updateBits().
Referenced by setup().
|
overridevirtual |
Set minimum system voltage.
Sets the minimum system voltage threshold. The system voltage (VSYS) is prevented from dropping below this value during load transients. Value is quantized to nearest 100mV step.
| mv | Minimum system voltage in millivolts (3000-3700mV) |
Implements PmicPowerBase.
Definition at line 40 of file SY6970Power.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 SY6970Power.cpp.
References SensorCommWrapper::updateBits().