unleashed-firmware/lib/drivers/bq27220_reg.h
あく 0469ef0e55
FuriHal, drivers: rework gauge initialization routine (#3912)
* FuriHal, drivers: rework gauge initialization, ensure that we can recover from any kind of internal/external issue
* Make PVS happy
* Format sources
* bq27220: add gaps injection into write operations
* Drivers: bq27220 cleanup and various fixes
* Drivers: bq27220 verbose logging and full access routine fix
* Drivers: better cfg mode exit handling in bq27220 driver
* Drivers: rewrite bq27220 based on bqstudio+ev2400, experiments and guessing. Fixes all known issues.
* PVS: hello license check
* Drivers: minimize reset count in bq27220 init sequence
* Drivers: bq27220 hide debug logging, reorganize routine to ensure predictable result and minimum amount of interaction with gauge, add documentation and notes.
* Drivers: more reliable bq27220_full_access routine
* Drivers: replace some warning with error in bq27220
* Drivers: move static asserts to headers in bq27220
* Fix PVS warnings
* Drivers: simplify logic in bq27220

---------

Co-authored-by: hedger <hedger@users.noreply.github.com>
2024-10-06 22:36:05 +04:00

77 lines
3.1 KiB
C

#pragma once
#define BQ27220_ADDRESS (0xAAu)
#define BQ27220_I2C_TIMEOUT (50u)
#define CommandControl (0x00u)
#define CommandAtRate (0x02u)
#define CommandAtRateTimeToEmpty (0x04u)
#define CommandTemperature (0x06u)
#define CommandVoltage (0x08u)
#define CommandBatteryStatus (0x0Au)
#define CommandCurrent (0x0Cu)
#define CommandRemainingCapacity (0x10u)
#define CommandFullChargeCapacity (0x12u)
#define CommandAverageCurrent (0x14u)
#define CommandTimeToEmpty (0x16u)
#define CommandTimeToFull (0x18u)
#define CommandStandbyCurrent (0x1Au)
#define CommandStandbyTimeToEmpty (0x1Cu)
#define CommandMaxLoadCurrent (0x1Eu)
#define CommandMaxLoadTimeToEmpty (0x20u)
#define CommandRawCoulombCount (0x22u)
#define CommandAveragePower (0x24u)
#define CommandInternalTemperature (0x28u)
#define CommandCycleCount (0x2Au)
#define CommandStateOfCharge (0x2Cu)
#define CommandStateOfHealth (0x2Eu)
#define CommandChargeVoltage (0x30u)
#define CommandChargeCurrent (0x32u)
#define CommandBTPDischargeSet (0x34u)
#define CommandBTPChargeSet (0x36u)
#define CommandOperationStatus (0x3Au)
#define CommandDesignCapacity (0x3Cu)
#define CommandSelectSubclass (0x3Eu)
#define CommandMACData (0x40u)
#define CommandMACDataSum (0x60u)
#define CommandMACDataLen (0x61u)
#define CommandAnalogCount (0x79u)
#define CommandRawCurrent (0x7Au)
#define CommandRawVoltage (0x7Cu)
#define CommandRawIntTemp (0x7Eu)
#define Control_CONTROL_STATUS (0x0000u)
#define Control_DEVICE_NUMBER (0x0001u)
#define Control_FW_VERSION (0x0002u)
#define Control_HW_VERSION (0x0003u)
#define Control_BOARD_OFFSET (0x0009u)
#define Control_CC_OFFSET (0x000Au)
#define Control_CC_OFFSET_SAVE (0x000Bu)
#define Control_OCV_CMD (0x000Cu)
#define Control_BAT_INSERT (0x000Du)
#define Control_BAT_REMOVE (0x000Eu)
#define Control_SET_SNOOZE (0x0013u)
#define Control_CLEAR_SNOOZE (0x0014u)
#define Control_SET_PROFILE_1 (0x0015u)
#define Control_SET_PROFILE_2 (0x0016u)
#define Control_SET_PROFILE_3 (0x0017u)
#define Control_SET_PROFILE_4 (0x0018u)
#define Control_SET_PROFILE_5 (0x0019u)
#define Control_SET_PROFILE_6 (0x001Au)
#define Control_CAL_TOGGLE (0x002Du)
#define Control_SEALED (0x0030u)
#define Control_RESET (0x0041u)
#define Control_OERATION_STATUS (0x0054u)
#define Control_GAUGING_STATUS (0x0056u)
#define Control_EXIT_CAL (0x0080u)
#define Control_ENTER_CAL (0x0081u)
#define Control_ENTER_CFG_UPDATE (0x0090u)
#define Control_EXIT_CFG_UPDATE_REINIT (0x0091u)
#define Control_EXIT_CFG_UPDATE (0x0092u)
#define Control_RETURN_TO_ROM (0x0F00u)
#define UnsealKey1 (0x0414u)
#define UnsealKey2 (0x3672u)
#define FullAccessKey (0xffffu)