/**************************************************************************//**
 * @item     CosyOS-III Kernel
 * @file     ur_eapi.h
 * @brief    用户API扩展
 * @details  用户API的补充扩展定义，仅是定义无注释说明，所有内核服务的API说明
             均在 ur_api.h 中，并支持 doxygen。
 * @author   迟凯峰
 * @version  v3.0.0
 * @date     2026.07.21
 ******************************************************************************/

#ifndef __UR_EAPI_H
#define __UR_EAPI_H


/*
 * tpi(s)
 */

/* 清除就绪延时 */
//#define tClearDelay()                 sTSV_ClearDelay()
  #define pClearDelay()                 sPSV_ClearDelay()
  #define iClearDelay()                 sIPS_ClearDelay()


/*
 * utpi(s)
 */

/* 恢复任务 */
//#define uResumeTask(task)             sUSV_ResumeTask(task)
  #define tResumeTask(task)             sTSV_ResumeTask(task)
  #define pResumeTask(task)             sPSV_ResumeTask(task)
  #define iResumeTask(task)             sIPS_ResumeTask(task)

/* 挂起任务 */
//#define uSuspendTask(task)            sUSV_SuspendTask(task)
  #define tSuspendTask(task)            sTSV_SuspendTask(task)
  #define pSuspendTask(task)            sPSV_SuspendTask(task)
  #define iSuspendTask(task)            sIPS_SuspendTask(task)

/* 删除任务 */
//#define uDeleteTask(task)             sUSV_DeleteTask(task)
  #define tDeleteTask(task)             sTSV_DeleteTask(task)
  #define pDeleteTask(task)             sPSV_DeleteTask(task)
  #define iDeleteTask(task)             sIPS_DeleteTask(task)

/* 重置任务 */
//#define uResetTask(task, status)      sUSV_ResetTask(task, status)
  #define tResetTask(task, status)      sTSV_ResetTask(task, status)
  #define pResetTask(task, status)      sPSV_ResetTask(task, status)
  #define iResetTask(task, status)      sIPS_ResetTask(task, status)

/* 设置任务优先级 */
//#define uSetTaskPri(task, npri)       sUSV_SetTaskPri(task, npri)
  #define tSetTaskPri(task, npri)       sTSV_SetTaskPri(task, npri)
  #define pSetTaskPri(task, npri)       sPSV_SetTaskPri(task, npri)
  #define iSetTaskPri(task, npri)       sIPS_SetTaskPri(task, npri)

/* 清除阻塞（状态）*/
//#define uClearBlock(task)             sUSV_ClearBlock(task)
  #define tClearBlock(task)             sTSV_ClearBlock(task)
  #define pClearBlock(task)             sPSV_ClearBlock(task)
  #define iClearBlock(task)             sIPS_ClearBlock(task)

/* 设置阻塞-滴答周期 */
//#define uSetBlock_tc(task, tc)        sUSV_SetBlock(task, tc)
  #define tSetBlock_tc(task, tc)        sTSV_SetBlock(task, tc)
  #define pSetBlock_tc(task, tc)        sPSV_SetBlock(task, tc)
  #define iSetBlock_tc(task, tc)        sIPS_SetBlock(task, tc)

/* 设置阻塞-毫秒 */
//#define uSetBlock_ms(task, ms)        uSetBlock_tc(task, (1000UL * (ms)) / SYSCFG_SYSTICK_CYCLE)
  #define tSetBlock_ms(task, ms)        tSetBlock_tc(task, (1000UL * (ms)) / SYSCFG_SYSTICK_CYCLE)
  #define pSetBlock_ms(task, ms)        pSetBlock_tc(task, (1000UL * (ms)) / SYSCFG_SYSTICK_CYCLE)
  #define iSetBlock_ms(task, ms)        iSetBlock_tc(task, (1000UL * (ms)) / SYSCFG_SYSTICK_CYCLE)

