example: the code shows what the LED does, and a wrong comment goes
The comment on the failed alarm clear claimed it holds the LED dark; the next clock read rewrites the LED a tenth of a second later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f50cc749e7
commit
081f2e74cd
1 file changed
+2
-6
+2
-6
@@ -4,9 +4,7 @@
|
|||||||
using namespace avr::literals;
|
using namespace avr::literals;
|
||||||
|
|
||||||
// One source for the tiny85 (open-drain software I2C on the USI pins) and
|
// One source for the tiny85 (open-drain software I2C on the USI pins) and
|
||||||
// the mega328P (TWI hardware). On first power-up the clock is seeded and
|
// the mega328P (TWI hardware).
|
||||||
// alarm 1 armed; then the LED mirrors the seconds parity - a stuck LED
|
|
||||||
// means bus errors.
|
|
||||||
using dev = avr::device<{.clock = 8_MHz}>;
|
using dev = avr::device<{.clock = 8_MHz}>;
|
||||||
using bus = dev::i2c<{.frequency = 100_kHz}>;
|
using bus = dev::i2c<{.frequency = 100_kHz}>;
|
||||||
using rtc = ds3231::device<bus>;
|
using rtc = ds3231::device<bus>;
|
||||||
@@ -17,8 +15,6 @@ int main()
|
|||||||
avr::init<bus, led>();
|
avr::init<bus, led>();
|
||||||
|
|
||||||
if (auto stopped = rtc::oscillator_stopped(); stopped.value_or(false)) {
|
if (auto stopped = rtc::oscillator_stopped(); stopped.value_or(false)) {
|
||||||
// A failed seed leaves the LED dark before the loop ever runs - the
|
|
||||||
// same signal a stuck bus gives it below.
|
|
||||||
const bool seeded = rtc::write_clock({{2026, 1, 1}, {12, 0, 0}}) &&
|
const bool seeded = rtc::write_clock({{2026, 1, 1}, {12, 0, 0}}) &&
|
||||||
rtc::set_alarm1({}, ds3231::alarm1_rate::once_per_second) &&
|
rtc::set_alarm1({}, ds3231::alarm1_rate::once_per_second) &&
|
||||||
rtc::clear_oscillator_stopped();
|
rtc::clear_oscillator_stopped();
|
||||||
@@ -30,7 +26,7 @@ int main()
|
|||||||
led::write(now->second % 2 == 0);
|
led::write(now->second % 2 == 0);
|
||||||
}
|
}
|
||||||
if (auto fired = rtc::alarm1_fired(); fired.value_or(false) && !rtc::clear_alarm1()) {
|
if (auto fired = rtc::alarm1_fired(); fired.value_or(false) && !rtc::clear_alarm1()) {
|
||||||
led::clear(); // a clear that failed holds the LED dark, like any bus error
|
led::clear();
|
||||||
}
|
}
|
||||||
dev::delay<100_ms>();
|
dev::delay<100_ms>();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user