📄 ringlst.c
字号:
#define IN_RINGLST
#include "config.h"
void initRingList(RING_LST pRingLst,char * pBuf,int bufLen)
{
int i;
if(pRingLst==NULL)
{
return;
}
OS_ENTER_CRITICAL();
for(i=0;i<bufLen;i++)
{
pBuf[i]=0;
}
pRingLst->pBuf=pBuf;
pRingLst->bufLen=bufLen;
pRingLst->posAdd=0;
pRingLst->posGet=0;
pRingLst->usedBuf=0;
pRingLst->semSync=OSSemCreate(0);
OS_EXIT_CRITICAL();
return;
}
void addRingLst(RING_LST pRingLst,char n)
{
if(pRingLst==NULL)
{
return;
}
OS_ENTER_CRITICAL();
if(pRingLst->usedBuf<pRingLst->bufLen)
{
pRingLst->pBuf[pRingLst->posAdd]=n;
pRingLst->posAdd=(pRingLst->posAdd+1)%pRingLst->bufLen;
pRingLst->usedBuf++;
}
OS_EXIT_CRITICAL();
return;
}
uint8 getRingLst(RING_LST pRingLst,char *n)
{
if(pRingLst==NULL)
{
return FALSE;
}
OS_ENTER_CRITICAL();
if(pRingLst->usedBuf>0)
{
*n=pRingLst->pBuf[pRingLst->posGet];
pRingLst->posGet=(pRingLst->posGet+1)%pRingLst->bufLen;
pRingLst->usedBuf--;
OS_EXIT_CRITICAL();
return TRUE;
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -