From ade92bb83009da83bc861808a5ab02824ed736bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sun, 13 Aug 2023 21:16:41 +0200 Subject: [PATCH] Add additional registers for PCF85063A --- esphome/components/pcf85063/pcf85063.h | 52 +++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/esphome/components/pcf85063/pcf85063.h b/esphome/components/pcf85063/pcf85063.h index 1a3fd70..50d8c51 100644 --- a/esphome/components/pcf85063/pcf85063.h +++ b/esphome/components/pcf85063/pcf85063.h @@ -7,6 +7,18 @@ namespace esphome { namespace pcf85063 { +enum PCF85063ATimerInterruptMode_t : bool { + TIMER_INTERRUPT_MODE_FLAG = 0, + TIMER_INTERRUPT_MODE_PULSE = 1, +} + +enum PCF85063ATimerClockFrequency_t : uint8_t { + TIMER_CLOCK_4096HZ = 0, + TIMER_CLOCK_64HZ = 1, + TIMER_CLOCK_SECOND = 2, + TIMER_CLOCK_MINUTE = 3, +} + class PCF85063Component : public time::RealTimeClock, public i2c::I2CDevice { public: void setup() override; @@ -68,7 +80,7 @@ class PCF85063Component : public time::RealTimeClock, public i2c::I2CDevice { // Weekdays register uint8_t weekday : 3; - uint8_t unused_3 : 5; + uint8_t : 5; // Months register uint8_t month : 4; @@ -78,6 +90,44 @@ class PCF85063Component : public time::RealTimeClock, public i2c::I2CDevice { // Years register uint8_t year : 4; uint8_t year_10 : 4; + + // PCF85063A Additional registers + // Second alarm + uint8_t alarm_second : 4; + uint8_t alarm_second_10 : 3; + bool alarm_second_enabled : 1; + + // Minute alarm + uint8_t alarm_minute : 4; + uint8_t alarm_minute_10 : 3; + bool alarm_minute_enabled : 1; + + // Hour alarm + uint8_t alarm_hour : 4; + uint8_t alarm_hour_10 : 2; + uint8_t : 1; + bool alarm_hour_enabled : 1; + + // Day alarm + uint8_t alarm_day : 4; + uint8_t alarm_day_10 : 2; + uint8_t : 1; + bool alarm_day_enabled : 1; + + // Weekday alarm + uint8_t alarm_weekday : 3; + uint8_t : 4; + bool alarm_weekday_enabled : 1; + + // Timer value + uint8_t timer_value : 8; + + // Timer mode + PCF85063ATimerInterruptMode_t timer_interrupt_mode : 1; + bool timer_interrupt_enable : 1; + bool timer_enable : 1; + PCF85063ATimerClockFrequency_t timer_clock_frequency : 2; + uint8_t : 3; } reg; mutable uint8_t raw[sizeof(reg)]; } pcf85063_;