diff options
| author | tyx <[email protected]> | 2022-04-05 00:52:45 +0800 |
|---|---|---|
| committer | guo <[email protected]> | 2022-04-06 10:26:04 +0800 |
| commit | b3f20ff9d2fd8727964dbf04990b2388d2595fc0 (patch) | |
| tree | dcb4157850ae3f66f02a2b9754ea4ebc270863dd /components | |
| parent | f35c9d6df733aae38a0ec0bbf1091eb6ee9787b2 (diff) | |
[drivers][alarm] Fix week alarm bug
Diffstat (limited to 'components')
| -rw-r--r-- | components/drivers/rtc/alarm.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/components/drivers/rtc/alarm.c b/components/drivers/rtc/alarm.c index 973e6432d0..49ac851804 100644 --- a/components/drivers/rtc/alarm.c +++ b/components/drivers/rtc/alarm.c @@ -170,11 +170,14 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now) case RT_ALARM_WEEKLY: { /* alarm at wday */ - sec_alarm += alarm->wktime.tm_wday * 24 * 3600; - sec_now += now->tm_wday * 24 * 3600; + if (alarm->wktime.tm_wday == now->tm_wday) + { + sec_alarm += alarm->wktime.tm_wday * 24 * 3600; + sec_now += now->tm_wday * 24 * 3600; - if (((sec_now - sec_alarm) <= RT_ALARM_DELAY) && (sec_now >= sec_alarm)) - wakeup = RT_TRUE; + if (sec_now == sec_alarm) + wakeup = RT_TRUE; + } } break; case RT_ALARM_MONTHLY: @@ -201,7 +204,8 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now) if ((wakeup == RT_TRUE) && (alarm->callback != RT_NULL)) { - timestamp = time(RT_NULL); + timestamp = (time_t)0; + get_timestamp(×tamp); alarm->callback(alarm, timestamp); } } |
