-
Notifications
You must be signed in to change notification settings - Fork 0
/
os-timer.h
55 lines (47 loc) · 2.17 KB
/
os-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
#ifndef _OS_TIMER_H_
#define _OS_TIMER_H_
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C"
{
#endif
typedef void (*OsTimerCallback_t)(int id, void *param);
/*****************************************************************************\
* @description : Initialize the OsTimer module.
* @return {*}
\*****************************************************************************/
void OsTimerInit();
/*****************************************************************************\
* @description : Register a timer
* ------------
* @callback [I]: timer triggered callback function.
* @param [I]: input parameter for callback function.
* @period_us [I]: micro second delay to trigger the timer.
* @repeatable [I]: true=auto reload period_us.
* @id [O]: output the timer id for Kill. (Will be auto killed after
* triggered, if not repeatable timer)
* @return error or success
\*****************************************************************************/
int OsTimerRegister(OsTimerCallback_t callback, void *param, uint64_t period_us, bool repeatable, int *id);
/*****************************************************************************\
* @description : return number of active timer
* @return number of active timer
\*****************************************************************************/
int OsTimerCount();
/*****************************************************************************\
* @description : Kill a timer
* @id [I]: timer id, which given by OsTimerRegister(...,&id)
* @return error or success
\*****************************************************************************/
int OsTimerKill(int id);
/*****************************************************************************\
* @description : delay micro seconds
* @param [I]: delay_us
* @return error or success
\*****************************************************************************/
int OsTimerDelayUs(uint64_t delay_us);
#ifdef __cplusplus
}
#endif
#endif