2023-05-03 14:01:32 +03:00
|
|
|
|
/*
|
|
|
|
|
|
* timer.hpp
|
|
|
|
|
|
*
|
2024-02-21 10:41:56 +03:00
|
|
|
|
* Created on: 10 мар. 2023 г.
|
2023-05-03 14:01:32 +03:00
|
|
|
|
* Author: sychev
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef FREE_RTOS_TIMER_TIMER_HPP_
|
|
|
|
|
|
#define FREE_RTOS_TIMER_TIMER_HPP_
|
|
|
|
|
|
|
2023-07-05 15:44:24 +03:00
|
|
|
|
#include <free_rtos/semaphore/semaphore.hpp>
|
2023-05-03 14:01:32 +03:00
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
#include <kernel/dpl/HwiP.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace free_rtos {
|
|
|
|
|
|
|
|
|
|
|
|
class Timer {
|
|
|
|
|
|
public:
|
|
|
|
|
|
struct Settings {
|
2024-02-21 10:41:56 +03:00
|
|
|
|
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;
|
2023-05-03 14:01:32 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
2024-02-21 10:41:56 +03:00
|
|
|
|
|
2023-05-03 14:01:32 +03:00
|
|
|
|
bool Init(Settings& sett);
|
|
|
|
|
|
|
2024-02-21 10:41:56 +03:00
|
|
|
|
|
2023-10-06 17:50:38 +03:00
|
|
|
|
uint32_t Wait();
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
|
|
|
|
|
void Start();
|
|
|
|
|
|
|
|
|
|
|
|
void Stop();
|
2023-10-06 17:50:38 +03:00
|
|
|
|
|
|
|
|
|
|
uint32_t GetTickCounter() {
|
|
|
|
|
|
return tick_counter_;
|
|
|
|
|
|
}
|
2023-05-03 14:01:32 +03:00
|
|
|
|
private:
|
|
|
|
|
|
friend void timer_isr_callback(void * arg);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2024-02-21 10:41:56 +03:00
|
|
|
|
uint32_t base_addr_;
|
|
|
|
|
|
uint32_t int_num_;
|
|
|
|
|
|
HwiP_Object hwi_obj_;
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
|
|
|
|
|
Semaphore sem_;
|
2023-10-06 17:50:38 +03:00
|
|
|
|
uint32_t tick_counter_{0x00000000};
|
2023-05-03 14:01:32 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* FREE_RTOS_TIMER_TIMER_HPP_ */
|