A feature complete driver for the MAX17048 lithium fuel gauge from Maxim.

Dependents:   MAX17048_HelloWorld ECGAFE_copy MAX17048_HelloWorld Orion_newPCB_test_LV ... more

Now fully tested!

Revision:
3:32087cca331f
Parent:
2:0a98e081b48c
Child:
4:e61b2723d2cf
--- a/MAX17048.h	Wed Aug 14 04:52:16 2013 +0000
+++ b/MAX17048.h	Wed Aug 28 17:53:53 2013 +0000
@@ -29,16 +29,24 @@
  *
  * MAX17048 gauge(p28, p27);
  *
- * int main() {
- *     while (1) {
- *         //Read the cell voltage
- *         float vcell = gauge.vcell();
+ * int main()
+ * {
+ *     //Try to open the MAX17048
+ *     if (gauge.open()) {
+ *         printf("Device detected!\n");
  *
- *         //Print the cell voltage
- *         printf("Vcell = %f\n", vcell);
+ *         while (1) {
+ *             //Read the cell voltage
+ *             float vcell = gauge.vcell();
  *
- *         //Sleep for 0.5 seconds
- *         wait(0.5);
+ *             //Print the cell voltage
+ *             printf("Vcell = %f\n", vcell);
+ *
+ *             //Sleep for 0.5 seconds
+ *             wait(0.5);
+ *         }
+ *     } else {
+ *         printf("Device not detected!\n");
  *     }
  * }
  * @endcode
@@ -64,6 +72,14 @@
      */
     MAX17048(PinName sda, PinName scl);
 
+    /** Probe for the MAX17048 and load the default RCOMP value if present
+     *
+     * @returns
+     *   'true' if the device exists on the bus,
+     *   'false' if the device doesn't exist on the bus.
+     */
+    bool open(void);
+
     /** Command the MAX17048 to perform a power-on reset
      */
     void reset(void);