BQ28Z610 Driver
BQ28Z610 Battery fuel gauge device driver for Arduino
data_flash_access.h
Go to the documentation of this file.
1 
47 #pragma once
48 
49 #include <Arduino.h>
50 
51 #include "globals.h"
52 #include "utils.h"
54 #include "service.h"
55 
59 class DF_ADDR {
60  public:
61  static const word MIN = 0x4000;
62  static const word MAX = 0x5FFF;
63 
67  static const word MANUFACTURER_NAME = 0x406B;
71  static const word DEVICE_NAME = 0x4080;
75  static const word DEVICE_CHEMISTRY = 0x4095;
76 
77  static const word GAS_GAUGING_CYCLE_COUNT = 0x4240;
81  static const word GAS_GAUGING_UPDATE_STATUS = 0x420E;
82 
83  static const word FET_OPTIONS = 0x4600;
84 
88  static const word DESIGN_CAPACITY_MAH = 0x462A;
92  static const word DESIGN_CAPACITY_CWH = 0x462C;
93 
94  static const word SOC_FLAG_CONFIG_A = 0x4632;
95 
99  static const word TC_SET_RSOC_THRESHOLD = 0x464B;
103  static const word TC_CLEAR_RSOC_THRESHOLD = 0x464C;
104 
105  static const word DA_CONFIGURATION = 0x469B;
106 
110  static const word CHARGE_TERM_TAPER_CURRENT = 0x4693;
111 
112  static const word OCC_THRESHOLD = 0x46C9;
113 
117  static const word OTC_THRESHOLD = 0x46D8;
118  static const word OTC_RECOVERY = 0x46DB;
119 
123  static const word Q_MAX_CELL_1 = 0x4206;
127  static const word Q_MAX_CELL_2 = 0x4208;
131  static const word Q_MAX_PACK = 0x420A;
132 
152  static const word CELL0_RA_FLAG = 0x4100;
170  static const word CELL1_RA_FLAG = 0x4140;
192  static const word X_CELL0_RA_FLAG = 0x4180;
214  static const word X_CELL1_RA_FLAG = 0x41C0;
215 };
216 
229 void dfReadBytes(word addr, byte *retval, int len);
230 
264 void dfWriteBytes(word addr, byte *data, int len);
265 
269 byte dfReadByte(word addr);
270 
274 byte dfReadU1(word addr);
275 
279 void dfWriteByte(word addr, byte value);
280 
292 word dfReadWord(word addr);
293 
301 void dfWriteWord(word addr, word value);
302 
307 int dfReadI2(word addr);
308 
313 void dfWriteI2(word addr, int value);
314 
319 word dfReadU2(word addr);
320 
325 void dfWriteU2(word addr, word value);
326 
331 String dfReadString(word addr);
332 
340 String dfDeviceName();
341 
352 
361 void dfWriteDesignCapacityMah(int designCapacityMah);
362 
373 
385 void dfWriteDesignCapacityCwh(int designCapacityCwh);
386 
414 byte dfReadFetOptions();
415 
426 void dfWriteFetOptionsCHGFET(bool chgFetBitValue);
427 
453 byte dfReadDaConfiguration();
454 
486 
516 void dfWriteGasGaugingUpdateStatus(byte updateStatus);
517 
525 void dfReadAllData();
526 
539 void dfPrintRaTable();
540 
545 int dfReadTaperCurrent();
546 
551 void dfWriteTaperCurrent(int taperCurrent);
552 
566 void dfResetRaTableFlags();
567 
614 word dfReadSocFlagConfigA();
615 
661 void dfWriteSocFlagConfigA(word socFlagConfigA);
662 
668 
673 void dfWriteTcSetRsocThreshold(byte setThreshold);
674 
680 
685 void dfWriteTcClearRsocThreshold(byte clearThreshold);
686 
691 int dfReadQmaxCell1();
692 
697 int dfReadQmaxCell2();
698 
703 int dfReadQmaxPack();
704 
716 void dfWriteQmax(word qMaxCell0, word qMaxCell1);
717 
722 word dfReadCycleCount();
723 
728 void dfWriteCycleCount(word cycleCount);
12.2 0x3E, 0x3F AltManufacturerAccess() headers
Data Flash addresses.
Definition: data_flash_access.h:59
static const word MANUFACTURER_NAME
I2C Configuration; Data; Manufacturer Name; S21.
Definition: data_flash_access.h:67
static const word MAX
Maximum Data Flash address.
Definition: data_flash_access.h:62
static const word DA_CONFIGURATION
Settings; Configuration; DA Configuration; H1.
Definition: data_flash_access.h:105
static const word DESIGN_CAPACITY_MAH
Gas Gauging; Design; Design Capacity mAh; I2.
Definition: data_flash_access.h:88
static const word TC_SET_RSOC_THRESHOLD
Gas Gauging; TC; Set % RSOC Threshold; U1.
Definition: data_flash_access.h:99
static const word DEVICE_CHEMISTRY
I2C Configuration; Data; Device Chemistry; S5.
Definition: data_flash_access.h:75
static const word FET_OPTIONS
Settings; Configuration; FET Options; H1.
Definition: data_flash_access.h:83
static const word DEVICE_NAME
I2C Configuration; Data; Device Name; S21.
Definition: data_flash_access.h:71
static const word OTC_RECOVERY
13.10.8 OTC - Overtemperature in Charge: Protections; OTC; 0x46DB; Recovery; I2
Definition: data_flash_access.h:118
static const word TC_CLEAR_RSOC_THRESHOLD
Gas Gauging; TC; Clear % RSOC Threshold; U1.
Definition: data_flash_access.h:103
static const word X_CELL1_RA_FLAG
Ra Table; R_a1x; 0x41C0; xCell1 R_a flag; H2.
Definition: data_flash_access.h:214
static const word GAS_GAUGING_UPDATE_STATUS
Gas Gauging; State; Update Status; H1.
Definition: data_flash_access.h:81
static const word Q_MAX_CELL_2
Gas Gauging; State; Qmax Cell 2; I2.
Definition: data_flash_access.h:127
static const word DESIGN_CAPACITY_CWH
Gas Gauging; Design; Design Capacity cWh; I2.
Definition: data_flash_access.h:92
static const word Q_MAX_PACK
Gas Gauging; State; Qmax Pack; I2.
Definition: data_flash_access.h:131
static const word X_CELL0_RA_FLAG
Ra Table; R_a0x; 0x4180; xCell0 R_a flag; H2.
Definition: data_flash_access.h:192
static const word CELL1_RA_FLAG
Ra Table; R_a1; 0x4140; Cell1 R_a flag; H2.
Definition: data_flash_access.h:170
static const word SOC_FLAG_CONFIG_A
Settings; Configuration; 0x4632; SOC Flag Config A; H2.
Definition: data_flash_access.h:94
static const word OCC_THRESHOLD
13.10.3 OCC- Overcurrent In Charge: Protections; OCC; 0x46C9; Threshold; I2
Definition: data_flash_access.h:112
static const word CELL0_RA_FLAG
Definition: data_flash_access.h:152
static const word MIN
Minimum Data Flash address.
Definition: data_flash_access.h:61
static const word Q_MAX_CELL_1
Gas Gauging; State; Qmax Cell 1; I2.
Definition: data_flash_access.h:123
static const word GAS_GAUGING_CYCLE_COUNT
Gas Gauging; State; Cycle Count; U2.
Definition: data_flash_access.h:77
static const word CHARGE_TERM_TAPER_CURRENT
Advanced Charge Algorithm; Termination Config; Charge Term Taper Current; I2.
Definition: data_flash_access.h:110
static const word OTC_THRESHOLD
13.10.8 OTC - Overtemperature in Charge: Protections; OTC; 0x46D8; Threshold; I2
Definition: data_flash_access.h:117
int dfReadI2(word addr)
Read Two-byte Integer value from the Data Flash by address.
Definition: data_flash_access.cpp:218
byte dfReadTcSetRsocThreshold()
Gas Gauging; TC; 0x464B; Set % RSOC Threshold.
Definition: data_flash_access.cpp:736
void dfWriteTcSetRsocThreshold(byte setThreshold)
Gas Gauging; TC; 0x464B; Set % RSOC Threshold.
Definition: data_flash_access.cpp:744
word dfReadWord(word addr)
Read a word value (two bytes) from the Data Flash by address.
Definition: data_flash_access.cpp:193
void dfResetRaTableFlags()
Reset "R_a flags" in the Data Flash to the Default values:
Definition: data_flash_access.cpp:517
String dfDeviceName()
Read the Device Name from the Data Flash.
Definition: data_flash_access.cpp:271
int dfReadQmaxPack()
Gas Gauging; State; 0x420A; Qmax Pack; I2.
Definition: data_flash_access.cpp:784
byte dfReadByte(word addr)
Definition: data_flash_access.cpp:162
String dfReadString(word addr)
Read String value from the Data Flash by address.
Definition: data_flash_access.cpp:250
void dfWriteFetOptionsCHGFET(bool chgFetBitValue)
Settings; Configuration; FET Options; H1.
Definition: data_flash_access.cpp:609
void dfWriteCycleCount(word cycleCount)
Gas Gauging; State; 0x4240; Cycle Count; U2.
Definition: data_flash_access.cpp:819
byte dfReadU1(word addr)
Definition: data_flash_access.cpp:171
int dfReadDesignCapacityMah()
Read the Design Capacity in mAh from the Data Flash.
Definition: data_flash_access.cpp:289
void dfWriteWord(word addr, word value)
Write a word value (two bytes) to the Data Flash by address.
Definition: data_flash_access.cpp:206
void dfReadAllData()
Read and print all data from the Data Flash.
Definition: data_flash_access.cpp:534
void dfWriteTaperCurrent(int taperCurrent)
Advanced Charge Algorithm; Termination Config; 0x4693; Charge Term Taper Current; I2.
Definition: data_flash_access.cpp:595
void dfWriteDesignCapacityCwh(int designCapacityCwh)
Write Design Energy in cWh to the Data Flash.
Definition: data_flash_access.cpp:333
void dfWriteByte(word addr, byte value)
Definition: data_flash_access.cpp:178
int dfReadQmaxCell1()
Gas Gauging; State; 0x4206; Qmax Cell 1; I2.
Definition: data_flash_access.cpp:768
int dfReadDesignCapacityCwh()
Read the Design Energy in cWh from the Data Flash.
Definition: data_flash_access.cpp:316
void dfPrintRaTable()
Print data from R_a table.
Definition: data_flash_access.cpp:560
word dfReadU2(word addr)
Read Two-byte unsigned integer value from the Data Flash by address.
Definition: data_flash_access.cpp:234
void dfWriteDesignCapacityMah(int designCapacityMah)
Write Design Capacity in mAh to the Data Flash.
Definition: data_flash_access.cpp:303
word dfReadCycleCount()
Gas Gauging; State; 0x4240; Cycle Count; U2.
Definition: data_flash_access.cpp:811
byte dfReadDaConfiguration()
Settings; Configuration; 0x469B; DA Configuration; H1.
Definition: data_flash_access.cpp:404
void dfWriteI2(word addr, int value)
Write int value to the Data Flash by address.
Definition: data_flash_access.cpp:226
void dfReadBytes(word addr, byte *retval, int len)
Read array of bytes from the Data Flash by address.
Definition: data_flash_access.cpp:90
byte dfReadGasGaugingUpdateStatus()
Gas Gauging; Update Status; 0x420E; H1.
Definition: data_flash_access.cpp:450
byte dfReadTcClearRsocThreshold()
Gas Gauging; TC; 0x464C; Clear % RSOC Threshold.
Definition: data_flash_access.cpp:752
void dfWriteSocFlagConfigA(word socFlagConfigA)
Settings; Configuration; 0x4632; SOC Flag Config A; H2.
Definition: data_flash_access.cpp:728
void dfWriteTcClearRsocThreshold(byte clearThreshold)
Gas Gauging; TC; 0x464C; Clear % RSOC Threshold.
Definition: data_flash_access.cpp:760
byte dfReadFetOptions()
Settings; Configuration; 0x4600; FET Options; H1.
Definition: data_flash_access.cpp:364
word dfReadSocFlagConfigA()
Settings; Configuration; 0x4632; SOC Flag Config A; H2.
Definition: data_flash_access.cpp:663
int dfReadQmaxCell2()
Gas Gauging; State; 0x4208; Qmax Cell 2; I2.
Definition: data_flash_access.cpp:776
void dfWriteGasGaugingUpdateStatus(byte updateStatus)
Gas Gauging; Update Status; 0x420E; H1.
Definition: data_flash_access.cpp:500
void dfWriteU2(word addr, word value)
Write unsigned int value to the Data Flash by address.
Definition: data_flash_access.cpp:242
void dfWriteBytes(word addr, byte *data, int len)
Write array of data to the Data Flash.
Definition: data_flash_access.cpp:133
int dfReadTaperCurrent()
Advanced Charge Algorithm; Termination Config; 0x4693; Charge Term Taper Current; I2.
Definition: data_flash_access.cpp:587
void dfWriteQmax(word qMaxCell0, word qMaxCell1)
Qmax Pack = min(Qmax Cell 1, Qmax Cell 2)
Definition: data_flash_access.cpp:799
Global constants.
Custom functions headers.
Util functions headers.