diff options
author | Joel Challis <git@zvecr.com> | 2021-08-16 17:28:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-16 17:28:12 +0100 |
commit | 2bc8215ce5f5c7473bb75de95cef4ab468d7e837 (patch) | |
tree | 3fa646a2a10cacc52f3e5e67d2cc6c1253d7c3a8 /tmk_core/common | |
parent | 4818debcd05819de774000bb641fea8baa49b787 (diff) | |
download | qmk_firmware-2bc8215ce5f5c7473bb75de95cef4ab468d7e837.tar.gz qmk_firmware-2bc8215ce5f5c7473bb75de95cef4ab468d7e837.zip |
Unify behaviour of wait on AVR (#14025)
Diffstat (limited to 'tmk_core/common')
-rw-r--r-- | tmk_core/common/avr/_wait.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/tmk_core/common/avr/_wait.h b/tmk_core/common/avr/_wait.h index 56eb316fa..ae1a25131 100644 --- a/tmk_core/common/avr/_wait.h +++ b/tmk_core/common/avr/_wait.h | |||
@@ -17,8 +17,26 @@ | |||
17 | 17 | ||
18 | #include <util/delay.h> | 18 | #include <util/delay.h> |
19 | 19 | ||
20 | #define wait_ms(ms) _delay_ms(ms) | 20 | #define wait_ms(ms) \ |
21 | #define wait_us(us) _delay_us(us) | 21 | do { \ |
22 | if (__builtin_constant_p(ms)) { \ | ||
23 | _delay_ms(ms); \ | ||
24 | } else { \ | ||
25 | for (uint16_t i = ms; i > 0; i--) { \ | ||
26 | _delay_ms(1); \ | ||
27 | } \ | ||
28 | } \ | ||
29 | } while (0) | ||
30 | #define wait_us(us) \ | ||
31 | do { \ | ||
32 | if (__builtin_constant_p(us)) { \ | ||
33 | _delay_us(us); \ | ||
34 | } else { \ | ||
35 | for (uint16_t i = us; i > 0; i--) { \ | ||
36 | _delay_us(1); \ | ||
37 | } \ | ||
38 | } \ | ||
39 | } while (0) | ||
22 | 40 | ||
23 | /* The AVR series GPIOs have a one clock read delay for changes in the digital input signal. | 41 | /* The AVR series GPIOs have a one clock read delay for changes in the digital input signal. |
24 | * But here's more margin to make it two clocks. */ | 42 | * But here's more margin to make it two clocks. */ |