summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/rtc/rtc_as3514.c33
1 files changed, 9 insertions, 24 deletions
diff --git a/firmware/drivers/rtc/rtc_as3514.c b/firmware/drivers/rtc/rtc_as3514.c
index 837806d2ea..f2716e52e8 100644
--- a/firmware/drivers/rtc/rtc_as3514.c
+++ b/firmware/drivers/rtc/rtc_as3514.c
@@ -122,36 +122,21 @@ bool rtc_check_alarm_started(bool release_alarm)
{
(void) release_alarm;
- /* was it an alarm that triggered power on ? */
- bool alarm_start = false;
-
/* 3 first reads give the 23 bits counter and enable bit */
ascodec_read(AS3543_WAKEUP); /* bits 7:0 */
ascodec_read(AS3543_WAKEUP); /* bits 15:8 */
- if(ascodec_read(AS3543_WAKEUP) & (1<<7)) /* enable bit */
- {
-#if 0 /* we could have a persistent setting for wake-up time */
- alarm_enabled = true;
-#endif
-
- /* subsequent reads give the 16 bytes static SRAM */
- wakeup_h = ascodec_read(AS3543_WAKEUP);
- wakeup_m = ascodec_read(AS3543_WAKEUP);
-
- struct tm tm;
- rtc_read_datetime(&tm);
+ if(!(ascodec_read(AS3543_WAKEUP) & (1<<7))) /* enable bit */
+ return false;
- /* do we wake up at the programmed time, or for another reason ? */
- if(wakeup_h == tm.tm_hour && wakeup_m == tm.tm_min)
- alarm_start = true;
- }
+ /* subsequent reads give the 16 bytes static SRAM */
+ wakeup_h = ascodec_read(AS3543_WAKEUP);
+ wakeup_m = ascodec_read(AS3543_WAKEUP);
- /* disable alarm */
- ascodec_write(AS3543_WAKEUP, 0); /* bits 7:0 */
- ascodec_write(AS3543_WAKEUP, 0); /* bits 15:8 */
- ascodec_write(AS3543_WAKEUP, 0); /* bits 22:16 + enable bit */
+ struct tm tm;
+ rtc_read_datetime(&tm);
- return alarm_start;
+ /* were we powered up at the programmed time ? */
+ return wakeup_h == tm.tm_hour && wakeup_m == tm.tm_min;
}
bool rtc_check_alarm_flag(void)