From 1615d768eaed8f5260d4c49b2c768634d275399f Mon Sep 17 00:00:00 2001 From: skullY Date: Tue, 22 Oct 2019 23:20:00 -0700 Subject: [PATCH] Use the method @zvecr identified to wait more accurately on chibios --- tmk_core/common/wait.h | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/tmk_core/common/wait.h b/tmk_core/common/wait.h index cb1f386a616..3bec7188106 100644 --- a/tmk_core/common/wait.h +++ b/tmk_core/common/wait.h @@ -13,22 +13,9 @@ extern "C" { # define wait_us(us) _delay_us(us) #elif defined PROTOCOL_CHIBIOS # include "ch.h" -# define wait_ms(ms) \ - do { \ - if (ms != 0) { \ - chThdSleepMilliseconds(ms); \ - } else { \ - chThdSleepMicroseconds(1); \ - } \ - } while (0) -# define wait_us(us) \ - do { \ - if (us != 0) { \ - chThdSleepMicroseconds(us); \ - } else { \ - chThdSleepMicroseconds(1); \ - } \ - } while (0) +// FIXME: This doesn't compile if `NKRO_ENABLED = no` +# define wait_ms(ms) chSysPolledDelayX(MS2RTC(STM32_SYSCLK, x)) +# define wait_us(us) chSysPolledDelayX(US2RTC(STM32_SYSCLK, x)) #elif defined PROTOCOL_ARM_ATSAM # include "clks.h" # define wait_ms(ms) CLK_delay_ms(ms)