WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
Event
Event 的协作图:

结构体

struct  tagEvent
 

宏定义

#define LOS_WAITMODE_AND   4U
 
#define LOS_WAITMODE_OR   2U
 
#define LOS_WAITMODE_CLR   1U
 
#define LOS_ERRNO_EVENT_SETBIT_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x00)
 
#define LOS_ERRNO_EVENT_READ_TIMEOUT   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x01)
 
#define LOS_ERRNO_EVENT_EVENTMASK_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x02)
 
#define LOS_ERRNO_EVENT_READ_IN_INTERRUPT   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x03)
 
#define LOS_ERRNO_EVENT_FLAGS_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x04)
 
#define LOS_ERRNO_EVENT_READ_IN_LOCK   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x05)
 
#define LOS_ERRNO_EVENT_PTR_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x06)
 
#define LOS_ERRNO_EVENT_READ_IN_SYSTEM_TASK   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x07)
 
#define LOS_ERRNO_EVENT_SHOULD_NOT_DESTORY   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x08)
 
#define LOS_EventCondRead(eventCB, eventCond, timeout)
 Read an event by condition.
 

类型定义

typedef struct tagEvent EVENT_CB_S
 
typedef struct tagEventPEVENT_CB_S
 

函数

UINT32 LOS_EventInit (PEVENT_CB_S eventCB)
 Initialize an event control block.
 
UINT32 LOS_EventPoll (UINT32 *eventId, UINT32 eventMask, UINT32 mode)
 Obtain an event specified by the event ID.
 
UINT32 LOS_EventRead (PEVENT_CB_S eventCB, UINT32 eventMask, UINT32 mode, UINT32 timeout)
 Read an event.
 
UINT32 LOS_EventWrite (PEVENT_CB_S eventCB, UINT32 events)
 Write an event.
 
UINT32 LOS_EventClear (PEVENT_CB_S eventCB, UINT32 events)
 Clear the event occurring in a specified task.
 
UINT32 LOS_EventDestroy (PEVENT_CB_S eventCB)
 Destroy an event.
 
UINT32 LOS_EventCondWrite (PEVENT_CB_S eventCB)
 Write an event by condition..
 

详细描述

宏定义说明

◆ LOS_ERRNO_EVENT_EVENTMASK_INVALID

#define LOS_ERRNO_EVENT_EVENTMASK_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x02)

Event reading error code: The EVENTMASK input parameter value is valid. The input parameter value must not be 0.

Value: 0x02001c02.

Solution: Pass in a valid EVENTMASK value.

◆ LOS_ERRNO_EVENT_FLAGS_INVALID

#define LOS_ERRNO_EVENT_FLAGS_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x04)

Event reading error code: The flag input parameter value used in the event reading API is invalid. This input parameter value is obtained by performing an OR operation on corresponding bits of either OS_EVENT_ANY or OS_EVENT_ANY and corresponding bits of either OS_EVENT_WAIT or OS_EVENT_NOWAIT. The waiting time must be set to a nonzero value when an event is read in the mode of OS_EVENT_WAIT.

Value: 0x02001c04.

Solution: Pass in a valid flag value.

◆ LOS_ERRNO_EVENT_PTR_NULL

#define LOS_ERRNO_EVENT_PTR_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x06)

Event reading error code: Null pointer.

Value: 0x02001c06.

Solution: Check whether the input parameter is null.

◆ LOS_ERRNO_EVENT_READ_IN_INTERRUPT

#define LOS_ERRNO_EVENT_READ_IN_INTERRUPT   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x03)

Event reading error code: The event is being read during an interrupt.

Value: 0x02001c03.

Solution: Read the event in a task.

◆ LOS_ERRNO_EVENT_READ_IN_LOCK

#define LOS_ERRNO_EVENT_READ_IN_LOCK   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x05)

Event reading error code: The task is locked and is unable to read the event.

