Release:5.20灰测
This commit is contained in:
22
Core/User/App/task_sys.h
Normal file
22
Core/User/App/task_sys.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef __TASK_SYS_H
|
||||
#define __TASK_SYS_H
|
||||
|
||||
/* includes ----------------------------------------------------------------------------------------------*/
|
||||
#include "global.h"
|
||||
#include "cmsis_os.h" // 或使用 HAL_GetTick() 等
|
||||
|
||||
// 获取当前系统时间(毫秒)
|
||||
//#define GET_TICK() (osKernelSysTick()) // FreeRTOS/CMSIS-RTOS
|
||||
#define GET_TICK() (HAL_GetTick()) // STM32 HAL 用户可换这行
|
||||
|
||||
// 非阻塞延时宏:每 interval_ms 执行一次 {code}
|
||||
#define RUN_EVERY(interval_ms, static_tick_var, code) \
|
||||
do { \
|
||||
static uint32_t static_tick_var = 0; \
|
||||
if ((GET_TICK() - static_tick_var) >= (interval_ms)) { \
|
||||
static_tick_var = GET_TICK(); \
|
||||
code; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#endif /* __TASK_SYS_H */
|
||||
Reference in New Issue
Block a user