/* 设置阻塞-秒钟 */
//#define uSetBlock_s(task, s)          uSetBlock_ms(task, 1000UL * (s))
  #define tSetBlock_s(task, s)          tSetBlock_ms(task, 1000UL * (s))
  #define pSetBlock_s(task, s)          pSetBlock_ms(task, 1000UL * (s))
  #define iSetBlock_s(task, s)          iSetBlock_ms(task, 1000UL * (s))

/* 设置阻塞-分钟 */
//#define uSetBlock_m(task, m)          uSetBlock_s(task, 60UL * (m))
  #define tSetBlock_m(task, m)          tSetBlock_s(task, 60UL * (m))
  #define pSetBlock_m(task, m)          pSetBlock_s(task, 60UL * (m))
  #define iSetBlock_m(task, m)          iSetBlock_s(task, 60UL * (m))

/* 设置阻塞-小时 */
//#define uSetBlock_h(task, h)          uSetBlock_m(task, 60UL * (h))
  #define tSetBlock_h(task, h)          tSetBlock_m(task, 60UL * (h))
  #define pSetBlock_h(task, h)          pSetBlock_m(task, 60UL * (h))
  #define iSetBlock_h(task, h)          iSetBlock_m(task, 60UL * (h))

/* 给予二值信号量 */
//#define uGiveBin(bin)                 sUSV_GiveBin(bin)
  #define tGiveBin(bin)                 sTSV_GiveBin(bin)
  #define pGiveBin(bin)                 sPSV_GiveBin(bin)
  #define iGiveBin(bin)                 sIPS_WriteBin(bin, true)

/* 上锁二值信号量 */
//#define uLockBin(bin)                 bin.binary = false
  #define tLockBin(bin)                 bin.binary = false
  #define pLockBin(bin)                 bin.binary = false
  #define iLockBin(bin)                 sIPS_WriteBin(bin, false)


/*
 * uti(s)
 */

/* 给予计数信号量 */
//#define uGiveSem(sem)                 sUSV_GiveSem(sem)
  #define tGiveSem(sem)                 sTSV_GiveSem(sem)
  #define iGiveSem(sem)                 sIPS_GiveSem(sem)

/* 发送飞信 */
//#define uSendFetion(tbox, tion)       sUSV_SendFetion(tbox, tion)
  #define tSendFetion(tbox, tion)       sTSV_SendFetion(tbox, tion)
  #define iSendFetion(tbox, tion)       sIPS_SendFetion(tbox, tion)

/* 发送邮件 */
//#define uSendMail(mbox, mail)         sUSV_SendMail(mbox, mail)
  #define tSendMail(mbox, mail)         sTSV_SendMail(mbox, mail)
  #define iSendMail(mbox, mail)         sIPS_SendMail(mbox, mail)

/* 发送消息 */
//#define uSendMsg(que, msg)            sUSV_SendMsg(que, msg)
  #define tSendMsg(que, msg)            sTSV_SendMsg(que, msg)
  #define iSendMsg(que, msg)            sIPS_SendMsg(que, msg)

/* 清除标志组 */
//#define uClearFlagGroup(group)        sUSV_ClearFlagGroup(group)
  #define tClearFlagGroup(group)        sTSV_ClearFlagGroup(group)
  #define iClearFlagGroup(group)        sIPS_ClearFlagGroup(group)

/* 设置标志位 */
//#define uSetFlagBit(group, bit)       uSetFlagBits(group, 1) bit)
  #define tSetFlagBit(group, bit)       tSetFlagBits(group, 1) bit)
  #define iSetFlagBit(group, bit)       iSetFlagBits(group, 1) bit)

/* 清除标志位 */
//#define uClearFlagBit(group, bit)     uClearFlagBits(group, 1) bit)
  #define tClearFlagBit(group, bit)     tClearFlagBits(group, 1) bit)
  #define iClearFlagBit(group, bit)     iClearFlagBits(group, 1) bit)

