From d85d10ccdbe3ad23c723be55885ac220d1f6af7f Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 21 Oct 2023 12:27:29 +0100 Subject: [PATCH] Fix CallbackTimer::start not in IRAM (#2676) 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 --- Sming/Core/CallbackTimer.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Sming/Core/CallbackTimer.h b/Sming/Core/CallbackTimer.h index e8ef1989ac..9844c6ed86 100644 --- a/Sming/Core/CallbackTimer.h +++ b/Sming/Core/CallbackTimer.h @@ -207,7 +207,18 @@ template 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 @@ -410,17 +421,4 @@ template class CallbackTimer : protected TimerApi bool started = false; ///< Timer is active, or has fired }; -template bool CallbackTimer::start(bool repeating) -{ - stop(); - if(!callbackSet || !intervalSet) { - return false; - } - - TimerApi::arm(repeating); - started = true; - this->repeating = repeating; - return true; -} - /** @} */