PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

delay.h 1.0KB

3 years ago
123456789101112131415161718192021222324252627282930
  1. #include "Arduino.h"
  2. #ifdef __cplusplus
  3. extern "C" {
  4. #endif
  5. /***************************************************************************************************/
  6. // delayMicroseconds for 2 MHz cpu speed
  7. void delay_lp(uint32_t msec);
  8. uint32_t micros_lp(void);
  9. static inline void delayMicroseconds_lp(uint32_t) __attribute__((always_inline, unused));
  10. static inline void delayMicroseconds_lp(uint32_t usec) {
  11. uint32_t n = usec >> 1;
  12. if (n == 0) return;
  13. __asm__ volatile(
  14. "L_%=_delayMicroseconds:" "\n\t"
  15. "nop" "\n\t"
  16. #ifdef KINETISL
  17. "sub %0, #1" "\n\t"
  18. #else
  19. "subs %0, #1" "\n\t"
  20. #endif
  21. "bne L_%=_delayMicroseconds" "\n"
  22. : "+r" (n) :
  23. );
  24. }
  25. /***************************************************************************************************/
  26. #ifdef __cplusplus
  27. }
  28. #endif