timer_count32.h 745 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef _TIMER_COUNT32_H__
  2. #define _TIMER_COUNT32_H__
  3. #include "os/os_type.h"
  4. typedef struct {
  5. u32 exec_count;
  6. u32 exec_time;
  7. u32 intval_count;
  8. u32 intval_time;
  9. u32 exec_max_time;
  10. u32 exec_max_error_time;
  11. u32 exec_time_error;
  12. }measure_time_t;
  13. void timer_count32_init(void);
  14. u32 timer_count32_get(void);
  15. u32 timer_count32_delta_us(u32 prev_count, u32 *p_update);
  16. void time_measure_start(measure_time_t *m);
  17. void time_measure_end(measure_time_t *m);
  18. #define COUNT_CLK (10 * 1000000)
  19. #define COUNT_2_US(c) (c/10)
  20. static __inline__ u32 timer_count32_getus(u32 now, u32 count) {
  21. u32 delta = now - count;
  22. if (now < count) { //wrap
  23. delta = 0xFFFFFFFF - count + now + 1;
  24. }
  25. return COUNT_2_US(delta);
  26. }
  27. #endif /* _TIMER_COUNT32_H__ */