diff --git a/src/M5StamPLC.cpp b/src/M5StamPLC.cpp index c76e713..ab78d01 100644 --- a/src/M5StamPLC.cpp +++ b/src/M5StamPLC.cpp @@ -233,6 +233,7 @@ void M5_STAMPLC::rx8130_init() if (!RX8130.begin()) { ESP_LOGE(TAG, "rx8130 init failed!"); } else { + RX8130.initBat(); RX8130.disableIrq(); RX8130.clearIrqFlags(); } diff --git a/src/utils/rx8130/rx8130.cpp b/src/utils/rx8130/rx8130.cpp index 3985803..11a169e 100644 --- a/src/utils/rx8130/rx8130.cpp +++ b/src/utils/rx8130/rx8130.cpp @@ -81,6 +81,14 @@ bool RX8130_Class::begin() return result; } +void RX8130_Class::initBat() +{ + uint8_t data = readRegister8(RX8130_REG_CTRL1); + // Enable backup battery charging + data |= 0b00110000; + writeRegister8(RX8130_REG_CTRL1, data); +} + void RX8130_Class::setTime(struct tm *time) { uint8_t rbuf = 0; diff --git a/src/utils/rx8130/rx8130.h b/src/utils/rx8130/rx8130.h index 5a4ec02..f23bd8d 100644 --- a/src/utils/rx8130/rx8130.h +++ b/src/utils/rx8130/rx8130.h @@ -18,6 +18,7 @@ class RX8130_Class : public m5::I2C_Device { bool begin(); + void initBat(); void setTime(struct tm *time); void getTime(struct tm *time); void clearIrqFlags();