@@ -258,14 +258,6 @@ 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
-
269
261
static constexpr uint8_t AW9523_REG_CONFIG0 = 0x04 ;
270
262
static constexpr uint8_t AW9523_REG_CONFIG1 = 0x05 ;
271
263
static constexpr uint8_t AW9523_REG_GCR = 0x11 ;
@@ -275,7 +267,7 @@ static constexpr uint8_t AW9523_REG_LEDMODE1 = 0x13;
275
267
void AXP2101::coreS3_init () {
276
268
write1Byte (0x69 , 0b00110101 ); // AXP CHG_LED
277
269
// write1Byte(0x97, (0b11110 - 2));
278
- write1Byte (0x90 , 0xBF ); // AXP ALDO~4,BLDO0~2,DIDO1 Enable
270
+ write1Byte (0x90 , 0xBF ); // AXP ALDO~4,BLDO0~2,DIDO1 Enable
279
271
write1Byte (0x95 , 0b00011100 ); // AXP ALDO4 voltage / SD card / 3.3 V
280
272
281
273
write1Byte (AW9523_ADDR, 0x02 , 0b00000101 ); // P0
@@ -303,31 +295,37 @@ void AXP2101::coreS3_AW9523_init() {
303
295
write1Byte (0x58 , 0x02 , 0b00000100 );
304
296
}
305
297
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 ;
298
+ void AXP2101::setBoostEn (bool state) {
299
+ uint8_t value = read8Bit (AW9523_ADDR, 0x03 );
300
+ if (state == true )
301
+ value |= 0b10000000 ;
302
+ else
303
+ value &= ~0b10000000 ;
310
304
write1Byte (AW9523_ADDR, 0x03 , value);
311
305
}
312
306
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 ;
307
+ void AXP2101::setBusOutEn (bool state) {
308
+ uint8_t value = read8Bit (AW9523_ADDR, 0x02 );
309
+ if (state == true )
310
+ value |= 0b00000010 ;
311
+ else
312
+ value &= ~0b00000010 ;
317
313
write1Byte (AW9523_ADDR, 0x02 , value);
318
314
}
319
315
320
- void AXP2101::set_BOOST_BUS_OUT_EN (bool state) {
321
- set_BOOST_EN (state);
316
+ void AXP2101::setBoostBusOutEn (bool state) {
317
+ setBoostEn (state);
322
318
// 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);
319
+ if (state == false ) delay (250 );
320
+ setBusOutEn (state);
325
321
}
326
322
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 ;
323
+ void AXP2101::setUsbOtgEn (bool state) {
324
+ uint8_t value = read8Bit (AW9523_ADDR, 0x02 );
325
+ if (state == true )
326
+ value |= 0b00100000 ;
327
+ else
328
+ value &= ~0b00100000 ;
331
329
write1Byte (AW9523_ADDR, 0x02 , value);
332
330
}
333
331
0 commit comments