pcf8563-dd 0.3.0

A driver for the PCF8563/BM8563 real-time clock (uses device-driver crate)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
# =============================================================================
# PCF8563/BM8563 Real-Time Clock Device Driver Definition
# =============================================================================
# This file defines the register map and configuration for the PCF8563
# Real-Time Clock IC manufactured by NXP (and BM8563 clone).
#
# Features:
# - Year, month, day, weekday, hours, minutes, seconds
# - Century flag
# - Low backup current (~0.25µA at 3.0V)
# - Programmable clock output (32.768kHz, 1.024kHz, 32Hz, 1Hz)
# - Alarm and timer functions
# - Voltage-low detector
#
# Interface: I2C (up to 400kHz)
# Slave address: 0x51 (7-bit) / 0xA2 write, 0xA3 read (8-bit)
# =============================================================================

config:
  # Address type for all registers (8-bit addressing)
  register_address_type: u8

  # Default byte order - not really relevant for 8-bit registers
  default_byte_order: BE

  # Default bit order - LSB0 (bit 0 is least significant)
  default_bit_order: LSB0

  # Default access patterns
  default_register_access: RW
  default_field_access: RW

  # Enable defmt support for debugging
  defmt_feature: "defmt"

  # Name conversion for register/field names
  name_word_boundaries: ["Underscore", "Hyphen", "LowerUpper", "UpperDigit", "DigitUpper"]

# =============================================================================
# CONTROL AND STATUS REGISTERS
# =============================================================================

ControlStatus1:
  type: register
  address: 0x00
  size_bits: 8
  access: RW
  reset_value: 0x08
  description: |
    Control and status register 1.
    Controls clock operation, test modes, and power-on reset override.
  fields:
    test1:
      base: bool
      start: 7
      description: |
        EXT_CLK test mode.
        - false (0): Normal mode (default)
        - true (1): EXT_CLK test mode - CLKOUT becomes input for external clock
    stop:
      base: bool
      start: 5
      description: |
        RTC clock stop control.
        - false (0): RTC source clock runs
        - true (1): RTC clock stopped, all divider flip-flops reset to 0
                    (CLKOUT at 32.768kHz still available)
    testc:
      base: bool
      start: 3
      description: |
        Power-On Reset (POR) override facility.
        - false (0): POR override disabled (normal operation)
        - true (1): POR override may be enabled

ControlStatus2:
  type: register
  address: 0x01
  size_bits: 8
  access: RW
  reset_value: 0x00
  description: |
    Control and status register 2.
    Controls timer/alarm interrupts and flags.
  fields:
    ti_tp:
      base: bool
      start: 4
      description: |
        Timer interrupt mode.
        - false (0): INT active when TF is active (level mode)
        - true (1): INT pulses active (pulse mode)
    af:
      base: bool
      start: 3
      description: |
        Alarm flag.
        Read: false = alarm inactive, true = alarm active
        Write: false = clears flag, true = flag unchanged
    tf:
      base: bool
      start: 2
      description: |
        Timer flag.
        Read: false = timer inactive, true = timer active
        Write: false = clears flag, true = flag unchanged
    aie:
      base: bool
      start: 1
      description: |
        Alarm interrupt enable.
        - false (0): Alarm interrupt disabled
        - true (1): Alarm interrupt enabled
    tie:
      base: bool
      start: 0
      description: |
        Timer interrupt enable.
        - false (0): Timer interrupt disabled
        - true (1): Timer interrupt enabled

# =============================================================================
# TIME AND DATE REGISTERS
# =============================================================================

Seconds:
  type: register
  address: 0x02
  size_bits: 8
  access: RW
  description: |
    Seconds register with voltage-low flag.
    Seconds are BCD encoded (0-59).
  fields:
    vl:
      base: bool
      start: 7
      description: |
        Voltage-low flag (clock integrity indicator).
        - false (0): Clock integrity guaranteed
        - true (1): Clock integrity not guaranteed (set at power-on)
        Must be cleared by software after setting time.
    seconds_ten:
      base: uint
      start: 4
      end: 7
      description: |
        Seconds ten's digit (BCD, 0-5).
    seconds_unit:
      base: uint
      start: 0
      end: 4
      description: |
        Seconds unit digit (BCD, 0-9).

