-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtimer.h
57 lines (45 loc) · 1.4 KB
/
timer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* @file timer.h
* @author Sebastien CAUX (sebcaux)
* @copyright Robotips 2016-2017
* @copyright UniSwarm 2018-2023
*
* @date April 10, 2016, 11:04 PM
*
* @brief Timers support for udevkit
*/
#ifndef TIMER_H
#define TIMER_H
#ifdef __cplusplus
extern "C" {
#endif
#include "timer_device.h"
// ====== device assignation ======
#define timer(d) MKDEV(DEV_CLASS_TIMER, ((d)-1))
rt_dev_t timer_getFreeDevice(void);
int timer_open(rt_dev_t device);
int timer_close(rt_dev_t device);
bool timer_isOpened(rt_dev_t device);
// ==== device enable/disable =====
int timer_enable(rt_dev_t device);
int timer_disable(rt_dev_t device);
bool timer_isEnabled(rt_dev_t device);
int timer_setHandler(rt_dev_t device, void (*handler)(void));
// ========= timer mode ===========
int timer_setPeriodMs(rt_dev_t device, uint32_t periodMs);
uint32_t timer_periodMs(rt_dev_t device);
int timer_setPeriodUs(rt_dev_t device, uint32_t periodUs);
uint32_t timer_periodUs(rt_dev_t device);
int timer_setPeriod(rt_dev_t device, uint32_t period);
uint32_t timer_period(rt_dev_t device);
// ======== counter mode ==========
int timer_setCounter(rt_dev_t device, uint16_t diviser);
#define timer_clearValue(device) timer_setValue((device), 0)
int timer_setValue(rt_dev_t device, uint16_t value);
uint16_t timer_value(rt_dev_t device);
// ======= dynamic clock =======
void timer_reconfig(void);
#ifdef __cplusplus
}
#endif
#endif // TIMER_H