From a38f678d41eccf9f32fcde2d6c16162d13e68e98 Mon Sep 17 00:00:00 2001 From: CarlWachter Date: Mon, 18 Sep 2023 20:45:09 +0200 Subject: [PATCH] fixes + timer isRunning --- include/sta/rtos/timer.hpp | 1 + src/timer.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/sta/rtos/timer.hpp b/include/sta/rtos/timer.hpp index 2fe4bc0..2fc06bd 100644 --- a/include/sta/rtos/timer.hpp +++ b/include/sta/rtos/timer.hpp @@ -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 */ diff --git a/src/timer.cpp b/src/timer.cpp index 7e42d1c..180286a 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -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