mirror of
https://gitee.com/cosyos/cosyos.git
synced 2026-08-17 08:42:13 +08:00
71 lines
1.5 KiB
C
71 lines
1.5 KiB
C
/**************************************************************************//**
|
|
* @item CosyOS-III Kernel
|
|
* @file sv_tick.c
|
|
* @brief 滴答服务
|
|
* @details 仅在 SysTick中断 中调用并执行。
|
|
* @author 迟凯峰
|
|
* @version v3.0.0
|
|
* @date 2026.07.21
|
|
******************************************************************************/
|
|
|
|
#include "os_var.h"
|
|
#include "sv_com.h"
|
|
|
|
/**
|
|
@addtogroup 滴答服务
|
|
@{
|
|
*/
|
|
|
|
#if (SYSCFG_SEMAPHORE == __ENABLED__)
|
|
/**
|
|
\brief 获取计数信号量
|
|
\param[in] hsem 计数信号量句柄
|
|
\return 结果
|
|
\retval false 失败
|
|
\retval true 成功
|
|
*/
|
|
bool st_take_semaph(s_semaph_tsp hsem) MCUCFG_OSIT_ATTRIBUTE
|
|
{
|
|
s_semaph_t counter = hsem->counter;
|
|
if(counter){
|
|
hsem->counter = counter - 1;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
#endif
|
|
|
|
#if (SYSCFG_MSGQUEUE == __ENABLED__)
|
|
/**
|
|
\brief 接收消息
|
|
\param[in] hque 队列句柄
|
|
\return 消息指针
|
|
\retval NULL 无消息
|
|
*/
|
|
void *st_recv_msg(s_msgque_tsp hque) MCUCFG_OSIT_ATTRIBUTE
|
|
{
|
|
void *msg = OS_NULL;
|
|
#if (SYSCFG_MSGQUEUE_INTRECV == __ENABLED__)
|
|
hque->lock = false;
|
|
__mx_MMB();
|
|
#endif
|
|
|
|
if(hque->counter){
|
|
if(hque->type == __DYNAMIC__){
|
|
msg = sc_recv_msg_dynque((s_dynque_tsp)hque);
|
|
}
|
|
else{
|
|
msg = sc_recv_msg_staque((s_staque_tsp)hque);
|
|
}
|
|
}
|
|
|
|
#if (SYSCFG_MSGQUEUE_INTRECV == __ENABLED__)
|
|
__mx_MMB();
|
|
hque->lock = true;
|
|
#endif
|
|
return msg;
|
|
}
|
|
#endif
|
|
|
|
/** @} */
|