mirror of
https://github.com/openstenoproject/qmk
synced 2024-11-22 00:14:38 +00:00
Unify behaviour of wait on AVR (#14025)
This commit is contained in:
parent
4818debcd0
commit
2bc8215ce5
1 changed files with 20 additions and 2 deletions
|
@ -17,8 +17,26 @@
|
|||
|
||||
#include <util/delay.h>
|
||||
|
||||
#define wait_ms(ms) _delay_ms(ms)
|
||||
#define wait_us(us) _delay_us(us)
|
||||
#define wait_ms(ms) \
|
||||
do { \
|
||||
if (__builtin_constant_p(ms)) { \
|
||||
_delay_ms(ms); \
|
||||
} else { \
|
||||
for (uint16_t i = ms; i > 0; i--) { \
|
||||
_delay_ms(1); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#define wait_us(us) \
|
||||
do { \
|
||||
if (__builtin_constant_p(us)) { \
|
||||
_delay_us(us); \
|
||||
} else { \
|
||||
for (uint16_t i = us; i > 0; i--) { \
|
||||
_delay_us(1); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* The AVR series GPIOs have a one clock read delay for changes in the digital input signal.
|
||||
* But here's more margin to make it two clocks. */
|
||||
|
|
Loading…
Reference in a new issue