Files
cosyos/Hook/tick_hook.c
T
零中断延迟的RTOSandGitee 67e74cf1be update Hook/tick_hook.c.
Signed-off-by: 零中断延迟的RTOS <cosyos@139.com>
2025-08-09 05:18:21 +00:00

79 lines
2.5 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**************************************************************************//**
* @item CosyOS-III Hook
* @file tick_hook.c
* @brief 滴答钩子
* @details 每个系统滴答周期,在系统滴答中断中都会被调用一次,
适用于每滴答周期/秒/分/时/日/月/年/...做一次的工作。
* @note 1. 如果在滴答钩子中调用服务,应调用前缀为“t”的滴答服务。
2. 如果在滴答钩子中调用自定义函数,对于8051来说,如果系统中断被配置为
使用独立的REGBANK(与任务使用不同的REGBANK),自定义函数需要添加
using属性、或声明为相对寄存器访问。
demo1:
void your_function(void) MCUCFG_OSIT_ATTRIBUTE {... ...}
demo2:
#pragma NOAREGS
void your_function(void) {... ...}
#pragma AREGS
* @author 迟凯峰
* @version V2.0.1
* @date 2025.08.08
******************************************************************************/
#include "CosyOS.H"
#if 1 /* 编译开关 *//* 如果该函数在用户文件中实现且此处的弱定义无效,可手动移除该函数(1 改为 0)*/ \
&& (SYSCFG_TICKHOOK == __ENABLED__)
__WEAK void tick_hook(void) MCUCFG_OSIT_ATTRIBUTE
{
if(true){ /* 每滴答周期执行一次 */
}
#if (SYSCFG_SOFTRTC == __ENABLED__)
if(s_sign_every.halfsec){
s_sign_every.halfsec = false;
if(true){ /* 每半秒执行一次(每半秒,first tick)*/
}
if(s_sign_every.second){
s_sign_every.second = false;
if(true){ /* 每秒钟执行一次(每秒,first tick)*/
}
if(s_sign_every.minute){
s_sign_every.minute = false;
if(true){ /* 每分钟执行一次(每分0秒,first tick*/
}
if(s_sign_every.hour){
s_sign_every.hour = false;
if(true){ /* 每小时执行一次(每时0分0秒,first tick*/
}
if(s_sign_every.day){
s_sign_every.day = false;
if(true){ /* 每天执行一次(每天0时0分0秒,first tick*/
}
if(s_sign_every.month){
s_sign_every.month = false;
if(true){ /* 每月执行一次(每月1日0时0分0秒,first tick*/
}
if(s_sign_every.year){
s_sign_every.year = false;
if(true){ /* 每年执行一次(每年1月1日0时0分0秒,first tick*/
}
}
}
}
}
}
}
}
#endif
}
#endif