BQ28Z610 Driver
BQ28Z610 Battery fuel gauge device driver for Arduino
|
Custom functions headers. More...
#include <Arduino.h>
#include "globals.h"
#include "utils.h"
#include "std_data_commands.h"
#include "alt_manufacturer_access.h"
#include "data_flash_access.h"
Go to the source code of this file.
Functions | |
int | securityMode () |
Request current security mode of the device. More... | |
void | unsealDevice (u32 key=DeviceSecurity::DEFAULT_UNSEAL_KEY) |
9.5.2 SEALED to UNSEALED More... | |
void | fullAccessDevice (u32 key=DeviceSecurity::DEFAULT_FULL_ACCESS_KEY) |
9.5.3 UNSEALED to FULL ACCESS More... | |
void | manufactoryChargeFet (bool mode) |
Brings Charge FET into desired mode. More... | |
void | manufactoryDischargeFet (bool mode) |
Brings Discharge FET into desired mode. More... | |
void | fetControl (bool mode) |
Brings ManufacturingStatus[FET_EN] into desired mode. More... | |
bool | isPermanentFail () |
Chapter 3: Permanent Fail. More... | |
float | cellVoltage1 () |
float | cellVoltage2 () |
float | batVoltage () |
float | packVoltage () |
void | CellUndervoltageProtectionCheck () |
2.2 Cell Undervoltage Protection | |
void | ShortCircuitInChargeProtectionCheck () |
2.6.2 Short Circuit in Charge Protection | |
void | ShortCircuitInDischargeProtectionCheck () |
2.6.3 Short Circuit in Discharge Protection | |
void | OvertemperatureInChargeProtectionCheck () |
2.8 Overtemperature in Charge Protection More... | |
void | PermanentFailCheck () |
Chapter 3 Permanent Fail. More... | |
void | fetsStatus () |
Print flags that correspond to the FETs status. More... | |
void | setEnabledChargingSocThreshold (bool enabled) |
Enable or Disable turning charging FET off at 60% SOC. More... | |
void | learningCycleInit (int designCapacityMah, int designEnergyCwh, word qMaxCell0, word qMaxCell1, word cycleCount) |
Write initial parameters to the Gas Gauging Device. More... | |
void | learningCycleLog () |
Print into Serial port the important information for the Learning Cycle. More... | |
int | dod0PassedQ () |
12.2.40 AltManufacturerAccess() 0x0074 ITStatus2 More... | |
int | getOccThreshold () |
Overcurrent in Charge trip threshold. More... | |
void | setOccThreshold (int occThreshold) |
Overcurrent in Charge trip threshold. More... | |
Custom functions headers.
MIT License
Copyright (c) 2024 Oleksii Sylichenko
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
float batVoltage | ( | ) |
float cellVoltage1 | ( | ) |
float cellVoltage2 | ( | ) |
int dod0PassedQ | ( | ) |
12.2.40 AltManufacturerAccess() 0x0074 ITStatus2
void fetControl | ( | bool | mode | ) |
Brings ManufacturingStatus[FET_EN] into desired mode.
void fetsStatus | ( | ) |
Print flags that correspond to the FETs status.
void fullAccessDevice | ( | u32 | key | ) |
9.5.3 UNSEALED to FULL ACCESS
UNSEALED to FULL ACCESS instructs the device to allow full access to all standard and extended registers and data flash. The device is shipped from TI in this mode. The keys for UNSEALED to FULL ACCESS can be read and changed via the MAC command SecurityKey() when in FULL ACCESS mode. Changing from UNSEALED to FULL ACCESS is performed by using the AltManufacturerAccess() command, by writing the first word of the Full Access Key to AltManufacturerAccess(), followed by the second word of the Full Access Key to AltManufacturerAccess(). In FULL ACCESS mode, the command to go to boot ROM can be sent.
int getOccThreshold | ( | ) |
Overcurrent in Charge trip threshold.
13.10.3 OCC - Overcurrent In Charge: Protections; OCC; 0x46C9; Threshold; I2
bool isPermanentFail | ( | ) |
Chapter 3: Permanent Fail.
void learningCycleInit | ( | int | designCapacityMah, |
int | designEnergyCwh, | ||
word | qMaxCell0, | ||
word | qMaxCell1, | ||
word | cycleCount | ||
) |
Write initial parameters to the Gas Gauging Device.
Write into Data Flash:
Reset "R_a flags" in the Data Flash to the Default values:
void learningCycleLog | ( | ) |
Print into Serial port the important information for the Learning Cycle.
void manufactoryChargeFet | ( | bool | mode | ) |
Brings Charge FET into desired mode.
void manufactoryDischargeFet | ( | bool | mode | ) |
Brings Discharge FET into desired mode.
void OvertemperatureInChargeProtectionCheck | ( | ) |
2.8 Overtemperature in Charge Protection
Trip:
float packVoltage | ( | ) |
void PermanentFailCheck | ( | ) |
Chapter 3 Permanent Fail.
int securityMode | ( | ) |
Request current security mode of the device.
12.2.30 AltManufacturerAccess() 0x0054 OperationStatus() SEC1, SEC0 (Bits 14, 13): SECURITY Mode 0, 0 = Reserved 0, 1 = Full Access 1, 0 = Unsealed 1, 1 = Sealed
12.1.1 0x00/01 ManufacturerAccessControl() SEC1, SEC0 (Bits 14, 13): SECURITY Mode 0, 0 = Reserved 0, 1 = Full Access - doesn't work correct! It's (0, 0) in fact 1, 0 = Unsealed 1, 1 = Sealed
void setEnabledChargingSocThreshold | ( | bool | enabled | ) |
Enable or Disable turning charging FET off at 60% SOC.
void setOccThreshold | ( | int | occThreshold | ) |
Overcurrent in Charge trip threshold.
13.10.3 OCC - Overcurrent In Charge: Protections; OCC; 0x46C9; Threshold; I2
Should be not greater than C/2, where C - FullChargeCapacity.
void unsealDevice | ( | u32 | key | ) |
9.5.2 SEALED to UNSEALED
SEALED to UNSEALED instructs the device to extend access to the standard and extended registers and data flash space and clears the [SEC1][SEC0] flags. In UNSEALED mode, all data, standard and extended registers and DF have read/write access. Unsealing is a two-step command performed by writing the first word of the unseal key to AltManufacturerAccess() (MAC), followed by the second word of the unseal key to AltManufacturerAccess(). The unseal key can be read and changed via the MAC SecurityKey() command when in FULL ACCESS mode. To return to the SEALED mode, either a hardware reset is needed, or the MAC SealDevice() command is needed to transit from FULL ACCESS or UNSEALED to SEALED.