Doc update RTCs. No functional change

This commit is contained in:
Theo Arends 2025-12-17 21:28:40 +01:00
parent 3892bc7a1a
commit 5951ea63e4

View File

@ -20,6 +20,9 @@
* #define USE_BM8563 * #define USE_BM8563
* BM8563 at I2C address 0x51 * BM8563 at I2C address 0x51
* Used by M5Stack and IOTTIMER (v3) * Used by M5Stack and IOTTIMER (v3)
* #define USE_PCF85063
* PCF85063 at I2C address 0x51
* Used by Waveshare ESP32-S3-POE-ETH-8DI-8RO
* #define USE_PCF85363 * #define USE_PCF85363
* PCF85363 at I2C address 0x51 * PCF85363 at I2C address 0x51
* Used by Shelly 3EM * Used by Shelly 3EM
@ -50,13 +53,11 @@ struct {
char name[10]; char name[10];
} RtcChip; } RtcChip;
/*********************************************************************************************\ /*********************************************************************************************\
* RV-3028-C7 RTC Controller * RV-3028-C7 RTC Controller
* *
* I2C Address: 0x52 * I2C Address: 0x52
\*********************************************************************************************/ \*********************************************************************************************/
#ifdef USE_RV3028 #ifdef USE_RV3028
#define XI2C_94 94 // See I2CDEVICES.md #define XI2C_94 94 // See I2CDEVICES.md
@ -78,11 +79,9 @@ struct {
// Status register bits // Status register bits
#define RV3028_PORF 0 // Power-on Reset flag (bit 0 in STATUS register) #define RV3028_PORF 0 // Power-on Reset flag (bit 0 in STATUS register)
/*-------------------------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------------------------*\
* Init register to activate BSM from VBACKUP (Direct Switching Mode) * Init register to activate BSM from VBACKUP (Direct Switching Mode)
\*-------------------------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------------------------*/
void RV3028_EnableDSM(void) { void RV3028_EnableDSM(void) {
uint8_t current_eeprom; uint8_t current_eeprom;
@ -116,7 +115,6 @@ uint32_t RV3028ReadTime(void) {
return 0; // Invalid RTC time data return 0; // Invalid RTC time data
} }
TIME_T tm; TIME_T tm;
tm.second = Bcd2Dec(I2cRead8(RtcChip.address, RV3028_SECONDS, RtcChip.bus) & 0x7F); tm.second = Bcd2Dec(I2cRead8(RtcChip.address, RV3028_SECONDS, RtcChip.bus) & 0x7F);
tm.minute = Bcd2Dec(I2cRead8(RtcChip.address, RV3028_MINUTES, RtcChip.bus) & 0x7F); tm.minute = Bcd2Dec(I2cRead8(RtcChip.address, RV3028_MINUTES, RtcChip.bus) & 0x7F);
@ -152,10 +150,8 @@ void RV3028SetTime(uint32_t epoch_time) {
// Enable LSM mode (VBACKUP) // Enable LSM mode (VBACKUP)
RV3028_EnableDSM(); RV3028_EnableDSM();
} }
/*-------------------------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------------------------*\
* Detection * Detection
\*-------------------------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------------------------*/
@ -280,7 +276,6 @@ void D3231ShowSensor(bool json) {
} }
#endif // #ifdef DS3231_ENABLE_TEMP #endif // #ifdef DS3231_ENABLE_TEMP
/*-------------------------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------------------------*\
* Get time as TIME_T and set the DS3231 time to this value * Get time as TIME_T and set the DS3231 time to this value
\*-------------------------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------------------------*/
@ -324,8 +319,6 @@ void DS3231Detected(void) {
} }
#endif // USE_DS3231 #endif // USE_DS3231
/*********************************************************************************************\ /*********************************************************************************************\
* PCF85063 support * PCF85063 support
* *
@ -337,7 +330,6 @@ void DS3231Detected(void) {
#define PCF85063_ADDRESS 0x51 // PCF85063 I2C Address #define PCF85063_ADDRESS 0x51 // PCF85063 I2C Address
#define PCF85063_REG_CTRL1 0x00 #define PCF85063_REG_CTRL1 0x00
#define PCF85063_REG_CTRL2 0x01 #define PCF85063_REG_CTRL2 0x01
#define PCF85063_REG_OFFSET 0x02 #define PCF85063_REG_OFFSET 0x02
@ -349,7 +341,9 @@ void DS3231Detected(void) {
#define PCF85063_REG_MONTHS 0x09 #define PCF85063_REG_MONTHS 0x09
#define PCF85063_REG_YEARS 0x0A #define PCF85063_REG_YEARS 0x0A
/*-------------------------------------------------------------------------------------------*\
* Read time and return the epoch time (second since 1-1-1970 00:00)
\*-------------------------------------------------------------------------------------------*/
uint32_t Pcf85063ReadTime(void) { uint32_t Pcf85063ReadTime(void) {
Wire.beginTransmission(RtcChip.address); Wire.beginTransmission(RtcChip.address);
Wire.write(PCF85063_REG_SECONDS); Wire.write(PCF85063_REG_SECONDS);
@ -376,12 +370,13 @@ uint32_t Pcf85063ReadTime(void) {
return MakeTime(tm); return MakeTime(tm);
} }
/*-------------------------------------------------------------------------------------------*\
* Get time as TIME_T and set time to this value
\*-------------------------------------------------------------------------------------------*/
void Pcf85063SetTime(uint32_t epoch_time) { void Pcf85063SetTime(uint32_t epoch_time) {
TIME_T tm; TIME_T tm;
BreakTime(epoch_time, tm); BreakTime(epoch_time, tm);
uint8_t year = (tm.year -30); uint8_t year = (tm.year -30);
if (year > 99) { year = 99; } if (year > 99) { year = 99; }
@ -428,8 +423,6 @@ void Pcf85063Detected(void) {
} }
#endif // USE_PCF85063 #endif // USE_PCF85063
/*********************************************************************************************\ /*********************************************************************************************\
* BM8563 - Real Time Clock * BM8563 - Real Time Clock
* *