lc709203f.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef _LC709203F_H__
  2. #define _LC709203F_H__
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "define.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #define LC709203F_INTERVAL 3600000
  10. #define LC709203F_ADDR 0x0B
  11. #define LC709203F_BEFORE_RSOC_REG 0x04
  12. #define LC709203F_THERMISTOR_B_REG 0x06
  13. #define LC709203F_INITIAL_RSOC_REG 0x07
  14. #define LC709203F_CELL_TEMP_REG 0x08
  15. #define LC709203F_CELL_VOLTAGE_REG 0x09
  16. #define LC709203F_CURRENT_DIRECTION_REG 0x0A
  17. #define LC709203F_APA_REG 0x0B
  18. #define LC709203F_APT_REG 0x0C
  19. #define LC709203F_RSOC_REG 0x0D
  20. #define LC709203F_ITE_REG 0x0F
  21. #define LC709203F_VERSION_REG 0x11
  22. #define LC709203F_PARAM_CHANGE_REG 0x12
  23. #define LC709203F_ALARM_RSOC_REG 0x13
  24. #define LC709203F_ALARM_CELLV_REG 0x14
  25. #define LC709203F_POWER_MODE_REG 0x15
  26. #define LC709203F_STATUS_BIT_REG 0x16
  27. #define LC709203F_PARAM_NUM_REG 0x1A
  28. #define LC709203F_SLEEP_MODE 0x0002
  29. #define LC709203F_OPERATIONAL_MODE 0x0001
  30. #define LC709203F_I2C_MODE 0x0000
  31. #define LC709203F_THERMISTOR_MODE 0x0001
  32. #define LC709203F_AUTO_MODE 0x0000
  33. #define LC709203F_CHARGE_MODE 0x0001
  34. #define LC709203F_DISCHARGE_MODE 0xFFFF
  35. typedef struct{
  36. uint16_t operational_mode;
  37. uint16_t apa;
  38. uint16_t bat_profile;
  39. uint16_t status_bit;
  40. uint16_t current_direction;
  41. }lc709203f_param_s;
  42. #ifdef BAT_ER2450
  43. #define LC709203F_PARAM_DEFAULT_CONFIG \
  44. { \
  45. .operational_mode=LC709203F_OPERATIONAL_MODE, \
  46. .apa=0x10, \
  47. .bat_profile=0x0001, \
  48. .status_bit=LC709203F_I2C_MODE, \
  49. .current_direction=LC709203F_DISCHARGE_MODE, \
  50. }
  51. #endif
  52. #ifdef BAT_ER18505
  53. #define LC709203F_PARAM_DEFAULT_CONFIG \
  54. { \
  55. .operational_mode=LC709203F_OPERATIONAL_MODE, \
  56. .apa=0x36, \
  57. .bat_profile=0x0001, \
  58. .status_bit=LC709203F_I2C_MODE, \
  59. .current_direction=LC709203F_DISCHARGE_MODE, \
  60. }
  61. #endif
  62. typedef struct{
  63. uint16_t bat_percent;
  64. uint16_t bat_voltage;
  65. }lc709203f_data_s;
  66. void lc709203f_init(void);
  67. void lc709203f_read_value(void);
  68. void lc709203f_timers_init(void);
  69. extern lc709203f_data_s lc709203f_data;
  70. extern uint8_t bat_percent;
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif // _LC709203F_H__
  75. /** @} */