time.h 904 B

1234567891011121314151617181920212223242526272829303132333435363738
  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_stk(x) (x)
  16. #define time_sysclk(x) stk_sysclk(x)
  17. #define sysclk_time(x) sysclk_stk(x)
  18. time_t time_now(void);
  19. #define time_diff(x,y) ((int32_t)((y)-(x))) /* d = y - x */
  20. #define time_add(x,d) ((time_t)((x)+(d))) /* y = x + d */
  21. #define time_sub(x,d) ((time_t)((x)-(d))) /* y = x - d */
  22. #define time_since(x) time_diff(x, time_now())
  23. void time_init(void);
  24. /*
  25. * Local variables:
  26. * mode: C
  27. * c-file-style: "Linux"
  28. * c-basic-offset: 4
  29. * tab-width: 4
  30. * indent-tabs-mode: nil
  31. * End:
  32. */