Loading...
Searching...
No Matches
bq25896_reg.h
1#pragma once
2
3#include <stdbool.h>
4#include <stdint.h>
5
6#if defined(BITS_BIG_ENDIAN) && BITS_BIG_ENDIAN == 1
7#error Bit structures defined in this file are not portable to BE
8#endif
9
10#define BQ25896_ADDRESS 0xD6
11#define BQ25896_I2C_TIMEOUT 50
12
13#define IILIM_1600 (1 << 5)
14#define IILIM_800 (1 << 4)
15#define IILIM_400 (1 << 3)
16#define IILIM_200 (1 << 2)
17#define IILIM_100 (1 << 1)
18#define IILIM_50 (1 << 0)
19
20typedef struct {
21 uint8_t IINLIM : 6; // Input Current Limit, mA, offset: +100mA
22 bool EN_ILIM : 1; // Enable ILIM Pin
23 bool EN_HIZ : 1; // Enable HIZ Mode
24} REG00;
25
26#define VINDPM_OS_1600 (1 << 4)
27#define VINDPM_OS_800 (1 << 3)
28#define VINDPM_OS_400 (1 << 2)
29#define VINDPM_OS_200 (1 << 1)
30#define VINDPM_OS_100 (1 << 0)
31
32typedef enum {
33 Bhot34 = 0b00, // – VBHOT1 Threshold (34.75%) (default)
34 Bhot37 = 0b01, // – VBHOT0 Threshold (Typ. 37.75%)
35 Bhot31 = 0b10, // – VBHOT2 Threshold (Typ. 31.25%)
36 BhotDisable = 0b11, // – Disable boost mode thermal protection
37} Bhot;
38
39typedef struct {
40 uint8_t VINDPM_OS : 5; // Input Voltage Limit Offset, mV
41 bool BCOLD : 1; // Boost Mode Cold Temperature Monitor Threshold
42 Bhot BHOT : 2; // Boost Mode Hot Temperature Monitor Threshold
43} REG01;
44
45typedef struct {
46 bool AUTO_DPDM_EN : 1; // Automatic Input Detection Enable
47 bool FORCE_DPDM : 1; // Force Input Detection
48 uint8_t RES : 2; // Reserved
49 bool ICO_EN : 1; // Input Current Optimizer (ICO) Enable
50 bool BOOST_FREQ : 1; // Boost Mode Frequency Selection
51 bool CONV_RATE : 1; // ADC Conversion Rate Selection
52 bool CONV_START : 1; // ADC Conversion Start Control
53} REG02;
54
55#define SYS_MIN_400 (1 << 2)
56#define SYS_MIN_200 (1 << 1)
57#define SYS_MIN_100 (1 << 0)
58
59typedef struct {
60 bool MIN_VBAT_SEL : 1; // Minimum Battery Voltage (falling) to exit boost mode
61 uint8_t SYS_MIN : 3; // Minimum System Voltage Limit, mV, offset: +3000mV
62 bool CHG_CONFIG : 1; // Charge Enable Configuration
63 bool OTG_CONFIG : 1; // Boost (OTG) Mode Configuration
64 bool WD_RST : 1; // I2C Watchdog Timer Reset
65 bool BAT_LOADEN : 1; // Battery Load (IBATLOAD) Enable
66} REG03;
67
68#define ICHG_4096 (1 << 6)
69#define ICHG_2048 (1 << 5)
70#define ICHG_1024 (1 << 4)
71#define ICHG_512 (1 << 3)
72#define ICHG_256 (1 << 2)
73#define ICHG_128 (1 << 1)
74#define ICHG_64 (1 << 0)
75
76typedef struct {
77 uint8_t ICHG : 7; // Fast Charge Current Limit, mA
78 bool EN_PUMPX : 1; // Current pulse control Enable
79} REG04;
80
81#define IPRETERM_512 (1 << 3)
82#define IPRETERM_256 (1 << 2)
83#define IPRETERM_128 (1 << 1)
84#define IPRETERM_64 (1 << 0)
85
86typedef struct {
87 uint8_t ITERM : 4; // Termination Current Limit, offset: +64mA
88 uint8_t IPRECHG : 4; // Precharge Current Limit, offset: +64mA
89} REG05;
90
91#define VREG_512 (1 << 5)
92#define VREG_256 (1 << 4)
93#define VREG_128 (1 << 3)
94#define VREG_64 (1 << 2)
95#define VREG_32 (1 << 1)
96#define VREG_16 (1 << 0)
97
98typedef struct {
99 bool VRECHG : 1; // Battery Recharge Threshold Offset
100 bool BATLOWV : 1; // Battery Precharge to Fast Charge Threshold
101 uint8_t VREG : 6; // Charge Voltage Limit, offset: +3840mV
102} REG06;
103
104typedef enum {
105 WatchdogDisable = 0b00,
106 Watchdog40 = 0b01,
107 Watchdog80 = 0b10,
108 Watchdog160 = 0b11,
109} Watchdog;
110
111typedef enum {
112 ChgTimer5 = 0b00,
113 ChgTimer8 = 0b01,
114 ChgTimer12 = 0b10,
115 ChgTimer20 = 0b11,
116} ChgTimer;
117
118typedef struct {
119 bool JEITA_ISET : 1; // JEITA Low Temperature Current Setting
120 ChgTimer CHG_TIMER : 2; // Fast Charge Timer Setting
121 bool EN_TIMER : 1; // Charging Safety Timer Enable
122 Watchdog WATCHDOG : 2; // I2C Watchdog Timer Setting
123 bool STAT_DIS : 1; // STAT Pin Disable
124 bool EN_TERM : 1; // Charging Termination Enable
125} REG07;
126
127#define BAT_COMP_80 (1 << 2)
128#define BAT_COMP_40 (1 << 1)
129#define BAT_COMP_20 (1 << 0)
130
131#define VCLAMP_128 (1 << 2)
132#define VCLAMP_64 (1 << 1)
133#define VCLAMP_32 (1 << 0)
134
135#define TREG_60 (0b00)
136#define TREG_80 (0b01)
137#define TREG_100 (0b10)
138#define TREG_120 (0b11)
139
140typedef struct {
141 uint8_t TREG : 2; // Thermal Regulation Threshold
142 uint8_t VCLAMP : 3; // IR Compensation Voltage Clamp
143 uint8_t BAT_COMP : 3; // IR Compensation Resistor Setting
144} REG08;
145
146typedef struct {
147 bool PUMPX_DN : 1; // Current pulse control voltage down enable
148 bool PUMPX_UP : 1; // Current pulse control voltage up enable
149 bool BATFET_RST_EN : 1; // BATFET full system reset enable
150 bool BATFET_DLY : 1; // BATFET turn off delay control
151 bool JEITA_VSET : 1; // JEITA High Temperature Voltage Setting
152 bool BATFET_DIS : 1; // Force BATFET off to enable ship mode
153 bool TMR2X_EN : 1; // Safety Timer Setting during DPM or Thermal Regulation
154 bool FORCE_ICO : 1; // Force Start Input Current Optimizer
155} REG09;
156
157#define BOOSTV_512 (1 << 3)
158#define BOOSTV_256 (1 << 2)
159#define BOOSTV_128 (1 << 1)
160#define BOOSTV_64 (1 << 0)
161
162typedef enum {
163 BoostLim_500 = 0b000,
164 BoostLim_750 = 0b001,
165 BoostLim_1200 = 0b010,
166 BoostLim_1400 = 0b011,
167 BoostLim_1650 = 0b100,
168 BoostLim_1875 = 0b101,
169 BoostLim_2150 = 0b110,
170 BoostLim_Rsvd = 0b111,
171} BoostLim;
172
173typedef struct {
174 uint8_t BOOST_LIM : 3; // Boost Mode Current Limit
175 bool PFM_OTG_DIS : 1; // PFM mode allowed in boost mode
176 uint8_t BOOSTV : 4; // Boost Mode Voltage Regulation, offset: +4550mV
177} REG0A;
178
179typedef enum {
180 VBusStatNo = 0b000,
181 VBusStatUSB = 0b001,
182 VBusStatExternal = 0b010,
183 VBusStatOTG = 0b111,
184} VBusStat;
185
186typedef enum {
187 ChrgStatNo = 0b00,
188 ChrgStatPre = 0b01,
189 ChrgStatFast = 0b10,
190 ChrgStatDone = 0b11,
191} ChrgStat;
192
193typedef struct {
194 bool VSYS_STAT : 1; // VSYS Regulation Status
195 bool RES : 1; // Reserved: Always reads 1
196 bool PG_STAT : 1; // Power Good Status
197 ChrgStat CHRG_STAT : 2; // Charging Status
198 VBusStat VBUS_STAT : 3; // VBUS Status register
199} REG0B;
200
201typedef enum {
202 ChrgFaultNO = 0b00,
203 ChrgFaultIN = 0b01,
204 ChrgFaultTH = 0b10,
205 ChrgFaultTIM = 0b11,
206} ChrgFault;
207
208typedef enum {
209 NtcFaultNo = 0b000,
210 NtcFaultWarm = 0b010,
211 NtcFaultCool = 0b011,
212 NtcFaultCold = 0b101,
213 NtcFaultHot = 0b110,
214} NtcFault;
215
216typedef struct {
217 NtcFault NTC_FAULT : 3; // NTC Fault Status
218 bool BAT_FAULT : 1; // Battery Fault Status
219 ChrgFault CHRG_FAULT : 2; // Charge Fault Status
220 bool BOOST_FAULT : 1; // Boost Mode Fault Status
221 bool WATCHDOG_FAULT : 1; // Watchdog Fault Status
222} REG0C;
223
224#define VINDPM_6400 (1 << 6)
225#define VINDPM_3200 (1 << 5)
226#define VINDPM_1600 (1 << 4)
227#define VINDPM_800 (1 << 3)
228#define VINDPM_400 (1 << 2)
229#define VINDPM_200 (1 << 1)
230#define VINDPM_100 (1 << 0)
231
232typedef struct {
233 uint8_t VINDPM : 7; // Absolute VINDPM Threshold, offset: +2600mV
234 bool FORCE_VINDPM : 1; // VINDPM Threshold Setting Method
235} REG0D;
236
237typedef struct {
238 uint8_t BATV : 7; // ADC conversion of Battery Voltage (VBAT), offset: +2304mV
239 bool THERM_STAT : 1; // Thermal Regulation Status
240} REG0E;
241
242typedef struct {
243 uint8_t SYSV : 7; // ADDC conversion of System Voltage (VSYS), offset: +2304mV
244 uint8_t RES : 1; // Reserved: Always reads 0
245} REG0F;
246
247typedef struct {
248 uint8_t TSPCT : 7; // ADC conversion of TS Voltage (TS) as percentage of REGN, offset: +21%
249 uint8_t RES : 1; // Reserved: Always reads 0
250} REG10;
251
252typedef struct {
253 uint8_t VBUSV : 7; // ADC conversion of VBUS voltage (VBUS), offset: +2600mV
254 bool VBUS_GD : 1; // VBUS Good Status
255} REG11;
256
257typedef struct {
258 uint8_t ICHGR : 7; // ADC conversion of Charge Current (IBAT) when VBAT > VBATSHORT
259 uint8_t RES : 1; // Reserved: Always reads 0
260} REG12;
261
262typedef struct {
263 uint8_t
264 IDPM_LIM : 6; // Input Current Limit in effect while Input Current Optimizer (ICO) is enabled, offset: 100mA (default)
265 bool IDPM_STAT : 1; // IINDPM Status
266 bool VDPM_STAT : 1; // VINDPM Status
267} REG13;
268
269typedef struct {
270 uint8_t DEV_REV : 2; // Device Revision
271 bool TS_PROFILE : 1; // Temperature Profile
272 uint8_t PN : 3; // Device Configuration
273 bool ICO_OPTIMIZED : 1; // Input Current Optimizer (ICO) Status
274 bool REG_RST : 1; // Register Reset
275} REG14;
Definition bq25896_reg.h:20
Definition bq25896_reg.h:39
Definition bq25896_reg.h:45
Definition bq25896_reg.h:59
Definition bq25896_reg.h:76
Definition bq25896_reg.h:86
Definition bq25896_reg.h:98
Definition bq25896_reg.h:118
Definition bq25896_reg.h:140
Definition bq25896_reg.h:146
Definition bq25896_reg.h:173
Definition bq25896_reg.h:193
Definition bq25896_reg.h:216
Definition bq25896_reg.h:232
Definition bq25896_reg.h:237
Definition bq25896_reg.h:242
Definition bq25896_reg.h:247
Definition bq25896_reg.h:252
Definition bq25896_reg.h:257
Definition bq25896_reg.h:262
Definition bq25896_reg.h:269