Library to interface to the TI BQ27441, a fuel gauge monitor
Fork of battery-gauge-bq27441 by
Diff: bq27441.cpp
- Revision:
- 2:93310a83401a
- Parent:
- 1:566163f17cde
- Child:
- 3:ebd56471d57c
diff -r 566163f17cde -r 93310a83401a bq27441.cpp --- a/bq27441.cpp Mon Apr 10 11:18:51 2017 +0100 +++ b/bq27441.cpp Tue Apr 11 09:57:10 2017 +0000 @@ -19,7 +19,7 @@ * This file defines the API to the TI BQ27441 battery gauge chip. */ -/// Define these to print debug information. +/** Define these to print debug information. */ //#define DEBUG_BQ27441 //#define DEBUG_BQ27441_BLOCK_DATA @@ -34,19 +34,19 @@ // COMPILE-TIME MACROS // ---------------------------------------------------------------- -/// How many loops to wait for a configuration update to be permitted. -// Experience suggests that the limit really does need to be this large. +/** How many loops to wait for a configuration update to be permitted. +* Experience suggests that the limit really does need to be this large. */ #define CONFIG_UPDATE_LOOPS 200 -/// How long to delay when running around the config update loop. +/** How long to delay when running around the config update loop. */ #define CONFIG_UPDATE_LOOP_DELAY_MS 100 -/// How long to wait for all the ADC readings to be performed. +/** How long to wait for all the ADC readings to be performed. */ #define ADC_READ_WAIT_MS 1000 -/// Delay after the last config update before we can unseal the -// chip again (see section 6.4.5.1.1 of the BQ27441 technical -// reference manual). +/** Delay after the last config update before we can unseal the +* chip again (see section 6.4.5.1.1 of the BQ27441 technical +* reference manual). */ #define UNSEAL_DELAY_MS 4000 // ---------------------------------------------------------------- @@ -57,7 +57,7 @@ // GENERIC PRIVATE FUNCTIONS // ---------------------------------------------------------------- -/// Read two bytes from an address. +// Read two bytes from an address. // Note: gpI2c should be locked before this is called. bool BatteryGaugeBq27441::getTwoBytes (uint8_t registerAddress, uint16_t *pBytes) { @@ -82,7 +82,7 @@ return success; } -/// Compute the checksum over a block of data. +// Compute the checksum over a block of data. uint8_t BatteryGaugeBq27441::computeChecksum(const char * pData) { uint8_t checkSum = 0; @@ -122,7 +122,7 @@ return checkSum; } -/// Read data of a given length and class ID. +// Read data of a given length and class ID. // Note: gpI2c should be locked before this is called. bool BatteryGaugeBq27441::readExtendedData(uint8_t subClassId, int32_t offset, int32_t length, char * pData) { @@ -232,7 +232,7 @@ return success; } -/// Write data of a given length and class ID to a given offset. This code taken from +// Write data of a given length and class ID to a given offset. This code taken from // section 3.1 of the SLUUAC9A application technical reference manual with hints from: // https://github.com/sparkfun/SparkFun_BQ27441_Arduino_Library/blob/master/src/SparkFunBQ27441.cpp. // Note: gpI2c should be locked before this is called. @@ -424,7 +424,7 @@ } -/// Check if the chip is SEALED or UNSEALED. +// Check if the chip is SEALED or UNSEALED. // Note: gpI2c should be locked before this is called. bool BatteryGaugeBq27441::isSealed(void) { @@ -454,7 +454,7 @@ return sealed; } -/// Put the chip into SEALED mode. +// Put the chip into SEALED mode. // Note: gpI2c should be locked before this is called. bool BatteryGaugeBq27441::seal(void) { @@ -491,7 +491,7 @@ return success; } -/// Send the seal code to the device to unseal it. +// Send the seal code to the device to unseal it. // Note: gpI2c should be locked before this is called. bool BatteryGaugeBq27441::unseal(uint16_t sealCode) { @@ -530,7 +530,7 @@ return success; } -/// Make sure that the device is awake and has taken a reading. +// Make sure that the device is awake and has taken a reading. // Note: the function does its own locking of gpI2C so that it isn't // locked for the entire time we wait for ADC readings to complete. bool BatteryGaugeBq27441::makeAdcReading(void) @@ -551,7 +551,7 @@ return success; } -/// Set Hibernate mode. +// Set Hibernate mode. // Note: gpI2c should be locked before this is called. bool BatteryGaugeBq27441::setHibernate(void) { @@ -569,7 +569,7 @@ // PUBLIC FUNCTIONS // ---------------------------------------------------------------- -/// Constructor. +// Constructor. BatteryGaugeBq27441::BatteryGaugeBq27441(void) { gpI2c = NULL; @@ -578,12 +578,12 @@ gSealCode = 0; } -/// Destructor. +// Destructor. BatteryGaugeBq27441::~BatteryGaugeBq27441(void) { } -/// Initialise ourselves. +// Initialise ourselves. bool BatteryGaugeBq27441::init (I2C * pI2c, uint8_t address, uint16_t sealCode) { uint16_t answer; @@ -657,7 +657,7 @@ return gReady; } -/// Switch on the battery capacity monitor. +// Switch on the battery capacity monitor. bool BatteryGaugeBq27441::enableGauge (bool isSlow) { bool success = false; @@ -711,7 +711,7 @@ return success; } -/// Switch off the battery capacity monitor. +// Switch off the battery capacity monitor. bool BatteryGaugeBq27441::disableGauge (void) { bool success = false; @@ -730,7 +730,7 @@ return success; } -/// Check whether a battery has been detected or not. +// Check whether a battery has been detected or not. bool BatteryGaugeBq27441::isBatteryDetected (void) { bool isDetected = false; @@ -770,7 +770,7 @@ return isDetected; } -/// Get the temperature of the chip. +// Get the temperature of the chip. bool BatteryGaugeBq27441::getTemperature (int32_t *pTemperatureC) { bool success = false; @@ -809,7 +809,7 @@ return success; } -/// Get the voltage of the battery. +// Get the voltage of the battery. bool BatteryGaugeBq27441::getVoltage (int32_t *pVoltageMV) { bool success = false; @@ -845,7 +845,7 @@ return success; } -/// Get the current flowing from the battery. +// Get the current flowing from the battery. bool BatteryGaugeBq27441::getCurrent (int32_t *pCurrentMA) { bool success = false; @@ -881,7 +881,7 @@ return success; } -/// Get the remaining battery capacity. +// Get the remaining battery capacity. bool BatteryGaugeBq27441::getRemainingCapacity (int32_t *pCapacityMAh) { bool success = false; @@ -918,7 +918,7 @@ return success; } -/// Get the battery percentage remaining +// Get the battery percentage remaining bool BatteryGaugeBq27441::getRemainingPercentage (int32_t *pBatteryPercent) { bool success = false; @@ -959,7 +959,7 @@ return success; } -/// Advanced function to read a configuration data block. +// Advanced function to read a configuration data block. bool BatteryGaugeBq27441::advancedGetConfig(uint8_t subClassId, int32_t offset, int32_t length, char * pData) { bool success = false; @@ -985,7 +985,7 @@ return success; } -/// Advanced function to write a configuration data block. +// Advanced function to write a configuration data block. bool BatteryGaugeBq27441::advancedSetConfig(uint8_t subClassId, int32_t offset, int32_t length, const char * pData) { bool success = false; @@ -1011,7 +1011,7 @@ return success; } -/// Send a control word. +// Send a control word. bool BatteryGaugeBq27441::advancedSendControlWord (uint16_t controlWord, uint16_t *pDataReturned) { bool success = false; @@ -1045,7 +1045,7 @@ return success; } -/// Read two bytes starting at a given address on the chip. +// Read two bytes starting at a given address on the chip. bool BatteryGaugeBq27441::advancedGet (uint8_t address, uint16_t *pDataReturned) { bool success = false; @@ -1073,7 +1073,7 @@ return success; } -/// Check if the chip is SEALED or UNSEALED. +// Check if the chip is SEALED or UNSEALED. bool BatteryGaugeBq27441::advancedIsSealed() { bool sealed = false; @@ -1094,7 +1094,7 @@ return sealed; } -/// Put the chip into SEALED mode. +// Put the chip into SEALED mode. bool BatteryGaugeBq27441::advancedSeal() { bool success = false; @@ -1115,7 +1115,7 @@ return success; } -/// Unseal the device. +// Unseal the device. bool BatteryGaugeBq27441::advancedUnseal(uint16_t sealCode) { bool success = false; @@ -1147,7 +1147,7 @@ return success; } -/// Do a hard reset of the chip. +// Do a hard reset of the chip. bool BatteryGaugeBq27441::advancedReset(void) { bool success = false; @@ -1189,4 +1189,4 @@ return success; } -// End Of File +/* End Of File */