multi_timer.h 969 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2016 Zibin Zheng <[email protected]>
  3. * All rights reserved
  4. */
  5. #ifndef _MULTI_TIMER_H_
  6. #define _MULTI_TIMER_H_
  7. //#include "stdint.h"
  8. #include "TypeDef.h"
  9. #include "string.h"
  10. #define TIMER_TICK 10
  11. #define TIMER_MAX 60000 //86400000 //
  12. typedef struct Timer {
  13. uint32_t timeout;
  14. uint32_t repeat;
  15. void (*timeout_cb)(void);
  16. struct Timer* next;
  17. }Timer;
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. extern void timer_init_Head(void);
  22. extern void timer_init(struct Timer* handle, void(*timeout_cb)(), uint32_t timeout, uint32_t repeat);
  23. extern int timer_start(struct Timer* handle);
  24. extern void timer_stop(struct Timer* handle);
  25. extern void timer_ticks(void);
  26. extern void timer_loop(void);
  27. extern void timer_app(struct Timer* handle, void(*timeout_cb)(), uint32_t timeout, uint32_t repeat);
  28. // void timer_again(struct Timer* handle);
  29. // void timer_set_repeat(struct Timer* handle, uint32_t repeat);
  30. #ifdef __cplusplus
  31. }
  32. #endif
  33. #endif