This class provides APIs to all of the registers of the TI BQ35100 battery gauge, as used on the u-blox C030 primary battery shield.

Dependents:   example-battery-gauge-bq35100

Revision:
0:cec745c014b7
Child:
1:ee7cc8d75283
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/battery_gauge_bq35100.h	Mon Jul 03 16:12:22 2017 +0000
@@ -0,0 +1,81 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2017 u-blox
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BATTERY_GAUGE_BQ35100_H
+#define BATTERY_GAUGE_BQ35100_H
+
+/**
+ * @file battery_gauge_bq35100.h
+ * This file defines the API to the TI BQ35100 battery gauge chip.
+ */
+
+/* ----------------------------------------------------------------
+ * COMPILE-TIME MACROS
+ * -------------------------------------------------------------- */
+
+/** Device I2C address. */
+#define BATTERY_GAUGE_BQ35100_ADDRESS 0x55
+
+/** The default seal code. */
+#define SEAL_CODE_DEFAULT 0x8000
+
+/* ----------------------------------------------------------------
+ * CLASSES
+ * -------------------------------------------------------------- */
+
+/** BQ35100 battery gauge driver. */
+class BatteryGaugeBq35100 {
+public:
+
+    /** Constructor. */
+    BatteryGaugeBq35100(void);
+    /** Destructor. */
+    ~BatteryGaugeBq35100(void);
+
+    /** Initialise the BQ35100 chip.  Once initialised
+    * the chip is put into its lowest power state.  Any API call
+    * will awaken the chip from this state and then return it once
+    * more to the lowest possible power state.
+    * @param pI2c a pointer to the I2C instance to use.
+    * @param address 7-bit I2C address of the battery gauge chip.
+    * @param sealCode the 16 bit seal code that will unseal the device if it is sealed.
+    * @return true if successful, otherwise false.
+    */
+    bool init (I2C * pI2c, uint8_t address = BATTERY_GAUGE_BQ35100_ADDRESS, uint16_t sealCode = SEAL_CODE_DEFAULT);
+    
+protected:
+    /** Pointer to the I2C interface. */
+    I2C * gpI2c;
+    /** The address of the device. */
+    uint8_t gAddress;
+    /** The seal code for the device. */
+    uint16_t gSealCode;
+    /** Flag to indicate device is ready. */
+    bool gReady;
+    
+    /** Read two bytes starting at a given address.
+    * Note: gpI2c should be locked before this is called.
+    * @param registerAddress the register address to start reading from.
+    * @param pBytes place to put the two bytes.
+    * @return true if successful, otherwise false.
+    */
+    bool getTwoBytes (uint8_t registerAddress, uint16_t *pBytes);
+
+};
+
+#endif
+
+/* End Of File */