mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-18 17:13:32 +08:00
[drivers][alarm] Fix week alarm bug
This commit is contained in:
parent
f35c9d6df7
commit
b3f20ff9d2
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user