Skip to content

Commit

Permalink
add axp192 v-bus check
Browse files Browse the repository at this point in the history
  • Loading branch information
Gitshaoxiang committed Dec 21, 2021
1 parent 0f35979 commit 2e3f34b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/AXP192.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ AXP192::AXP192()
{
}


// Will be deprecated
void AXP192::begin(mbus_mode_t mode)
{
begin();
}

void AXP192::begin()
{
Wire1.begin(21, 22);
Wire1.setClock(400000);

Expand Down Expand Up @@ -61,8 +67,15 @@ void AXP192::begin(mbus_mode_t mode)
delay(100);
// I2C_WriteByteDataAt(0X15,0XFE,0XFF);

// bus power mode_output
SetBusPowerMode(mode);
// axp: check v-bus status
if(Read8bit(0x00) & 0x08) {
Write1Byte(0x30, Read8bit(0x30) | 0x80);
// if v-bus can use, disable M-Bus 5V output to input
SetBusPowerMode(kMBusModeInput);
}else{
// if not, enable M-Bus 5V output
SetBusPowerMode(kMBusModeOutput);
}
}

void AXP192::Write1Byte(uint8_t Addr, uint8_t Data)
Expand Down
4 changes: 3 additions & 1 deletion src/AXP192.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class AXP192 {
};

AXP192();
void begin(mbus_mode_t mode = kMBusModeOutput);
void begin();
// Will be deprecated
void begin(mbus_mode_t mode);
void ScreenBreath(uint8_t brightness);
bool GetBatState();

Expand Down

0 comments on commit 2e3f34b

Please sign in to comment.