@@ -127,6 +127,24 @@ static bool pmic_init(void) {
127
127
return false;
128
128
}
129
129
130
+ // Reg: 3Ah
131
+ // APS Low battery warning level 1: 3.695V
132
+ write_buf [0 ] = AXP192_APS_LOW_BATT_LEVEL_1 ;
133
+ write_buf [1 ] = AXP192_APS_LOW_BATT_VOLTAGE_3_695V ;
134
+ rc = common_hal_busio_i2c_write (internal_i2c , AXP192_I2C_ADDRESS , write_buf , sizeof (write_buf ));
135
+ if (rc != 0 ) {
136
+ return false;
137
+ }
138
+
139
+ // Reg: 3Bh
140
+ // APS Low battery warning level 2: 3.600V
141
+ write_buf [0 ] = AXP192_APS_LOW_BATT_LEVEL_2 ;
142
+ write_buf [1 ] = AXP192_APS_LOW_BATT_VOLTAGE_3_600V ;
143
+ rc = common_hal_busio_i2c_write (internal_i2c , AXP192_I2C_ADDRESS , write_buf , sizeof (write_buf ));
144
+ if (rc != 0 ) {
145
+ return false;
146
+ }
147
+
130
148
// Reg: 82h
131
149
// ADC all on
132
150
write_buf [0 ] = AXP192_ADC_ENABLE_1 ;
@@ -204,7 +222,7 @@ static bool pmic_init(void) {
204
222
return false;
205
223
}
206
224
207
- // Reg: 28h
225
+ // Reg: 26h
208
226
// DCDC1 (ESP32 VDD): 3.350V
209
227
write_buf [0 ] = AXP192_DCDC1_OUT_VOLTAGE ;
210
228
write_buf [1 ] = AXP192_DCDC1_OUT_VOLTAGE_3_350V ;
@@ -213,6 +231,54 @@ static bool pmic_init(void) {
213
231
return false;
214
232
}
215
233
234
+ // Reg: 40h
235
+ // IRQ enable control register 1
236
+ write_buf [0 ] = AXP192_IRQ_1_ENABLE ;
237
+ write_buf [1 ] = AXP192_IRQ_X_DISABLE_ALL ;
238
+ rc = common_hal_busio_i2c_write (internal_i2c , AXP192_I2C_ADDRESS , write_buf , sizeof (write_buf ));
239
+ if (rc != 0 ) {
240
+ return false;
241
+ }
242
+
243
+ // Reg: 41h
244
+ // IRQ enable control register 2
245
+ write_buf [0 ] = AXP192_IRQ_2_ENABLE ;
246
+ write_buf [1 ] = AXP192_IRQ_X_DISABLE_ALL ;
247
+ rc = common_hal_busio_i2c_write (internal_i2c , AXP192_I2C_ADDRESS , write_buf , sizeof (write_buf ));
248
+ if (rc != 0 ) {
249
+ return false;
250
+ }
251
+
252
+ // Reg: 42h
253
+ // IRQ enable control register 3
254
+ // Enable power on key short and long press interrupt
255
+ write_buf [0 ] = AXP192_IRQ_2_ENABLE ;
256
+ write_buf [1 ] = AXP192_IRQ_3_PEK_SHORT_PRESS |
257
+ AXP192_IRQ_3_PEK_LONG_PRESS ;
258
+ rc = common_hal_busio_i2c_write (internal_i2c , AXP192_I2C_ADDRESS , write_buf , sizeof (write_buf ));
259
+ if (rc != 0 ) {
260
+ return false;
261
+ }
262
+
263
+ // Reg: 43h
264
+ // IRQ enable control register 4
265
+ // Enable power on key short and long press interrupt
266
+ write_buf [0 ] = AXP192_IRQ_2_ENABLE ;
267
+ write_buf [1 ] = AXP192_IRQ_4_LOW_VOLTAGE_WARNING ;
268
+ rc = common_hal_busio_i2c_write (internal_i2c , AXP192_I2C_ADDRESS , write_buf , sizeof (write_buf ));
269
+ if (rc != 0 ) {
270
+ return false;
271
+ }
272
+
273
+ // Reg: 44h
274
+ // IRQ enable control register 5
275
+ write_buf [0 ] = AXP192_IRQ_2_ENABLE ;
276
+ write_buf [1 ] = AXP192_IRQ_X_DISABLE_ALL ;
277
+ rc = common_hal_busio_i2c_write (internal_i2c , AXP192_I2C_ADDRESS , write_buf , sizeof (write_buf ));
278
+ if (rc != 0 ) {
279
+ return false;
280
+ }
281
+
216
282
return true;
217
283
}
218
284
@@ -279,7 +345,17 @@ void board_init(void) {
279
345
}
280
346
281
347
if (!display_init ()) {
282
- mp_printf (& mp_plat_print , "could not initialize ili9342c LCD " );
348
+ mp_printf (& mp_plat_print , "could not initialize the display " );
283
349
return ;
284
350
}
285
351
}
352
+
353
+ bool espressif_board_reset_pin_number (gpio_num_t pin_number ) {
354
+ // Set IR led gpio high to prevent power drain from the led
355
+ if (pin_number == 9 ) {
356
+ gpio_set_direction (pin_number , GPIO_MODE_DEF_OUTPUT );
357
+ gpio_set_level (pin_number , true);
358
+ return true;
359
+ }
360
+ return false;
361
+ }
0 commit comments