Value: 0x02001c05.

Solution: Unlock the task and read the event.

◆ LOS_ERRNO_EVENT_READ_IN_SYSTEM_TASK

#define LOS_ERRNO_EVENT_READ_IN_SYSTEM_TASK   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x07)

Event reading error code: The event is being read in system-level task. old usage: The event is being read in software timer task (LOS_ERRNO_EVENT_READ_IN_SWTMR_TSK).

Value: 0x02001c07.

Solution: Read the event in a valid task.

弃用:
This error code is obsolete since LiteOS 5.0.0.

◆ LOS_ERRNO_EVENT_READ_TIMEOUT

#define LOS_ERRNO_EVENT_READ_TIMEOUT   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x01)

Event reading error code: Event reading times out.

Value: 0x02001c01.

Solution: Increase the waiting time for event reading, or make another task write a mask for the event.

◆ LOS_ERRNO_EVENT_SETBIT_INVALID

#define LOS_ERRNO_EVENT_SETBIT_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x00)

Event error code: Bit 25 of the event mask cannot be set to an event because it is set to an error code.

Value: 0x02001c00.

Solution: Set bits excluding bit 25 of the event mask to events.

◆ LOS_ERRNO_EVENT_SHOULD_NOT_DESTORY

#define LOS_ERRNO_EVENT_SHOULD_NOT_DESTORY   LOS_ERRNO_OS_ERROR(LOS_MOD_EVENT, 0x08)

Event reading error code: should not be distory.

Value: 0x02001c08.

Solution: Check whether the event list is not empty.

◆ LOS_EventCondRead

#define LOS_EventCondRead (   eventCB,
  eventCond,
  timeout 
)
值:
({ \
UINT32 ret = LOS_OK; \
UINT32 readTime = (timeout); \
\
while (!(eventCond)) { \
ret = EventCondRead(eventCB, &readTime); \
if (ret != LOS_OK) { \
break; \
} \
} \
ret = (eventCond) ? LOS_OK : ret; \
ret; \
})
UINT32 EventCondRead(PEVENT_CB_S eventCB, UINT32 *timeout)
#define LOS_OK
Definition los_typedef.h:122
unsigned int UINT32
Definition los_typedef.h:52

Read an event by condition.

Description:
This API is used to read a specified event control block. If #eventCond is not true, the task is blocked, and the waiting stops only when #eventCond is true or times out.
注意
Do not read event during an interrupt. Do not recommend to use this API in software timer callback. This API does not care about event masks. The user is responsible for the risks caused by eventCond. This API must be used together with LOS_EventCondWrite. Do not use EventCondRead.
参数
eventCB[IN/OUT] Type PEVENT_CB_S. Pointer to the event control block to be checked. This parameter must point to a valid memory.
eventCond[IN] Type BOOL. The condition used to measure whether an event is completed.
timeout[IN] Type UINT32. Timeout interval of event reading (unit: Tick).
返回值
TypeUINT32. LOS_ERRNO_EVENT_PTR_NULL The passed-in pointer is null.
TypeUINT32. LOS_ERRNO_EVENT_READ_IN_INTERRUPT The event is being read during an interrupt.
TypeUINT32. LOS_ERRNO_EVENT_READ_TIMEOUT The event reading times out.
TypeUINT32. LOS_ERRNO_EVENT_READ_IN_LOCK The event reading task is locked.
TypeUINT32. LOS_OK The event expected to occur by the user.
Dependency:
  • los_event.h: the header file that contains the API declaration.
参见
LOS_EventRead | LOS_EventWriteCondition

◆ LOS_WAITMODE_AND

#define LOS_WAITMODE_AND   4U

Event reading mode: The task waits for all its expected events to occur.

◆ LOS_WAITMODE_CLR

#define LOS_WAITMODE_CLR   1U

Event reading mode: The event flag is immediately cleared after the event is read.

