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!

Files at this revision

API Documentation at this revision

Comitter:
neilt6
Date:
Fri May 02 17:28:52 2014 +0000
Parent:
8:65c889800b3a
Child:
10:4f695111eb54
Commit message:
Added an I2C frequency argument to the constructor

Changed in this revision

MAX17048.cpp Show annotated file Show diff for this revision Revisions of this file
MAX17048.h Show annotated file Show diff for this revision Revisions of this file
--- a/MAX17048.cpp	Tue Nov 12 21:43:55 2013 +0000
+++ b/MAX17048.cpp	Fri May 02 17:28:52 2014 +0000
@@ -19,10 +19,10 @@
 const char MAX17048::RCOMP0 = 0x97;
 const int MAX17048::m_ADDR = (0x36 << 1);
 
-MAX17048::MAX17048(PinName sda, PinName scl) : m_I2C(sda, scl)
+MAX17048::MAX17048(PinName sda, PinName scl, int hz) : m_I2C(sda, scl)
 {
-    //Set the I2C bus frequency to 400kHz
-    m_I2C.frequency(400000);
+    //Set the I2C bus frequency
+    m_I2C.frequency(hz);
 }
 
 bool MAX17048::open()
--- a/MAX17048.h	Tue Nov 12 21:43:55 2013 +0000
+++ b/MAX17048.h	Fri May 02 17:28:52 2014 +0000
@@ -73,8 +73,9 @@
      *
      * @param sda The I2C data pin.
      * @param scl The I2C clock pin.
+     * @param hz The I2C bus frequency (defaults to 400kHz).
      */
-    MAX17048(PinName sda, PinName scl);
+    MAX17048(PinName sda, PinName scl, int hz = 400000);
 
     /** Probe for the MAX17048 and indicate if it's present on the bus
      *