Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend SoftwareTimer with option to make it non-repeating, add reset function & ISR-safe functions. #260

Merged
merged 4 commits into from
May 15, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cores/nRF5/utility/SoftwareTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,29 @@ class SoftwareTimer
_handle = xTimerCreate(NULL, ms2tick(ms), true, NULL, callback);
}

void begin(uint32_t ms, TimerCallbackFunction_t callback, bool repeating)
MacGyverNL marked this conversation as resolved.
Show resolved Hide resolved
{
_handle = xTimerCreate(NULL, ms2tick(ms), repeating, NULL, callback);
}

TimerHandle_t getHandle(void)
{
return _handle;
}

void start(void) { xTimerStart(_handle, 0); }
void stop (void) { xTimerStop (_handle, 0); }
void reset(void) { xTimerReset(_handle, 0); }

BaseType_t startFromISR(BaseType_t* pxHigherPriorityTaskWoken) {
MacGyverNL marked this conversation as resolved.
Show resolved Hide resolved
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)
{
Expand Down