mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-08-02 10:01:54 +00:00
timer type as boolean
This commit is contained in:
parent
1d77846e9e
commit
0dedcc9f82
@ -30,11 +30,9 @@ namespace sta
|
||||
*
|
||||
* @param callback The callback function to call upon timer timeout.
|
||||
* @param arg The argument to pass to the callback function.
|
||||
* @param type The type of timer to create. The Options are:
|
||||
* - osTimerOnce: One-shot timer.
|
||||
* - osTimerPeriodic: Repeating timer.
|
||||
* @param repeating True if the timer should repeat. False if it should only run once.
|
||||
*/
|
||||
RtosTimer(std::function<void(void*)>, void *arg, osTimerType_t type = osTimerOnce);
|
||||
RtosTimer(std::function<void(void*)>, void *arg, bool repeating = false);
|
||||
|
||||
/**
|
||||
* @brief Initializes the timer with a callback that has no effect.
|
||||
|
@ -5,13 +5,15 @@
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
namespace sta {
|
||||
RtosTimer::RtosTimer(std::function<void(void*)> callback, void *arg, osTimerType_t type /*= osTimerOnce */)
|
||||
RtosTimer::RtosTimer(std::function<void(void*)> callback, void *arg, bool repeating /*= false */)
|
||||
: timer_id_{NULL},
|
||||
timer_attr_{.name="Timer", .attr_bits=type},
|
||||
timer_attr_{.name="Timer", .attr_bits=repeating ? osTimerPeriodic : osTimerOnce},
|
||||
callback_{callback},
|
||||
callbackArg_{arg},
|
||||
running_{false}
|
||||
{
|
||||
osTimerType_t type = repeating ? osTimerPeriodic : osTimerOnce;
|
||||
|
||||
// Pass an anonymous function as the callback which will invoke the currently registered callback.
|
||||
timer_id_ = osTimerNew(timeoutHandler, type, this, &timer_attr_);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user