timer_count32.h 770 B

12345678910111213141516171819202122232425262728293031323334
  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. u32 intval_time_error;
  13. }measure_time_t;
  14. void timer_count32_init(void);
  15. u32 timer_count32_get(void);
  16. u32 timer_count32_delta_us(u32 prev_count, u32 *p_update);
  17. void time_measure_start(measure_time_t *m);
  18. void time_measure_end(measure_time_t *m);
  19. #define COUNT_CLK (10 * 1000000)
  20. #define COUNT_2_US(c) (c/120)
  21. static __inline__ u32 timer_count32_getus(u32 now, u32 count) {
  22. u32 delta = now - count;
  23. if (now < count) { //wrap
  24. delta = 0xFFFFFFFF - count + now + 1;
  25. }
  26. return COUNT_2_US(delta);
  27. }
  28. #endif /* _TIMER_COUNT32_H__ */