You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MultiTimer is a software timer extension module that allows for the expansion of timer tasks as needed, replacing the traditional flag-checking method. It offers a more elegant and convenient way to manage the timing sequences of a program.
5
5
6
-
## 使用方法
7
-
1.配置系统时间基准接口,安装定时器驱动;
6
+
## How to Use
7
+
1.Configure the system time base interface and install the timer driver:
8
8
9
9
```c
10
10
uint64_tPlatformTicksGetFunc(void)
11
11
{
12
-
/* Platform implementation */
12
+
/* Platform-specific implementation */
13
13
}
14
14
15
15
multiTimerInstall(PlatformTicksGetFunc);
16
16
```
17
17
18
-
2. 实例化一个定时器对象;
18
+
2. Instantiate a timer object:
19
19
20
20
```c
21
21
MultiTimer timer1;
22
22
```
23
23
24
-
3.设置定时时间,超时回调处理函数, 用户上下指针,启动定时器;
24
+
3.Set the timing, timeout callback function, user data pointer, and start the timer:
1. The clock frequency of the timer directly affects its accuracy. It is recommended to use ticks with higher precision such as 1ms, 5ms, or 10ms.
45
45
46
-
2.定时器的回调函数内不应执行耗时操作,否则可能因占用过长的时间,导致其他定时器无法正常超时;
46
+
2. The callback function of the timer should not perform time-consuming operations, as this may occupy too much time, causing other timers to not timeout properly.
3. Since the timer's callback function is executed within `multiTimerYield`, care should be taken not to use too much stack space to avoid stack overflow.
The `test_linux.c` file serves as a demo for Linux platforms, showcasing how to use MultiTimer for creating and managing multiple timers with different intervals and behaviors.
53
52
54
53
```c
54
+
#include"MultiTimer.h"
55
55
#include<stdio.h>
56
+
#include<unistd.h>
56
57
#include<sys/time.h>
57
-
#include<time.h>
58
-
#include"MultiTimer.h"
59
58
60
-
MultiTimer timer1;
61
-
MultiTimer timer2;
62
-
MultiTimer timer3;
59
+
// Platform-specific function to get current ticks (milliseconds)
0 commit comments