2020 * #define USE_BM8563
2121 * BM8563 at I2C address 0x51
2222 * Used by M5Stack and IOTTIMER (v3)
23+ * #define USE_PCF85063
24+ * PCF85063 at I2C address 0x51
25+ * Used by Waveshare ESP32-S3-POE-ETH-8DI-8RO
2326 * #define USE_PCF85363
2427 * PCF85363 at I2C address 0x51
2528 * Used by Shelly 3EM
@@ -50,13 +53,11 @@ struct {
5053 char name[10 ];
5154} RtcChip;
5255
53-
5456/* ********************************************************************************************\
5557 * RV-3028-C7 RTC Controller
5658 *
5759 * I2C Address: 0x52
5860\*********************************************************************************************/
59-
6061#ifdef USE_RV3028
6162
6263#define XI2C_94 94 // See I2CDEVICES.md
@@ -78,11 +79,9 @@ struct {
7879// Status register bits
7980#define RV3028_PORF 0 // Power-on Reset flag (bit 0 in STATUS register)
8081
81-
8282/* -------------------------------------------------------------------------------------------*\
8383 * Init register to activate BSM from VBACKUP (Direct Switching Mode)
8484\*-------------------------------------------------------------------------------------------*/
85-
8685void RV3028_EnableDSM (void ) {
8786 uint8_t current_eeprom;
8887
@@ -116,7 +115,6 @@ uint32_t RV3028ReadTime(void) {
116115 return 0 ; // Invalid RTC time data
117116 }
118117
119-
120118 TIME_T tm;
121119 tm.second = Bcd2Dec (I2cRead8 (RtcChip.address , RV3028_SECONDS, RtcChip.bus ) & 0x7F );
122120 tm.minute = Bcd2Dec (I2cRead8 (RtcChip.address , RV3028_MINUTES, RtcChip.bus ) & 0x7F );
@@ -152,10 +150,8 @@ void RV3028SetTime(uint32_t epoch_time) {
152150
153151 // Enable LSM mode (VBACKUP)
154152 RV3028_EnableDSM ();
155-
156153}
157154
158-
159155/* -------------------------------------------------------------------------------------------*\
160156 * Detection
161157\*-------------------------------------------------------------------------------------------*/
@@ -280,7 +276,6 @@ void D3231ShowSensor(bool json) {
280276}
281277#endif // #ifdef DS3231_ENABLE_TEMP
282278
283-
284279/* -------------------------------------------------------------------------------------------*\
285280 * Get time as TIME_T and set the DS3231 time to this value
286281\*-------------------------------------------------------------------------------------------*/
@@ -324,8 +319,6 @@ void DS3231Detected(void) {
324319}
325320#endif // USE_DS3231
326321
327-
328-
329322/* ********************************************************************************************\
330323 * PCF85063 support
331324 *
@@ -337,7 +330,6 @@ void DS3231Detected(void) {
337330
338331#define PCF85063_ADDRESS 0x51 // PCF85063 I2C Address
339332
340-
341333#define PCF85063_REG_CTRL1 0x00
342334#define PCF85063_REG_CTRL2 0x01
343335#define PCF85063_REG_OFFSET 0x02
@@ -349,7 +341,9 @@ void DS3231Detected(void) {
349341#define PCF85063_REG_MONTHS 0x09
350342#define PCF85063_REG_YEARS 0x0A
351343
352-
344+ /* -------------------------------------------------------------------------------------------*\
345+ * Read time and return the epoch time (second since 1-1-1970 00:00)
346+ \*-------------------------------------------------------------------------------------------*/
353347uint32_t Pcf85063ReadTime (void ) {
354348 Wire.beginTransmission (RtcChip.address );
355349 Wire.write (PCF85063_REG_SECONDS);
@@ -376,12 +370,13 @@ uint32_t Pcf85063ReadTime(void) {
376370 return MakeTime (tm);
377371}
378372
379-
373+ /* -------------------------------------------------------------------------------------------*\
374+ * Get time as TIME_T and set time to this value
375+ \*-------------------------------------------------------------------------------------------*/
380376void Pcf85063SetTime (uint32_t epoch_time) {
381377 TIME_T tm;
382378 BreakTime (epoch_time, tm);
383379
384-
385380 uint8_t year = (tm.year -30 );
386381 if (year > 99 ) { year = 99 ; }
387382
@@ -428,8 +423,6 @@ void Pcf85063Detected(void) {
428423}
429424#endif // USE_PCF85063
430425
431-
432-
433426/* ********************************************************************************************\
434427 * BM8563 - Real Time Clock
435428 *
0 commit comments