STC3115 Arduino I2C Driver
STC3115 Gas Gauge I2C Driver for Arduino
 All Classes Functions
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
STC3115 Class Reference
Inheritance diagram for STC3115:
STC3115I2CCore

Public Member Functions

 STC3115 (uint8_t address=0x70)
 Initialize STC3115 I2C driver with given address. More...
 
bool begin (int batteryCapacity=BATT_CAPACITY, int rSense=RSENSE)
 Initialize the STC3115 Gas Gauge chip. More...
 
int getTemperature ()
 Get temperature of the battery. Temperature unit is celcius. More...
 
int getVoltage ()
 Get battery voltage. More...
 
int getCurrent ()
 Get battery current. More...
 
int getChargeValue ()
 Get the remaining capacity in mAh unit. More...
 
int getSOC ()
 Get SOC of the battery. More...
 
int getOCV ()
 Get OCV of the battery. More...
 
int getRemainingTime ()
 
int getChipID ()
 Get the chip ID from STC3115. More...
 
int getStatus ()
 Get STC3115 status. More...
 
void enableDebugging (Stream *stream=NULL)
 
void disableDebugging ()
 
int getRunningCounter ()
 Get the STC3115 conversion counter value. More...
 
bool readBatteryData ()
 Read battery measurement data in one go. More...
 
bool reset ()
 Reset gauge. More...
 
bool stop ()
 Store last reading data to RAM and then stop the gauge. More...
 
bool powerDown ()
 Power down the gauge. More...
 
void run ()
 Gradually update battery status on the internal structure & RAM. This function should be called inside loop.
 
bool startPowerSavingMode ()
 Start power saving mode. More...
 
bool stopPowerSavingMode ()
 Stop power saving mode. More...
 
bool isBatteryDetected ()
 Check whether the battery is detected or not. More...
 
- Public Member Functions inherited from STC3115I2CCore
 STC3115I2CCore (uint8_t address=0x70)
 Initialize STC3115 I2C driver and assign the address. More...
 
bool beginI2C ()
 Initialize I2C and check whether the address is available or not. More...
 
bool readRegister (uint8_t *output, uint8_t reg)
 Read an unsigned byte from a register and return the read status. More...
 
bool readRegisterRegion (uint8_t *output, uint8_t reg, uint8_t length)
 Read unsigned bytes from register range. More...
 
bool readRegisterInt16 (int16_t *output, uint8_t reg)
 Read 2 bytes of data and convert it to a signed integer. More...
 
bool readRegisterInt (int *output, uint8_t reg)
 Read signed integer value from a register. More...
 
bool writeRegister (uint8_t reg, uint8_t data)
 Write unsigned byte data to a register. More...
 
bool writeRegisterInt (uint8_t reg, int data)
 Write signed integer data to a register. More...
 
bool writeRegister (uint8_t reg, uint8_t *data, size_t length)
 Write array of unsigned bytes to a register. More...
 

Static Public Member Functions

static int convert (short value, unsigned short factor)
 Convert measurement data with given factor. More...
 

Public Attributes

STC3115ConfigData config
 

Protected Member Functions

void initConfig (int battCapacity, int rSense)
 Initialize STC3115 config default values.
 
int calculateCRC8RAM (uint8_t *data, size_t length)
 Calculate the CRC8 of a buffer. More...
 
void initRAM ()
 Initialize STC3115 RAM data.
 
bool readRAMData ()
 Read STC3115 RAM data and store it to an internal structure. More...
 
int updateRAMCRC8 ()
 Update STC3115 RAM CRC8 value. More...
 
bool writeRAMData ()
 Write data from internal structure to STC3115 RAM. More...
 
bool startup ()
 Write SOC data to STC3115 and run. More...
 
bool restore ()
 Restore SOC value from RAM and run. More...
 
void setParamAndRun ()
 Write configuration to STC3115 registers.
 

Protected Attributes

STC3115BatteryData batteryData
 
STC3115RAMData ramData
 
bool debugEnabled
 
Stream * debugStream
 
- Protected Attributes inherited from STC3115I2CCore
uint8_t address
 

Constructor & Destructor Documentation

STC3115::STC3115 ( uint8_t  address = 0x70)

Initialize STC3115 I2C driver with given address.

Parameters
address

Member Function Documentation

bool STC3115::begin ( int  battCapacity = BATT_CAPACITY,
int  rSense = RSENSE 
)

Initialize the STC3115 Gas Gauge chip.

Parameters
battCapacitymaximum battery capacity
rSenseRSENSE value
Returns
true if the gauge is initialized.
false if the gauge initialization is failed.
int STC3115::calculateCRC8RAM ( uint8_t *  data,
size_t  length 
)
protected

Calculate the CRC8 of a buffer.

Parameters
datapointer to array of uint8_t
lengthlength of the array
Returns
int CRC8 of the data
int STC3115::convert ( short  value,
unsigned short  factor 
)
static

Convert measurement data with given factor.

Parameters
valuevalue to be converted
factorconversion factor
Returns
int
int STC3115::getChargeValue ( )

Get the remaining capacity in mAh unit.

Returns
int
int STC3115::getChipID ( )

Get the chip ID from STC3115.

Returns
int chip ID of the STC3115
int STC3115::getCurrent ( )

Get battery current.

Returns
float
int STC3115::getOCV ( )

Get OCV of the battery.

Returns
int
int STC3115::getRunningCounter ( )

Get the STC3115 conversion counter value.

Returns
int conversion counter
int STC3115::getSOC ( )

Get SOC of the battery.

Returns
int
int STC3115::getStatus ( )

Get STC3115 status.

Returns
int
int STC3115::getTemperature ( )

Get temperature of the battery. Temperature unit is celcius.

Returns
int
int STC3115::getVoltage ( )

Get battery voltage.

Returns
float
bool STC3115::isBatteryDetected ( )

Check whether the battery is detected or not.

Returns
true if the battery is detected
false otherwise
bool STC3115::powerDown ( )

Power down the gauge.

Returns
true
false
bool STC3115::readBatteryData ( )

Read battery measurement data in one go.

Returns
true
false
bool STC3115::readRAMData ( )
protected

Read STC3115 RAM data and store it to an internal structure.

Returns
true
false
bool STC3115::reset ( )

Reset gauge.

Returns
true
false
bool STC3115::restore ( )
protected

Restore SOC value from RAM and run.

Returns
true
false
bool STC3115::startPowerSavingMode ( )

Start power saving mode.

Returns
true
false
bool STC3115::startup ( )
protected

Write SOC data to STC3115 and run.

Returns
true
false
bool STC3115::stop ( )

Store last reading data to RAM and then stop the gauge.

Returns
true
false
bool STC3115::stopPowerSavingMode ( )

Stop power saving mode.

Returns
true
false
int STC3115::updateRAMCRC8 ( )
protected

Update STC3115 RAM CRC8 value.

Returns
int RAM CRC8
bool STC3115::writeRAMData ( )
protected

Write data from internal structure to STC3115 RAM.

Returns
true
false

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