BQ28Z610 Driver
BQ28Z610 Battery fuel gauge device driver for Arduino
flags.h
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include <Arduino.h>
32 
36 struct Flag {
37 
41  byte n;
42 
46  const char *caption;
47 };
48 
58  public:
59  static Flag SEC1() {
60  return {14, PSTR("SEC1 (Bit 14): SECURITY Mode")};
61  }
62  static Flag SEC0() {
63  return {13, PSTR("SEC0 (Bit 13): SECURITY Mode")};
64  }
65  static Flag AUTHCALM() {
66  return {12, PSTR("AUTHCALM (Bit 12): Automatic CALIBRATION mode")};
67  }
68  static Flag CheckSumValid() {
69  return {9, PSTR("CheckSumValid (Bit 9): Checksum Valid")};
70  }
71  static Flag BTP_INT() {
72  return {7, PSTR("BTP_INT (Bit 7): Battery Trip Point Interrupt")};
73  }
74  static Flag LDMD() {
75  return {3, PSTR("LDMD (Bit 3): LOAD Mode")};
76  }
77  static Flag R_DIS() {
78  return {2, PSTR("R_DIS (Bit 2): Resistance Updates")};
79  }
80  static Flag VOK() {
81  return {1, PSTR("VOK (Bit 1): Voltage OK for QMax Update")};
82  }
83  static Flag QMax() {
84  return {0, PSTR("QMax (Bit 0): QMax Updates. This bit toggles after every QMax update")};
85  }
86 };
87 
92  public:
93  static const byte ERR_CODE = 0b111;
94  static Flag EC0() {
95  return {0, PSTR("EC0 (Bit 0): Error Code")};
96  }
97  static Flag EC1() {
98  return {1, PSTR("EC1 (Bit 1): Error Code")};
99  }
100  static Flag EC2() {
101  return {2, PSTR("EC2 (Bit 2): Error Code")};
102  }
103  static Flag EC3() {
104  return {3, PSTR("EC3 (Bit 3): Error Code")};
105  }
106  static Flag FD() {
107  return {4, PSTR("FD (Bit 4): Fully Discharged: [Battery ok; Battery fully depleted]")};
108  }
109  static Flag FC() {
110  return {5, PSTR("FC (Bit 5): Fully Charged: [Battery not fully charged; Battery fully charged]")};
111  }
112  static Flag DSG() {
113  return {6, PSTR("DSG (Bit 6): Discharging: [Battery is charging; Battery is discharging]")};
114  }
115  static Flag INIT() {
116  return {7, PSTR("INIT (Bit 7): Initialization: [Inactive; Active]")};
117  }
118  static Flag RTA() {
119  return {8, PSTR("RTA (Bit 8): Remaining Time Alarm: [Inactive; Active]")};
120  }
121  static Flag RCA() {
122  return {9, PSTR("RCA (Bit 9): Remaining Capacity Alarm: [Inactive; Active]")};
123  }
124  static Flag TDA() {
125  return {11, PSTR("TDA (Bit 11): Terminate Discharge Alarm: [Inactive; Active]")};
126  }
127  static Flag OTA() {
128  return {12, PSTR("OTA (Bit 12): Overtemperature Alarm: [Inactive; Active]")};
129  }
130  static Flag TCA() {
131  return {14, PSTR("TCA (Bit 14): Terminate Charge Alarm: [Inactive; Active]")};
132  }
133  static Flag OCA() {
134  return {15, PSTR("OCA (Bit 15): Overcharged Alarm: [Inactive; Active]")};
135  }
136 };
137 
142  public:
143  static Flag DSG() {
144  return {27, PSTR("UTD (Bit 27): Undertemperature During Discharge")};
145  }
146  static Flag UTC() {
147  return {26, PSTR("UTC (Bit 26): Undertemperature During Charge")};
148  }
149  static Flag CTOS() {
150  return {21, PSTR("CTOS (Bit 21): Charge Timeout Suspend")};
151  }
152  static Flag PTOS() {
153  return {19, PSTR("PTOS (Bit 19): Precharge Timeout Suspend")};
154  }
155  static Flag OTD() {
156  return {13, PSTR("OTD (Bit 13): Overtemperature During Discharge")};
157  }
158  static Flag OTC() {
159  return {12, PSTR("OTC (Bit 12): Overtemperature During Charge")};
160  }
161  static Flag ASCD() {
162  return {10, PSTR("ASCD (Bit 10): Short-Circuit During Discharge")};
163  }
164  static Flag ASCC() {
165  return {8, PSTR("ASCC (Bit 8): Short-Circuit During Charge")};
166  }
167  static Flag AOLD() {
168  return {6, PSTR("AOLD (Bit 6): Overload During Discharge")};
169  }
170  static Flag OCD() {
171  return {4, PSTR("OCD (Bit 4): Overcurrent During Discharge")};
172  }
173  static Flag OCC() {
174  return {2, PSTR("OCC (Bit 2): Overcurrent During Charge")};
175  }
176  static Flag COV() {
177  return {1, PSTR("COV (Bit 1): Cell Overvoltage")};
178  }
179  static Flag CUV() {
180  return {0, PSTR("CUV (Bit 0): Cell Undervoltage")};
181  }
182 };
183 
188  public:
189  static Flag UTD() {
190  return {27, PSTR("UTD (Bit 27): Undertemperature During Discharge")};
191  }
192  static Flag UTC() {
193  return {26, PSTR("UTC (Bit 26): Undertemperature During Charge")};
194  }
195  static Flag CTO() {
196  return {20, PSTR("CTO (Bit 20): Charge Timeout")};
197  }
198  static Flag PTO() {
199  return {18, PSTR("PTO (Bit 18): Precharge Timeout")};
200  }
201  static Flag OTD() {
202  return {13, PSTR("OTD (Bit 13): Overtemperature During Discharge")};
203  }
204  static Flag OTC() {
205  return {12, PSTR("OTC (Bit 12): Overtemperature During Charge")};
206  }
207  static Flag ASCD() {
208  return {10, PSTR("ASCD (Bit 10): Short-Circuit During Discharge")};
209  }
210  static Flag ASCC() {
211  return {8, PSTR("ASCC (Bit 8): Short-Circuit During Charge")};
212  }
213  static Flag AOLD() {
214  return {6, PSTR("AOLD (Bit 6): Overload During Discharge")};
215  }
216  static Flag OCD() {
217  return {4, PSTR("OCD (Bit 4): Overcurrent During Discharge")};
218  }
219  static Flag OCC() {
220  return {2, PSTR("OCC (Bit 2): Overcurrent During Charge")};
221  }
222  static Flag COV() {
223  return {1, PSTR("COV (Bit 1): Cell Overvoltage")};
224  }
225  static Flag CUV() {
226  return {0, PSTR("CUV (Bit 0): Cell Undervoltage")};
227  }
228 };
229 
234  public:
235  static Flag DFW() {
236  return {26, PSTR("DFW (Bit 26): Data Flash Wearout Failure")};
237  }
238  static Flag IFC() {
239  return {24, PSTR("IFC (Bit 24): Instruction Flash Checksum Failure")};
240  }
241  static Flag DFETF() {
242  return {17, PSTR("DFETF (Bit 17): Discharge FET Failure")};
243  }
244  static Flag CFETF() {
245  return {16, PSTR("CFETF (Bit 16): Charge FET Failure")};
246  }
247  static Flag VIMR() {
248  return {12, PSTR("VIMR (Bit 12): Voltage Imbalance While Pack Is At Rest Failure")};
249  }
250  static Flag VIMA() {
251  return {11, PSTR("VIMA (Bit 11): Voltage Imbalance While Pack Is Active Failure")};
252  }
253  static Flag SOV() {
254  return {1, PSTR("SOV (Bit 1): Safety Cell Overvoltage Failure")};
255  }
256 };
257 
262  public:
263  static Flag EMSHUT() {
264  return {29, PSTR("EMSHUT (Bit 29): Emergency FET Shutdown")};
265  }
266  static Flag CB() {
267  return {28, PSTR("CB (Bit 28): Cell Balancing")};
268  }
269  static Flag SLPCC() {
270  return {27, PSTR("SLPCC (Bit 27): CC Measurement in SLEEP mode")};
271  }
272  static Flag SLPAD() {
273  return {26, PSTR("SLPAD (Bit 26): ADC Measurement in SLEEP mode")};
274  }
275  static Flag SMBLCAL() {
276  return {25, PSTR("SMBLCAL (Bit 25): Auto-offset calibration when Bus low is detected")};
277  }
278  static Flag INIT() {
279  return {24, PSTR("INIT (Bit 24): Initialization after full reset")};
280  }
281  static Flag SLEEPM() {
282  return {23, PSTR("SLEEPM (Bit 23): SLEEP mode")};
283  }
284  static Flag XL() {
285  return {22, PSTR("XL (Bit 22): 400-kHz mode")};
286  }
287  static Flag CAL_OFFSET() {
288  return {21, PSTR("CAL_OFFSET (Bit 21): Calibration Output (raw CC Offset data)")};
289  }
290  static Flag CAL() {
291  return {20, PSTR("CAL (Bit 20): Calibration Output (raw ADC and CC data)")};
292  }
293  static Flag AUTHCALM() {
294  return {19, PSTR("AUTHCALM (Bit 19): Auto CC Offset Calibration by MAC AutoCCOffset")};
295  }
296  static Flag AUTH() {
297  return {18, PSTR("AUTH (Bit 18): Authentication in progress")};
298  }
299  static Flag SDM() {
300  return {16, PSTR("SDM (Bit 16): SHUTDOWN triggered via command")};
301  }
302 
303  // =====
304 
305  static Flag SLEEP() {
306  return {15, PSTR("SLEEP (Bit 15): SLEEP mode conditions met")};
307  }
308  static Flag XCHG() {
309  return {14, PSTR("XCHG (Bit 14): Charging disabled")};
310  }
311  static Flag XDSG() {
312  return {13, PSTR("XDSG (Bit 13): Discharging disabled")};
313  }
314  static Flag PF() {
315  return {12, PSTR("PF (Bit 12): PERMANENT FAILURE mode status")};
316  }
317  static Flag SS() {
318  return {11, PSTR("SS (Bit 11): SAFETY mode status")};
319  }
320  static Flag SDV() {
321  return {10, PSTR("SDV (Bit 10): SHUTDOWN triggered via low pack voltage")};
322  }
323  static Flag SEC1() {
324  return {9, PSTR("SEC1 (Bit 9)")};
325  }
326  static Flag SEC0() {
327  return {8, PSTR("SEC0 (Bit 8)")};
328  }
329  static Flag BTP_INT() {
330  return {7, PSTR("BTP_INT (Bit 7): Battery Trip Point (BTP) Interrupt output")};
331  }
332  static Flag CHG() {
333  return {2, PSTR("CHG (Bit 2): CHG FET status")};
334  }
335  static Flag DSG() {
336  return {1, PSTR("DSG (Bit 1): DSG FET status")};
337  }
338 };
339 
344  public:
345  static Flag VCT() {
346  return {15, PSTR("VCT (Bit 15): Charge Termination")};
347  }
348  static Flag MCHG() {
349  return {14, PSTR("MCHG (Bit 14): Maintenance Charge")};
350  }
351  static Flag SU() {
352  return {13, PSTR("SU (Bit 13): Charge Suspend")};
353  }
354  static Flag IN() {
355  return {12, PSTR("IN (Bit 12): Charge Inhibit")};
356  }
357  static Flag HV() {
358  return {11, PSTR("HV (Bit 11): High Voltage Region")};
359  }
360  static Flag MV() {
361  return {10, PSTR("MV (Bit 10): Mid Voltage Region")};
362  }
363  static Flag LV() {
364  return {9, PSTR("LV (Bit 9): Low Voltage Region")};
365  }
366  static Flag PV() {
367  return {8, PSTR("PV (Bit 8): Precharge Voltage Region")};
368  }
369  static Flag OT() {
370  return {6, PSTR("OT (Bit 6): Over Temperature Region")};
371  }
372  static Flag HT() {
373  return {5, PSTR("HT (Bit 5): High Temperature Region")};
374  }
375  static Flag STH() {
376  return {4, PSTR("STH (Bit 4): Standard Temperature High Region")};
377  }
378  static Flag RT() {
379  return {3, PSTR("RT (Bit 3): Room Temperature Region")};
380  }
381  static Flag STL() {
382  return {2, PSTR("STL (Bit 2): Standard Temperature Low Region")};
383  }
384  static Flag LT() {
385  return {1, PSTR("LT (Bit 1): Low Temperature Region")};
386  }
387  static Flag UT() {
388  return {0, PSTR("UT (Bit 0): Under Temperature Region")};
389  }
390 };
391 
396  public:
397  static Flag OCVFR() {
398  return {20, PSTR("OCVFR (Bit 20): Open Circuit Voltage in Flat Region (during RELAX)")};
399  }
400  static Flag LDMD() {
401  return {19, PSTR("LDMD (Bit 19): LOAD mode")};
402  }
403  static Flag RX() {
404  return {18, PSTR("RX (Bit 18): Resistance Update (Toggles after every resistance update)")};
405  }
406  static Flag QMax() {
407  return {17, PSTR("QMax (Bit 17): QMax Update (Toggles after every QMax update)")};
408  }
409  static Flag VDQ() {
410  return {16, PSTR("VDQ (Bit 16): Discharge Qualified for Learning (based on RU flag)")};
411  }
412  static Flag NSFM() {
413  return {15, PSTR("NSFM (Bit 15): Negative Scale Factor Mode")};
414  }
415  static Flag SLPQMax() {
416  return {13, PSTR("SLPQMax (Bit 13): QMax Update During Sleep")};
417  }
418  static Flag QEN() {
419  return {12, PSTR("QEN (Bit 12): Impedance Track Gauging (Ra and QMax updates are enabled)")};
420  }
421  static Flag VOK() {
422  return {11, PSTR("VOK (Bit 11): Voltage OK for QMax Update")};
423  }
424  static Flag RDIS() {
425  return {10, PSTR("RDIS (Bit 10): Resistance Updates")};
426  }
427  static Flag REST() {
428  return {8, PSTR("REST (Bit 8): Rest")}; // documentation contains a typo
429  }
430  static Flag CF() {
431  return {7, PSTR("CF (Bit 7): Condition Flag")};
432  }
433  static Flag DSG() {
434  return {6, PSTR("DSG (Bit 6): Discharge/Relax")};
435  }
436  static Flag EDV() {
437  return {5, PSTR("EDV (Bit 5): End-of-Discharge Termination Voltage")};
438  }
439  static Flag BAL_EN() {
440  return {4, PSTR("BAL_EN (Bit 4): Cell Balancing")};
441  }
442  static Flag TC() {
443  return {3, PSTR("TC (Bit 3): Terminate Charge")};
444  }
445  static Flag TD() {
446  return {2, PSTR("TD (Bit 2): Terminate Discharge")};
447  }
448  static Flag FC() {
449  return {1, PSTR("FC (Bit 1): Fully Charged")};
450  }
451  static Flag FD() {
452  return {0, PSTR("FD (Bit 0): Fully Discharged")};
453  }
454 };
455 
460  public:
461  static Flag CAL_EN() {
462  return {15, PSTR("CAL_EN (Bit 15) CALIBRATION Mode")};
463  }
464  static Flag PF_EN() {
465  return {6, PSTR("PF_EN (Bit 6) Permanent Failure Mode")};
466  }
467  static Flag LF_EN() {
468  return {5, PSTR("LF_EN (Bit 5) Lifetime Data Collection Mode")};
469  }
470  static Flag FET_EN() {
471  return {4, PSTR("FET_EN (Bit 4) All FET Action Mode")};
472  }
473  static Flag GAUGE_EN() {
474  return {3, PSTR("GAUGE_EN (Bit 3) Gas Gauging Mode")};
475  }
476  static Flag DSG_TEST() {
477  return {2, PSTR("DSG_TEST (Bit 2)Discharge FET Test")};
478  }
479  static Flag CHG_TEST() {
480  return {1, PSTR("CHG_TEST (Bit 1) Charge FET Test")};
481  }
482 };
483 
512  public:
517  static Flag OTFET() {
518  return {2, PSTR("Bit 2: OTFET - FET action in OVERTEMPERATURE mode")};
519  }
524  static Flag CHGSU() {
525  return {3, PSTR("Bit 3: CHGSU - FET action in CHARGE SUSPEND mode")};
526  }
531  static Flag CHGIN() {
532  return {4, PSTR("Bit 4: CHGIN - FET action in CHARGE INHIBIT mode")};
533  }
538  static Flag CHGFET() {
539  return {5, PSTR("Bit 5: CHGFET - FET action on valid charge termination")};
540  }
545  static Flag SLEEPCHG() {
546  return {6, PSTR("Bit 6: SLEEPCHG - CHG FET enabled during sleep")};
547  }
548 };
549 
565  public:
570  static Flag CC0() {
571  return {0, PSTR("Bit 0: CC0—Cell Count")};
572  }
578  return {3, PSTR("Bit 3: IN_SYSTEM_SLEEP—In-system SLEEP mode")};
579  }
584  static Flag SLEEP() {
585  return {4, PSTR("Bit 4: SLEEP—SLEEP Mode")};
586  }
591  static Flag CTEMP() {
592  return {6, PSTR("Bit 6: CTEMP—Cell Temperature protection source")};
593  }
594 };
595 
606  public:
613  static const byte UPDATE_STATUS = 0b11;
614  static Flag Update0() {
615  return {0, PSTR("Bit 0: Update0 - Update Status")};
616  }
617  static Flag Update1() {
618  return {1, PSTR("Bit 1: Update0 - Update Status")};
619  }
624  static Flag Enable() {
625  return {2, PSTR("Bit 2: Enable - Impedance Track gauging and lifetime updating is enabled")};
626  }
631  static Flag QMax_update() {
632  return {3, PSTR("Bit 3: QMax_update - QMax was updated in the field (in real conditions)")};
633  }
634 };
635 
680  public:
681  static Flag TDSETV() {
682  return {0, PSTR("Bit 0: TDSETV - Enables the TD flag set by the cell voltage threshold")};
683  }
684  static Flag TDCLEARV() {
685  return {1, PSTR("Bit 1: TDCLEARV - Enables the TD flag clear by cell voltage threshold")};
686  }
687  static Flag TDSETRSOC() {
688  return {2, PSTR("Bit 2: TDSETRSOC - Enables the TD flag set by RSOC threshold")};
689  }
690  static Flag TDCLEARRSOC() {
691  return {3, PSTR("Bit 3: TDCLEARRSOC - Enables the TD flag cleared by the RSOC threshold")};
692  }
693  static Flag TCSETV() {
694  return {4, PSTR("Bit 4: TCSETV - Enables the TC flag set by cell voltage threshold")};
695  }
696  static Flag TCCLEARV() {
697  return {5, PSTR("Bit 5: TCCLEARV - Enables the TC flag clear by cell voltage threshold")};
698  }
699  static Flag TCSETRSOC() {
700  return {6, PSTR("Bit 6: TCSETRSOC - Enables the TC flag set by the RSOC threshold")};
701  }
702  static Flag TCCLEARRSOC() {
703  return {7, PSTR("Bit 7: TCCLEARRSOC - Enables the TC flag cleared by the RSOC threshold")};
704  }
705  static Flag FCSETVCT() {
706  return {10, PSTR("Bit 10: FCSETVCT - Enables the FC flag set by primary charge termination")};
707  }
708  static Flag TCSETVCT() {
709  return {11, PSTR("Bit 11: TCSETVCT - Enables the TC flag set by primary charge termination")};
710  }
711 };
12.1.6 0x0A/0B BatteryStatus()
Definition: flags.h:91
12.2.31 AltManufacturerAccess() 0x0055 ChargingStatus()
Definition: flags.h:343
Data Flash: Settings; Configuration; 0x469B; DA Configuration; H1.
Definition: flags.h:564
static Flag IN_SYSTEM_SLEEP()
Definition: flags.h:577
static Flag CC0()
Definition: flags.h:570
static Flag SLEEP()
Definition: flags.h:584
static Flag CTEMP()
Definition: flags.h:591
Data Flash: Settings; Configuration; FET Options; H1.
Definition: flags.h:511
static Flag SLEEPCHG()
Definition: flags.h:545
static Flag CHGSU()
Definition: flags.h:524
static Flag CHGIN()
Definition: flags.h:531
static Flag CHGFET()
Definition: flags.h:538
static Flag OTFET()
Definition: flags.h:517
Data Flash: Gas Gauging; State; 0x420E; Update Status; H1.
Definition: flags.h:605
static Flag QMax_update()
Definition: flags.h:631
static const byte UPDATE_STATUS
Definition: flags.h:613
static Flag Enable()
Definition: flags.h:624
12.2.32 AltManufacturerAccess() 0x0056 GaugingStatus()
Definition: flags.h:395
12.1.1 0x00/01 ManufacturerAccessControl()
Definition: flags.h:57
12.2.33 AltManufacturerAccess() 0x0057 ManufacturingStatus()
Definition: flags.h:459
12.2.30 AltManufacturerAccess() 0x0054 OperationStatus()
Definition: flags.h:261
12.2.29 AltManufacturerAccess() 0x0053 PFStatus()
Definition: flags.h:233
Data Flash: Settings; Configuration; 0x4632; SOC Flag Config A; H2.
Definition: flags.h:679
12.2.26 AltManufacturerAccess() 0x0050 SafetyAlert()
Definition: flags.h:141
12.2.27 AltManufacturerAccess() 0x0051 SafetyStatus()
Definition: flags.h:187
Structure that stores flag information.
Definition: flags.h:36
byte n
Definition: flags.h:41
const char * caption
Definition: flags.h:46