SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
AXP192Regs.hpp
Go to the documentation of this file.
1
41#pragma once
42#include <stdint.h>
43
48 struct bmu {
49 static constexpr uint8_t STATUS = 0x00;
50 static constexpr uint8_t MODE_CHGSTATUS = 0x01;
51 static constexpr uint8_t OTG_STATUS = 0x02;
52 static constexpr uint8_t IC_TYPE = 0x03;
53 static constexpr uint8_t DATA_BUFFER1 = 0x06;
54 static constexpr uint8_t DATA_BUFFER2 = 0x07;
55 static constexpr uint8_t DATA_BUFFER3 = 0x08;
56 static constexpr uint8_t DATA_BUFFER4 = 0x09;
57 };
58
62 struct pwr {
63 static constexpr uint8_t LDO23_DC123_EXT_CTL = 0x12;
64 static constexpr uint8_t DC1_VOLTAGE = 0x26;
65 static constexpr uint8_t DC2OUT_VOL = 0x23;
66 static constexpr uint8_t DC2_DVM = 0x25;
67 static constexpr uint8_t DC3OUT_VOL = 0x27;
68 static constexpr uint8_t LDO23OUT_VOL = 0x28;
69 static constexpr uint8_t LDO3OUT_VOL = 0x29;
70 static constexpr uint8_t DCDC_MODESET = 0x80;
71 };
72
76 struct pmu {
77 static constexpr uint8_t IPS_SET = 0x30;
78 static constexpr uint8_t VOFF_SET = 0x31;
79 static constexpr uint8_t OFF_CTL = 0x32;
80 static constexpr uint8_t POK_SET = 0x36;
81
82 // REG30H[1:0] current-limit encoding (AXP192)
83 // bit1: limit enable, bit0: 0=500mA, 1=100mA
84 static constexpr uint8_t INPUT_CURR_MASK = 0x03;
85
86 static inline uint8_t encodeInputCurrentLimit(uint32_t mA)
87 {
88 // AXP192 supports: OFF, 100mA, 500mA
89 if (mA >= 500) {
90 return 0x02; // enable + 500mA
91 }
92 if (mA >= 100) {
93 return 0x03; // enable + 100mA
94 }
95 return 0x00; // limit off
96 }
97
98 static inline uint32_t decodeInputCurrentLimit(uint8_t reg)
99 {
100 uint8_t code = reg & INPUT_CURR_MASK;
101 if ((code & 0x02) == 0) {
102 return 0;
103 }
104 return (code & 0x01) ? 100 : 500;
105 }
106 };
107
111 struct chg {
112 static constexpr uint8_t CHARGE1 = 0x33;
113 static constexpr uint8_t CHARGE2 = 0x34;
114 static constexpr uint8_t BACKUP_CHG = 0x35;
115
116 // Charger constants
117 static constexpr uint16_t CHG_CUR_MIN = 100;
118 static constexpr uint16_t CHG_CUR_MAX = 1320;
119 static constexpr uint16_t CHG_CUR_STEP = 90;
120 };
121
125 struct ac {
126 static constexpr uint8_t ACIN_VOL_H8 = 0x56;
127 static constexpr uint8_t ACIN_VOL_L4 = 0x57;
128 static constexpr uint8_t ACIN_CUR_H8 = 0x58;
129 static constexpr uint8_t ACIN_CUR_L4 = 0x59;
130 };
131
135 struct adc {
136 static constexpr uint8_t VBUS_VOL_H8 = 0x5A;
137 static constexpr uint8_t VBUS_VOL_L4 = 0x5B;
138 static constexpr uint8_t VBUS_CUR_H8 = 0x5C;
139 static constexpr uint8_t VBUS_CUR_L4 = 0x5D;
140 static constexpr uint8_t INTERNAL_TEMP_H8 = 0x5E;
141 static constexpr uint8_t INTERNAL_TEMP_L4 = 0x5F;
142 static constexpr uint8_t TS_IN_H8 = 0x62;
143 static constexpr uint8_t TS_IN_L4 = 0x63;
144 static constexpr uint8_t GPIO0_ADC_H8 = 0x64;
145 static constexpr uint8_t GPIO0_ADC_L4 = 0x65;
146 static constexpr uint8_t GPIO1_ADC_H8 = 0x66;
147 static constexpr uint8_t GPIO1_ADC_L4 = 0x67;
148 static constexpr uint8_t GPIO2_ADC_H8 = 0x68;
149 static constexpr uint8_t GPIO2_ADC_L4 = 0x69;
150 static constexpr uint8_t GPIO3_ADC_H8 = 0x6A;
151 static constexpr uint8_t GPIO3_ADC_L4 = 0x6B;
152 static constexpr uint8_t BAT_AVERVOL_H8 = 0x78;
153 static constexpr uint8_t BAT_AVERVOL_L4 = 0x79;
154 static constexpr uint8_t BAT_AVERCHGCUR_H8 = 0x7A;
155 static constexpr uint8_t BAT_AVERCHGCUR_L5 = 0x7B;
156 static constexpr uint8_t BAT_AVERDISCHGCUR_H8 = 0x7C;
157 static constexpr uint8_t BAT_AVERDISCHGCUR_L5 = 0x7D;
158 static constexpr uint8_t APS_AVERVOL_H8 = 0x7E;
159 static constexpr uint8_t APS_AVERVOL_L4 = 0x7F;
160 static constexpr uint8_t ADC_EN1 = 0x82;
161 static constexpr uint8_t ADC_EN2 = 0x83;
162 static constexpr uint8_t ADC_SPEED = 0x84;
163 static constexpr uint8_t ADC_INPUTRANGE = 0x85;
164 };
165
169 struct irq {
170 static constexpr uint8_t ENABLE1 = 0x40;
171 static constexpr uint8_t ENABLE2 = 0x41;
172 static constexpr uint8_t ENABLE3 = 0x42;
173 static constexpr uint8_t ENABLE4 = 0x43;
174 static constexpr uint8_t STATUS1 = 0x44;
175 static constexpr uint8_t STATUS2 = 0x45;
176 static constexpr uint8_t STATUS3 = 0x46;
177 static constexpr uint8_t STATUS4 = 0x47;
178 static constexpr uint8_t ENABLE5 = 0x4A;
179 static constexpr uint8_t STATUS5 = 0x4D;
180 };
181
185 struct gpio {
186 static constexpr uint8_t GPIO0_CTL = 0x90;
187 static constexpr uint8_t GPIO0_VOL = 0x91;
188 static constexpr uint8_t GPIO1_CTL = 0x92;
189 static constexpr uint8_t GPIO2_CTL = 0x93;
190 static constexpr uint8_t GPIO012_SIGNAL = 0x94;
191 static constexpr uint8_t GPIO34_CTL = 0x95;
192 static constexpr uint8_t GPIO34_SIGNAL = 0x96;
193 static constexpr uint8_t GPIO012_PULLDOWN = 0x97;
194 static constexpr uint8_t PWM1_FREQ = 0x98;
195 static constexpr uint8_t PWM1_DUTY1 = 0x99;
196 static constexpr uint8_t PWM1_DUTY2 = 0x9A;
197 static constexpr uint8_t PWM2_FREQ = 0x9B;
198 static constexpr uint8_t PWM2_DUTY1 = 0x9C;
199 static constexpr uint8_t PWM2_DUTY2 = 0x9D;
200 static constexpr uint8_t GPIO5_CTL = 0x9E;
201 };
202
206 struct timer {
207 static constexpr uint8_t TIMER_CTL = 0x8A;
208 };
209
217 struct factory {
219 static constexpr float ACIN_VOLTAGE_STEP = 1.7f;
221 static constexpr float ACIN_CURRENT_STEP = 0.625f;
223 static constexpr float TS_VOLTAGE_STEP = 0.8f;
225 static constexpr float VBUS_VOLTAGE_STEP = 1.7f;
227 static constexpr float VBUS_CURRENT_STEP = 0.375f;
229 static constexpr float BAT_VOLTAGE_STEP = 1.1f;
231 static constexpr float BAT_CHARGE_CUR_STEP = 0.5f;
233 static constexpr float BAT_DISCHARGE_CUR_STEP = 0.5f;
235 static constexpr float APS_VOLTAGE_STEP = 1.4f;
237 static constexpr float INTERNAL_TEMP_STEP = 0.1f;
239 static constexpr float INTERNAL_TEMP_OFFSET = 144.7f;
241 static constexpr float FACTORY_GPIO_VOLTAGE = 0.5f;
242 };
243
244 static constexpr uint8_t CHIP_ID = 0x03;
245};
AC input measurement registers.
static constexpr uint8_t ACIN_VOL_L4
static constexpr uint8_t ACIN_CUR_L4
static constexpr uint8_t ACIN_CUR_H8
static constexpr uint8_t ACIN_VOL_H8
ADC measurement and control registers.
static constexpr uint8_t BAT_AVERCHGCUR_L5
static constexpr uint8_t GPIO2_ADC_H8
static constexpr uint8_t APS_AVERVOL_H8
static constexpr uint8_t BAT_AVERDISCHGCUR_L5
static constexpr uint8_t INTERNAL_TEMP_H8
static constexpr uint8_t VBUS_VOL_L4
static constexpr uint8_t TS_IN_H8
static constexpr uint8_t BAT_AVERCHGCUR_H8
static constexpr uint8_t GPIO0_ADC_L4
static constexpr uint8_t GPIO1_ADC_L4
static constexpr uint8_t ADC_EN2
static constexpr uint8_t TS_IN_L4
static constexpr uint8_t BAT_AVERDISCHGCUR_H8
static constexpr uint8_t ADC_SPEED
static constexpr uint8_t GPIO3_ADC_L4
static constexpr uint8_t ADC_INPUTRANGE
static constexpr uint8_t VBUS_CUR_L4
static constexpr uint8_t GPIO2_ADC_L4
static constexpr uint8_t GPIO3_ADC_H8
static constexpr uint8_t VBUS_CUR_H8
static constexpr uint8_t GPIO1_ADC_H8
static constexpr uint8_t ADC_EN1
static constexpr uint8_t APS_AVERVOL_L4
static constexpr uint8_t BAT_AVERVOL_L4
static constexpr uint8_t INTERNAL_TEMP_L4
static constexpr uint8_t BAT_AVERVOL_H8
static constexpr uint8_t GPIO0_ADC_H8
static constexpr uint8_t VBUS_VOL_H8
Battery Management Unit (BMU) registers.
static constexpr uint8_t DATA_BUFFER1
static constexpr uint8_t MODE_CHGSTATUS
static constexpr uint8_t DATA_BUFFER4
static constexpr uint8_t DATA_BUFFER3
static constexpr uint8_t OTG_STATUS
static constexpr uint8_t STATUS
static constexpr uint8_t DATA_BUFFER2
static constexpr uint8_t IC_TYPE
Charger control registers.
static constexpr uint8_t CHARGE1
static constexpr uint16_t CHG_CUR_MIN
static constexpr uint8_t CHARGE2
static constexpr uint16_t CHG_CUR_STEP
static constexpr uint16_t CHG_CUR_MAX
static constexpr uint8_t BACKUP_CHG
Factory-calibrated ADC conversion step sizes.
static constexpr float INTERNAL_TEMP_OFFSET
Internal temperature offset: 144.7 degC.
static constexpr float ACIN_VOLTAGE_STEP
ACIN voltage/current steps: 1.7 mV/0.625 mA per LSB.
static constexpr float BAT_VOLTAGE_STEP
BAT voltage step: 1.1 mV per LSB.
static constexpr float VBUS_CURRENT_STEP
VBUS current step: 0.375 mA per LSB.
static constexpr float APS_VOLTAGE_STEP
APS voltage step: 1.4 mV per LSB.
static constexpr float INTERNAL_TEMP_STEP
Internal temperature step: 0.1 degC per LSB.
static constexpr float ACIN_CURRENT_STEP
ACIN current step: 0.625 mA per LSB.
static constexpr float BAT_DISCHARGE_CUR_STEP
BAT discharge current step: 0.5 mA per LSB.
static constexpr float BAT_CHARGE_CUR_STEP
BAT charge current step: 0.5 mA per LSB.
static constexpr float VBUS_VOLTAGE_STEP
VBUS voltage step: 1.7 mV per LSB.
static constexpr float FACTORY_GPIO_VOLTAGE
GPIO voltage step: 0.5 V per LSB.
static constexpr float TS_VOLTAGE_STEP
TS voltage step: 0.8 mV per LSB.
GPIO control and signal registers.
static constexpr uint8_t GPIO1_CTL
static constexpr uint8_t PWM2_FREQ
static constexpr uint8_t GPIO012_SIGNAL
static constexpr uint8_t GPIO34_SIGNAL
static constexpr uint8_t PWM2_DUTY2
static constexpr uint8_t GPIO2_CTL
static constexpr uint8_t GPIO012_PULLDOWN
static constexpr uint8_t GPIO0_VOL
static constexpr uint8_t GPIO0_CTL
static constexpr uint8_t PWM1_FREQ
static constexpr uint8_t PWM1_DUTY2
static constexpr uint8_t PWM1_DUTY1
static constexpr uint8_t GPIO34_CTL
static constexpr uint8_t GPIO5_CTL
static constexpr uint8_t PWM2_DUTY1
Interrupt control and status registers.
static constexpr uint8_t ENABLE4
static constexpr uint8_t STATUS3
static constexpr uint8_t STATUS2
static constexpr uint8_t STATUS4
static constexpr uint8_t ENABLE1
static constexpr uint8_t STATUS1
static constexpr uint8_t ENABLE5
static constexpr uint8_t ENABLE3
static constexpr uint8_t ENABLE2
static constexpr uint8_t STATUS5
Power Management Unit (PMU) registers.
static constexpr uint8_t INPUT_CURR_MASK
static uint8_t encodeInputCurrentLimit(uint32_t mA)
static constexpr uint8_t POK_SET
static constexpr uint8_t IPS_SET
static uint32_t decodeInputCurrentLimit(uint8_t reg)
static constexpr uint8_t VOFF_SET
static constexpr uint8_t OFF_CTL
Power output channel control registers.
static constexpr uint8_t DC2_DVM
static constexpr uint8_t LDO23_DC123_EXT_CTL
static constexpr uint8_t LDO23OUT_VOL
static constexpr uint8_t DC1_VOLTAGE
static constexpr uint8_t DC3OUT_VOL
static constexpr uint8_t LDO3OUT_VOL
static constexpr uint8_t DC2OUT_VOL
static constexpr uint8_t DCDC_MODESET
Timer control registers.
static constexpr uint8_t TIMER_CTL
static constexpr uint8_t CHIP_ID