udelay.c
354 Bytes
#include <os.h>
#include <bbint.h>
void
__osBbDelay(u32 usec) {
u32 start, count, sum;
u32 cycles;
start = osGetCount();
sum = 0;
cycles = OS_USEC_TO_CYCLES(usec);
do {
count = osGetCount();
if (count >= start)
sum += count-start;
else
sum += (0xFFFFFFFF-start)+count+1;
start = count;
} while(sum < cycles);
}