From e8eb74da585ab30aa6f6594056aa92a262512500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=B8=96=E4=BA=89?= Date: Fri, 20 Nov 2020 09:02:20 +0800 Subject: [PATCH] [rtc.alarm][fix]fix alarm when update datetime --- components/drivers/rtc/alarm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/drivers/rtc/alarm.c b/components/drivers/rtc/alarm.c index 71b6e7236a..53cb538321 100644 --- a/components/drivers/rtc/alarm.c +++ b/components/drivers/rtc/alarm.c @@ -8,6 +8,7 @@ * 2012-10-27 heyuanjie87 first version. * 2013-05-17 aozima initial alarm event & mutex in system init. * 2020-10-15 zhangsz add alarm flags hour minute second. + * 2020-11-09 zhangsz fix alarm set when modify rtc time. */ #include @@ -102,7 +103,7 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now) { alarm->wktime.tm_hour = now->tm_hour; alarm->wktime.tm_min = now->tm_min; - alarm->wktime.tm_sec = alarm->wktime.tm_sec + 1; + alarm->wktime.tm_sec = now->tm_sec + 1; if (alarm->wktime.tm_sec > 59) { alarm->wktime.tm_sec = 0; @@ -125,7 +126,7 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now) alarm->wktime.tm_hour = now->tm_hour; if (alarm->wktime.tm_sec == now->tm_sec) { - alarm->wktime.tm_min = alarm->wktime.tm_min + 1; + alarm->wktime.tm_min = now->tm_min + 1; if (alarm->wktime.tm_min > 59) { alarm->wktime.tm_min = 0; @@ -144,7 +145,7 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now) if ((alarm->wktime.tm_min == now->tm_min) && (alarm->wktime.tm_sec == now->tm_sec)) { - alarm->wktime.tm_hour = alarm->wktime.tm_hour + 1; + alarm->wktime.tm_hour = now->tm_hour + 1; if (alarm->wktime.tm_hour > 23) { alarm->wktime.tm_hour = 0;