BQ28Z610 Driver
BQ28Z610 Battery fuel gauge device driver for Arduino
Loading...
Searching...
No Matches
globals.h
Go to the documentation of this file.
1
29#pragma once
30
31#include <Arduino.h>
32
33#include "flags.h"
34
35extern bool
44
45const char START_MESSAGE[] PROGMEM = "\n============ START: [BQ28Z610 Driver] ============\nLicense: MIT License\nCopyright (c) 2024 Oleksii Sylichenko\n==================================================\n";
46
51const int DEVICE_ADDR = 0x55;
52
57 public:
61 static const byte FULL_ACCESS = 1;
65 static const byte UNSEALED = 2;
69 static const byte SEALED = 3;
70};
71
79 public:
83 static const u32 DEFAULT_UNSEAL_KEY = 0x36720414;
93 static const u32 DEFAULT_FULL_ACCESS_KEY = 0xFFFFFFFF;
94};
95
105 public:
106 static const int REQUEST_MAX_SIZE = 32;
108
109 static const int ADDR_SIZE = 2;
110 static const int CHECKSUM_SIZE = 1;
111 static const int LENGTH_SIZE = 1;
114
115 static const int DATA_INDEX = 2;
116 static const int CHECKSUM_INDEX = 34;
117 static const int LENGTH_INDEX = 35;
118
119 static const int RESPONSE_MAX_SIZE = 36;
120 static const int MAX = RESPONSE_MAX_SIZE;
121};
122
130 public:
134 static const byte MANUFACTURER_ACCESS_CONTROL = 0x00;
138 static const byte TEMPERATURE = 0x06;
142 static const byte VOLTAGE = 0x08;
146 static const byte BATTERY_STATUS = 0x0A;
150 static const byte CURRENT = 0x0C;
154 static const byte REMAINING_CAPACITY = 0x10;
158 static const byte FULL_CHARGE_CAPACITY = 0x12;
162 static const byte AVERAGE_CURRENT = 0x14;
166 static const byte CYCLE_COUNT = 0x2A;
170 static const byte RELATIVE_STATE_OF_CHARGE = 0x2C;
174 static const byte STATE_OF_HEALTH = 0x2E;
178 static const byte CHARGING_VOLTAGE = 0x30;
182 static const byte CHARGING_CURRENT = 0x32;
186 static const byte DESIGN_CAPACITY = 0x3C;
190 static const byte ALT_MANUFACTURER_ACCESS = 0x3E;
194 static const byte MAC_DATA = 0x40;
200 static const byte MAC_DATA_CHECKSUM = 0x60;
201};
202
207 public:
211 static const word DEVICE_TYPE = 0x0001;
215 static const word FIRMWARE_VERSION = 0x0002;
219 static const word HARDWARE_VERSION = 0x0003;
223 static const word CHEMICAL_ID = 0x0006;
227 static const word DEVICE_RESET = 0x0012;
231 static const word CHG_FET = 0x001F;
235 static const word DSG_FET = 0x0020;
239 static const word GAUGE_EN = 0x0021;
243 static const word FET_CONTROL = 0x0022;
247 static const word LIFETIME_DATA_RESET = 0x0028;
251 static const word PERMANENT_FAIL_DATA_RESET = 0x0029;
255 static const word SEAL_DEVICE = 0x0030;
259 static const word SAFETY_ALERT = 0x0050;
263 static const word PF_ALERT = 0x0052;
267 static const word PF_STATUS = 0x0053;
271 static const word OPERATION_STATUS = 0x0054;
275 static const word CHARGING_STATUS = 0x0055;
279 static const word GAUGING_STATUS = 0x0056;
283 static const word MANUFACTURER_STATUS = 0x0057;
287 static const word DA_STATUS_1 = 0x0071;
291 static const word DA_STATUS_2 = 0x0072;
295 static const word IT_STATUS_1 = 0x0073;
299 static const word IT_STATUS_2 = 0x0074;
303 static const word IT_STATUS_3 = 0x0075;
304};
305
312 public:
316 static const byte CELL_VOLTAGE_1 = 0;
320 static const byte CELL_VOLTAGE_2 = 2;
324 static const byte BAT_VOLTAGE = 8;
328 static const byte PACK_VOLTAGE = 10;
332 static const byte CELL_CURRENT_1 = 12;
336 static const byte CELL_CURRENT_2 = 14;
340 static const byte CELL_POWER_1 = 20;
344 static const byte CELL_POWER_2 = 22;
348 static const byte POWER = 28;
352 static const byte AVG_POWER = 30;
353};
354
368 public:
372 static const byte DOD0_1 = 10;
373
377 static const byte DOD0_2 = 12;
378
382 static const byte DOD0_Passed_Q = 14;
383
387 static const byte DOD0_Passed_Energy = 16;
388
392 static const byte DOD0_Time = 18;
393
397 static const byte DODEOC_1 = 20;
398
402 static const byte DODEOC_2 = 22;
403};
404
411 public:
415 static const byte QMax_1 = 0;
419 static const byte QMax_2 = 2;
423 static const byte QMaxDOD0_1 = 4;
427 static const byte QMaxDOD0_2 = 6;
431 static const byte QMaxPassedQ = 8;
435 static const byte QMaxTime = 10;
439 static const byte Tk = 12;
443 static const byte Ta = 14;
447 static const byte RAW_DOD0_1 = 16;
451 static const byte RAW_DOD0_2 = 18;
452};
453
457class Units {
458 public:
459 static PGM_P MAH() {
460 return PSTR("mAh");
461 }
462 static PGM_P CWH() {
463 return PSTR("cWh");
464 }
465 static PGM_P MW() {
466 return PSTR("mW");
467 }
468 static PGM_P MA() {
469 return PSTR("mA");
470 }
471 static PGM_P V() {
472 return PSTR("V");
473 }
474 static PGM_P PERCENT() {
475 return PSTR("%");
476 }
477 static PGM_P CELSIUS() {
478 return PSTR("°C");
479 }
480};
481
485const float DECIPART = 0.1;
489const float DECIPART_DECIMAL = 1;
490
494const float PERMIL = 0.001;
498const byte PERMIL_DECIMAL = 3;
12.2 0x3E, 0x3F AltManufacturerAccess() Commands
Definition globals.h:206
static const word DA_STATUS_2
Definition globals.h:291
static const word SEAL_DEVICE
Definition globals.h:255
static const word PF_STATUS
Definition globals.h:267
static const word GAUGING_STATUS
Definition globals.h:279
static const word PF_ALERT
Definition globals.h:263
static const word SAFETY_ALERT
Definition globals.h:259
static const word IT_STATUS_1
Definition globals.h:295
static const word PERMANENT_FAIL_DATA_RESET
Definition globals.h:251
static const word CHARGING_STATUS
Definition globals.h:275
static const word DEVICE_TYPE
Definition globals.h:211
static const word MANUFACTURER_STATUS
Definition globals.h:283
static const word CHG_FET
Definition globals.h:231
static const word FET_CONTROL
Definition globals.h:243
static const word GAUGE_EN
Definition globals.h:239
static const word CHEMICAL_ID
Definition globals.h:223
static const word FIRMWARE_VERSION
Definition globals.h:215
static const word DSG_FET
Definition globals.h:235
static const word LIFETIME_DATA_RESET
Definition globals.h:247
static const word DEVICE_RESET
Definition globals.h:227
static const word OPERATION_STATUS
Definition globals.h:271
static const word HARDWARE_VERSION
Definition globals.h:219
Block Protocol contants.
Definition globals.h:104
static const int PAYLOAD_MAX_SIZE
The maximum number of data bytes that can be obtained from the device in a single function call.
Definition globals.h:107
static const int ADDR_SIZE
Number of bytes for address, 2.
Definition globals.h:109
static const int LENGTH_SIZE
Number of bytes for Length, 1.
Definition globals.h:111
static const int LENGTH_INDEX
The index of the byte that stores the total length of the response.
Definition globals.h:117
static const int CHECKSUM_SIZE
Number of bytes for Checksum, 1.
Definition globals.h:110
static const int RESPONSE_MAX_SIZE
Maximum size of the full response in bytes.
Definition globals.h:119
static const int SERVICE_SIZE
Number of the service bytes (address, checksum, length), 4.
Definition globals.h:113
static const int REQUEST_MAX_SIZE
The maximum number of bytes that can be obtained from the device in a single request.
Definition globals.h:106
static const int CHECKSUM_AND_LENGTH_SIZE
Number of bytes for the Checksum and Length, 2.
Definition globals.h:112
static const int DATA_INDEX
Index of the byte from which data starts.
Definition globals.h:115
static const int CHECKSUM_INDEX
The index of the byte that stores the checksum of the response.
Definition globals.h:116
12.2.37 AltManufacturerAccess() 0x0071 DAStatus1()
Definition globals.h:311
static const byte CELL_POWER_1
Definition globals.h:340
static const byte BAT_VOLTAGE
Definition globals.h:324
static const byte PACK_VOLTAGE
Definition globals.h:328
static const byte CELL_VOLTAGE_1
Definition globals.h:316
static const byte POWER
Definition globals.h:348
static const byte CELL_CURRENT_2
Definition globals.h:336
static const byte CELL_POWER_2
Definition globals.h:344
static const byte CELL_VOLTAGE_2
Definition globals.h:320
static const byte CELL_CURRENT_1
Definition globals.h:332
static const byte AVG_POWER
Definition globals.h:352
Chapter 9 Device Security.
Definition globals.h:78
static const u32 DEFAULT_FULL_ACCESS_KEY
BQ28Z610 default Full Access key.
Definition globals.h:93
static const u32 DEFAULT_UNSEAL_KEY
BQ28Z610 default Unseal key.
Definition globals.h:83
12.2.40 AltManufacturerAccess() 0x0074 ITStatus2()
Definition globals.h:367
static const byte DODEOC_1
Definition globals.h:397
static const byte DOD0_1
Definition globals.h:372
static const byte DOD0_Passed_Q
Definition globals.h:382
static const byte DODEOC_2
Definition globals.h:402
static const byte DOD0_2
Definition globals.h:377
static const byte DOD0_Passed_Energy
Definition globals.h:387
static const byte DOD0_Time
Definition globals.h:392
12.2.41 AltManufacturerAccess() 0x0075 ITStatus3()
Definition globals.h:410
static const byte QMaxPassedQ
Definition globals.h:431
static const byte QMaxDOD0_2
Definition globals.h:427
static const byte RAW_DOD0_2
Definition globals.h:451
static const byte Ta
Definition globals.h:443
static const byte QMaxDOD0_1
Definition globals.h:423
static const byte QMaxTime
Definition globals.h:435
static const byte QMax_2
Definition globals.h:419
static const byte Tk
Definition globals.h:439
static const byte RAW_DOD0_1
Definition globals.h:447
static const byte QMax_1
Definition globals.h:415
Constants for securityMode() result.
Definition globals.h:56
static const byte UNSEALED
Definition globals.h:65
static const byte FULL_ACCESS
Definition globals.h:61
static const byte SEALED
Definition globals.h:69
12.1 Standard Data Commands
Definition globals.h:129
static const byte CURRENT
Definition globals.h:150
static const byte TEMPERATURE
Definition globals.h:138
static const byte ALT_MANUFACTURER_ACCESS
Definition globals.h:190
static const byte MANUFACTURER_ACCESS_CONTROL
Definition globals.h:134
static const byte MAC_DATA
Definition globals.h:194
static const byte VOLTAGE
Definition globals.h:142
static const byte CHARGING_CURRENT
Definition globals.h:182
static const byte AVERAGE_CURRENT
Definition globals.h:162
static const byte REMAINING_CAPACITY
Definition globals.h:154
static const byte RELATIVE_STATE_OF_CHARGE
Definition globals.h:170
static const byte BATTERY_STATUS
Definition globals.h:146
static const byte CYCLE_COUNT
Definition globals.h:166
static const byte CHARGING_VOLTAGE
Definition globals.h:178
static const byte MAC_DATA_CHECKSUM
Definition globals.h:200
static const byte DESIGN_CAPACITY
Definition globals.h:186
static const byte FULL_CHARGE_CAPACITY
Definition globals.h:158
static const byte STATE_OF_HEALTH
Definition globals.h:174
Units of measurement to print to serial port.
Definition globals.h:457
Flags constants.
bool DEBUG
Print extended info.
Definition globals.h:43
bool SILENCE
Do not print data into Serial from the functions.
const float DECIPART_DECIMAL
Number of decimal places.
Definition globals.h:489
const int DEVICE_ADDR
Standard BQ28Z610 Device I2C Address.
Definition globals.h:51
const float DECIPART
1/10 part
Definition globals.h:485
const byte PERMIL_DECIMAL
Number of decimal places.
Definition globals.h:498
const float PERMIL
1/1000 part
Definition globals.h:494