Minutes:
  type: register
  address: 0x03
  size_bits: 8
  access: RW
  description: |
    Minutes register.
    Minutes are BCD encoded (0-59).
  fields:
    minutes_ten:
      base: uint
      start: 4
      end: 7
      description: |
        Minutes ten's digit (BCD, 0-5).
    minutes_unit:
      base: uint
      start: 0
      end: 4
      description: |
        Minutes unit digit (BCD, 0-9).

Hours:
  type: register
  address: 0x04
  size_bits: 8
  access: RW
  description: |
    Hours register.
    Hours are BCD encoded (0-23, 24-hour format).
  fields:
    hours_ten:
      base: uint
      start: 4
      end: 6
      description: |
        Hours ten's digit (BCD, 0-2).
    hours_unit:
      base: uint
      start: 0
      end: 4
      description: |
        Hours unit digit (BCD, 0-9).

Days:
  type: register
  address: 0x05
  size_bits: 8
  access: RW
  description: |
    Days register.
    Days are BCD encoded (1-31).
  fields:
    days_ten:
      base: uint
      start: 4
      end: 6
      description: |
        Days ten's digit (BCD, 0-3).
    days_unit:
      base: uint
      start: 0
      end: 4
      description: |
        Days unit digit (BCD, 0-9).

Weekdays:
  type: register
  address: 0x06
  size_bits: 8
  access: RW
  description: |
    Weekdays register.
    Weekday value (0-6, user-definable assignment).
  fields:
    weekday:
      base: uint
      start: 0
      end: 3
      description: |
        Weekday value (0-6).
        Default assignment: 0=Sunday, 1=Monday, ..., 6=Saturday
        (can be reassigned by user)

CenturyMonths:
  type: register
  address: 0x07
  size_bits: 8
  access: RW
  description: |
    Century flag and months register.
    Months are BCD encoded (1-12).
  fields:
    century:
      base: bool
      start: 7
      description: |
        Century flag.
        - false (0): Century is X
        - true (1): Century is X+1
        Toggled automatically when years overflows from 99 to 00.
    months_ten:
      base: uint
      start: 4
      end: 5
      description: |
        Months ten's digit (BCD, 0-1).
    months_unit:
      base: uint
      start: 0
      end: 4
      description: |
        Months unit digit (BCD, 0-9).

Years:
  type: register
  address: 0x08
  size_bits: 8
  access: RW
  description: |
    Years register.
    Years are BCD encoded (0-99).
  fields:
    years_ten:
      base: uint
      start: 4
      end: 8
      description: |
        Years ten's digit (BCD, 0-9).
    years_unit:
      base: uint
      start: 0
      end: 4
      description: |
        Years unit digit (BCD, 0-9).

# =============================================================================
# ALARM REGISTERS
# =============================================================================

MinuteAlarm:
  type: register
  address: 0x09
  size_bits: 8
  access: RW
  reset_value: 0x80
  description: |
    Minute alarm register.
    Minutes are BCD encoded (0-59).
  fields:
    ae_m:
      base: bool
      start: 7
      description: |
        Minute alarm enable (active low).
        - false (0): Minute alarm enabled
        - true (1): Minute alarm disabled (default)
    minute_alarm_ten:
      base: uint
      start: 4
      end: 7
      description: |
        Minute alarm ten's digit (BCD, 0-5).
    minute_alarm_unit:
      base: uint
      start: 0
      end: 4
      description: |
        Minute alarm unit digit (BCD, 0-9).

