Modify licenses
[scp/ocu/5gnr.git] / Include / vos_timer.h
1 /******************************************************************************
2 *
3 *   Copyright (c) 2020 ICT/CAS.
4 *
5 *   Licensed under the O-RAN Software License, Version 1.0 (the "Software License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       https://www.o-ran.org/software
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 *
17 *******************************************************************************/
18
19
20
21 #ifndef __VOS_TIMER_H__
22 #define __VOS_TIMER_H__
23 #include "vos_types.h"
24
25 #ifdef    __cplusplus
26 extern "C"
27 {
28 #endif /* __cplusplus */
29
30
31 /** VOS Timer 类型枚举值 */
32 typedef enum
33 {
34     VOS_TIMER_LOOP,             ///< 循环执行的timer
35     VOS_TIMER_NO_LOOP,          ///< 执行一次的timer
36 }VOS_TIMER_TYPE_EN;
37
38
39 /**
40  * 创建定时器
41  * @param[in]   ulModuleId         模块ID
42  * @param[in]   msgQId             如果pfTimerFunc非空则无效;如果pfTimerFunc为NULL,则向msgQId队列发送定时器超时消息
43  * @param[in]   lMillSec           定时器的时间,毫秒
44  * @param[in]   pfTimerFunc        超时回调函数
45  * @param[in]   pArg               回调函数参数
46  * @param[in]   enType             定时器类型
47  * @return      返回Timer ID,失败则返回VOS_ERROR
48  */
49 LONG VOS_TimerCreate(ULONG ulModuleId, ULONG msgQId, LONG lMillSec,
50     VOID  (*pfTimerFunc)(VOID *), VOID  *pArg, VOS_TIMER_TYPE_EN enType);
51
52
53 /**
54 * 改变定时器时间,不能在超时回调函数中调用
55 * @param[in]   ulModuleId         模块ID
56 * @param[in]   ulTimerId          定时器Id
57 * @param[in]   lMillSec           定时器的时间,毫秒
58 * @return      成功返回VOS_OK,失败则返回VOS_ERROR
59 */
60 LONG VOS_TimerChange(ULONG ulModuleId, ULONG ulTimerId, LONG lMillSec);
61
62
63 /**
64 * 删除定时器
65 * @param[in]   ulModuleId         模块ID
66 * @param[in]   ulTimerId          定时器Id
67 * @return      成功VOS_OK,失败则返回VOS_ERROR
68 */
69 LONG VOS_TimerDelete(ULONG ulModuleId, ULONG ulTimerId);
70
71
72 /**
73  * 创建微秒定时器,必须绑核
74  * @param[in]   ulModuleId         模块ID
75  * @param[in]   luSec              定时器的时间,微妙
76  * @param[in]   pfTimerFunc        超时回调函数
77  * @param[in]   pArg               回调函数参数
78  * @param[in]   enType             定时器类型
79  * @param[in]   cpuNum             CPU个数
80  * @param[in]   cpus               CPU ID 数组
81  * @return      返回Timer ID,失败则返回VOS_ERROR
82  */
83 LONG VOS_usTimerCreate(ULONG ulModuleId,LONG luSec,VOID  (*pfTimerFunc)(VOID *), VOID  *pArg, VOS_TIMER_TYPE_EN enType,LONG cpuNum,LONG cpus[]);
84
85
86
87 /**
88  * 创建微秒定时器,必须绑核
89  * @param[in]   ulModuleId         模块ID
90  * @param[in]   ulTimerId          Timer ID
91  * @return      成功VOS_OK,失败则返回VOS_ERROR
92  */
93 LONG VOS_usTimerDestroy(ULONG ulModuleId, ULONG ulTimerId);
94
95
96 #ifdef __cplusplus
97 }
98 #endif /* __cplusplus */
99 #endif /* __VOS_TIMER_H__ */