summaryrefslogtreecommitdiff
path: root/firmware/drivers/rtc/rtc_as3514.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/rtc/rtc_as3514.c')
-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)
122{ 122{
123 (void) release_alarm; 123 (void) release_alarm;
124 124
125 /* was it an alarm that triggered power on ? */
126 bool alarm_start = false;
127
128 /* 3 first reads give the 23 bits counter and enable bit */ 125 /* 3 first reads give the 23 bits counter and enable bit */
129 ascodec_read(AS3543_WAKEUP); /* bits 7:0 */ 126 ascodec_read(AS3543_WAKEUP); /* bits 7:0 */
130 ascodec_read(AS3543_WAKEUP); /* bits 15:8 */ 127 ascodec_read(AS3543_WAKEUP); /* bits 15:8 */
131 if(ascodec_read(AS3543_WAKEUP) & (1<<7)) /* enable bit */ 128 if(!(ascodec_read(AS3543_WAKEUP) & (1<<7))) /* enable bit */
132 { 129 return false;
133#if 0 /* we could have a persistent setting for wake-up time */
134 alarm_enabled = true;
135#endif
136
137 /* subsequent reads give the 16 bytes static SRAM */
138 wakeup_h = ascodec_read(AS3543_WAKEUP);
139 wakeup_m = ascodec_read(AS3543_WAKEUP);
140
141 struct tm tm;
142 rtc_read_datetime(&tm);
143 130
144 /* do we wake up at the programmed time, or for another reason ? */ 131 /* subsequent reads give the 16 bytes static SRAM */
145 if(wakeup_h == tm.tm_hour && wakeup_m == tm.tm_min) 132 wakeup_h = ascodec_read(AS3543_WAKEUP);
146 alarm_start = true; 133 wakeup_m = ascodec_read(AS3543_WAKEUP);
147 }
148 134
149 /* disable alarm */ 135 struct tm tm;
150 ascodec_write(AS3543_WAKEUP, 0); /* bits 7:0 */ 136 rtc_read_datetime(&tm);
151 ascodec_write(AS3543_WAKEUP, 0); /* bits 15:8 */
152 ascodec_write(AS3543_WAKEUP, 0); /* bits 22:16 + enable bit */
153 137
154 return alarm_start; 138 /* were we powered up at the programmed time ? */
139 return wakeup_h == tm.tm_hour && wakeup_m == tm.tm_min;
155} 140}
156 141
157bool rtc_check_alarm_flag(void) 142bool rtc_check_alarm_flag(void)