Skip to content

Commit b797603

Browse files
committed
Format Code
1 parent ae56708 commit b797603

File tree

4 files changed

+36
-29
lines changed

4 files changed

+36
-29
lines changed

src/AXP2101.cpp

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,6 @@ void write1Byte(uint8_t dev_addr, uint8_t addr, uint8_t data) {
258258
Wire1.endTransmission();
259259
}
260260

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-
269261
static constexpr uint8_t AW9523_REG_CONFIG0 = 0x04;
270262
static constexpr uint8_t AW9523_REG_CONFIG1 = 0x05;
271263
static constexpr uint8_t AW9523_REG_GCR = 0x11;
@@ -275,7 +267,7 @@ static constexpr uint8_t AW9523_REG_LEDMODE1 = 0x13;
275267
void AXP2101::coreS3_init() {
276268
write1Byte(0x69, 0b00110101); // AXP CHG_LED
277269
// 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
279271
write1Byte(0x95, 0b00011100); // AXP ALDO4 voltage / SD card / 3.3 V
280272

281273
write1Byte(AW9523_ADDR, 0x02, 0b00000101); // P0
@@ -303,31 +295,37 @@ void AXP2101::coreS3_AW9523_init() {
303295
write1Byte(0x58, 0x02, 0b00000100);
304296
}
305297

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;
310304
write1Byte(AW9523_ADDR, 0x03, value);
311305
}
312306

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;
317313
write1Byte(AW9523_ADDR, 0x02, value);
318314
}
319315

320-
void AXP2101::set_BOOST_BUS_OUT_EN(bool state) {
321-
set_BOOST_EN(state);
316+
void AXP2101::setBoostBusOutEn(bool state) {
317+
setBoostEn(state);
322318
// 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);
325321
}
326322

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;
331329
write1Byte(AW9523_ADDR, 0x02, value);
332330
}
333331

src/AXP2101.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ class AXP2101 : public I2C_PORT {
104104
void coreS3_init(); ////
105105
void coreS3_AW9523_init();
106106

107-
void set_BOOST_EN(bool state);
108-
void set_BUS_OUT_EN(bool state);
109-
void set_BOOST_BUS_OUT_EN(bool state);
110-
void set_USB_OTG_EN(bool state);
107+
void setBoostEn(bool state);
108+
void setBusOutEn(bool state);
109+
void setBoostBusOutEn(bool state);
110+
void setUsbOtgEn(bool state);
111111

112112
void coreS3_VBUS_boost(bool state);
113113
};

src/utility/I2C_PORT.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ uint8_t I2C_PORT::read8Bit(uint8_t subAddress) {
3434
return _wire->read();
3535
}
3636

37+
uint8_t I2C_PORT::read8Bit(uint8_t address, uint8_t subAddress) {
38+
_wire->beginTransmission(address);
39+
_wire->write(subAddress);
40+
_wire->endTransmission();
41+
_wire->requestFrom(address, (size_t)1);
42+
return _wire->read();
43+
}
44+
3745
uint16_t I2C_PORT::read12Bit(uint8_t subAddress) {
3846
uint8_t buff[2];
3947
readBuff(subAddress, 2, buff);

src/utility/I2C_PORT.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class I2C_PORT {
2121
void write1Byte(uint8_t address, uint8_t subAddress, uint8_t data);
2222
void write16Bit(uint8_t subAddress, uint8_t data_1, uint8_t data_2);
2323
uint8_t read8Bit(uint8_t subAddress);
24+
uint8_t read8Bit(uint8_t address, uint8_t subAddress);
2425
uint16_t read12Bit(uint8_t subAddress);
2526
uint16_t read13Bit(uint8_t subAddress);
2627
uint16_t read16Bit(uint8_t subAddress);

0 commit comments

Comments
 (0)