summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
author张世争 <[email protected]>2020-11-20 09:02:20 +0800
committer张世争 <[email protected]>2020-11-20 09:02:20 +0800
commite8eb74da585ab30aa6f6594056aa92a262512500 (patch)
tree00f77536f0afeb259dcfb5e0cd375464e15819a0 /components
parent9dc0bbb814dff797eabb1cbcc133410c75471cd0 (diff)
[rtc.alarm][fix]fix alarm when update datetime
Diffstat (limited to 'components')
-rw-r--r--components/drivers/rtc/alarm.c7
1 files 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 <rtthread.h>
@@ -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;