2 #ifndef LIBPROPELLER_MAX17048_H_
3 #define LIBPROPELLER_MAX17048_H_
5 #include "libpropeller/i2c/i2c.h"
47 status_ = bus_->
Ping(kDeviceAddress);
60 int soc = GetShort(kSOC);
61 return ((
unsigned) soc) >> 8;
69 int voltage = GetShort(kVCELL);
73 voltage = ((voltage * 7812) / 100) / 1000;
89 int rate = (GetShort(kCRATE) << 16) >> 16;
91 return (rate * 208) / 100;
99 return GetShort(kVERSION);
105 const static unsigned char kDeviceAddress = 0b01101100;
107 const static unsigned char kVCELL = 0x02;
108 const static unsigned char kSOC = 0x04;
109 const static unsigned char kVERSION = 0x08;
110 const static unsigned char kCRATE = 0x16;
115 int GetShort(
char address) {
117 bus_->
Get(kDeviceAddress, address, data, 2);
118 int result = (data[0] << 8) | data[1];
126 #endif // LIBPROPELLER_MAX17048_H_