@@ -258,6 +258,14 @@ void write1Byte(uint8_t dev_addr, uint8_t addr, uint8_t data) {
258
258
Wire1.endTransmission ();
259
259
}
260
260
261
+ uint8_t read1Byte (uint8_t dev_addr, uint8_t addr) {
262
+ Wire1.beginTransmission (dev_addr);
263
+ Wire1.write (addr);
264
+ Wire1.endTransmission ();
265
+ Wire1.requestFrom (dev_addr, (size_t )1 );
266
+ return Wire1.read ();
267
+ }
268
+
261
269
static constexpr uint8_t AW9523_REG_CONFIG0 = 0x04 ;
262
270
static constexpr uint8_t AW9523_REG_CONFIG1 = 0x05 ;
263
271
static constexpr uint8_t AW9523_REG_GCR = 0x11 ;
@@ -295,6 +303,34 @@ void AXP2101::coreS3_AW9523_init() {
295
303
write1Byte (0x58 , 0x02 , 0b00000100 );
296
304
}
297
305
306
+ void AXP2101::set_BOOST_EN (bool state) {
307
+ uint8_t value = read1Byte (AW9523_ADDR, 0x03 );
308
+ if (state == true ) value |= 0b10000000 ;
309
+ else value &= ~0b10000000 ;
310
+ write1Byte (AW9523_ADDR, 0x03 , value);
311
+ }
312
+
313
+ void AXP2101::set_BUS_OUT_EN (bool state) {
314
+ uint8_t value = read1Byte (AW9523_ADDR, 0x02 );
315
+ if (state == true ) value |= 0b00000010 ;
316
+ else value &= ~0b00000010 ;
317
+ write1Byte (AW9523_ADDR, 0x02 , value);
318
+ }
319
+
320
+ void AXP2101::set_BOOST_BUS_OUT_EN (bool state) {
321
+ set_BOOST_EN (state);
322
+ // delay is required to prevent reverse current flow from VBUS to BUS_OUT
323
+ if (state == false ) delay (250 );
324
+ set_BUS_OUT_EN (state);
325
+ }
326
+
327
+ void AXP2101::set_USB_OTG_EN (bool state) {
328
+ uint8_t value = read1Byte (AW9523_ADDR, 0x02 );
329
+ if (state == true ) value |= 0b00100000 ;
330
+ else value &= ~0b00100000 ;
331
+ write1Byte (AW9523_ADDR, 0x02 , value);
332
+ }
333
+
298
334
/* *
299
335
* @brief vbus boost state setup
300
336
*
0 commit comments