core/clock/hour_latch.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /** | ||
| 2 | * @file hour_latch.c | ||
| 3 | * @brief The hourly buzz latch, host-testable off-device. | ||
| 4 | * | ||
| 5 | * @ingroup lib_core | ||
| 6 | */ | ||
| 7 | #include "clock/hour_latch.h" | ||
| 8 | |||
| 9 | 1 | time_t hour_latch_start(time_t now, int tm_min, int tm_sec) | |
| 10 | { | ||
| 11 | 1 | return now - tm_min * 60 - tm_sec; | |
| 12 | } | ||
| 13 | |||
| 14 | 8 | bool hour_latch_take(HourLatch *latch, int tick_min, time_t start) | |
| 15 | { | ||
| 16 |
4/4✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 5 times.
|
8 | if (tick_min != 0 || start == latch->last_start) |
| 17 | { | ||
| 18 | 3 | return false; | |
| 19 | } | ||
| 20 | |||
| 21 | 5 | latch->last_start = start; | |
| 22 | 5 | return true; | |
| 23 | } | ||
| 24 | |||
| 25 | 2 | void hour_latch_seed(HourLatch *latch, time_t start) | |
| 26 | { | ||
| 27 | 2 | latch->last_start = start; | |
| 28 | 2 | } | |
| 29 |