diff --git a/include/sta/rtos/timer.hpp b/include/sta/rtos/timer.hpp index b576078..2fe4bc0 100644 --- a/include/sta/rtos/timer.hpp +++ b/include/sta/rtos/timer.hpp @@ -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 \ No newline at end of file +#endif // STA_RTOS_TIMER_HPP diff --git a/src/timer.cpp b/src/timer.cpp index 398cdd3..6302ecd 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -2,12 +2,15 @@ #include 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 +28,4 @@ namespace sta { if (status != osOK) STA_DEBUG_PRINTLN("Timer stop failed"); } -} // namespace sta \ No newline at end of file +} // namespace sta