mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-24 12:22:57 +00:00
6e984a8b5e
Microsecond (us) delays are now handled by a busy wait loop according to MCU frequency. This replaces the system counter method which had an overhead of around 12us. TC5 device and supporting routines removed as it was the old us delay counter. wait_ms is now properly a macro to CLK_delay_ms. wait_us is now properly a macro to CLK_delay_us. Removed CLK_get_us as it has no use. All calls to CLK_get_ms() have been replaced by timer_read64() with corrected typing. All calls to CLK_delay_ms() have been replaced by wait_ms(). All calls to CLK_delay_us() have been replaced by wait_us() and timings verified or updated as needed after review on scope. Corrected typing of variables using 64bit ms timer readings if needed.
34 lines
681 B
C
34 lines
681 B
C
#ifndef WAIT_H
|
|
#define WAIT_H
|
|
|
|
#include <inttypes.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#if defined(__AVR__)
|
|
# include <util/delay.h>
|
|
# define wait_ms(ms) _delay_ms(ms)
|
|
# define wait_us(us) _delay_us(us)
|
|
#elif defined PROTOCOL_CHIBIOS
|
|
# include "ch.h"
|
|
# define wait_ms(ms) chThdSleepMilliseconds(ms)
|
|
# define wait_us(us) chThdSleepMicroseconds(us)
|
|
#elif defined PROTOCOL_ARM_ATSAM
|
|
# include "clks.h"
|
|
# define wait_ms(ms) CLK_delay_ms(ms)
|
|
# define wait_us(us) CLK_delay_us(us)
|
|
#elif defined(__arm__)
|
|
# include "wait_api.h"
|
|
#else // Unit tests
|
|
void wait_ms(uint32_t ms);
|
|
#define wait_us(us) wait_ms(us / 1000)
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|