更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_swtmr_pri.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 * of conditions and the following disclaimer in the documentation and/or other materials
13 * provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16 * to endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _LOS_SWTMR_PRI_H
33#define _LOS_SWTMR_PRI_H
34
35#include "los_swtmr.h"
36#include "los_spinlock.h"
37#include "los_sched_pri.h"
38
39#ifdef LOSCFG_SECURITY_VID
40#include "vid_api.h"
41#else
42#define MAX_INVALID_TIMER_VID OS_SWTMR_MAX_TIMERID //最大支持的软件定时器数量 < 65535
43#endif
44
45#ifdef __cplusplus
46#if __cplusplus
47extern "C" {
48#endif /* __cplusplus */
49#endif /* __cplusplus */
50
51/**
52 * @ingroup los_swtmr_pri
53 * Software timer state
54 */
55enum SwtmrState { //定时器状态
56 OS_SWTMR_STATUS_UNUSED, /**< The software timer is not used. | 定时器未使用,系统在定时器模块初始化时,会将系统中所有定时器资源初始化成该状态。 */
57 OS_SWTMR_STATUS_CREATED, /**< The software timer is created. | 定时器创建后未启动,或已停止.定时器创建后,不处于计数状态时,定时器将变成该状态。 */
58 OS_SWTMR_STATUS_TICKING /**< The software timer is timing. | 定时器处于计数状态,在定时器创建后调用LOS_SwtmrStart接口启动,定时器将变成该状态,是定时器运行时的状态。 */
59};
60
61/**
62 * @ingroup los_swtmr_pri
63 * Structure of the callback function that handles software timer timeout
64 */
65typedef struct {//处理软件定时器超时的回调函数的结构体
66 SWTMR_PROC_FUNC handler; /**< Callback function that handles software timer timeout | 处理软件定时器超时的回调函数*/
67 UINTPTR arg; /**< Parameter passed in when the callback function
68 that handles software timer timeout is called | 调用处理软件计时器超时的回调函数时传入的参数*/
69 LOS_DL_LIST node; ///< 挂入定时器超时队列,详见 SwtmrWake( ... )
70#ifdef LOSCFG_SWTMR_DEBUG
72#endif
74
75/**
76 * @ingroup los_swtmr_pri
77 * Type of the pointer to the structure of the callback function that handles software timer timeout
78 */ //指向处理软件计时器超时的回调函数结构的指针的类型
80
81extern SWTMR_CTRL_S *g_swtmrCBArray;//软件定时器数组,后续统一注解为定时器池
82
83//通过参数ID找到对应定时器描述体
84#define OS_SWT_FROM_SID(swtmrID) ((SWTMR_CTRL_S *)g_swtmrCBArray + ((swtmrID) % LOSCFG_BASE_CORE_SWTMR_LIMIT))
85
86/**
87 * @ingroup los_swtmr_pri
88 * @brief Scan a software timer.
89 *
90 * @par Description:
91 * <ul>
92 * <li>This API is used to scan a software timer when a Tick interrupt occurs and determine whether
93 * the software timer expires.</li>
94 * </ul>
95 * @attention
96 * <ul>
97 * <li>None.</li>
98 * </ul>
99 *
100 * @param None.
101 *
102 * @retval None.
103 * @par Dependency:
104 * <ul><li>los_swtmr_pri.h: the header file that contains the API declaration.</li></ul>
105 * @see LOS_SwtmrStop
106 */
107
108extern UINT32 OsSwtmrGetNextTimeout(VOID);
109extern BOOL OsIsSwtmrTask(const LosTaskCB *taskCB);
110extern VOID OsSwtmrResponseTimeReset(UINT64 startTime);
111extern UINT32 OsSwtmrInit(VOID);
112extern VOID OsSwtmrRecycle(UINT32 processID);
116
117#ifdef LOSCFG_SWTMR_DEBUG
118typedef struct {
131
132typedef struct {
139
140extern BOOL OsSwtmrDebugDataUsed(UINT32 swtmrID);
141extern UINT32 OsSwtmrDebugDataGet(UINT32 swtmrID, SwtmrDebugData *data, UINT32 len, UINT8 *mode);
142#endif
143
144#ifdef __cplusplus
145#if __cplusplus
146}
147#endif /* __cplusplus */
148#endif /* __cplusplus */
149
150#endif /* _LOS_SWTMR_PRI_H */
VOID(* SWTMR_PROC_FUNC)(UINTPTR arg)
Define the type of a callback function that handles software timer timeout.
Definition: los_swtmr.h:260
BOOL(* SCHED_TL_FIND_FUNC)(UINTPTR, UINTPTR)
Definition: los_sched_pri.h:73
BOOL OsIsSwtmrTask(const LosTaskCB *taskCB)
Definition: los_swtmr.c:383
VOID OsSwtmrResponseTimeReset(UINT64 startTime)
Definition: los_swtmr.c:610
UINT32 OsSwtmrTaskIDGetByCpuid(UINT16 cpuid)
Definition: los_swtmr.c:378
BOOL OsSwtmrWorkQueueFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
Definition: los_swtmr.c:661
UINT32 OsSwtmrDebugDataGet(UINT32 swtmrID, SwtmrDebugData *data, UINT32 len, UINT8 *mode)
Definition: los_swtmr.c:142
SWTMR_CTRL_S * g_swtmrCBArray
Definition: los_swtmr.c:112
UINT32 OsSwtmrGetNextTimeout(VOID)
Scan a software timer.
Definition: los_swtmr.c:675
SwtmrHandlerItem * SwtmrHandlerItemPtr
Definition: los_swtmr_pri.h:79
UINT32 OsSwtmrInit(VOID)
Definition: los_swtmr.c:441
SwtmrState
Definition: los_swtmr_pri.h:55
@ OS_SWTMR_STATUS_UNUSED
Definition: los_swtmr_pri.h:56
@ OS_SWTMR_STATUS_CREATED
Definition: los_swtmr_pri.h:57
@ OS_SWTMR_STATUS_TICKING
Definition: los_swtmr_pri.h:58
SPIN_LOCK_S g_swtmrSpin
BOOL OsSwtmrDebugDataUsed(UINT32 swtmrID)
Definition: los_swtmr.c:133
VOID OsSwtmrRecycle(UINT32 processID)
回收指定进程的软时钟
Definition: los_swtmr.c:391
unsigned short UINT16
Definition: los_typedef.h:56
long unsigned int UINT64
Definition: los_typedef.h:66
unsigned char UINT8
Definition: los_typedef.h:55
unsigned long UINTPTR
Definition: los_typedef.h:68
unsigned int UINT32
Definition: los_typedef.h:57
size_t BOOL
Definition: los_typedef.h:88
UINT64 readyStartTime
SWTMR_PROC_FUNC handler
SwtmrDebugBase base
LOS_DL_LIST node
挂入定时器超时队列,详见 SwtmrWake( ... )
Definition: los_swtmr_pri.h:69
SWTMR_PROC_FUNC handler
Definition: los_swtmr_pri.h:66