2023-05-03 14:01:32 +03:00
|
|
|
|
/*
|
|
|
|
|
|
* timer_sw.cpp
|
|
|
|
|
|
*
|
|
|
|
|
|
* Created on: 13 <EFBFBD><EFBFBD><EFBFBD>. 2023 <EFBFBD>.
|
|
|
|
|
|
* Author: sychev
|
|
|
|
|
|
*/
|
2023-06-26 18:22:30 +03:00
|
|
|
|
#include "free_rtos/timer_sw/timer_sw.hpp"
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
|
|
|
|
|
void TimerSw::start(uint32_t period) {
|
|
|
|
|
|
enable_ = true;
|
|
|
|
|
|
cnt_ = 0;
|
|
|
|
|
|
prd_ = period;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TimerSw::stop() {
|
|
|
|
|
|
enable_ = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TimerSw::tick(uint32_t ticks) {
|
|
|
|
|
|
|
|
|
|
|
|
if (!enable_) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cnt_+=ticks;
|
|
|
|
|
|
|
|
|
|
|
|
if (cnt_ >= prd_) {
|
|
|
|
|
|
cnt_ = 0;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|