pt-timer.h 835 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef _PT_TIMER_H_
  2. #define _PT_TIMER_H_
  3. #include <stdint.h>
  4. #ifndef boolean
  5. #define boolean unsigned char
  6. #endif
  7. #ifndef NULL
  8. #define NULL 0
  9. #endif
  10. //如果使用__USE_WT_TIMER_ 建议系统滴答10ms为佳 可使用497天后重置计数器
  11. #define __USE_WT_TIMER_
  12. #ifdef __USE_WT_TIMER_
  13. typedef struct _pt_timer_t {
  14. volatile uint32_t ms;
  15. }timer_t,pt_timer_t;
  16. #else
  17. typedef struct _pt_timer_t {
  18. struct _pt_timer_t *next;
  19. volatile uint16_t ms; // ³¬Ê±±êÖ¾¡£³¬Ê±Ê±ÉèÖÃΪ 0
  20. volatile uint16_t ticks;
  21. }timer_t,pt_timer_t;
  22. #endif
  23. void PTTimerInitPool(pt_timer_t *pool);
  24. void PTTimerStart(pt_timer_t *pool, pt_timer_t *timer, uint16_t ms);
  25. boolean PTTimerIsExpired(pt_timer_t *timer);
  26. void PTTimerStop(pt_timer_t *pool, pt_timer_t *timer);
  27. void PTTimerTick(pt_timer_t *pool);
  28. #endif /* _PT_TIMER_H_ */