Skip to content

Commit

Permalink
Fix CallbackTimer::start not in IRAM (#2676)
Browse files Browse the repository at this point in the history
Known issue with templated code where compiler silently ignores section attribute.
https://sming.readthedocs.io/en/latest/framework/core/pgmspace.html#templated-code

Co-authored-by: mikee47 <[email protected]>
  • Loading branch information
mikee47 and mikee47 authored Oct 21, 2023
1 parent c3834dc commit d85d10c
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions Sming/Core/CallbackTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,18 @@ template <typename TimerApi> class CallbackTimer : protected TimerApi
* @param repeating True to restart timer when it triggers, false for one-shot (Default: true)
* @retval bool True if timer started
*/
IRAM_ATTR bool start(bool repeating = true);
__forceinline bool IRAM_ATTR start(bool repeating = true)
{
stop();
if(!callbackSet || !intervalSet) {
return false;
}

TimerApi::arm(repeating);
started = true;
this->repeating = repeating;
return true;
}

/** @brief Start one-shot timer
* @retval bool True if timer started
Expand Down Expand Up @@ -410,17 +421,4 @@ template <typename TimerApi> class CallbackTimer : protected TimerApi
bool started = false; ///< Timer is active, or has fired
};

template <typename TimerApi> bool CallbackTimer<TimerApi>::start(bool repeating)
{
stop();
if(!callbackSet || !intervalSet) {
return false;
}

TimerApi::arm(repeating);
started = true;
this->repeating = repeating;
return true;
}

/** @} */

0 comments on commit d85d10c

Please sign in to comment.