• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 /* *
20 * @file hi_event.h
21 * Description: system event API.CNcomment:系统事件接口。CNend
22 * @li Before sending, waiting, or clearing an event, the event must be created to obtain the event ID.
23 CNcomment:在发送、等待、清空事件之前首先需要创建事件,获取事件使用ID。CNend
24 * @li Wait event: The wait event API cannot be called in the interrupt, interrupt off,
25 * and lock task contexts to avoid uncontrollable exceptional scheduling.CNcomment:等待事件:在中断、
26 关中断、锁任务上下文禁止调用等待事件接口,进而产生不可控的异常调度。CNend
27 * @li TX event: The TX event API cannot be called in the interrupt off context to avoid uncontrollable
28 exceptional scheduling.CNcomment:发送事件:在关中断上下文禁止调用发送事件接口,
29 进而产生不可控的异常调度。CNend
30 * @li Each bit of bit[0:23] of an event can represent an event type. The meaning of each bit is allocated by the user.
31 CNcomment:一个事件的[0:23]bit的每一bit可以表示一种事件,每一位的意义由用户自定义分配。CNend
32 * @li Bit[24:31] of an event are reserved and cannot be used by the user.
33 CNcomment:一个事件的[24:31]bit系统保留,用户不得使用。CNend
34 *
35 */
36 
37 /* * @defgroup iot_event Event
38  * @ingroup osa
39  */
40 #ifndef __HI_EVENT_H__
41 #define __HI_EVENT_H__
42 #include <hi_types_base.h>
43 
44 #define HI_INVALID_EVENT_ID           0xffffffff   /**< Failed to obtain the event ID.CNcoment:获取事件ID失败CNend  */
45 #define HI_EVENT_WAITMODE_AND         4            /**< If all expected events occur, the wait is successful.
46                                                         It cannot be used with HI_EVENT_WAITMODE_OR at the same time.
47                                                         CNcomment:所有预期等待的事件均发生时,才认定等待成功,
48                                                         不允许与HI_EVENT_WAITMODE_OR同时使用 CNend */
49 #define HI_EVENT_WAITMODE_OR          2            /**< If any of the expected events occurs, the wait is successful.
50                                                         It cannot be used with HI_EVENT_WAITMODE_AND at the same time.
51                                                         CNcomment:所有预期等待的事件发生任意一种,认定等待成功,
52                                                         不允许与HI_EVENT_WAITMODE_AND同时使用 CNend */
53 #define HI_EVENT_WAITMODE_CLR         1            /**< The waited event is cleared when the wait event is successful.
54                                                         CNcomment:等待事件成功时,清除等待到的事件CNend  */
55 
56 /* *
57 * @ingroup  iot_event
58 * @brief  Creates an event.CNcomment:创建事件。CNend
59 *
60 * @par 描述:
61 *           Creates an event to obtain the event ID.CNcomment:创建事件,获取事件使用ID。CNend
62 *
63 * @attention
64 *           @li The read/write event interface cannot be invoked before system initialization.
65 CNcomment:在系统初始化之前不能调用读写事件接口。CNend
66 *           @li In the interrupt, the event object can be written, but cannot be read.
67 CNcomment:在中断中,可以对事件对象进行写操作,但不能读操作。CNend
68 *           @li In the lock task scheduling state, a write operation can be performed on an event object, but the
69 *               read operation cannot be performed.CNcomment:在锁任务调度状态下,可以对事件对象进行写操作,
70 但不能读操作。CNend
71 *
72 * @param  id       [OUT] type #hi_u32*,Event ID.
73 *
74 * @retval #0       Success.
75 * @retval #Other   Failure. For details, see hi_errno.h.
76 *
77 * @par 依赖:
78 *           @li hi_event.h:Describes event APIs.CNcomment:文件用于描述事件相关接口。CNend
79 * @see  hi_event_delete。
80 * @since Hi3861_V100R001C00
81 */
82 hi_u32 hi_event_create(HI_OUT hi_u32 *id);
83 
84 /* *
85 * @ingroup  iot_event
86 * @brief  Defines the TX event. CNcomment:发送事件。CNend
87 *
88 * @par 描述:
89 *           Defines the TX event.CNcomment:发送事件。CNend
90 *
91 * @attention
92 *           @li The read/write event interface cannot be invoked before system initialization.
93 CNcomment:在系统初始化之前不能调用读写事件接口。CNend
94 *           @li In the interrupt, the event object can be written, but cannot be read.
95 CNcomment:在中断中,可以对事件对象进行写操作,但不能读操作。CNend
96 *           @li In the lock task scheduling state, a write operation can be performed on an event object, but the
97 *               read operation cannot be performed.CNcomment:在锁任务调度状态下,可以对事件对象进行写操作,
98 但不能读操作。CNend
99 *
100 * @param  id       [OUT]  type #hi_u32*,Event ID.
101 * @param  event_bits [IN] type #hi_u32,Set of events to be sent.CNcomment:事件bit位。CNend
102 *
103 * @retval #0       Success.
104 * @retval #Other   Failure. For details, see hi_errno.h.
105 *
106 * @par 依赖:
107 *           @li hi_event.h:Describes event APIs.CNcomment:文件用于描述事件相关接口。CNend
108 * @see  hi_event_wait。
109 * @since Hi3861_V100R001C00
110 */
111 hi_u32 hi_event_send(hi_u32 id, hi_u32 event_bits);
112 
113 /* *
114 * @ingroup  iot_event
115 * @brief  Defines the wait event.CNcomment:等待事件。CNend
116 *
117 * @par 描述:
118 *          Defines the wait event.CNcomment:等待事件。CNend
119 *
120 * @attention
121 *           @li The read/write event interface cannot be invoked before system initialization.
122 CNcomment:在系统初始化之前不能调用读写事件接口。CNend
123 *           @li In the interrupt, the event object can be written, but cannot be read.
124 CNcomment:在中断中,可以对事件对象进行写操作,但不能读操作。CNend
125 *           @li In the lock task scheduling state, a write operation can be performed on an event object, but the
126 *               read operation cannot be performed.CNcomment:在锁任务调度状态下,可以对事件对象进行写操作,
127 但不能读操作。CNend
128 *
129 * @param  id       [OUT]  type #hi_u32*,Event ID.
130 * @param  mask       [IN] type #hi_u32,Set of events to be waited for, which may be one bit or multiple bits in
131 *                    bits 0-23.CNcomment:预等待的事件集合,可以为0~23bit中的1bit或多bit。CNend
132 * @param  event_bits [IN] type #hi_u32,Set of events to be sent.CNcomment:事件bit位。CNend
133 * @param  timeout    [IN] type #hi_u32,Waiting timeout period (unit: ms).
134 CNcomment:等待超时时间(单位:ms)。CNend
135 * @param  flag       [IN] type #hi_u32,Waiting option. For details, see #HI_EVENT_WAITMODE_AND,
136 *                    #HI_EVENT_WAITMODE_OR, and #HI_EVENT_WAITMODE_CLR.
137 CNcomment:等待选项,取值见#HI_EVENT_WAITMODE_AND、#HI_EVENT_WAITMODE_OR、#HI_EVENT_WAITMODE_CLR。CNend
138 *
139 * @retval #0       Success.
140 * @retval #Other   Failure. For details, see hi_errno.h.
141 *
142 * @par 依赖:
143 *           @li hi_event.h:Describes event APIs.CNcomment:文件用于描述事件相关接口。CNend
144 * @see  hi_event_send。
145 * @since Hi3861_V100R001C00
146 */
147 hi_u32 hi_event_wait(hi_u32 id, hi_u32 mask, HI_OUT hi_u32 *event_bits, hi_u32 timeout, hi_u32 flag);
148 
149 /* *
150 * @ingroup  iot_event
151 * @brief  Defines the clearing event.CNcomment:清除事件。CNend
152 *
153 * @par 描述:
154 *           Defines the clearing event.CNcomment:清除事件。CNend
155 *
156 * @attention
157 *           @li The read/write event interface cannot be invoked before system initialization.
158 CNcomment:在系统初始化之前不能调用读写事件接口。CNend
159 *           @li In the interrupt, the event object can be written, but cannot be read.
160 CNcomment:在中断中,可以对事件对象进行写操作,但不能读操作。CNend
161 *           @li In the lock task scheduling state, a write operation can be performed on an event object, but the
162 *               read operation cannot be performed.CNcomment:在锁任务调度状态下,可以对事件对象进行写操作,
163 但不能读操作。CNend
164 *
165 * @param  id       [OUT]  type #hi_u32*,Event ID.
166 * @param  event_bits [IN] type #hi_u32,Set of events to be cleared, which may be one bit or multiple bits in
167 *                    bits 0-23.CNcomment:清除的事件集合,可以为0~23bit中的1bit或多bit。CNend
168 *
169 * @retval #0       Success.
170 * @retval #Other   Failure. For details, see hi_errno.h.
171 *
172 * @par 依赖:
173 *           @li hi_event.h:Describes event APIs.CNcomment:文件用于描述事件相关接口。CNend
174 * @see  hi_event_wait。
175 * @since Hi3861_V100R001C00
176 */
177 hi_u32 hi_event_clear(hi_u32 id, hi_u32 event_bits);
178 
179 /* *
180 * @ingroup  iot_event
181 * @brief  Deletion event.CNcomment:删除事件。CNend
182 *
183 * @par 描述:
184 *           Defines the deletion event, releasing an event ID.CNcomment:删除事件,释放事件使用id。CNend
185 *
186 * @attention
187 *           @li The read/write event interface cannot be invoked before system initialization.
188 CNcomment:在系统初始化之前不能调用读写事件接口。CNend
189 *           @li In the interrupt, the event object can be written, but cannot be read.
190 CNcomment:在中断中,可以对事件对象进行写操作,但不能读操作。CNend
191 *           @li In the lock task scheduling state, a write operation can be performed on an event object, but the
192 *               read operation cannot be performed.CNcomment:在锁任务调度状态下,可以对事件对象进行写操作,
193 但不能读操作。CNend
194 *
195 * @param  id       [OUT]  type #hi_u32*,Event ID.
196 *
197 * @retval #0       Success.
198 * @retval #Other   Failure. For details, see hi_errno.h.
199 *
200 * @par 依赖:
201 *           @li hi_event.h:Describes event APIs.CNcomment:文件用于描述事件相关接口。CNend
202 * @see  hi_event_create。
203 * @since Hi3861_V100R001C00
204 */
205 hi_u32 hi_event_delete(hi_u32 id);
206 
207 /* *
208 * @ingroup  iot_event
209 * @brief  Initializes event resources.CNcomment:初始化事件资源。CNend
210 *
211 * @par 描述:
212 *           Initializes event resources. This API is called during system initialization only once.
213 CNcomment:初始化event资源,初始化阶段调用。CNend
214 *
215 * @attention Change the number of event resources based on the site requirements.
216 CNcomment:用户需根据实际使用情况修改event资源个数CNend
217 *
218 * @param  max_event_cnt   [IN] type #hi_u8,Number of event resources.CNcomment:event资源个数。CNend
219 * @param  event_space   [IN]   type #hi_pvoid,Event resource space. If the value is null,
220 * it indicates that the space is applied internally. If this parameter is not null,
221 * external space is used to create event resources. Currently, set this parameter to HI_NULL.
222 CNcomment:event资源空间。传空表示空间由内部申请;非空表示使用外部空间用于创建event资源。
223 当前请传HI_NULL。CNend
224 *
225 * @retval #0       Success.
226 * @retval #Other   Failure. For details, see hi_errno.h.
227 *
228 * @par 依赖:
229 *           @li hi_event.h:Describes event APIs.CNcomment:文件用于描述事件相关接口。CNend
230 * @see  None
231 * @since Hi3861_V100R001C00
232 */
233 hi_u32 hi_event_init(hi_u8 max_event_cnt, hi_pvoid event_space);
234 
235 #endif
236