SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
SY6970Power Class Reference

#include <SY6970Power.hpp>

Inheritance diagram for SY6970Power:
[legend]

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.
 

Detailed Description

Definition at line 62 of file SY6970Power.hpp.

Constructor & Destructor Documentation

◆ SY6970Power()

SY6970Power::SY6970Power ( SY6970Core core)
explicit

Construct power management interface.

Parameters
coreReference to SY6970 core communication

Definition at line 38 of file SY6970Power.cpp.

◆ ~SY6970Power()

SY6970Power::~SY6970Power ( )
default

Member Function Documentation

◆ enableBoost()

bool SY6970Power::enableBoost ( bool  enable)
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.

Parameters
enabletrue to enable OTG, false to disable
Returns
true on success
Note
OTG cannot be enabled while VBUS is present.
See also
isBoostEnabled()
setBoostVoltage()

Reimplemented from PmicPowerBase.

Definition at line 103 of file SY6970Power.cpp.

References SY6970Core::isVbusPresent(), and SensorCommWrapper::updateBits().

◆ enableShipMode()

bool SY6970Power::enableShipMode ( bool  enable)
overridevirtual

Enable or disable ship mode.

Ship mode disconnects the battery from the system by turning off the BATFET. This is used for:

  • Shipping mode (device stored for long periods)
  • Complete power off when no external power is available

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).

Parameters
enabletrue to enter ship mode (battery disconnected), false to exit
Returns
true on success, false on I2C error
Note
To exit ship mode, connect VBUS. The BATFET will automatically turn on when valid VBUS is detected.
This function writes to REG09 BATFET_DIS bit.
See also
isShipModeEnabled()

Reimplemented from PmicPowerBase.

Definition at line 142 of file SY6970Power.cpp.

References SensorCommWrapper::updateBits().

◆ enableWatchdog()

bool SY6970Power::enableWatchdog ( bool  enable)
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.

Parameters
enabletrue to enable watchdog (default 40s timeout), false to disable
Returns
true on success, false on I2C error
Note
When watchdog expires, register settings are reset to defaults. Call resetWatchdog() regularly to prevent this.
This function controls REG07 WATCHDOG[1:0] bits.
See also
setWatchdogTimeout()
resetWatchdog()
isWatchdogEnabled()

Implements PmicWatchdogBase.

Definition at line 154 of file SY6970Power.cpp.

References SensorCommWrapper::updateBits().

◆ getBoostVoltage()

uint16_t SY6970Power::getBoostVoltage ( ) const
overridevirtual

Get boost output voltage.

Returns
Boost voltage in millivolts

Reimplemented from PmicPowerBase.

Definition at line 134 of file SY6970Power.cpp.

References SensorCommWrapper::readReg().

Referenced by loop().

◆ getInputCurrentLimit()

uint32_t SY6970Power::getInputCurrentLimit ( ) const
overridevirtual

Get input current limit.

Returns
Input current limit in milliamps

Implements PmicPowerBase.

Definition at line 96 of file SY6970Power.cpp.

References SensorCommWrapper::readReg().

Referenced by setup().

◆ getInputVoltageLimit()

uint32_t SY6970Power::getInputVoltageLimit ( ) const
overridevirtual

Get input voltage limit.

Returns
Input voltage limit in millivolts

Implements PmicPowerBase.

Definition at line 74 of file SY6970Power.cpp.

References SensorCommWrapper::readReg().

Referenced by setup().

◆ getMinimumSystemVoltage()

uint32_t SY6970Power::getMinimumSystemVoltage ( ) const
overridevirtual

Get minimum system voltage.

Returns
Minimum system voltage in millivolts

Implements PmicPowerBase.

Definition at line 53 of file SY6970Power.cpp.

References SensorCommWrapper::readReg().

Referenced by setup().

◆ getWatchdogTimeout()

uint16_t SY6970Power::getWatchdogTimeout ( ) const
overridevirtual

Get the current watchdog timeout setting.

Returns
Timeout in seconds (0 if disabled, or 40/80/160)
See also
setWatchdogTimeout()

Implements PmicWatchdogBase.

Definition at line 185 of file SY6970Power.cpp.

References SensorCommWrapper::readReg().

◆ isBoostEnabled()

bool SY6970Power::isBoostEnabled ( ) const
overridevirtual

Check if boost mode is enabled.

Returns
true if OTG mode is active

Reimplemented from PmicPowerBase.

