diff options
Diffstat (limited to 'tmk_core/common/chibios/_wait.h')
-rw-r--r-- | tmk_core/common/chibios/_wait.h | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/tmk_core/common/chibios/_wait.h b/tmk_core/common/chibios/_wait.h index 5bface53e1..4a5172536b 100644 --- a/tmk_core/common/chibios/_wait.h +++ b/tmk_core/common/chibios/_wait.h @@ -16,6 +16,7 @@ #pragma once #include <ch.h> +#include <hal.h> /* chThdSleepX of zero maps to infinite - so we map to a tiny delay to still yield */ #define wait_ms(ms) \ @@ -26,14 +27,19 @@ chThdSleepMicroseconds(1); \ } \ } while (0) -#define wait_us(us) \ - do { \ - if (us != 0) { \ - chThdSleepMicroseconds(us); \ - } else { \ - chThdSleepMicroseconds(1); \ - } \ - } while (0) + +#ifdef WAIT_US_TIMER +void wait_us(uint16_t duration); +#else +# define wait_us(us) \ + do { \ + if (us != 0) { \ + chThdSleepMicroseconds(us); \ + } else { \ + chThdSleepMicroseconds(1); \ + } \ + } while (0) +#endif /* For GPIOs on ARM-based MCUs, the input pins are sampled by the clock of the bus * to which the GPIO is connected. @@ -46,7 +52,7 @@ * (A fairly large value of 0.25 microseconds is set.) */ -#include "wait.c" +#include "_wait.c" #ifndef GPIO_INPUT_PIN_DELAY # define GPIO_INPUT_PIN_DELAY (STM32_SYSCLK / 1000000L / 4) |