-
Notifications
You must be signed in to change notification settings - Fork 81
Description
Hello,
m5stack tough
My first goal was to be able to write to rtc time. but the init of i2c was always faulty for fail.
After several tries to initiate an i2C on the core board using either micropython orC/C++ with m5 unified libraries with no luck,
I decide to initiate the i2c channel with esp32 own library, but use m5. librarie to get/set time to rtc and it worked flawless.
From what I saw in your sources the m5 i2c lies under src/lgfx/v1/platforms/esp32/Bus_I2C.cpp ( why not in core ) and seems to have wrong implementation of the i2c intialization.
After using this code I was able to connect to all devices on i2c bus like the internal bm8563 and write successfully rtc time which remains after reboot.
static std::unique_ptrespp::I2c i2c;
static std::unique_ptrespp::Bm8563 bm8563;
bool init() {
i2c = std::make_uniqueespp::I2c(espp::I2c::Config{
.port = I2C_NUM_0,
.sda_io_num = (gpio_num_t)21,
.scl_io_num = (gpio_num_t)22,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
});
Unit connection:
bm8563 = std::make_uniqueespp::Bm8563(espp::Bm8563::Config{
.write = std::bind_front(&espp::I2c::write, i2c.get()),
.write_then_read = std::bind_front(&espp::I2c::write_read, i2c.get()),
});