/* 设置多标志位 */
//#define uSetFlagBits(group, nbit)     sUSV_WriteFlagBits(group, true, nbit)
  #define tSetFlagBits(group, nbit)     sTSV_WriteFlagBits(group, true, nbit)
  #define iSetFlagBits(group, nbit)     sIPS_WriteFlagBits(group, +, nbit)

/* 清除多标志位 */
//#define uClearFlagBits(group, nbit)   sUSV_WriteFlagBits(group, false, nbit)
  #define tClearFlagBits(group, nbit)   sTSV_WriteFlagBits(group, false, nbit)
  #define iClearFlagBits(group, nbit)   sIPS_WriteFlagBits(group, -, nbit)

/* 定时中断-滴答周期 */
//#define uTimInt_tc(tmid, tc)          sUSV_TimInt(tmid, tc)
  #define tTimInt_tc(tmid, tc)          sTSV_TimInt(tmid, tc)
  #define iTimInt_tc(tmid, tc)          sIPS_TimInt(tmid, tc)

/* 定时中断-毫秒 */
//#define uTimInt_ms(tmid, ms)          uTimInt_tc(tmid, (1000UL * (ms)) / SYSCFG_SYSTICK_CYCLE)
  #define tTimInt_ms(tmid, ms)          tTimInt_tc(tmid, (1000UL * (ms)) / SYSCFG_SYSTICK_CYCLE)
  #define iTimInt_ms(tmid, ms)          iTimInt_tc(tmid, (1000UL * (ms)) / SYSCFG_SYSTICK_CYCLE)

/* 定时中断-秒钟 */
//#define uTimInt_s(tmid, s)            uTimInt_ms(tmid, 1000UL * (s))
  #define tTimInt_s(tmid, s)            tTimInt_ms(tmid, 1000UL * (s))
  #define iTimInt_s(tmid, s)            iTimInt_ms(tmid, 1000UL * (s))

/* 定时中断-分钟 */
//#define uTimInt_m(tmid, m)            uTimInt_s(tmid, 60UL * (m))
  #define tTimInt_m(tmid, m)            tTimInt_s(tmid, 60UL * (m))
  #define iTimInt_m(tmid, m)            iTimInt_s(tmid, 60UL * (m))

/* 定时中断-小时 */
//#define uTimInt_h(tmid, h)            uTimInt_m(tmid, 60UL * (h))
  #define tTimInt_h(tmid, h)            tTimInt_m(tmid, 60UL * (h))
  #define iTimInt_h(tmid, h)            iTimInt_m(tmid, 60UL * (h))

/* 终止定时中断 */
//#define uTimInt_Cancel(tmid)          uTimInt_tc(tmid, 0)
  #define tTimInt_Cancel(tmid)          tTimInt_tc(tmid, 0)
  #define iTimInt_Cancel(tmid)          iTimInt_tc(tmid, 0)

/* 定时查询-滴答周期 */
//#define uTimQry_tc(tmid, tc)          sUSV_TimQry(tmid, tc)
  #define tTimQry_tc(tmid, tc)          sTSV_TimQry(tmid, tc)
  #define iTimQry_tc(tmid, tc)          sIPS_TimQry(tmid, tc)

/* 定时查询-毫秒 */
//#define uTimQry_ms(tmid, ms)          uTimQry_tc(tmid, (1000UL * (ms)) / SYSCFG_SYSTICK_CYCLE)
  #define tTimQry_ms(tmid, ms)          tTimQry_tc(tmid, (1000UL * (ms)) / SYSCFG_SYSTICK_CYCLE)
  #define iTimQry_ms(tmid, ms)          iTimQry_tc(tmid, (1000UL * (ms)) / SYSCFG_SYSTICK_CYCLE)

/* 定时查询-秒钟 */
//#define uTimQry_s(tmid, s)            uTimQry_ms(tmid, 1000UL * (s))
  #define tTimQry_s(tmid, s)            tTimQry_ms(tmid, 1000UL * (s))
  #define iTimQry_s(tmid, s)            iTimQry_ms(tmid, 1000UL * (s))

