Has anyone noticed the glaring bug in Due delay() function?
void delay( uint32_t ms )
{
uint32_t end = GetTickCount() + ms;
while (GetTickCount() < end)
yield();
}
[ Namely failure to deal with wrap-around ]
Suggested fix:
void delay (uint32_t ms)
{
if (ms == 0)
return ;
uint32_t start = GetTickCount () ;
do { yield () ; } while (GetTickCount() - start < ms) ;
}