在数据队列创建函数
uint8 QueueCreate(void *Buf,
uint32 SizeOfBuf,
uint8 (* ReadEmpty)(),
uint8 (* WriteFull)()
)
{
DataQueue *Queue;
if (Buf != NULL && SizeOfBuf >= (sizeof(DataQueue))) /* 判断参数是否有效 */
{
Queue = (DataQueue *)Buf;
OS_ENTER_CRITICAL();
/* 初始化结构体数据 */
Queue->MaxData = (SizeOfBuf - (uint32)(((DataQueue *)0)->Buf)) /
sizeof(QUEUE_DATA_TYPE);
Queue->End = Queue->Buf + Queue->MaxData; /* 计算数据缓冲的结束地址 */
Queue->Out = Queue->Buf;
Queue->In = Queue->Buf;
Queue->NData = 0;
Queue->ReadEmpty = ReadEmpty;
Queue->WriteFull = WriteFull;
OS_EXIT_CRITICAL();
return QUEUE_OK;
}
else
{
return NOT_OK;
}
}
中计算最大数据数目然后给了Queue->MaxData,试问一下(uint32)(((DataQueue *)0)->Buf该如何理解? |