更新一下 我在楼主位的函数,希望给个更好的方法
BOOLEAN CBTimeDly(INT8U tc, INT16U milli)
{
static __IO INT16U ticks[TC_TOTAL + 1] = {0};
static BOOLEAN time1st_OK = TRUE;
BOOLEAN timeOut_OK = FALSE;
INT8U loops = 0;
if (tc <= TC_TOTAL) {
CB_UsedTC_标志寄存器_g = (INT16U)((INT16U)CB_UsedTC_标志寄存器_g | (INT16U)((INT16U)(1 << tc)));
if (time1st_OK) {
time1st_OK = FALSE;
for (loops = 0; loops <= TC_TOTAL; loops++) {
ticks[loops] = CBTime_Get();
}
}
else {
if ((CBTime_Get() - ticks[tc]) >= milli) {
ticks[tc] = CBTime_Get();
timeOut_OK = TRUE;
}
else {
timeOut_OK = FALSE;
};
}
}
else {
timeOut_OK = FALSE;
}
return timeOut_OK;
}
|