📄 rzkcreateeventgroup.c
字号:
/*
* File : RZKCreateEventGroup
*
* Description : This file defines an API to create an event group.
*
* Copyright 2004 ZiLOG Inc. ALL RIGHTS RESERVED.
*
* This file contains unpublished confidential and proprietary information
* of ZiLOG, Inc.
* NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED
* IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
* This is not a license and no use of any kind of this work is authorized
* in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's
* sole discretion
*/
#include <string.h>
#include "ZSysgen.h"
#include "ZTypes.h"
#include "ZThread.h"
#include "ZEventgroup.h"
#include "externvar.h"
#define pCurrentThread ((RZK_TCB_t *) hCurrentThread)
/** extern functions */
extern void* RZKMemcpy(void *, const void *, RZK_LENGTH_t); // IAR port, UINT changed to RZK_LENGTH_t
extern RZK_HANDLE_t AcquireControlBlock (RZK_TCB_t *, UINT, UINT);
/** extern variables */
extern RZK_THREADHANDLE_t hCurrentThread;
extern RZK_EG_CB_t nEventGroup[];
/* Function : RZKCreateEventGroup
*
* Description : This function creates an event group and initializes
* parameters in the eventgroup control block.
*
* Inputs : szName - name of EventGroup
* mEventMask - Mask value for the EventGroup.
*
* Outputs : Handle to event group or NULL on failure
*
*
* Dependencies : hCurrentThread
*/
RZK_EVENTHANDLE_t RZKCreateEventGroup
(
RZK_NAME_t szName[MAX_OBJECT_NAME_LEN],
RZK_MASK_t mEventMask
)
{
/* Local Variable */
RZK_EVENTGROUP_t *hEventGroup;
/* CALL AcquireEventControlBlock FUNCTION */
hEventGroup = (RZK_EVENTGROUP_t *)
AcquireControlBlock((RZK_TCB_t *) &nEventGroup[0],
MAX_EVENTGROUPS, sizeof(RZK_EVENTGROUP_t));/* Changed on 08-05-03 */
/*This function sets the BUSY bit in Event Control Block */
#ifndef RZK_PERFORMANCE
if (hEventGroup == NULL)
{
pCurrentThread->errNum = RZKERR_CB_UNAVAILABLE;
return NULL;
}
#endif
/* Initialise all parameters */
#ifdef RZK_KERNEL_AWARE
RZKMemcpy(hEventGroup->szName,szName, MAX_OBJECT_NAME_LEN);
#endif /* RZK_KERNEL_AWARE */
#ifdef RZK_DEBUG
hEventGroup->magic_num = MAGIC_NUM_EVENT;
#endif
hEventGroup->uMask = mEventMask;
hEventGroup->eEventsReceived = 0;
hEventGroup->pLastPosition = hEventGroup->pResNext = ( RZK_TCB_t* ) NULL;
/* Set the OBJECT_CREATED and OBJECT_BUSY flags in the uState of the EventGroup structure */
hEventGroup->uState = OBJECT_CREATED | OBJECT_BUSY;
pCurrentThread->errNum = RZKERR_SUCCESS;
return hEventGroup;
} /* End of RZKCreateEventGroup */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -