We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
void cpostProcess(void) { size_t tick; for (size_t i = 0; i < CPOST_MAX_HANDLER_SIZE; i++) { if (cpostHandlers[i].handler) { tick = CPOST_GET_TICK(); if (cpostHandlers[i].time == 0 || (tick >= cpostHandlers[i].time ? CPOST_GET_TICK() >= cpostHandlers[i].time : CPOST_MAX_TICK - cpostHandlers[i].time + CPOST_GET_TICK())) { cpostHandlers[i].handler(cpostHandlers[i].param); cpostHandlers[i].handler = NULL; } } } }
CPOST_MAX_TICK - cpostHandlers[i].time + CPOST_GET_TICK() 这一个判断条件是当 tick<time 时执行,判断是否计时溢出。 这里的话 max >= time 肯定会为真,而只有 max-time=0 且 tick=0 时为假, 这会造成误判吗? 这里不会造成误判的前提是调用此函数的周期必须小于等于systick的周期吗?
The text was updated successfully, but these errors were encountered:
这里好像有问题,我验证下
Sorry, something went wrong.
No branches or pull requests
void cpostProcess(void)
{
size_t tick;
for (size_t i = 0; i < CPOST_MAX_HANDLER_SIZE; i++)
{
if (cpostHandlers[i].handler)
{
tick = CPOST_GET_TICK();
if (cpostHandlers[i].time == 0 ||
(tick >= cpostHandlers[i].time
? CPOST_GET_TICK() >= cpostHandlers[i].time
: CPOST_MAX_TICK - cpostHandlers[i].time + CPOST_GET_TICK()))
{
cpostHandlers[i].handler(cpostHandlers[i].param);
cpostHandlers[i].handler = NULL;
}
}
}
}
CPOST_MAX_TICK - cpostHandlers[i].time + CPOST_GET_TICK()
这一个判断条件是当 tick<time 时执行,判断是否计时溢出。
这里的话 max >= time 肯定会为真,而只有 max-time=0 且 tick=0 时为假,
这会造成误判吗?
这里不会造成误判的前提是调用此函数的周期必须小于等于systick的周期吗?
The text was updated successfully, but these errors were encountered: