From 75d2a8009e15cb3a4bb68914b84ff773bfb9f26b Mon Sep 17 00:00:00 2001 From: Pol Van Aubel Date: Thu, 2 May 2019 01:07:22 +0200 Subject: [PATCH] Extend SoftwareTimer with ISR-safe functions. --- cores/nRF5/utility/SoftwareTimer.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cores/nRF5/utility/SoftwareTimer.h b/cores/nRF5/utility/SoftwareTimer.h index ac724431..a36731d1 100644 --- a/cores/nRF5/utility/SoftwareTimer.h +++ b/cores/nRF5/utility/SoftwareTimer.h @@ -52,6 +52,11 @@ class SoftwareTimer _handle = xTimerCreate(NULL, ms2tick(ms), true, NULL, callback); } + void begin(uint32_t ms, TimerCallbackFunction_t callback, bool repeating) + { + _handle = xTimerCreate(NULL, ms2tick(ms), repeating, NULL, callback); + } + TimerHandle_t getHandle(void) { return _handle; @@ -59,6 +64,17 @@ class SoftwareTimer void start(void) { xTimerStart(_handle, 0); } void stop (void) { xTimerStop (_handle, 0); } + void reset(void) { xTimerReset(_handle, 0); } + + BaseType_t startFromISR(BaseType_t* pxHigherPriorityTaskWoken) { + return xTimerStartFromISR(_handle, pxHigherPriorityTaskWoken); + } + BaseType_t stopFromISR(BaseType_t* pxHigherPriorityTaskWoken) { + return xTimerStopFromISR (_handle, pxHigherPriorityTaskWoken); + } + BaseType_t resetFromISR(BaseType_t* pxHigherPriorityTaskWoken) { + return xTimerResetFromISR(_handle, pxHigherPriorityTaskWoken); + } void setPeriod(uint32_t ms) {