◆ LOS_WAITMODE_OR

#define LOS_WAITMODE_OR   2U

Event reading mode: The task waits for any of its expected events to occur.

类型定义说明

◆ EVENT_CB_S

typedef struct tagEvent EVENT_CB_S

Event control structure

◆ PEVENT_CB_S

typedef struct tagEvent * PEVENT_CB_S

函数说明

◆ LOS_EventClear()

UINT32 LOS_EventClear ( PEVENT_CB_S  eventCB,
UINT32  events 
)
extern

Clear the event occurring in a specified task.

Description:
This API is used to set the ID of an event that has a specified mask and of which the information is stored in an event control block pointed to by eventCB to 0. eventCB must point to valid memory.
注意
The value of events needs to be reversed when it is passed-in.
参数
eventCB[IN/OUT] Pointer to the event control block to be cleared.
events[IN] Mask of the event to be cleared.
返回值
LOS_ERRNO_EVENT_PTR_NULLNull pointer.
LOS_OKThe event is successfully cleared.
Dependency:
  • los_event.h: the header file that contains the API declaration.
参见
LOS_EventPoll | LOS_EventRead | LOS_EventWrite
自从
Huawei LiteOS V100R001C00

◆ LOS_EventCondWrite()

UINT32 LOS_EventCondWrite ( PEVENT_CB_S  eventCB)
extern

Write an event by condition..

Description:
This API is used to write a specified event control block, and all tasks that read this #eventCB will be woken up.
注意
This API does not care about event masks. This API must be used together with LOS_EventCondRead.
参数
eventCB[IN/OUT] Pointer to the control block to which the event is to be written. This parameter must point to a valid memory.
返回值
LOS_ERRNO_EVENT_PTR_NULLNull pointer.
LOS_OKThe event is successfully written.
Dependency:
  • los_event.h: the header file that contains the API declaration.
参见
LOS_EventWrite | LOS_EventReadCondition

◆ LOS_EventDestroy()

UINT32 LOS_EventDestroy ( PEVENT_CB_S  eventCB)
extern

Destroy an event.

Description:
This API is used to destroy an event.
注意
The specific event should be a valid one.
参数
eventCB[IN/OUT] Pointer to the event control block to be destroyed.
返回值
LOS_ERRNO_EVENT_PTR_NULLNull pointer.
LOS_ERRNO_EVENT_SHOULD_NOT_DESTORYThe event should not be destroyed because the event list is not empty.
LOS_OKThe event is successfully cleared.
Dependency:
  • los_event.h: the header file that contains the API declaration.
参见
LOS_EventPoll | LOS_EventRead | LOS_EventWrite
自从
Huawei LiteOS V100R001C00

◆ LOS_EventInit()

UINT32 LOS_EventInit ( PEVENT_CB_S  eventCB)
extern

Initialize an event control block.

Description:
This API is used to initialize the event control block pointed to by eventCB.
注意
None.
参数
eventCB[IN/OUT] Pointer to the event control block to be initialized.
返回值
LOS_ERRNO_EVENT_PTR_NULLNull pointer.
LOS_OKThe event control block is successfully initialized.
Dependency:
  • los_event.h: the header file that contains the API declaration.
参见
LOS_EventClear
自从
Huawei LiteOS V100R001C00

◆ LOS_EventPoll()

UINT32 LOS_EventPoll ( UINT32 eventId,
UINT32  eventMask,
UINT32  mode 
)
extern

Obtain an event specified by the event ID.

Description:
This API is used to check whether an event expected by the user occurs according to the event ID, event mask, and event reading mode, and process the event based on the event reading mode. The event ID must point to valid memory.
注意
  • When the mode is LOS_WAITMODE_CLR, the eventId is passed-out.
  • Otherwise the eventId is passed-in.
  • An error code and an event return value can be same. To differentiate the error code and return value, bit 25 of the event mask is forbidden to be used.
