Adds sitara_depot/free_rtos Original one is on server_gorbunov/SmartForce4.0/sitara_depot
34 lines
452 B
C++
34 lines
452 B
C++
/*
|
|
* timer_sw.cpp
|
|
*
|
|
* Created on: 13 ìàð. 2023 ã.
|
|
* Author: sychev
|
|
*/
|
|
#include "timer_sw/timer_sw.hpp"
|
|
|
|
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;
|
|
}
|