refactor: one alarm encoder, named register bits, and the example 14 B smaller
Both alarms' registers come from one encoder that derives DY/DT and the mask bits from the rate, and the battery checks the bytes each Table 2 row writes instead of restating the enum values. Register addresses and bits are named, the year register is the year less 2000 rather than a division, and an alarm day reads back with one decode for both forms. Over the whole API the image is 10 B smaller on both parts; a rate only known at run time costs set_alarm1 6 B more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4df536d0a5
commit
f9bc2cd8e2
4 files changed
+156
-134
No files matched your search
@@ -14,7 +14,7 @@ auto now = rtc::read_clock(); // result<date_time>
|
||||
auto armed = rtc::set_alarm1({}, ds3231::alarm1_rate::once_per_second);
|
||||
```
|
||||
|
||||
`example/main.cpp` is the full tour. libavr rides as the `libavr/` submodule,
|
||||
`example/main.cpp` is a complete program. libavr rides as the `libavr/` submodule,
|
||||
pinned to the commit this driver builds against; `LIBAVR_ROOT` (cache or
|
||||
environment) overrides it for development against a working tree:
|
||||
|
||||
@@ -26,9 +26,10 @@ cmake --build --preset attiny85-generated
|
||||
|
||||
Presets cover attiny85/atmega328p in both libavr modes (generated and
|
||||
reflect); `ctest` runs the consteval battery over the BCD, the hours
|
||||
register's two formats, the weekday and the alarm rate encodings, and holds
|
||||
the example to its stated size — **1480 B** on the mega328P and **1270 B**
|
||||
on the tiny85, byte-identical across the two modes. The legacy
|
||||
register's two formats, the weekday, the alarm registers each rate writes and
|
||||
the control and status write-backs, and holds the example to its stated size —
|
||||
**1468 B** on the mega328P and **1256 B** on the tiny85, byte-identical across
|
||||
the two modes. The legacy
|
||||
yazoalfa-based driver lives on the `master` branch.
|
||||
|
||||
The weekday register is derived from the date by default. A program that
|
||||
@@ -91,6 +92,6 @@ One reference describes one part, hence `--project`. Release is what the gate
|
||||
compares, the presets defining no debug build; Debug carries the `-Og
|
||||
-gdwarf-4` pair libavr's own debug preset uses.
|
||||
|
||||
Differences from legacy: weekday-rate alarms now actually set the DY bit
|
||||
(the old `setAlarmHelper` always cleared it), reads/writes are single
|
||||
coherent bus transactions, and errors are reported instead of ignored.
|
||||
Differences from legacy: weekday-rate alarms set the DY bit (the legacy
|
||||
driver always cleared it), each register block is read or written in one
|
||||
coherent bus transaction, and errors are reported instead of ignored.
|
||||
Reference in new issue
Block a user