diff options
author | Takeshi ISHII <2170248+mtei@users.noreply.github.com> | 2021-08-24 22:34:24 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-24 14:34:24 +0100 |
commit | c9c60d227e38abdf08ca86bcdad3a0cac2579e3f (patch) | |
tree | 03ec990a4d98c4a94330e4cccaadc76bc7381c67 /tmk_core/common | |
parent | c4dbf4bf0118dd785802861beb247433b5b7411d (diff) | |
download | qmk_firmware-c9c60d227e38abdf08ca86bcdad3a0cac2579e3f.tar.gz qmk_firmware-c9c60d227e38abdf08ca86bcdad3a0cac2579e3f.zip |
add wait_cpuclock() macro for AVR and CPU_CLOCK macro (#12755)
Diffstat (limited to 'tmk_core/common')
-rw-r--r-- | tmk_core/common/avr/_wait.h | 4 | ||||
-rw-r--r-- | tmk_core/common/chibios/_wait.h | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/tmk_core/common/avr/_wait.h b/tmk_core/common/avr/_wait.h index ae1a25131..683db6ae5 100644 --- a/tmk_core/common/avr/_wait.h +++ b/tmk_core/common/avr/_wait.h | |||
@@ -37,6 +37,8 @@ | |||
37 | } \ | 37 | } \ |
38 | } \ | 38 | } \ |
39 | } while (0) | 39 | } while (0) |
40 | #define wait_cpuclock(n) __builtin_avr_delay_cycles(n) | ||
41 | #define CPU_CLOCK F_CPU | ||
40 | 42 | ||
41 | /* The AVR series GPIOs have a one clock read delay for changes in the digital input signal. | 43 | /* The AVR series GPIOs have a one clock read delay for changes in the digital input signal. |
42 | * But here's more margin to make it two clocks. */ | 44 | * But here's more margin to make it two clocks. */ |
@@ -44,4 +46,4 @@ | |||
44 | # define GPIO_INPUT_PIN_DELAY 2 | 46 | # define GPIO_INPUT_PIN_DELAY 2 |
45 | #endif | 47 | #endif |
46 | 48 | ||
47 | #define waitInputPinDelay() __builtin_avr_delay_cycles(GPIO_INPUT_PIN_DELAY) | 49 | #define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY) |
diff --git a/tmk_core/common/chibios/_wait.h b/tmk_core/common/chibios/_wait.h index 4a5172536..b740afbd2 100644 --- a/tmk_core/common/chibios/_wait.h +++ b/tmk_core/common/chibios/_wait.h | |||
@@ -41,6 +41,10 @@ void wait_us(uint16_t duration); | |||
41 | } while (0) | 41 | } while (0) |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | #include "_wait.c" | ||
45 | |||
46 | #define CPU_CLOCK STM32_SYSCLK | ||
47 | |||
44 | /* For GPIOs on ARM-based MCUs, the input pins are sampled by the clock of the bus | 48 | /* For GPIOs on ARM-based MCUs, the input pins are sampled by the clock of the bus |
45 | * to which the GPIO is connected. | 49 | * to which the GPIO is connected. |
46 | * The connected buses differ depending on the various series of MCUs. | 50 | * The connected buses differ depending on the various series of MCUs. |
@@ -51,11 +55,8 @@ void wait_us(uint16_t duration); | |||
51 | * If the GPIO_INPUT_PIN_DELAY macro is not defined, the following default values will be used. | 55 | * If the GPIO_INPUT_PIN_DELAY macro is not defined, the following default values will be used. |
52 | * (A fairly large value of 0.25 microseconds is set.) | 56 | * (A fairly large value of 0.25 microseconds is set.) |
53 | */ | 57 | */ |
54 | |||
55 | #include "_wait.c" | ||
56 | |||
57 | #ifndef GPIO_INPUT_PIN_DELAY | 58 | #ifndef GPIO_INPUT_PIN_DELAY |
58 | # define GPIO_INPUT_PIN_DELAY (STM32_SYSCLK / 1000000L / 4) | 59 | # define GPIO_INPUT_PIN_DELAY (CPU_CLOCK / 1000000L / 4) |
59 | #endif | 60 | #endif |
60 | 61 | ||
61 | #define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY) | 62 | #define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY) |