4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-01-18 20:33:30 +08:00

[drivers][alarm] Fix week alarm bug

This commit is contained in:
tyx 2022-04-05 00:52:45 +08:00 committed by guo
parent f35c9d6df7
commit b3f20ff9d2

View File

@ -170,12 +170,15 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now)
case RT_ALARM_WEEKLY:
{
/* alarm at wday */
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))
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(&timestamp);
alarm->callback(alarm, timestamp);
}
}