Fix delay_us and delay_ns not showing up

This commit is contained in:
Jeremy Soller 2019-11-22 14:30:21 -07:00
parent 9cfd3a8d5a
commit da60fc9080
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
2 changed files with 11 additions and 10 deletions

View File

@ -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++) {

View File

@ -4,6 +4,17 @@
#include <stdint.h>
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