ESPHome  2024.10.2
pcf8563.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace pcf8563 {
9 
11  public:
12  void setup() override;
13  void update() override;
14  void dump_config() override;
15  float get_setup_priority() const override;
16  void read_time();
17  void write_time();
18 
19  protected:
20  bool read_rtc_();
21  bool write_rtc_();
22  union PCF8563Reg {
23  struct {
24  // Control_1 register
25  bool : 3;
26  bool power_on_reset : 1;
27  bool : 1;
28  bool stop : 1;
29  bool : 1;
30  bool ext_test : 1;
31 
32  // Control_2 register
33  bool time_int : 1;
34  bool alarm_int : 1;
35  bool timer_flag : 1;
36  bool alarm_flag : 1;
38  bool : 3;
39 
40  // Seconds register
41  uint8_t second : 4;
42  uint8_t second_10 : 3;
43  bool clock_int : 1;
44 
45  // Minutes register
46  uint8_t minute : 4;
47  uint8_t minute_10 : 3;
48  uint8_t : 1;
49 
50  // Hours register
51  uint8_t hour : 4;
52  uint8_t hour_10 : 2;
53  uint8_t : 2;
54 
55  // Days register
56  uint8_t day : 4;
57  uint8_t day_10 : 2;
58  uint8_t : 2;
59 
60  // Weekdays register
61  uint8_t weekday : 3;
62  uint8_t unused_3 : 5;
63 
64  // Months register
65  uint8_t month : 4;
66  uint8_t month_10 : 1;
67  uint8_t : 2;
68  uint8_t century : 1;
69 
70  // Years register
71  uint8_t year : 4;
72  uint8_t year_10 : 4;
73 
74  // Minute Alarm register
75  uint8_t minute_alarm : 4;
76  uint8_t minute_alarm_10 : 3;
78 
79  // Hour Alarm register
80  uint8_t hour_alarm : 4;
81  uint8_t hour_alarm_10 : 2;
82  uint8_t : 1;
84 
85  // Day Alarm register
86  uint8_t day_alarm : 4;
87  uint8_t day_alarm_10 : 2;
88  uint8_t : 1;
90 
91  // Weekday Alarm register
92  uint8_t weekday_alarm : 3;
93  uint8_t : 4;
95 
96  // CLKout control register
97  uint8_t frequency_output : 2;
98  uint8_t : 5;
99  uint8_t clkout_enabled : 1;
100 
101  // Timer control register
103  uint8_t : 5;
104  uint8_t timer_enabled : 1;
105 
106  // Timer register
107  uint8_t countdown_period : 8;
108 
109  } reg;
110  mutable uint8_t raw[sizeof(reg)];
111  } pcf8563_;
112 };
113 
114 template<typename... Ts> class WriteAction : public Action<Ts...>, public Parented<PCF8563Component> {
115  public:
116  void play(Ts... x) override { this->parent_->write_time(); }
117 };
118 
119 template<typename... Ts> class ReadAction : public Action<Ts...>, public Parented<PCF8563Component> {
120  public:
121  void play(Ts... x) override { this->parent_->read_time(); }
122 };
123 } // namespace pcf8563
124 } // namespace esphome
struct esphome::pcf8563::PCF8563Component::PCF8563Reg::@127 reg
The RealTimeClock class exposes common timekeeping functions via the device&#39;s local real-time clock...
uint16_t x
Definition: tt21100.cpp:17
void play(Ts... x) override
Definition: pcf8563.h:121
union esphome::pcf8563::PCF8563Component::PCF8563Reg pcf8563_
float get_setup_priority() const override
Definition: pcf8563.cpp:30
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void play(Ts... x) override
Definition: pcf8563.h:116
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133
Helper class to easily give an object a parent of type T.
Definition: helpers.h:521