Added default constr + Assert after creation

This commit is contained in:
CarlWachter 2023-09-17 20:54:13 +02:00
parent c5f2d8e533
commit d031d66e71
2 changed files with 6 additions and 2 deletions

View File

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

View File

@ -2,12 +2,15 @@
#include <sta/debug/debug.hpp> #include <sta/debug/debug.hpp>
namespace sta { namespace sta {
RtosTimer::RtosTimer(){}
RtosTimer::RtosTimer(void (*callback)(void *arg), void *arg) { RtosTimer::RtosTimer(void (*callback)(void *arg), void *arg) {
timer_attr_.name = "Timer"; timer_attr_.name = "Timer";
timer_attr_.attr_bits = osTimerOnce; timer_attr_.attr_bits = osTimerOnce;
timer_attr_.cb_size = sizeof(osTimerAttr_t); timer_attr_.cb_size = sizeof(osTimerAttr_t);
timer_id_ = osTimerNew(callback, osTimerOnce, arg, &timer_attr_); timer_id_ = osTimerNew(callback, osTimerOnce, arg, &timer_attr_);
STA_ASSERT_MSG(timer_id != 0, "Failed to initialize timer");
} }
RtosTimer::~RtosTimer() { RtosTimer::~RtosTimer() {
@ -25,4 +28,4 @@ namespace sta {
if (status != osOK) STA_DEBUG_PRINTLN("Timer stop failed"); if (status != osOK) STA_DEBUG_PRINTLN("Timer stop failed");
} }
} // namespace sta } // namespace sta