sitara_depot/components/free_rtos/timer_sw/timer_sw.cpp

34 lines
466 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* timer_sw.cpp
*
* Created on: 13 мар. 2023 г.
* Author: sychev
*/
#include "free_rtos/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;
}