Definition at line 115 of file SY6970Power.cpp.

References SensorCommWrapper::readReg().

Referenced by loop().

◆ isShipModeEnabled()

bool SY6970Power::isShipModeEnabled ( ) const
overridevirtual

Check if ship mode is enabled.

Reads the BATFET_DIS bit from REG09 to determine if ship mode is active.

Returns
true if ship mode is active (battery disconnected)
false if ship mode is disabled (battery connected)
See also
enableShipMode()

Reimplemented from PmicPowerBase.

Definition at line 148 of file SY6970Power.cpp.

References SensorCommWrapper::readReg().

◆ isWatchdogEnabled()

bool SY6970Power::isWatchdogEnabled ( ) const
overridevirtual

Check if watchdog is enabled.

Returns
true if watchdog is enabled, false if disabled
See also
enableWatchdog()

Implements PmicWatchdogBase.

Definition at line 163 of file SY6970Power.cpp.

References SensorCommWrapper::readReg().

◆ resetWatchdog()

bool SY6970Power::resetWatchdog ( )
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.

Returns
true on success, false on I2C error
Note
Should be called at least once before the watchdog timeout. Recommended to call every 20-30 seconds for 40s timeout.
This function writes to REG03 WD_RST bit (self-clearing).
See also
enableWatchdog()
setWatchdogTimeout()

Implements PmicWatchdogBase.

Definition at line 194 of file SY6970Power.cpp.

References SensorCommWrapper::updateBits().

◆ setBoostVoltage()

bool SY6970Power::setBoostVoltage ( uint16_t  mv)
overridevirtual

Set boost output voltage.

Sets the output voltage when in OTG boost mode. Value is quantized to nearest 64mV step.

Parameters
mvBoost voltage in millivolts (4550-5510mV)
Returns
true on success
Note
Values not matching 64mV step will be quantized to nearest valid value.
Must have boost enabled first.
See also
getBoostVoltage()

Reimplemented from PmicPowerBase.

Definition at line 121 of file SY6970Power.cpp.

References SensorCommWrapper::updateBits().

◆ setInputCurrentLimit()

bool SY6970Power::setInputCurrentLimit ( uint32_t  mA)
overridevirtual

Set input current limit.

Sets the maximum input current drawn from VBUS. Value is quantized to nearest 50mA step.

Parameters
mAInput current limit in milliamps (100-3250mA)
Returns
true on success
Note
Values not matching 50mA step will be quantized to nearest valid value.
See also
getInputCurrentLimit()

Implements PmicPowerBase.

Definition at line 83 of file SY6970Power.cpp.

References SensorCommWrapper::updateBits().

Referenced by setup().

◆ setInputVoltageLimit()

bool SY6970Power::setInputVoltageLimit ( uint32_t  mv)
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.

Parameters
mvInput voltage limit in millivolts (3900-15300mV)
Returns
true on success
Note
Values not matching 100mV step will be quantized to nearest valid value.
See also
getInputVoltageLimit()

Implements PmicPowerBase.

Definition at line 61 of file SY6970Power.cpp.

References SensorCommWrapper::updateBits().

Referenced by setup().

◆ setMinimumSystemVoltage()

bool SY6970Power::setMinimumSystemVoltage ( uint32_t  mv)
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.

Parameters
mvMinimum system voltage in millivolts (3000-3700mV)
Returns
true on success
Note
Values not matching 100mV step will be quantized to nearest valid value.
See also
getMinimumSystemVoltage()

Implements PmicPowerBase.

Definition at line 40 of file SY6970Power.cpp.

References SensorCommWrapper::updateBits().

Referenced by setup().

◆ setWatchdogTimeout()

bool SY6970Power::setWatchdogTimeout ( uint16_t  timeout_s)
overridevirtual

Set the watchdog timeout duration.

Sets how long the watchdog will wait before triggering a fault. Must be called after enableWatchdog(true).

Parameters
timeout_sTimeout in seconds (0=disabled, values >0 enable watchdog) Valid chip values: 0, 40, 80, 160 seconds. Other values will be clamped.
Returns
true on success, false on I2C error
Note
Default timeout after enableWatchdog(true) is 40 seconds.
See also
enableWatchdog()
getWatchdogTimeout()

Implements PmicWatchdogBase.

Definition at line 170 of file SY6970Power.cpp.

References SensorCommWrapper::updateBits().


The documentation for this class was generated from the following files: