1 /* 2 * Copyright (c) 2023, ithinx GmbH 3 * Copyright (c) 2023, Tonies GmbH 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #ifndef ZEPHYR_DRIVERS_FUELGAUGE_BQ27Z746_GAUGE_H_ 9 #define ZEPHYR_DRIVERS_FUELGAUGE_BQ27Z746_GAUGE_H_ 10 11 #include <zephyr/drivers/i2c.h> 12 13 /* Registers */ 14 #define BQ27Z746_MANUFACTURERACCESS 0x00 /* R/W */ 15 #define BQ27Z746_ATRATE 0x02 /* R/W, Unit: mA, Range: -32768..32767 */ 16 #define BQ27Z746_ATRATETIMETOEMPTY 0x04 /* R/O, Unit: minutes, Range: 0..65535 */ 17 #define BQ27Z746_TEMPERATURE 0x06 /* R/O, Unit: 0.1 K, Range: 0..32767 */ 18 #define BQ27Z746_VOLTAGE 0x08 /* R/O, Unit: mV, Range: 0..32767 */ 19 #define BQ27Z746_BATTERYSTATUS 0x0A /* R/O, Unit: status bits */ 20 #define BQ27Z746_CURRENT 0x0C /* R/O, Unit: mA, Range: -32768..32767 */ 21 #define BQ27Z746_REMAININGCAPACITY 0x10 /* R/O, Unit: mAh, Range: 0..32767 */ 22 #define BQ27Z746_FULLCHARGECAPACITY 0x12 /* R/O, Unit: mAh, Range: 0..32767 */ 23 #define BQ27Z746_AVERAGECURRENT 0x14 /* R/O, Unit: mA, Range: -32768..32767 */ 24 #define BQ27Z746_AVERAGETIMETOEMPTY 0x16 /* R/O, Unit: minutes, Range: 0..65535 */ 25 #define BQ27Z746_AVERAGETIMETOFULL 0x18 /* R/O, Unit: minutes, Range: 0..65535 */ 26 #define BQ27Z746_MAXLOADCURRENT 0x1E /* R/O, Unit: mA, Range: 0..65535 */ 27 #define BQ27Z746_MAXLOADTIMETOEMPTY 0x20 /* R/O, Unit: minutes, Range: 0..65535 */ 28 #define BQ27Z746_AVERAGEPOWER 0x22 /* R/O, Unit: mW, Range: -32768..32767 */ 29 #define BQ27Z746_BTPDISCHARGESET 0x24 /* Datasheet unclear */ 30 #define BQ27Z746_BTPCHARGESET 0x26 /* Datasheet unclear */ 31 #define BQ27Z746_INTERNALTEMPERATURE 0x28 /* R/O, Unit: 0.1 K, Range: 0..32767 */ 32 #define BQ27Z746_CYCLECOUNT 0x2A /* R/O, Unit: none, Range: 0..65535 */ 33 #define BQ27Z746_RELATIVESTATEOFCHARGE 0x2C /* R/O, Unit: percent, Range: 0..100 */ 34 #define BQ27Z746_STATEOFHEALTH 0x2E /* R/O, Unit: percent, Range: 0..100 */ 35 #define BQ27Z746_CHARGINGVOLTAGE 0x30 /* R/O, Unit: mV, Range: 0..32767 */ 36 #define BQ27Z746_CHARGINGCURRENT 0x32 /* R/O, Unit: mA, Range: 0..32767 */ 37 #define BQ27Z746_TERMINATEVOLTAGE 0x34 /* R/W, Unit: mC, Range: 0..32767 */ 38 #define BQ27Z746_TIMESTAMPUPPER 0x36 /* R/O, Unit: seconds, Range: 0..65535 */ 39 #define BQ27Z746_TIMESTAMPLOWER 0x38 /* R/O, Unit: seconds, Range: 0..65535 */ 40 #define BQ27Z746_QMAXCYCLES 0x3A /* R/O, Unit: none, Range: 0..65535 */ 41 #define BQ27Z746_DESIGNCAPACITY \ 42 0x3C /* R/O (sealed), R/W (unsealed or factory access), Unit: mAh, Range: 0..32767 */ 43 #define BQ27Z746_ALTMANUFACTURERACCESS 0x3E /* R/W */ 44 #define BQ27Z746_MACDATA 0x40 /* R/O, MAC data */ 45 #define BQ27Z746_MACDATASUM 0x60 /* R/O, Checksum over MAC command and data */ 46 #define BQ27Z746_MACDATALEN 0x61 /* R/O, Length of the MAC data */ 47 #define BQ27Z746_VOLTHISETTHRESHOLD 0x62 /* R/W, Unit: mV, Range: 0..5000 */ 48 #define BQ27Z746_VOLTHICLEARTHRESHOLD 0x64 /* R/W, Unit: mV, Range: 0..5000 */ 49 #define BQ27Z746_VOLTLOSETTHRESHOLD 0x66 /* R/W, Unit: mV, Range: 0..5000 */ 50 #define BQ27Z746_VOLTLOCLEARTHRESHOLD 0x68 /* R/W, Unit: mV, Range: 0..5000 */ 51 #define BQ27Z746_TEMPHISETTHRESHOLD 0x6A /* R/W, Unit: degree celsius, Range: -128..127 */ 52 #define BQ27Z746_TEMPHICLEARTHRESHOLD 0x6B /* R/W, Unit: degree celsius, Range: -128..127 */ 53 #define BQ27Z746_TEMPLOSETTHRESHOLD 0x6C /* R/W, Unit: degree celsius, Range: -128..127 */ 54 #define BQ27Z746_TEMPLOCLEARTHRESHOLD 0x6D /* R/W, Unit: degree celsius, Range: -128..127 */ 55 #define BQ27Z746_INTERRUPTSTATUS 0x6E /* R/O, Unit: status bits */ 56 #define BQ27Z746_SOCDELTASETTHRESHOLD 0x6F /* R/W, Unit: percent, Range: 0..100 */ 57 58 /* MAC commands */ 59 #define BQ27Z746_MAC_CMD_DEVICETYPE 0x0001 60 #define BQ27Z746_MAC_CMD_FIRMWAREVERSION 0x0002 61 #define BQ27Z746_MAC_CMD_HARDWAREVERSION 0x0003 62 #define BQ27Z746_MAC_CMD_IFCHECKSUM 0x0004 63 #define BQ27Z746_MAC_CMD_STATICDFSIGNATURE 0x0005 64 #define BQ27Z746_MAC_CMD_CHEMID 0x0006 65 #define BQ27Z746_MAC_CMD_PREV_MACWRITE 0x0007 66 #define BQ27Z746_MAC_CMD_STATICCHEMDFSIGNATURE 0x0008 67 #define BQ27Z746_MAC_CMD_ALLDFSIGNATURE 0x0009 68 #define BQ27Z746_MAC_CMD_SHELFENABLE 0x000B 69 #define BQ27Z746_MAC_CMD_SHELFDISABLE 0x000C 70 #define BQ27Z746_MAC_CMD_SHUTDOWNMODE 0x0010 71 #define BQ27Z746_MAC_CMD_RESET1 0x0012 72 #define BQ27Z746_MAC_CMD_SHIPMODEENABLE 0x0015 73 #define BQ27Z746_MAC_CMD_SHIPMODEDISABLE 0x0016 74 #define BQ27Z746_MAC_CMD_QMAX_DAY 0x0017 75 #define BQ27Z746_MAC_CMD_CHARGEFETTOGGLE 0x001F 76 #define BQ27Z746_MAC_CMD_DISCHARGEFETTOGGLE 0x0020 77 #define BQ27Z746_MAC_CMD_GAUGING_IT_ENABLE 0x0021 78 #define BQ27Z746_MAC_CMD_FET_ENABLE 0x0022 79 #define BQ27Z746_MAC_CMD_LIFETIMEDATACOLLECTION 0x0023 80 #define BQ27Z746_MAC_CMD_LIFETIMEDATARESET 0x0028 81 #define BQ27Z746_MAC_CMD_CALIBRATIONMODE 0x002D 82 #define BQ27Z746_MAC_CMD_LIFETIMEDATAFLUSH 0x002E 83 #define BQ27Z746_MAC_CMD_LIFETIMEDATASPEEDUPMODE 0x002F 84 #define BQ27Z746_MAC_CMD_SEALDEVICE 0x0030 85 #define BQ27Z746_MAC_CMD_SECURITYKEYS 0x0035 86 #define BQ27Z746_MAC_CMD_RESET2 0x0041 87 #define BQ27Z746_MAC_CMD_TAMBIENTSYNC 0x0047 88 #define BQ27Z746_MAC_CMD_DEVICE_NAME 0x004A 89 #define BQ27Z746_MAC_CMD_DEVICE_CHEM 0x004B 90 #define BQ27Z746_MAC_CMD_MANUFACTURER_NAME 0x004C 91 #define BQ27Z746_MAC_CMD_MANUFACTURE_DATE 0x004D 92 #define BQ27Z746_MAC_CMD_SERIAL_NUMBER 0x004E 93 #define BQ27Z746_MAC_CMD_SAFETYALERT 0x0050 94 #define BQ27Z746_MAC_CMD_SAFETYSTATUS 0x0051 95 #define BQ27Z746_MAC_CMD_OPERATIONSTATUS 0x0054 96 #define BQ27Z746_MAC_CMD_CHARGINGSTATUS 0x0055 97 #define BQ27Z746_MAC_CMD_GAUGINGSTATUS 0x0056 98 #define BQ27Z746_MAC_CMD_MANUFACTURINGSTATUS 0x0057 99 #define BQ27Z746_MAC_CMD_LIFETIMEDATABLOCK1 0x0060 100 #define BQ27Z746_MAC_CMD_LIFETIMEDATABLOCK2 0x0061 101 #define BQ27Z746_MAC_CMD_LIFETIMEDATABLOCK3 0x0062 102 #define BQ27Z746_MAC_CMD_LIFETIMEDATABLOCK4 0x0063 103 #define BQ27Z746_MAC_CMD_LIFETIMEDATABLOCK6 0x0065 104 #define BQ27Z746_MAC_CMD_LIFETIMEDATABLOCK7 0x0065 105 #define BQ27Z746_MAC_CMD_LIFETIMEDATABLOCK8 0x0067 106 #define BQ27Z746_MAC_CMD_LIFETIMEDATABLOCK9 0x0068 107 #define BQ27Z746_MAC_CMD_LIFETIMEDATABLOCK10 0x0069 108 #define BQ27Z746_MAC_CMD_LIFETIMEDATABLOCK11 0x006A 109 #define BQ27Z746_MAC_CMD_LIFETIMEDATABLOCK12 0x006B 110 #define BQ27Z746_MAC_CMD_MANUFACTURERINFO 0x0070 111 #define BQ27Z746_MAC_CMD_DASTATUS1 0x0071 112 #define BQ27Z746_MAC_CMD_DASTATUS2 0x0072 113 #define BQ27Z746_MAC_CMD_ITSTATUS1 0x0073 114 #define BQ27Z746_MAC_CMD_ITSTATUS2 0x0074 115 #define BQ27Z746_MAC_CMD_ITSTATUS3 0x0075 116 #define BQ27Z746_MAC_CMD_FCC_SOH 0x0077 117 #define BQ27Z746_MAC_CMD_FILTERED_CAPACITY 0x0078 118 #define BQ27Z746_MAC_CMD_MANUFACTURERINFOB 0x007A 119 #define BQ27Z746_MAC_CMD_MANUFACTURERINFOC 0x007B 120 #define BQ27Z746_MAC_CMD_FET_CONTROL_OVERRIDE 0x0097 121 #define BQ27Z746_MAC_CMD_SYSTEM_RESET_ENABLE 0x00A3 122 #define BQ27Z746_MAC_CMD_SYSTEM_RESET 0x00A4 123 #define BQ27Z746_MAC_CMD_BATTSENSEOUTPUT 0x00B1 124 #define BQ27Z746_MAC_CMD_RATABLECELL0 0x00E0 125 #define BQ27Z746_MAC_CMD_ROMMODE 0x0F00 126 #define BQ27Z746_MAC_CMD_DATAFLASHACCESS 0x4000 127 #define BQ27Z746_MAC_CMD_SWITCHTOHDQ 0x7C40 128 #define BQ27Z746_MAC_CMD_EXITCALIBRATIONOUTPUT 0xF080 129 #define BQ27Z746_MAC_CMD_OUTPUTCCANDADCFORCALIBRATIO 0xF081 130 #define BQ27Z746_MAC_CMD_OUTPUTTEMPERATURECAL 0xF083 131 #define BQ27Z746_MAC_CMD_PROTECTORCALIBRATION 0xF0A0 132 #define BQ27Z746_MAC_CMD_PROTECTORIMAGE1 0xF0A1 133 #define BQ27Z746_MAC_CMD_PROTECTORIMAGE2 0xF0A2 134 #define BQ27Z746_MAC_CMD_PROTECTORIMAGESAVE 0xF0A3 135 #define BQ27Z746_MAC_CMD_PROTECTORIMAGELOCK 0xF0A4 136 #define BQ27Z746_MAC_CMD_PROTECTORFACTORYCONFIG 0xF0A5 137 138 struct bq27z746_config { 139 struct i2c_dt_spec i2c; 140 }; 141 142 #endif 143