这是农民讲习所的大作,有点疑问,比如串口中在接受中断中调用Queue_Push在主函数中调用Queue_Pop
//------------------------------------------------------------
//将数据压入队列
//------------------------------------------------------------
void Queue_Push( struct QueueBuffer idata * pQueueBuffer, unsigned char mData )
{
unsigned char idata *p;
p = pQueueBuffer->pIn;
*p++ = mData;
if (p == pQueueBuffer->aBufferEnd){
p = pQueueBuffer->aBufferStart;
}
pQueueBuffer->pIn = p;
pQueueBuffer->mCount ++;
}
//------------------------------------------------------------
//将数据弹出队列
//------------------------------------------------------------
unsigned char Queue_Pop( struct QueueBuffer idata *pQueueBuffer )
{
unsigned char mData;
unsigned char idata *p;
p = pQueueBuffer->pOut;
mData = *p;
if( ++p == pQueueBuffer->aBufferEnd ){
p = pQueueBuffer->aBufferStart;
}
pQueueBuffer->pOut = p;
pQueueBuffer->mCount --;
return mData;
} |