11bd4fe43Sopenharmony_ci/**
21bd4fe43Sopenharmony_ci * @file hi_event.h
31bd4fe43Sopenharmony_ci *
41bd4fe43Sopenharmony_ci * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
51bd4fe43Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
61bd4fe43Sopenharmony_ci * you may not use this file except in compliance with the License.
71bd4fe43Sopenharmony_ci * You may obtain a copy of the License at
81bd4fe43Sopenharmony_ci *
91bd4fe43Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
101bd4fe43Sopenharmony_ci *
111bd4fe43Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
121bd4fe43Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
131bd4fe43Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
141bd4fe43Sopenharmony_ci * See the License for the specific language governing permissions and
151bd4fe43Sopenharmony_ci * limitations under the License.
161bd4fe43Sopenharmony_ci *
171bd4fe43Sopenharmony_ci * Description: system event API.CNcomment:系统事件接口。CNend
181bd4fe43Sopenharmony_ci * @li Before sending, waiting, or clearing an event, the event must be created to obtain the event ID.
191bd4fe43Sopenharmony_ciCNcomment:在发送、等待、清空事件之前首先需要创建事件,获取事件使用ID。CNend
201bd4fe43Sopenharmony_ci * @li Wait event: The wait event API cannot be called in the interrupt, interrupt off,
211bd4fe43Sopenharmony_ci * and lock task contexts to avoid uncontrollable exceptional scheduling.CNcomment:等待事件:在中断、
221bd4fe43Sopenharmony_ci关中断、锁任务上下文禁止调用等待事件接口,进而产生不可控的异常调度。CNend
231bd4fe43Sopenharmony_ci * @li TX event: The TX event API cannot be called in the interrupt off context to avoid uncontrollable
241bd4fe43Sopenharmony_ciexceptional scheduling.CNcomment:发送事件:在关中断上下文禁止调用发送事件接口,
251bd4fe43Sopenharmony_ci进而产生不可控的异常调度。CNend
261bd4fe43Sopenharmony_ci * @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.
271bd4fe43Sopenharmony_ciCNcomment:一个事件的[0:23]bit的每一bit可以表示一种事件,每一位的意义由用户自定义分配。CNend
281bd4fe43Sopenharmony_ci * @li Bit[24:31] of an event are reserved and cannot be used by the user.
291bd4fe43Sopenharmony_ciCNcomment:一个事件的[24:31]bit系统保留,用户不得使用。CNend   \n
301bd4fe43Sopenharmony_ci */
311bd4fe43Sopenharmony_ci
321bd4fe43Sopenharmony_ci/**
331bd4fe43Sopenharmony_ci * @defgroup iot_event Event
341bd4fe43Sopenharmony_ci * @ingroup osa
351bd4fe43Sopenharmony_ci */
361bd4fe43Sopenharmony_ci#ifndef __HI_EVENT_H__
371bd4fe43Sopenharmony_ci#define __HI_EVENT_H__
381bd4fe43Sopenharmony_ci#include <hi_types_base.h>
391bd4fe43Sopenharmony_ci
401bd4fe43Sopenharmony_ci#define HI_INVALID_EVENT_ID           0xffffffff   /**< Failed to obtain the event ID.CNcoment:获取事件ID失败CNend  */
411bd4fe43Sopenharmony_ci#define HI_EVENT_WAITMODE_AND         4            /**< If all expected events occur, the wait is successful.
421bd4fe43Sopenharmony_ci                                                        It cannot be used with HI_EVENT_WAITMODE_OR at the same time.
431bd4fe43Sopenharmony_ci                                                        CNcomment:所有预期等待的事件均发生时,才认定等待成功,
441bd4fe43Sopenharmony_ci                                                        不允许与HI_EVENT_WAITMODE_OR同时使用 CNend */
451bd4fe43Sopenharmony_ci#define HI_EVENT_WAITMODE_OR          2            /**< If any of the expected events occurs, the wait is successful.
461bd4fe43Sopenharmony_ci                                                        It cannot be used with HI_EVENT_WAITMODE_AND at the same time.
471bd4fe43Sopenharmony_ci                                                        CNcomment:所有预期等待的事件发生任意一种,认定等待成功,
481bd4fe43Sopenharmony_ci                                                        不允许与HI_EVENT_WAITMODE_AND同时使用 CNend */
491bd4fe43Sopenharmony_ci#define HI_EVENT_WAITMODE_CLR         1            /**< The waited event is cleared when the wait event is successful.
501bd4fe43Sopenharmony_ci                                                        CNcomment:等待事件成功时,清除等待到的事件CNend  */
511bd4fe43Sopenharmony_ci
521bd4fe43Sopenharmony_ci/**
531bd4fe43Sopenharmony_ci* @ingroup  iot_event
541bd4fe43Sopenharmony_ci* @brief  Creates an event.CNcomment:创建事件。CNend
551bd4fe43Sopenharmony_ci*
561bd4fe43Sopenharmony_ci* @par 描述:
571bd4fe43Sopenharmony_ci*           Creates an event to obtain the event ID.CNcomment:创建事件,获取事件使用ID。CNend
581bd4fe43Sopenharmony_ci*
591bd4fe43Sopenharmony_ci* @attention
601bd4fe43Sopenharmony_ci*           @li The read/write event interface cannot be invoked before system initialization.
611bd4fe43Sopenharmony_ciCNcomment:在系统初始化之前不能调用读写事件接口。CNend
621bd4fe43Sopenharmony_ci*           @li In the interrupt, the event object can be written, but cannot be read.
631bd4fe43Sopenharmony_ciCNcomment:在中断中,可以对事件对象进行写操作,但不能读操作。CNend
641bd4fe43Sopenharmony_ci*           @li In the lock task scheduling state, a write operation can be performed on an event object, but the
651bd4fe43Sopenharmony_ci*               read operation cannot be performed.CNcomment:在锁任务调度状态下,可以对事件对象进行写操作,
661bd4fe43Sopenharmony_ci但不能读操作。CNend
671bd4fe43Sopenharmony_ci*
681bd4fe43Sopenharmony_ci* @param  id       [OUT] type #hi_u32*,Event ID.
691bd4fe43Sopenharmony_ci*
701bd4fe43Sopenharmony_ci* @retval #0       Success.
711bd4fe43Sopenharmony_ci* @retval #Other   Failure. For details, see hi_errno.h.
721bd4fe43Sopenharmony_ci*
731bd4fe43Sopenharmony_ci* @par 依赖:
741bd4fe43Sopenharmony_ci*           @li hi_event.h:Describes event APIs.CNcomment:文件用于描述事件相关接口。CNend
751bd4fe43Sopenharmony_ci* @see  hi_event_delete。
761bd4fe43Sopenharmony_ci*/
771bd4fe43Sopenharmony_cihi_u32 hi_event_create(HI_OUT hi_u32 *id);
781bd4fe43Sopenharmony_ci
791bd4fe43Sopenharmony_ci/**
801bd4fe43Sopenharmony_ci* @ingroup  iot_event
811bd4fe43Sopenharmony_ci* @brief  Defines the TX event. CNcomment:发送事件。CNend
821bd4fe43Sopenharmony_ci*
831bd4fe43Sopenharmony_ci* @par 描述:
841bd4fe43Sopenharmony_ci*           Defines the TX event.CNcomment:发送事件。CNend
851bd4fe43Sopenharmony_ci*
861bd4fe43Sopenharmony_ci* @attention
871bd4fe43Sopenharmony_ci*           @li The read/write event interface cannot be invoked before system initialization.
881bd4fe43Sopenharmony_ciCNcomment:在系统初始化之前不能调用读写事件接口。CNend
891bd4fe43Sopenharmony_ci*           @li In the interrupt, the event object can be written, but cannot be read.
901bd4fe43Sopenharmony_ciCNcomment:在中断中,可以对事件对象进行写操作,但不能读操作。CNend
911bd4fe43Sopenharmony_ci*           @li In the lock task scheduling state, a write operation can be performed on an event object, but the
921bd4fe43Sopenharmony_ci*               read operation cannot be performed.CNcomment:在锁任务调度状态下,可以对事件对象进行写操作,
931bd4fe43Sopenharmony_ci但不能读操作。CNend
941bd4fe43Sopenharmony_ci*
951bd4fe43Sopenharmony_ci* @param  id         [IN]  type #hi_u32,Event ID.
961bd4fe43Sopenharmony_ci* @param  event_bits [IN] type #hi_u32,Set of events to be sent.CNcomment:事件bit位。CNend
971bd4fe43Sopenharmony_ci*
981bd4fe43Sopenharmony_ci* @retval #0       Success.
991bd4fe43Sopenharmony_ci* @retval #Other   Failure. For details, see hi_errno.h.
1001bd4fe43Sopenharmony_ci*
1011bd4fe43Sopenharmony_ci* @par 依赖:
1021bd4fe43Sopenharmony_ci*           @li hi_event.h:Describes event APIs.CNcomment:文件用于描述事件相关接口。CNend
1031bd4fe43Sopenharmony_ci* @see  hi_event_wait。
1041bd4fe43Sopenharmony_ci*/
1051bd4fe43Sopenharmony_cihi_u32 hi_event_send(hi_u32 id, hi_u32 event_bits);
1061bd4fe43Sopenharmony_ci
1071bd4fe43Sopenharmony_ci/**
1081bd4fe43Sopenharmony_ci* @ingroup  iot_event
1091bd4fe43Sopenharmony_ci* @brief  Defines the wait event.CNcomment:等待事件。CNend
1101bd4fe43Sopenharmony_ci*
1111bd4fe43Sopenharmony_ci* @par 描述:
1121bd4fe43Sopenharmony_ci*          Defines the wait event.CNcomment:等待事件。CNend
1131bd4fe43Sopenharmony_ci*
1141bd4fe43Sopenharmony_ci* @attention
1151bd4fe43Sopenharmony_ci*           @li The read/write event interface cannot be invoked before system initialization.
1161bd4fe43Sopenharmony_ciCNcomment:在系统初始化之前不能调用读写事件接口。CNend
1171bd4fe43Sopenharmony_ci*           @li In the interrupt, the event object can be written, but cannot be read.
1181bd4fe43Sopenharmony_ciCNcomment:在中断中,可以对事件对象进行写操作,但不能读操作。CNend
1191bd4fe43Sopenharmony_ci*           @li In the lock task scheduling state, a write operation can be performed on an event object, but the
1201bd4fe43Sopenharmony_ci*               read operation cannot be performed.CNcomment:在锁任务调度状态下,可以对事件对象进行写操作,
1211bd4fe43Sopenharmony_ci但不能读操作。CNend
1221bd4fe43Sopenharmony_ci*
1231bd4fe43Sopenharmony_ci* @param  id         [IN] type #hi_u32,Event ID.
1241bd4fe43Sopenharmony_ci* @param  mask       [IN] type #hi_u32,Set of events to be waited for, which may be one bit or multiple bits in
1251bd4fe43Sopenharmony_ci*                    bits 0-23.CNcomment:预等待的事件集合,可以为0~23bit中的1bit或多bit。CNend
1261bd4fe43Sopenharmony_ci* @param  event_bits [OUT] type #hi_u32*,Set of events to be sent.CNcomment:事件bit位。CNend
1271bd4fe43Sopenharmony_ci* @param  timeout    [IN] type #hi_u32,Waiting timeout period (unit: ms).
1281bd4fe43Sopenharmony_ciCNcomment:等待超时时间(单位:ms)。CNend
1291bd4fe43Sopenharmony_ci* @param  flag       [IN] type #hi_u32,Waiting option. For details, see #HI_EVENT_WAITMODE_AND,
1301bd4fe43Sopenharmony_ci*                    #HI_EVENT_WAITMODE_OR, and #HI_EVENT_WAITMODE_CLR.
1311bd4fe43Sopenharmony_ciCNcomment:等待选项,取值见#HI_EVENT_WAITMODE_AND、#HI_EVENT_WAITMODE_OR、#HI_EVENT_WAITMODE_CLR。CNend
1321bd4fe43Sopenharmony_ci*
1331bd4fe43Sopenharmony_ci* @retval #0       Success.
1341bd4fe43Sopenharmony_ci* @retval #Other   Failure. For details, see hi_errno.h.
1351bd4fe43Sopenharmony_ci*
1361bd4fe43Sopenharmony_ci* @par 依赖:
1371bd4fe43Sopenharmony_ci*           @li hi_event.h:Describes event APIs.CNcomment:文件用于描述事件相关接口。CNend
1381bd4fe43Sopenharmony_ci* @see  hi_event_send。
1391bd4fe43Sopenharmony_ci*/
1401bd4fe43Sopenharmony_cihi_u32 hi_event_wait(hi_u32 id, hi_u32 mask, HI_OUT hi_u32 *event_bits, hi_u32 timeout, hi_u32 flag);
1411bd4fe43Sopenharmony_ci
1421bd4fe43Sopenharmony_ci/**
1431bd4fe43Sopenharmony_ci* @ingroup  iot_event
1441bd4fe43Sopenharmony_ci* @brief  Defines the clearing event.CNcomment:清除事件。CNend
1451bd4fe43Sopenharmony_ci*
1461bd4fe43Sopenharmony_ci* @par 描述:
1471bd4fe43Sopenharmony_ci*           Defines the clearing event.CNcomment:清除事件。CNend
1481bd4fe43Sopenharmony_ci*
1491bd4fe43Sopenharmony_ci* @attention
1501bd4fe43Sopenharmony_ci*           @li The read/write event interface cannot be invoked before system initialization.
1511bd4fe43Sopenharmony_ciCNcomment:在系统初始化之前不能调用读写事件接口。CNend
1521bd4fe43Sopenharmony_ci*           @li In the interrupt, the event object can be written, but cannot be read.
1531bd4fe43Sopenharmony_ciCNcomment:在中断中,可以对事件对象进行写操作,但不能读操作。CNend
1541bd4fe43Sopenharmony_ci*           @li In the lock task scheduling state, a write operation can be performed on an event object, but the
1551bd4fe43Sopenharmony_ci*               read operation cannot be performed.CNcomment:在锁任务调度状态下,可以对事件对象进行写操作,
1561bd4fe43Sopenharmony_ci但不能读操作。CNend
1571bd4fe43Sopenharmony_ci*
1581bd4fe43Sopenharmony_ci* @param  id         [IN] type #hi_u32,Event ID.
1591bd4fe43Sopenharmony_ci* @param  event_bits [IN] type #hi_u32,Set of events to be cleared, which may be one bit or multiple bits in
1601bd4fe43Sopenharmony_ci*                    bits 0-23.CNcomment:清除的事件集合,可以为0~23bit中的1bit或多bit。CNend
1611bd4fe43Sopenharmony_ci*
1621bd4fe43Sopenharmony_ci* @retval #0       Success.
1631bd4fe43Sopenharmony_ci* @retval #Other   Failure. For details, see hi_errno.h.
1641bd4fe43Sopenharmony_ci*
1651bd4fe43Sopenharmony_ci* @par 依赖:
1661bd4fe43Sopenharmony_ci*           @li hi_event.h:Describes event APIs.CNcomment:文件用于描述事件相关接口。CNend
1671bd4fe43Sopenharmony_ci* @see  hi_event_wait。
1681bd4fe43Sopenharmony_ci*/
1691bd4fe43Sopenharmony_cihi_u32 hi_event_clear(hi_u32 id, hi_u32 event_bits);
1701bd4fe43Sopenharmony_ci
1711bd4fe43Sopenharmony_ci/**
1721bd4fe43Sopenharmony_ci* @ingroup  iot_event
1731bd4fe43Sopenharmony_ci* @brief  Deletion event.CNcomment:删除事件。CNend
1741bd4fe43Sopenharmony_ci*
1751bd4fe43Sopenharmony_ci* @par 描述:
1761bd4fe43Sopenharmony_ci*           Defines the deletion event, releasing an event ID.CNcomment:删除事件,释放事件使用id。CNend
1771bd4fe43Sopenharmony_ci*
1781bd4fe43Sopenharmony_ci* @attention
1791bd4fe43Sopenharmony_ci*           @li The read/write event interface cannot be invoked before system initialization.
1801bd4fe43Sopenharmony_ciCNcomment:在系统初始化之前不能调用读写事件接口。CNend
1811bd4fe43Sopenharmony_ci*           @li In the interrupt, the event object can be written, but cannot be read.
1821bd4fe43Sopenharmony_ciCNcomment:在中断中,可以对事件对象进行写操作,但不能读操作。CNend
1831bd4fe43Sopenharmony_ci*           @li In the lock task scheduling state, a write operation can be performed on an event object, but the
1841bd4fe43Sopenharmony_ci*               read operation cannot be performed.CNcomment:在锁任务调度状态下,可以对事件对象进行写操作,
1851bd4fe43Sopenharmony_ci但不能读操作。CNend
1861bd4fe43Sopenharmony_ci*
1871bd4fe43Sopenharmony_ci* @param  id       [IN]  type #hi_u32,Event ID.
1881bd4fe43Sopenharmony_ci*
1891bd4fe43Sopenharmony_ci* @retval #0       Success.
1901bd4fe43Sopenharmony_ci* @retval #Other   Failure. For details, see hi_errno.h.
1911bd4fe43Sopenharmony_ci*
1921bd4fe43Sopenharmony_ci* @par 依赖:
1931bd4fe43Sopenharmony_ci*           @li hi_event.h:Describes event APIs.CNcomment:文件用于描述事件相关接口。CNend
1941bd4fe43Sopenharmony_ci* @see  hi_event_create。
1951bd4fe43Sopenharmony_ci*/
1961bd4fe43Sopenharmony_cihi_u32 hi_event_delete(hi_u32 id);
1971bd4fe43Sopenharmony_ci
1981bd4fe43Sopenharmony_ci/**
1991bd4fe43Sopenharmony_ci* @ingroup  iot_event
2001bd4fe43Sopenharmony_ci* @brief  Initializes event resources.CNcomment:初始化事件资源。CNend
2011bd4fe43Sopenharmony_ci*
2021bd4fe43Sopenharmony_ci* @par 描述:
2031bd4fe43Sopenharmony_ci*           Initializes event resources. This API is called during system initialization only once.
2041bd4fe43Sopenharmony_ciCNcomment:初始化event资源,初始化阶段调用。CNend
2051bd4fe43Sopenharmony_ci*
2061bd4fe43Sopenharmony_ci* @attention Change the number of event resources based on the site requirements.
2071bd4fe43Sopenharmony_ciCNcomment:用户需根据实际使用情况修改event资源个数CNend
2081bd4fe43Sopenharmony_ci*
2091bd4fe43Sopenharmony_ci* @param  max_event_cnt   [IN] type #hi_u8,Number of event resources.CNcomment:event资源个数。CNend
2101bd4fe43Sopenharmony_ci* @param  event_space   [IN]   type #hi_pvoid,Event resource space. If the value is null,
2111bd4fe43Sopenharmony_ci* it indicates that the space is applied internally. If this parameter is not null,
2121bd4fe43Sopenharmony_ci* external space is used to create event resources. Currently, set this parameter to HI_NULL.
2131bd4fe43Sopenharmony_ciCNcomment:event资源空间。传空表示空间由内部申请;非空表示使用外部空间用于创建event资源。
2141bd4fe43Sopenharmony_ci当前请传HI_NULL。CNend
2151bd4fe43Sopenharmony_ci*
2161bd4fe43Sopenharmony_ci* @retval #0       Success.
2171bd4fe43Sopenharmony_ci* @retval #Other   Failure. For details, see hi_errno.h.
2181bd4fe43Sopenharmony_ci*
2191bd4fe43Sopenharmony_ci* @par 依赖:
2201bd4fe43Sopenharmony_ci*           @li hi_event.h:Describes event APIs.CNcomment:文件用于描述事件相关接口。CNend
2211bd4fe43Sopenharmony_ci* @see  None
2221bd4fe43Sopenharmony_ci*/
2231bd4fe43Sopenharmony_cihi_u32 hi_event_init(hi_u8 max_event_cnt, hi_pvoid event_space);
2241bd4fe43Sopenharmony_ci
2251bd4fe43Sopenharmony_ci#endif
2261bd4fe43Sopenharmony_ci
227