/* 定时查询-分钟 */
//#define uTimQry_m(tmid, m)            uTimQry_s(tmid, 60UL * (m))
  #define tTimQry_m(tmid, m)            tTimQry_s(tmid, 60UL * (m))
  #define iTimQry_m(tmid, m)            iTimQry_s(tmid, 60UL * (m))

/* 定时查询-小时 */
//#define uTimQry_h(tmid, h)            uTimQry_m(tmid, 60UL * (h))
  #define tTimQry_h(tmid, h)            tTimQry_m(tmid, 60UL * (h))
  #define iTimQry_h(tmid, h)            iTimQry_m(tmid, 60UL * (h))

/* 终止定时查询 */
//#define uTimQry_Cancel(tmid)          uTimQry_tc(tmid, ~0)
  #define tTimQry_Cancel(tmid)          tTimQry_tc(tmid, ~0)
  #define iTimQry_Cancel(tmid)          iTimQry_tc(tmid, ~0)

/* 设置时间 */
//#define uSetTime(t)                   sUSV_SetTime(t)
  #define tSetTime(t)                   sTSV_SetTime(t)
  #define iSetTime(t)                   sIPS_SetTime(t)


/*
 * uti(l)
 */

/* 归还二值信号量 */
//#define uBackBin(bin)                 uGiveBin(bin)
  #define tBackBin(bin)                 sTSV_BackBin(bin)
  #define iBackBin(bin)                 sISV_BackBin(bin)

/* 获取二值信号量 */
//#define uTakeBin(bin, tc)             sUSV_TakeBin(bin, tc)
  #define tTakeBin(bin)                 sTSV_TakeBin(bin)
  #define iTakeBin(bin)                 sISV_TakeBin(bin)

/* 接收飞信 */
//#define uRecvFetion(tbox, tc)         sUSV_RecvFetion(tbox, tc)
  #define tRecvFetion(tbox)             sTSV_RecvFetion(tbox)
  #define iRecvFetion(tbox)             sISV_RecvFetion(tbox)

/* 接收邮件 */
//#define uRecvMail(mbox, tc)           sUSV_RecvMail(mbox, tc)
  #define tRecvMail(mbox)               sTSV_RecvMail(mbox)
  #define iRecvMail(mbox)               sISV_RecvMail(mbox)

/* 接收消息 */
//#define uRecvMsg(que, tc)             sUSV_RecvMsg(que, tc)
  #define tRecvMsg(que)                 sTSV_RecvMsg(que)
  #define iRecvMsg(que)                 sISV_RecvMsg(que)

/* 查询标志组 */
//#define uQueryFlagGroup(group)        sUSV_QueryFlagGroup(group)
  #define tQueryFlagGroup(group)        sTSV_QueryFlagGroup(group)
  #define iQueryFlagGroup(group)        sISV_QueryFlagGroup(group)


/*
 * ut
 */

/* 获取时间 */
//#define uGetTime(t)                   sUSV_GetTime(t)
  #define tGetTime(t)                   sTSV_GetTime(t)

/* 获取计数信号量 */
//#define uTakeSem(sem, tc)             sUSV_TakeSem(sem, tc)
  #define tTakeSem(sem)                 sTSV_TakeSem(sem)

/* 归还计数信号量 */
//#define uBackSem(sem)                 uGiveSem(sem)
  #define tBackSem(sem)                 tGiveSem(sem)

/* 发送私信 */
//#define uSendTaskmsg(task)            sUSV_SendTaskmsg(task)
  #define tSendTaskmsg(task)            sTSV_SendTaskmsg(task)


/*
 * 别名定义（API简化）
 */

#define uRecvTM  uRecvTaskmsg
#define uSendTM  uSendTaskmsg
#define tSendTM  tSendTaskmsg
#define uEndTM   uEndTaskmsg

#define uRecvFet uRecvFetion
#define tRecvFet tRecvFetion
#define iRecvFet iRecvFetion
#define uSendFet uSendFetion
#define tSendFet tSendFetion
#define iSendFet iSendFetion


#endif
