You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
590 B

  1. #pragma once
  2. #include <stdint.h> //定义布尔
  3. #define DO_IT_EACH_MS(time) \
  4. { \
  5. static uint32_t __ticket = 0; \
  6. if (systicket_haspassedms(__ticket) > (time)) { \
  7. __ticket = systicket_get_now_ms();
  8. #define END() \
  9. } \
  10. }
  11. // 初始化
  12. void systicket_init(void);
  13. // 获取当前ticket
  14. uint32_t systicket_get_now_ms(void);
  15. // 计算距离上一个ticket过去了多久
  16. uint32_t systicket_haspassedms(uint32_t ticket);
  17. // 延时
  18. void systicket_delay_ms(uint32_t nTime);