//*******************指令缓存队列*******************
struct{
uint32_t head;
uint32_t end;
uint16_t KeyBuf[10];
}KeyCQueue;
void KeyCQueue_init(void)
{
KeyCQueue.head = 0;
KeyCQueue.end = 0;
}
uint16_t KeyCQueue_GetQueue(void)//出队列
{
uint16_t value;
if(KeyCQueue.head == KeyCQueue.end) return 0;
value = KeyCQueue.KeyBuf[KeyCQueue.head];
KeyCQueue.head = (KeyCQueue.head + 1)%10;
KeyCQueue_Clear();
return value;
}
void KeyCQueue_EnQueue(uint16_t value)//入队列
{
if(KeyCQueue.head == (KeyCQueue.end + 1)%10) return ;
if(xxx==1)//如果xxx,指令不缓存
{
KeyCQueue.KeyBuf[KeyCQueue.end] = value;
KeyCQueue.end = (KeyCQueue.end + 1)%10;
}
}
void KeyCQueue_Clear(void)
{
KeyCQueue.head = 0;
KeyCQueue.end = 0;
}
指令缓存队列
于 2022-12-03 21:39:27 首次发布