pt-timer.h 881 B

1234567891011121314151617181920212223242526272829303132333435
  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. }pt_timer_t;
  16. uint32_t getSysTick(void);
  17. #else
  18. typedef struct _pt_timer_t {
  19. struct _pt_timer_t *next;
  20. volatile uint16_t ms; // ³¬Ê±±êÖ¾¡£³¬Ê±Ê±ÉèÖÃΪ 0
  21. volatile uint16_t ticks;
  22. }pt_timer_t;
  23. #endif
  24. void PTTimerInitPool(pt_timer_t *pool);
  25. void PTTimerStart(pt_timer_t *pool, pt_timer_t *timer, uint16_t ms);
  26. boolean PTTimerIsExpired(pt_timer_t *timer);
  27. void PTTimerStop(pt_timer_t *pool, pt_timer_t *timer);
  28. void PTTimerTick(pt_timer_t *pool);
  29. #endif /* _PT_TIMER_H_ */