max17043.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef MAX17043_H_
  2. #define MAX17043_H_
  3. #include "ets_sys.h"
  4. /*------------------------------------------------------------------------------*/
  5. // Debug Flag(s)
  6. /*------------------------------------------------------------------------------*/
  7. #define MAX17043_DEBUG 0
  8. /*------------------------------------------------------------------------------*/
  9. /*------------------------------------------------------------------------------*/
  10. // Device I2C ID
  11. /*------------------------------------------------------------------------------*/
  12. #define DEVICE_ADDRESS 0x36
  13. #define WRITE_ADDRESS 0x6C // develop macro
  14. #define READ_ADDRESS 0x6D // develop macro
  15. /*------------------------------------------------------------------------------*/
  16. /*------------------------------------------------------------------------------*/
  17. // Device Registers
  18. /*------------------------------------------------------------------------------*/
  19. #define VCELL_H 0x02 // 12-bit ADC battery voltage
  20. #define VCELL_L 0x03
  21. /*------------------------------------------------------------------------------*/
  22. #define SOC_H 0x04 // 16-bit capacity estimation
  23. #define SOC_L 0x05
  24. /*------------------------------------------------------------------------------*/
  25. #define MODE_H 0x06 // sends special commands to IC
  26. #define MODE_L 0x07
  27. /*------------------------------------------------------------------------------*/
  28. #define VERISON_H 0x08 // returns IC version
  29. #define VERSION_L 0x09
  30. /*------------------------------------------------------------------------------*/
  31. #define CONFIG_H 0x0C // battery compensation parameters
  32. #define CONFIG_L 0x0D
  33. /*------------------------------------------------------------------------------*/
  34. #define COMMAND_H 0xFE // sends special commands to IC
  35. #define COMMAND_L 0xFF
  36. /*------------------------------------------------------------------------------*/
  37. /*------------------------------------------------------------------------------*/
  38. // Function Prototypes
  39. /*------------------------------------------------------------------------------*/
  40. uint16_t max17043_getVoltage(void);
  41. uint16_t max17043_getSOC(void);
  42. bool max17043_sleep(uint8_t enable);
  43. bool max17043_quickStart(void);
  44. /*------------------------------------------------------------------------------*/
  45. /*------------------------------------------------------------------------------*/
  46. // Macro Definitions
  47. /*------------------------------------------------------------------------------*/
  48. #define max17043_i2c_init() i2c_master_gpio_init()
  49. /*------------------------------------------------------------------------------*/
  50. #endif