Merge pull request 'timer-fix' (#7) from timer-fix into main

Reviewed-on: https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils/pulls/7
This commit is contained in:
carlwachter 2023-09-17 19:17:06 +00:00
commit 621e6e3666
2 changed files with 7 additions and 2 deletions

View File

@ -19,6 +19,7 @@ namespace sta
class RtosTimer : public Timer
{
public:
RtosTimer();
RtosTimer(void (*callback)(void *arg), void *arg);
~RtosTimer();
@ -31,4 +32,4 @@ namespace sta
};
} // namespace sta
#endif // STA_RTOS_TIMER_HPP
#endif // STA_RTOS_TIMER_HPP

View File

@ -1,13 +1,17 @@
#include <sta/rtos/timer.hpp>
#include <sta/debug/debug.hpp>
#include <sta/debug/assert.hpp>
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");
}
RtosTimer::~RtosTimer() {
@ -25,4 +29,4 @@ namespace sta {
if (status != osOK) STA_DEBUG_PRINTLN("Timer stop failed");
}
} // namespace sta
} // namespace sta