summaryrefslogtreecommitdiff
path: root/components/drivers/rtc
diff options
context:
space:
mode:
authorthread-liu <[email protected]>2020-12-03 09:09:00 +0800
committerGitHub <[email protected]>2020-12-03 09:09:00 +0800
commitd97530e0ffc6e28a7a68f66dfcf775f02fc007e5 (patch)
tree523fdc8c8b15b4c68501ec7f09b29c26954a51db /components/drivers/rtc
parent73391c60fb7b26c5c05188b065196eea75d63145 (diff)
parentdf3d4b7bc9cab6dcc0aaf87cd32bd67bb1531036 (diff)
Merge branch 'master' into step4
Diffstat (limited to 'components/drivers/rtc')
-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;