Skip to content

Commit

Permalink
Bugfix: Rp2040 os_timer_setfn() can stall other timers.
Browse files Browse the repository at this point in the history
If called on first timer in queue then subsequent timers get disconnected.
Must explicitly `disarm` the timer first so it's properly removed from queue.
  • Loading branch information
mikee47 committed Oct 11, 2023
1 parent 12cdc8b commit ed23269
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions Sming/Arch/Host/Components/driver/os_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<os_timer_t*>(-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)
Expand Down
9 changes: 5 additions & 4 deletions Sming/Arch/Rp2040/Components/driver/os_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<os_timer_t*>(-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)
Expand Down

0 comments on commit ed23269

Please sign in to comment.