Fix BM8563 I2C bus 2 support

This commit is contained in:
Theo Arends
2026-03-11 16:02:32 +01:00
parent 783d18607f
commit 450819a7ab
5 changed files with 20 additions and 31 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file.
## [15.3.0.2]
### Added
- Environment sensors CCS811, SGP30 and SGP40 second I2C bus support
- Real Time Clocks PCF85063 and PCF85363 second I2C bus support
- Real Time Clocks BM8563, PCF85063 and PCF85363 second I2C bus support
### Breaking Changed
+1 -1
View File
@@ -118,7 +118,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
- Support for Sensirion SCD42 and SCD43 CO2 sensor
- Support for Sensirion STCC4 CO2 sensor
- Environment sensors CCS811, SGP30 and SGP40 second I2C bus support
- Real Time Clocks PCF85063 and PCF85363 second I2C bus support
- Real Time Clocks BM8563, PCF85063 and PCF85363 second I2C bus support
- I2S full duplex, auto rx sample rate [#24469](https://github.com/arendst/Tasmota/issues/24469)
- Sen5x power on delay of 60ms [#24452](https://github.com/arendst/Tasmota/issues/24452)
+3 -1
View File
@@ -4,8 +4,10 @@ BM8563::BM8563()
{
}
void BM8563::begin(void)
void BM8563::begin(TwoWire *wire)
{
myWire = wire;
myWire->begin();
WriteReg(0x00,0x00);
WriteReg(0x01,0x00);
WriteReg(0x0D,0x00);
+3 -2
View File
@@ -24,13 +24,14 @@ typedef struct
class BM8563 {
public:
BM8563();
/*
#if SOC_HP_I2C_NUM > 1
void setBus(uint32_t _bus) { myWire = _bus ? &Wire1 : &Wire; };
#else
void setBus(uint32_t _bus) { myWire = &Wire; };
#endif
void begin(void);
*/
void begin(TwoWire *wire);
void GetBm8563Time(void);
void SetTime(RTC_TimeTypeDef* RTC_TimeStruct);
@@ -162,7 +162,7 @@ void RV3028Detected(void) {
if (!RtcChip.detected && I2cEnabled(XI2C_94)) {
RtcChip.address = RV3028_ADDR;
for (RtcChip.bus = 0; RtcChip.bus < 2; RtcChip.bus++) {
if (!I2cSetDevice(RtcChip.address, RtcChip.bus)) continue;
if (!I2cSetDevice(RtcChip.address, RtcChip.bus)) { continue; }
if (I2cValidRead(RtcChip.address, RV3028_STATUS, 1, RtcChip.bus)) {
uint8_t status = I2cRead8(RtcChip.address, RV3028_STATUS, RtcChip.bus);
if (status & _BV(RV3028_PORF)) {
@@ -303,9 +303,7 @@ void DS3231Detected(void) {
if (!RtcChip.detected && I2cEnabled(XI2C_26)) {
RtcChip.address = DS3231_ADDRESS;
for (RtcChip.bus = 0; RtcChip.bus < 2; RtcChip.bus++) {
if (!I2cSetDevice(RtcChip.address, RtcChip.bus)) {
continue;
}
if (!I2cSetDevice(RtcChip.address, RtcChip.bus)) { continue; }
if (I2cValidRead(RtcChip.address, DS3231_STATUS, 1, RtcChip.bus)) {
RtcChip.detected = 1;
strcpy_P(RtcChip.name, PSTR("DS3231"));
@@ -439,20 +437,15 @@ void Pcf85063Detected(void) {
#define XI2C_59 59 // See I2CDEVICES.md
#include "BM8563.h"
struct {
BM8563 Rtc;
bool rtc_ready = false;
bool ntp_time_ok = false;
} bm8563_driver;
BM8563 Bm8563Rtc;
uint32_t BM8563GetUtc(void) {
RTC_TimeTypeDef RTCtime;
// 1. read has errors ???
bm8563_driver.Rtc.GetTime(&RTCtime);
Bm8563Rtc.GetTime(&RTCtime);
// core2_globs.Rtc.GetTime(&RTCtime);
RTC_DateTypeDef RTCdate;
bm8563_driver.Rtc.GetDate(&RTCdate);
Bm8563Rtc.GetDate(&RTCdate);
TIME_T tm;
tm.second = RTCtime.Seconds;
tm.minute = RTCtime.Minutes;
@@ -471,13 +464,13 @@ void BM8563SetUtc(uint32_t epoch_time) {
RTCtime.Hours = tm.hour;
RTCtime.Minutes = tm.minute;
RTCtime.Seconds = tm.second;
bm8563_driver.Rtc.SetTime(&RTCtime);
Bm8563Rtc.SetTime(&RTCtime);
RTC_DateTypeDef RTCdate;
RTCdate.WeekDay = tm.day_of_week;
RTCdate.Month = tm.month;
RTCdate.Date = tm.day_of_month;
RTCdate.Year = tm.year + 1970;
bm8563_driver.Rtc.SetDate(&RTCdate);
Bm8563Rtc.SetDate(&RTCdate);
}
/*-------------------------------------------------------------------------------------------*\
@@ -486,22 +479,15 @@ void BM8563SetUtc(uint32_t epoch_time) {
void BM8563Detected(void) {
if (!RtcChip.detected && I2cEnabled(XI2C_59)) {
RtcChip.address = BM8563_ADRESS;
if (I2cSetDevice(RtcChip.address, 0)) {
for (RtcChip.bus = 0; RtcChip.bus < 2; RtcChip.bus++) {
if (!I2cSetDevice(RtcChip.address, RtcChip.bus)) { continue; }
Bm8563Rtc.begin(&I2cGetWire(RtcChip.bus));
RtcChip.detected = 1;
}
#ifdef ESP32
else if (I2cSetDevice(RtcChip.address, 1)) {
RtcChip.detected = 1;
RtcChip.bus = 1;
bm8563_driver.Rtc.setBus(1); // switch to bus 1
}
#endif
if (RtcChip.detected) {
bm8563_driver.Rtc.begin();
strcpy_P(RtcChip.name, PSTR("BM8563"));
RtcChip.ReadTime = &BM8563GetUtc;
RtcChip.SetTime = &BM8563SetUtc;
RtcChip.mem_size = -1;
break;
}
}
}
@@ -638,6 +624,7 @@ void Pcf85363Detected(void) {
RtcChip.mem_size = 64;
RtcChip.MemRead = &Pcf8563MemRead;
RtcChip.MemWrite = &Pcf8563MemWrite;
break;
}
}
}
@@ -1002,7 +989,6 @@ void RtcChipDetect(void) {
Rx8025Detected();
#endif // USE_RX8025
if (!RtcChip.detected) { return; }
I2cSetActiveFound(RtcChip.address, RtcChip.name, RtcChip.bus);