Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/m5stack/M5Core2 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinyu-Zhao committed Jan 25, 2022
2 parents e6df726 + b75c495 commit 881d2ae
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/AXP192.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,31 +551,32 @@ void AXP192::SetLCDRSet(bool state)
Write1Byte(reg_addr, data);
}

// Select source for BUS_5V
// 0 : use internal boost
// 1 : powered externally
void AXP192::SetBusPowerMode(uint8_t state)
{
uint8_t data;
if (state == 0)
{
// Set GPIO to 3.3V (LDO OUTPUT mode)
data = Read8bit(0x91);
Write1Byte(0x91, (data & 0X0F) | 0XF0);

Write1Byte(0x91, (data & 0x0F) | 0xF0);
// Set GPIO0 to LDO OUTPUT, pullup N_VBUSEN to disable VBUS supply from BUS_5V
data = Read8bit(0x90);
Write1Byte(0x90, (data & 0XF8) | 0X02); //set GPIO0 to LDO OUTPUT , pullup N_VBUSEN to disable supply from BUS_5V

data = Read8bit(0x91);

data = Read8bit(0x12); //read reg 0x12
Write1Byte(0x12, data | 0x40); //set EXTEN to enable 5v boost
Write1Byte(0x90, (data & 0xF8) | 0x02);
// Set EXTEN to enable 5v boost
data = Read8bit(0x10);
Write1Byte(0x10, data | 0x04);
}
else
{
data = Read8bit(0x12); //read reg 0x10
Write1Byte(0x12, data & 0XBF); //set EXTEN to disable 5v boost

//delay(2000);

// Set EXTEN to disable 5v boost
data = Read8bit(0x10);
Write1Byte(0x10, data & ~0x04);
// Set GPIO0 to float, using enternal pulldown resistor to enable VBUS supply from BUS_5V
data = Read8bit(0x90);
Write1Byte(0x90, (data & 0xF8) | 0X01); //set GPIO0 to float , using enternal pulldown resistor to enable supply from BUS_5VS
Write1Byte(0x90, (data & 0xF8) | 0x07);
}
}

Expand Down

0 comments on commit 881d2ae

Please sign in to comment.