Files
BR_YKC/Core/User/App/task_sys.h

33 lines
1.0 KiB
C
Raw Normal View History

2026-05-21 12:19:01 +08:00
/**
******************************************************************************
* @file User\App\task_sys.h
* @author
* @version v0.1
* @date 2026-05-21
* @brief
******************************************************************************
*/
2026-05-21 10:01:28 +08:00
#ifndef __TASK_SYS_H
#define __TASK_SYS_H
2026-03-31 15:46:04 +08:00
2026-05-21 12:19:01 +08:00
/* includes ------------------------------------------------------------------*/
2026-03-31 15:46:04 +08:00
#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)
2026-05-21 10:01:28 +08:00
#endif /* __TASK_SYS_H */