pt-timer.h 563 B

12345678910111213141516171819202122
  1. #ifndef _PT_TIMER_H_
  2. #define _PT_TIMER_H_
  3. #include <stdint.h>
  4. typedef unsigned char boolean;
  5. #ifndef NULL
  6. #define NULL 0
  7. #endif
  8. typedef struct _pt_timer_t {
  9. struct _pt_timer_t *next;
  10. volatile uint16_t ms; // 超时标志。超时时设置为 0
  11. volatile uint16_t ticks;
  12. }timer_t, pt_timer_t;
  13. void PTTimerInitPool(pt_timer_t *pool);
  14. void PTTimerStart(pt_timer_t *pool, pt_timer_t *timer, uint16_t ms);
  15. boolean PTTimerIsExpired(pt_timer_t *timer);
  16. void PTTimerStop(pt_timer_t *pool, pt_timer_t *timer);
  17. void PTTimerTick(pt_timer_t *pool);
  18. #endif /* _PT_TIMER_H_ */