From 1615d768eaed8f5260d4c49b2c768634d275399f Mon Sep 17 00:00:00 2001 From: skullY Date: Tue, 22 Oct 2019 23:20:00 -0700 Subject: [PATCH 1/4] 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 cb1f386a61..3bec718810 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) From e5864cd471217db9775043026c171405e49e7de8 Mon Sep 17 00:00:00 2001 From: skullydazed Date: Tue, 22 Oct 2019 23:57:04 -0700 Subject: [PATCH 2/4] Update tmk_core/common/wait.h Co-Authored-By: Drashna Jaelre --- tmk_core/common/wait.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmk_core/common/wait.h b/tmk_core/common/wait.h index 3bec718810..286a36d4ca 100644 --- a/tmk_core/common/wait.h +++ b/tmk_core/common/wait.h @@ -14,7 +14,7 @@ extern "C" { #elif defined PROTOCOL_CHIBIOS # include "ch.h" // FIXME: This doesn't compile if `NKRO_ENABLED = no` -# define wait_ms(ms) chSysPolledDelayX(MS2RTC(STM32_SYSCLK, x)) +# define wait_ms(ms) chSysPolledDelayX(MS2RTC(STM32_SYSCLK, ms)) # define wait_us(us) chSysPolledDelayX(US2RTC(STM32_SYSCLK, x)) #elif defined PROTOCOL_ARM_ATSAM # include "clks.h" From e180496ab450b34cbc5b7e57ba09d0b25414b26e Mon Sep 17 00:00:00 2001 From: skullydazed Date: Tue, 22 Oct 2019 23:57:09 -0700 Subject: [PATCH 3/4] Update tmk_core/common/wait.h Co-Authored-By: Drashna Jaelre --- tmk_core/common/wait.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmk_core/common/wait.h b/tmk_core/common/wait.h index 286a36d4ca..8c4e6b0692 100644 --- a/tmk_core/common/wait.h +++ b/tmk_core/common/wait.h @@ -15,7 +15,7 @@ extern "C" { # include "ch.h" // FIXME: This doesn't compile if `NKRO_ENABLED = no` # define wait_ms(ms) chSysPolledDelayX(MS2RTC(STM32_SYSCLK, ms)) -# define wait_us(us) chSysPolledDelayX(US2RTC(STM32_SYSCLK, x)) +# define wait_us(us) chSysPolledDelayX(US2RTC(STM32_SYSCLK, us)) #elif defined PROTOCOL_ARM_ATSAM # include "clks.h" # define wait_ms(ms) CLK_delay_ms(ms) From 699e6b229bbc760cbea5acbcc4361d850a6e7204 Mon Sep 17 00:00:00 2001 From: skullydazed Date: Wed, 23 Oct 2019 13:35:39 -0700 Subject: [PATCH 4/4] Update tmk_core/common/wait.h Co-Authored-By: Joel Challis --- tmk_core/common/wait.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tmk_core/common/wait.h b/tmk_core/common/wait.h index 8c4e6b0692..469670fd10 100644 --- a/tmk_core/common/wait.h +++ b/tmk_core/common/wait.h @@ -13,6 +13,7 @@ extern "C" { # define wait_us(us) _delay_us(us) #elif defined PROTOCOL_CHIBIOS # include "ch.h" +# include "hal.h" // FIXME: This doesn't compile if `NKRO_ENABLED = no` # define wait_ms(ms) chSysPolledDelayX(MS2RTC(STM32_SYSCLK, ms)) # define wait_us(us) chSysPolledDelayX(US2RTC(STM32_SYSCLK, us))