fixes + timer isRunning

This commit is contained in:
CarlWachter 2023-09-18 20:45:09 +02:00
parent 580524c6e6
commit a38f678d41
2 changed files with 7 additions and 6 deletions

View File

@ -25,6 +25,7 @@ namespace sta
void start(uint32_t millis) override;
void stop() override;
bool isRunning() override;
private:
osTimerId_t timer_id_; /**< CMSIS RTOS2 Timer */

View File

@ -6,12 +6,8 @@ namespace sta {
RtosTimer::RtosTimer(){}
RtosTimer::RtosTimer(void (*callback)(void *arg), void *arg) {
timer_attr_.name = "Timer";
timer_attr_.attr_bits = osTimerOnce;
timer_attr_.cb_size = sizeof(osTimerAttr_t);
timer_id_ = osTimerNew(callback, osTimerOnce, arg, &timer_attr_);
STA_ASSERT_MSG(timer_id_ != 0, "Failed to initialize timer");
timer_id_ = osTimerNew(callback, osTimerOnce, arg, NULL);
STA_ASSERT_MSG(timer_id_ != NULL, "Failed to initialize timer");
}
RtosTimer::~RtosTimer() {
@ -29,4 +25,8 @@ namespace sta {
if (status != osOK) STA_DEBUG_PRINTLN("Timer stop failed");
}
bool RtosTimer::isRunning() {
return osTimerIsRunning(timer_id_);
}
} // namespace sta