time.h 880 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * time.h
  3. *
  4. * System-time abstraction over STM32 STK timer.
  5. *
  6. * Written & released by Keir Fraser <keir.xen@gmail.com>
  7. *
  8. * This is free and unencumbered software released into the public domain.
  9. * See the file COPYING for more details, or visit <http://unlicense.org>.
  10. */
  11. typedef uint32_t time_t;
  12. #define TIME_MHZ STK_MHZ
  13. #define time_us(x) stk_us(x)
  14. #define time_ms(x) stk_ms(x)
  15. #define time_sysclk(x) stk_sysclk(x)
  16. #define sysclk_time(x) sysclk_stk(x)
  17. time_t time_now(void);
  18. #define time_diff(x,y) ((int32_t)((y)-(x))) /* d = y - x */
  19. #define time_add(x,d) ((time_t)((x)+(d))) /* y = x + d */
  20. #define time_sub(x,d) ((time_t)((x)-(d))) /* y = x - d */
  21. #define time_since(x) time_diff(x, time_now())
  22. void time_init(void);
  23. /*
  24. * Local variables:
  25. * mode: C
  26. * c-file-style: "Linux"
  27. * c-basic-offset: 4
  28. * tab-width: 4
  29. * indent-tabs-mode: nil
  30. * End:
  31. */