typedef struct {
u8 head;
u8 tail;
u8 len;
}ListSt;
#define UART_BUFF_SIZE 100
u8 g_listBuff[UART_BUFF_SIZE];
ListSt g_uartListTcb = {0};
void AddItem(u8 dat)
{
if (g_uartListTcb.len == UART_BUFF_SIZE)
{
return;
}
g_listBuff[g_uartListTcb.tail] = dat;
g_uartListTcb.len++;
(g_uartListTcb.tail++) %= UART_BUFF_SIZE;
}
u8 GetItem(void)
{
u8 ret;
if (GetItem() == 0)
{
return;
}
ret = g_listBuff[g_uartListTcb.head];
g_uartListTcb.head++;
g_uartListTcb.head %= UART_BUFF_SIZE;
g_uartListTcb.len--;
return ret;
}
u8 GetItemRemain(void)
{
return g_uartListTcb.len;
}
|