Kiibohd Controller
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
Dieses Repo ist archiviert. Du kannst Dateien sehen und es klonen, kannst aber nicht pushen oder Issues/Pull-Requests öffnen.

delay.h 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef __DELAY_H
  2. #define __DELAY_H
  3. #include <stdint.h>
  4. // Convenience Macros, for delay compatibility with AVR-GCC
  5. #define _delay_ms(val) delay( val )
  6. #define _delay_us(val) delayMicroseconds( val )
  7. // the systick interrupt is supposed to increment this at 1 kHz rate
  8. extern volatile uint32_t systick_millis_count;
  9. static inline uint32_t millis(void) __attribute__((always_inline, unused));
  10. static inline uint32_t millis(void)
  11. {
  12. return systick_millis_count; // single aligned 32 bit is atomic;
  13. }
  14. static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
  15. static inline void delayMicroseconds(uint32_t usec)
  16. {
  17. #if F_CPU == 96000000
  18. uint32_t n = usec << 5;
  19. #elif F_CPU == 48000000
  20. uint32_t n = usec << 4;
  21. #elif F_CPU == 24000000
  22. uint32_t n = usec << 3;
  23. #endif
  24. asm volatile(
  25. "L_%=_delayMicroseconds:" "\n\t"
  26. "subs %0, #1" "\n\t"
  27. "bne L_%=_delayMicroseconds" "\n"
  28. : "+r" (n) :
  29. );
  30. }
  31. void yield(void) __attribute__ ((weak));
  32. uint32_t micros(void);
  33. void delay(uint32_t ms);
  34. #endif