参数
eventId[IN/OUT] Pointer to the ID of the event to be checked.
eventMask[IN] Mask of the event expected to occur by the user, indicating the event obtained after it is logically processed that matches the ID pointed to by eventId.
mode[IN] Event reading mode. The modes include LOS_WAITMODE_AND, LOS_WAITMODE_OR, LOS_WAITMODE_CLR.
返回值
LOS_ERRNO_EVENT_SETBIT_INVALIDBit 25 of the event mask cannot be set because it is set to an error number.
LOS_ERRNO_EVENT_EVENTMASK_INVALIDThe passed-in event mask is incorrect.
LOS_ERRNO_EVENT_FLAGS_INVALIDThe passed-in event mode is invalid.
LOS_ERRNO_EVENT_PTR_NULLThe passed-in pointer is null.
0The event expected by the user does not occur.
UINT32The event expected by the user occurs.
Dependency:
  • los_event.h: the header file that contains the API declaration.
参见
LOS_EventRead | LOS_EventWrite
自从
Huawei LiteOS V100R001C00

◆ LOS_EventRead()

UINT32 LOS_EventRead ( PEVENT_CB_S  eventCB,
UINT32  eventMask,
UINT32  mode,
UINT32  timeout 
)
extern

Read an event.

Description:
This API is used to block or schedule a task that reads an event of which the event control block, event mask, reading mode, and timeout information are specified.
注意
  • Do not read event during an interrupt.
  • An error code and an event return value can be same. To differentiate the error code and return value, bit 25 of the event mask is forbidden to be used.
  • Do not recommend to use this API in software timer callback.
参数
eventCB[IN/OUT] Pointer to the event control block to be checked. This parameter must point to valid memory.
eventMask[IN] Mask of the event expected to occur by the user, indicating the event obtained after it is logically processed that matches the ID pointed to by eventId.
mode[IN] Event reading mode.
timeout[IN] Timeout interval of event reading (unit: Tick).
返回值
LOS_ERRNO_EVENT_SETBIT_INVALIDBit 25 of the event mask cannot be set because it is set to an error number.
LOS_ERRNO_EVENT_EVENTMASK_INVALIDThe passed-in event reading mode is incorrect.
LOS_ERRNO_EVENT_READ_IN_INTERRUPTThe event is being read during an interrupt.
LOS_ERRNO_EVENT_FLAGS_INVALIDThe event mode is invalid.
LOS_ERRNO_EVENT_READ_IN_LOCKThe event reading task is locked.
LOS_ERRNO_EVENT_PTR_NULLThe passed-in pointer is null.
LOS_ERRNO_EVENT_READ_TIMEOUTThe event reading times out.
0The event expected by the user does not occur.
UINT32The event expected to occur by the user.
Dependency:
  • los_event.h: the header file that contains the API declaration.
参见
LOS_EventPoll | LOS_EventWrite
自从
Huawei LiteOS V100R001C00

◆ LOS_EventWrite()

UINT32 LOS_EventWrite ( PEVENT_CB_S  eventCB,
UINT32  events 
)
extern

Write an event.

Description:
This API is used to write an event specified by the passed-in event mask into an event control block pointed to by eventCB.
注意
To determine whether the LOS_EventRead API returns an event or an error code, bit 25 of the event mask is forbidden to be used.
参数
eventCB[IN/OUT] Pointer to the control block to which the event is to be written. This parameter must point to a valid memory.
events[IN] Event mask to be written.
返回值
LOS_ERRNO_EVENT_SETBIT_INVALIDBit 25 of the event mask cannot be set to an event because it is set to an error code.
LOS_ERRNO_EVENT_PTR_NULLNull pointer.
LOS_OKThe event is successfully written.
Dependency:
  • los_event.h: the header file that contains the API declaration.
参见
LOS_EventPoll | LOS_EventRead
自从
Huawei LiteOS V100R001C00