Mac Lobdell / MAX1704X

Dependents:   MAX1704X_example_app

Embed: (wiki syntax)

« Back to documentation index

MAX1704X Class Reference

MAX1704X Class Reference

MAX1704X class. More...

#include <MAX1704X.h>

Public Types

enum  Address
 

Represents the different I2C address possibilities for the MAX1704X.

More...

Public Member Functions

 MAX1704X (PinName sda, PinName scl, Address addr=ADDRESS_0, int hz=400000)
 Create an MAX1704X object connected to the specified I2C pins with the specified I2C slave address.
bool open ()
 Probe for the MAX1704X and indicate if it's present on the bus.
void power_on_reset (void)
 assert power on reset on MAX1704X
uint32_t read_ad ()
 Get the current ad of the MAX1704X.
uint16_t read_config ()
 Get the current config of the MAX1704X.
uint32_t read_percent ()
 Get the current battery charge percent from MAX1704X.

Detailed Description

MAX1704X class.

Used for reading MAX1704X lipo fuel guage connected via I2C.

Example:

 #include "mbed.h"
 #include "MAX1704X.h"

 //Create an MAX1704X object at the default address (ADDRESS_0)
 MAX1704X battery_level(p28, p27);

 int main()
 {
     //Try to open the MAX1704X
     if (battery_level.open()) {
         printf("Device detected!\n");

         while (1) {
             //Print the current battery level
             printf("battery = %d\n", battery_level);

             //Sleep for 1 seconds
             wait(1);
         }
     } else {
         error("Device not detected!\n");
     }
 }

Definition at line 52 of file MAX1704X.h.


Member Enumeration Documentation

enum Address

Represents the different I2C address possibilities for the MAX1704X.

Definition at line 58 of file MAX1704X.h.


Constructor & Destructor Documentation

MAX1704X ( PinName  sda,
PinName  scl,
Address  addr = ADDRESS_0,
int  hz = 400000 
)

Create an MAX1704X object connected to the specified I2C pins with the specified I2C slave address.

Parameters:
sdaThe I2C data pin.
sclThe I2C clock pin.
addrThe I2C slave address (defaults to ADDRESS_0).
hzThe I2C bus frequency (defaults to 400kHz).

Definition at line 21 of file MAX1704X.cpp.


Member Function Documentation

bool open (  )

Probe for the MAX1704X and indicate if it's present on the bus.

Returns:
'true' if the device exists on the bus, 'false' if the device doesn't exist on the bus.

Definition at line 30 of file MAX1704X.cpp.

void power_on_reset ( void   )

assert power on reset on MAX1704X

Returns:
void

Definition at line 95 of file MAX1704X.cpp.

uint32_t read_ad (  )

Get the current ad of the MAX1704X.

Returns:
The current ad.

Definition at line 42 of file MAX1704X.cpp.

uint16_t read_config (  )

Get the current config of the MAX1704X.

Returns:
The current config of the MAX170X.

Definition at line 61 of file MAX1704X.cpp.

uint32_t read_percent (  )

Get the current battery charge percent from MAX1704X.

Returns:
The current battery charge percent from MAX1704X.

Definition at line 77 of file MAX1704X.cpp.