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!
Diff: MAX17048.cpp
- Revision:
- 3:32087cca331f
- Parent:
- 2:0a98e081b48c
- Child:
- 4:e61b2723d2cf
--- a/MAX17048.cpp Wed Aug 14 04:52:16 2013 +0000 +++ b/MAX17048.cpp Wed Aug 28 17:53:53 2013 +0000 @@ -15,13 +15,27 @@ */ #include "MAX17048.h" -#include "mbed.h" MAX17048::MAX17048(PinName sda, PinName scl) : m_I2C(sda, scl) { //Nothing else to initialize } +bool MAX17048::open(void) +{ + //Probe for the MAX17048 using a Zero Length Transfer + if (!m_I2C.write(m_ADDR, NULL, 0)) { + //Load the default RCOMP value + writeRCOMP(m_RCOMP0); + + //Return success + return true; + } else { + //Return failure + return false; + } +} + void MAX17048::reset(void) { //Write the POR command