diff --git a/src/arch/8051/delay.c b/src/arch/8051/delay.c index 4a27b24..5003ff4 100644 --- a/src/arch/8051/delay.c +++ b/src/arch/8051/delay.c @@ -9,16 +9,6 @@ void delay_ticks(uint16_t ticks) { timer_stop(); } -// 1 us * 9.2 MHz / 12 is 69/90 -// Warning: this will round to the nearest tick -#define delay_us(X) \ - delay_ticks((uint16_t)((((uint32_t)(X)) * 69UL + 89UL) / 90UL)); - -// 1 ns * 9.2 MHz / 12 is 69/90000 -// Warning: this will round to the nearest tick -#define delay_ns(X) \ - delay_ticks((uint16_t)((((uint32_t)(X)) * 69UL + 89999UL) / 90000UL)); - // This loops through delays of one ms in order to avoid overflow void delay_ms(int ms) { for (int i = 0; i < ms; i++) { diff --git a/src/arch/8051/include/arch/delay.h b/src/arch/8051/include/arch/delay.h index c7393e7..30fa7db 100644 --- a/src/arch/8051/include/arch/delay.h +++ b/src/arch/8051/include/arch/delay.h @@ -4,6 +4,17 @@ #include void delay_ticks(uint16_t ticks); + +// 1 us * 9.2 MHz / 12 is 69/90 +// Warning: this will round to the nearest tick +#define delay_us(X) \ + delay_ticks((uint16_t)((((uint32_t)(X)) * 69UL + 89UL) / 90UL)); + +// 1 ns * 9.2 MHz / 12 is 69/90000 +// Warning: this will round to the nearest tick +#define delay_ns(X) \ + delay_ticks((uint16_t)((((uint32_t)(X)) * 69UL + 89999UL) / 90000UL)); + void delay_ms(int ms); #endif // _ARCH_DELAY_H