timer.c 759 B

1234567891011121314151617181920
  1. // Copyright 2023 Sergey Vlasov (@sigprof)
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. // Use an angle-bracket include so the header is located via the include
  4. // search path rather than source-relative lookup. timer.h uses
  5. // #include_next to chain to the active platform's _timer.h, and that
  6. // only has well-defined semantics when timer.h itself was found via -I.
  7. #include <timer.h>
  8. // Generate out-of-line copies for inline functions defined in timer.h.
  9. extern inline fast_timer_t timer_read_fast(void);
  10. extern inline fast_timer_t timer_elapsed_fast(fast_timer_t last);
  11. uint16_t timer_elapsed(uint16_t last) {
  12. return TIMER_DIFF_16(timer_read(), last);
  13. }
  14. uint32_t timer_elapsed32(uint32_t last) {
  15. return TIMER_DIFF_32(timer_read32(), last);
  16. }