sitara_depot/components/free_rtos/timer/timer.hpp

58 lines
925 B
C++
Raw Normal View History

/*
* timer.hpp
*
* Created on: 10 мар. 2023 г.
* Author: sychev
*/
#ifndef FREE_RTOS_TIMER_TIMER_HPP_
#define FREE_RTOS_TIMER_TIMER_HPP_
#include <free_rtos/semaphore/semaphore.hpp>
#include <cstdint>
#include <kernel/dpl/HwiP.h>
namespace free_rtos {
class Timer {
public:
struct Settings {
uint32_t input_clk_Hz;
uint32_t base_address;
uint32_t clock_src_mux_addr;
uint32_t int_num;
uint32_t int_priority;
uint32_t period_us;
};
bool Init(Settings& sett);
uint32_t Wait();
void Start();
void Stop();
uint32_t GetTickCounter() {
return tick_counter_;
}
private:
friend void timer_isr_callback(void * arg);
private:
uint32_t base_addr_;
uint32_t int_num_;
HwiP_Object hwi_obj_;
Semaphore sem_;
uint32_t tick_counter_{0x00000000};
};
}
#endif /* FREE_RTOS_TIMER_TIMER_HPP_ */