diff --git a/Sming/Arch/Host/Components/driver/os_timer.cpp b/Sming/Arch/Host/Components/driver/os_timer.cpp index ec80e5237d..e546c35256 100644 --- a/Sming/Arch/Host/Components/driver/os_timer.cpp +++ b/Sming/Arch/Host/Components/driver/os_timer.cpp @@ -93,11 +93,12 @@ void os_timer_disarm(struct os_timer_t* ptimer) void os_timer_setfn(struct os_timer_t* ptimer, os_timer_func_t* pfunction, void* parg) { - if(ptimer != nullptr) { - ptimer->timer_func = pfunction; - ptimer->timer_arg = parg; - ptimer->timer_next = reinterpret_cast(-1); + if(ptimer == nullptr) { + return; } + os_timer_disarm(ptimer); + ptimer->timer_func = pfunction; + ptimer->timer_arg = parg; } void os_timer_done(struct os_timer_t* ptimer) diff --git a/Sming/Arch/Rp2040/Components/driver/os_timer.cpp b/Sming/Arch/Rp2040/Components/driver/os_timer.cpp index ee8312357a..b524d56ceb 100644 --- a/Sming/Arch/Rp2040/Components/driver/os_timer.cpp +++ b/Sming/Arch/Rp2040/Components/driver/os_timer.cpp @@ -173,11 +173,12 @@ void IRAM_ATTR os_timer_disarm(struct os_timer_t* ptimer) void os_timer_setfn(struct os_timer_t* ptimer, os_timer_func_t* pfunction, void* parg) { - if(ptimer != nullptr) { - ptimer->timer_func = pfunction; - ptimer->timer_arg = parg; - ptimer->timer_next = reinterpret_cast(-1); + if(ptimer == nullptr) { + return; } + os_timer_disarm(ptimer); + ptimer->timer_func = pfunction; + ptimer->timer_arg = parg; } void os_timer_done(struct os_timer_t* ptimer)