From 3892d6eb9f37a1230764a932278fadbd322d3859 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Fri, 20 Oct 2023 13:00:25 +0100 Subject: [PATCH] Fix CallbackTimer::start not in IRAM Known issue with templated code where compiler silently ignores section attribute. https://sming.readthedocs.io/en/latest/framework/core/pgmspace.html#templated-code --- 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; -} - /** @} */