#include /* for ARM_SYSTIMER_CLO */ #include /* for read32() */ #include /* for uint32_t */ #include /* for CLOCKHZ */ void gilbraltar_delay_hot_loop(uint32_t cycle) { volatile uint32_t v; for (v = 0; v < cycle; v++) ; } void gilbraltar_delay_us(uint32_t us) { if (us > 0) { uint32_t ticks = us * (CLOCKHZ / 1000000) + 1; uint32_t s = read32(ARM_SYSTIMER_CLO); while (read32(ARM_SYSTIMER_CLO) - s < ticks) ; } } void gilbraltar_delay_ms(uint32_t ms) { if (ms > 0) gilbraltar_delay_us(ms * 1000); }