HourAlarm:
  type: register
  address: 0x0A
  size_bits: 8
  access: RW
  reset_value: 0x80
  description: |
    Hour alarm register.
    Hours are BCD encoded (0-23).
  fields:
    ae_h:
      base: bool
      start: 7
      description: |
        Hour alarm enable (active low).
        - false (0): Hour alarm enabled
        - true (1): Hour alarm disabled (default)
    hour_alarm_ten:
      base: uint
      start: 4
      end: 6
      description: |
        Hour alarm ten's digit (BCD, 0-2).
    hour_alarm_unit:
      base: uint
      start: 0
      end: 4
      description: |
        Hour alarm unit digit (BCD, 0-9).

DayAlarm:
  type: register
  address: 0x0B
  size_bits: 8
  access: RW
  reset_value: 0x80
  description: |
    Day alarm register.
    Days are BCD encoded (1-31).
  fields:
    ae_d:
      base: bool
      start: 7
      description: |
        Day alarm enable (active low).
        - false (0): Day alarm enabled
        - true (1): Day alarm disabled (default)
    day_alarm_ten:
      base: uint
      start: 4
      end: 6
      description: |
        Day alarm ten's digit (BCD, 0-3).
    day_alarm_unit:
      base: uint
      start: 0
      end: 4
      description: |
        Day alarm unit digit (BCD, 0-9).

WeekdayAlarm:
  type: register
  address: 0x0C
  size_bits: 8
  access: RW
  reset_value: 0x80
  description: |
    Weekday alarm register.
  fields:
    ae_w:
      base: bool
      start: 7
      description: |
        Weekday alarm enable (active low).
        - false (0): Weekday alarm enabled
        - true (1): Weekday alarm disabled (default)
    weekday_alarm:
      base: uint
      start: 0
      end: 3
      description: |
        Weekday alarm value (0-6).

# =============================================================================
# CLOCK OUTPUT CONTROL
# =============================================================================

ClkoutControl:
  type: register
  address: 0x0D
  size_bits: 8
  access: RW
  reset_value: 0x80
  description: |
    CLKOUT frequency control register.
  fields:
    fe:
      base: bool
      start: 7
      description: |
        CLKOUT enable.
        - false (0): CLKOUT inhibited (high-impedance)
        - true (1): CLKOUT active (default)
    fd:
      base: uint
      start: 0
      end: 2
      description: |
        CLKOUT frequency selection.
      conversion:
        name: ClkoutFrequency
        description: CLKOUT output frequency selection
        Freq32768Hz:
          value: 0b00
          description: "32.768 kHz (default)"
        Freq1024Hz:
          value: 0b01
          description: "1.024 kHz"
        Freq32Hz:
          value: 0b10
          description: "32 Hz"
        Freq1Hz:
          value: 0b11
          description: "1 Hz"

# =============================================================================
# TIMER CONTROL
# =============================================================================

TimerControl:
  type: register
  address: 0x0E
  size_bits: 8
  access: RW
  reset_value: 0x03
  description: |
    Timer control register.
  fields:
    te:
      base: bool
      start: 7
      description: |
        Timer enable.
        - false (0): Timer disabled (default)
        - true (1): Timer enabled
    td:
      base: uint
      start: 0
      end: 2
      description: |
        Timer source clock frequency selection.
        When not in use, set to 1/60 Hz for power saving.
      conversion:
        name: TimerFrequency
        description: Timer source clock frequency
        Freq4096Hz:
          value: 0b00
          description: "4096 Hz"
        Freq64Hz:
          value: 0b01
          description: "64 Hz"
        Freq1Hz:
          value: 0b10
          description: "1 Hz (1 second resolution)"
        Freq1_60Hz:
          value: 0b11
          description: "1/60 Hz (1 minute resolution, default, lowest power)"

Timer:
  type: register
  address: 0x0F
  size_bits: 8
  access: RW
  description: |
    Timer countdown value register.
    8-bit binary countdown timer (0-255).
    Countdown period = n / source_clock_frequency
    When read, returns current countdown value.
  fields:
    timer_value:
      base: uint
      start: 0
      end: 8
      description: |
        Timer countdown value (0-255).