Skip to content

Commit 75d2a80

Browse files
committed
Extend SoftwareTimer with ISR-safe functions.
1 parent 4468594 commit 75d2a80

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

cores/nRF5/utility/SoftwareTimer.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,29 @@ class SoftwareTimer
5252
_handle = xTimerCreate(NULL, ms2tick(ms), true, NULL, callback);
5353
}
5454

55+
void begin(uint32_t ms, TimerCallbackFunction_t callback, bool repeating)
56+
{
57+
_handle = xTimerCreate(NULL, ms2tick(ms), repeating, NULL, callback);
58+
}
59+
5560
TimerHandle_t getHandle(void)
5661
{
5762
return _handle;
5863
}
5964

6065
void start(void) { xTimerStart(_handle, 0); }
6166
void stop (void) { xTimerStop (_handle, 0); }
67+
void reset(void) { xTimerReset(_handle, 0); }
68+
69+
BaseType_t startFromISR(BaseType_t* pxHigherPriorityTaskWoken) {
70+
return xTimerStartFromISR(_handle, pxHigherPriorityTaskWoken);
71+
}
72+
BaseType_t stopFromISR(BaseType_t* pxHigherPriorityTaskWoken) {
73+
return xTimerStopFromISR (_handle, pxHigherPriorityTaskWoken);
74+
}
75+
BaseType_t resetFromISR(BaseType_t* pxHigherPriorityTaskWoken) {
76+
return xTimerResetFromISR(_handle, pxHigherPriorityTaskWoken);
77+
}
6278

6379
void setPeriod(uint32_t ms)
6480
{

0 commit comments

Comments
 (0)