mirror of
https://gitee.com/cosyos/cosyos.git
synced 2026-02-05 19:39:42 +08:00
87 lines
3.9 KiB
C
87 lines
3.9 KiB
C
/**************************************************************************//**
|
||
* @item CosyOS-III Kernel
|
||
* @file sv_tick.h
|
||
* @brief 滴答服务
|
||
* @details 仅在 SysTick中断 中调用并执行,包括在 滴答钩子(tick_hook)、
|
||
定时中断钩子(u_timint_##tmid)、定时查询钩子(u_timqry_##tmid)、
|
||
定时查询事件(u_timqryevent_##tmid)中调用。
|
||
* @author 迟凯峰
|
||
* @version V2.0.0
|
||
* @date 2025.08.04
|
||
******************************************************************************/
|
||
|
||
#ifndef __SV_TICK_H
|
||
#define __SV_TICK_H
|
||
|
||
#include "os_redef.h"
|
||
bool st_take_semaph (s_semaph_tsp hsem);
|
||
void *st_recv_msg (s_msgque_tsp hque);
|
||
|
||
/**
|
||
@addtogroup CosyOS_内核服务
|
||
@{
|
||
*//**
|
||
\defgroup 滴答服务
|
||
\brief 仅在 SysTick中断 中调用并执行,包括在 滴答钩子(tick_hook)、
|
||
定时中断钩子(u_timint_##tmid)、定时查询钩子(u_timqry_##tmid)、
|
||
定时查询事件(u_timqryevent_##tmid)中调用。
|
||
@{
|
||
*/
|
||
|
||
#define sTSV_ClearDelay() sc_clear_delay() /*!< 清除就绪延时 */
|
||
#define sTSV_ResumeTask(htask) sc_resume_task(htask) /*!< 恢复任务 */
|
||
#define sTSV_SuspendTask(htask) sc_suspend_task(htask) /*!< 挂起任务 */
|
||
#define sTSV_DeleteTask(htask) sc_delete_task(htask) /*!< 删除任务 */
|
||
#define sTSV_ClearBlock(htask) sc_clear_block(htask) /*!< 清除阻塞 */
|
||
#define sTSV_SetBlock(htask, tick) sc_set_block(htask, tick) /*!< 设置阻塞 */
|
||
#define sTSV_SetTaskPri(htask, npri) sc_set_taskpri(htask, npri) /*!< 设置任务优先级 */
|
||
#define sTSV_GiveBin(bin) sc_write_binary(&bin, true) /*!< 给予二值信号量 */
|
||
#define sTSV_GiveSem(sem) sc_give_semaph(&sem) /*!< 给予计数信号量 */
|
||
#define sTSV_SendFetion(tbox, tion) sc_send_fetion(&tbox, tion) /*!< 发送飞信 */
|
||
#define sTSV_SendMail(mbox, mail) sc_send_mail(&mbox, mail) /*!< 发送邮件 */
|
||
#define sTSV_SendMsg(que, msg) sc_send_msg((s_msgque_tsp)&que, msg)/*!< 发送消息 */
|
||
#define sTSV_TimInt(tmid, tick) sc_timint(tmid, tick) /*!< 定时中断 */
|
||
#define sTSV_TimQry(tmid, tick) sc_timqry(tmid, tick) /*!< 定时查询 */
|
||
|
||
#define sTSV_TakeSem(sem) st_take_semaph(&sem) /*!< 获取计数信号量 */
|
||
#define sTSV_RecvMsg(que) st_recv_msg((s_msgque_tsp)&que) /*!< 接收消息 */
|
||
|
||
#define sTSV_TakeBin(bin) si_take_binary(&bin) /*!< 获取二值信号量 */
|
||
#define sTSV_RecvFetion(tbox) si_recv_fetion(&tbox) /*!< 接收飞信 */
|
||
#define sTSV_RecvMail(mbox) si_recv_mail(&mbox) /*!< 接收邮件 */
|
||
|
||
#define sTSV_GetTime(t) s_memcpy(t, &s_rtc, sizeof(s_rtc)) /*!< 获取时间 */
|
||
|
||
/** 设置时间 */
|
||
#define sTSV_SetTime(t) \
|
||
do{ \
|
||
s_memcpy(&s_rtc, t, sizeof(s_rtc)); \
|
||
s_rtc_counter = 1000000UL / SYSCFG_SYSTICK_CYCLE / 2 + 1; \
|
||
}while(false)
|
||
|
||
/** 查询标志组 */
|
||
#define sTSV_QueryFlagGroup(group) \
|
||
( \
|
||
sizeof(group) == 1 ? *(s_u8_t *)&group ? true : false \
|
||
: sizeof(group) == 2 ? *(s_u16_t *)&group ? true : false \
|
||
: sizeof(group) == 4 ? *(s_u32_t *)&group ? true : false \
|
||
: false \
|
||
)
|
||
|
||
/** 清除标志组 */
|
||
#define sTSV_ClearFlagGroup(group) \
|
||
do{ \
|
||
sizeof(group) == 1 ? *(s_u8_t *)&group = false : MCUCFG_TERNARYMASK \
|
||
sizeof(group) == 2 ? *(s_u16_t *)&group = false : MCUCFG_TERNARYMASK \
|
||
sizeof(group) == 4 ? *(s_u32_t *)&group = false : false; \
|
||
}while(false)
|
||
|
||
/** 写多标志位 */
|
||
#define sTSV_WriteFlagBits(group, value, nbit) \
|
||
stWriteFlagBits_##nbit(group, value,
|
||
|
||
/** @} */
|
||
/** @} */
|
||
|
||
#endif
|