update 内核文件.

Signed-off-by: 零中断延迟的RTOS <cosyos@139.com>
This commit is contained in:
零中断延迟的RTOS
2026-06-20 02:48:47 +00:00
committed by Gitee
parent d2cbfc8113
commit ee45b70cc2
7 changed files with 4591 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
/**************************************************************************//**
* @item CosyOS-III Kernel
* @file CosyOS.H
* @brief 系统链接头文件
* @details 用户的各个c文件中应包含此文件。
* @author 迟凯峰
* @version V2.3.9
* @date 2026.06.20
******************************************************************************/
#ifndef __COSYOS_H
#define __COSYOS_H
#define COSYOS3_VERSION "v2.3.9"
#include "os_var.h"
#include "os_api.h"
#include "sv_com.h"
#include "sv_create.h"
#include "sv_int_fifo.h"
#include "sv_int_loc.h"
#include "sv_pend.h"
#include "sv_task.h"
#include "sv_tick.h"
#include "ur_api.h"
#include "ur_eapi.h"
#endif
+153
View File
@@ -0,0 +1,153 @@
/**************************************************************************//**
* @item CosyOS-III Kernel
* @file os_def.h
* @brief 初始宏定义
* @author 迟凯峰
* @version V2.3.9
* @date 2026.06.20
******************************************************************************/
#ifndef __OS_DEF_H
#define __OS_DEF_H
/*
* SYSAPI
*/
#define sDefStr(s) sDefStr_0(s)
#define sDefStr_0(s) #s
#define sCat2Str(s1, s2) sCat2Str_0(s1, s2)
#define sCat2Str_0(s1, s2) s1##s2
#define sCat3Str(s1, s2, s3) sCat3Str_0(s1, s2, s3)
#define sCat3Str_0(s1, s2, s3) s1##s2##s3
#define sDefBitField(v) s_u8_t v:1
#define sDefVoidBits(n) s_u8_t :n
/*
* CONST
*/
#define true 1
#define false 0
#define OS_NULL 0UL
/*
* CONFIG VALUE
*/
#define __DISABLED__ 0
#define __ENABLED__ 1
#define __STATIC__ 0 /*!< 静态队列 ............. */
#define __DYNAMIC__ 1 /*!< 动态队列 ............. */
#define __QUE_FIFO__ 0 /*!< 先入先出队列 ......... */
#define __QUE_LIFO__ 1 /*!< 后入先出队列 ......... */
#define __MCS_51__ 0 /*!< 指令集架构:MCS51 .... */
#define __MCS_251__ 1 /*!< 指令集架构:MCS251 ... */
#define __ARM__ 2 /*!< 指令集架构:ARM ...... */
#define __COOPERATIVE__ 1 /*!< 协作式调度............ */
#define __TIMESHARING__ 2 /*!< 时间片轮转调度........ */
#define __MSP__ 0x01
#define __PSP__ 0x02
#define __MSP_PSP__ (__MSP__ | __PSP__)
/*
* 任务相关
*/
/* 任务状态 */
#define OS_STATUS_READY 0x00 /*!< 就绪/运行状态 ............ */
#define OS_STATUS_FLOATING 0x01 /*!< 浮动状态 ................. */
#define OS_STATUS_BLOCKED 0x02 /*!< 阻塞状态 ................. */
#define OS_STATUS_TIMEOUT 0x04 /*!< 超时状态 ................. */
#define OS_STATUS_SUSPENDED 0x08 /*!< 挂起状态 ................. */
#define OS_STATUS_STOPPED 0x40 /*!< 停止状态 ................. */
#define OS_STATUS_DELETED 0x80 /*!< 已删除/未启动状态 ........ */
/* 阻塞类型 */
#define OS_BLOCKED_DELAY 0x00 /*!< 延时阻塞 ................. */
/*- 0x01/0x02/0x04sizeof(Group) -*//*!< 事件标志组阻塞(等待).... */
#define OS_BLOCKED_BINARY 0x10 /*!< 二值信号量阻塞(获取/等待)*/
#define OS_BLOCKED_MUTEX 0x20 /*!< 互斥信号量阻塞(获取).... */
#define OS_BLOCKED_SEMAPHORE 0x30 /*!< 计数信号量阻塞(获取).... */
#define OS_BLOCKED_TASKMSG 0x40 /*!< 接收私信阻塞 ............. */
#define OS_BLOCKED_FETION 0x50 /*!< 接收飞信阻塞 ............. */
#define OS_BLOCKED_MAIL 0x60 /*!< 接收邮件阻塞 ............. */
#define OS_BLOCKED_MSG 0x70 /*!< 接收消息阻塞 ............. */
/*
* DEBUG SEND TYPE
*/
#define OS_DEBUG_SEND_CMDLINE 0x01 /*!< 命令行发送 ... */
#define OS_DEBUG_SEND_TASKMGR 0x02 /*!< 任务管理器发送 */
/*
* TASKMGR LEN
*/
#define OS_TASKMGR_LEN_PRI 6
#define OS_TASKMGR_LEN_STA 6
#define OS_TASKMGR_LEN_CPU 9
/*
* SVID(服务ID,中断FIFO服务-系统专用ID)
*/
#define OS_SVID_CLEARDELAY 0x00 /*!< 清除就绪延时 ....... */
#define OS_SVID_RESUMETASK 0x01 /*!< 恢复任务 ........... */
#define OS_SVID_SUSPENDTASK 0x02 /*!< 挂起任务 ........... */
#define OS_SVID_DELETETASK 0x03 /*!< 删除任务 ........... */
#define OS_SVID_RESETTASK 0x04 /*!< 重置任务 ........... */
#define OS_SVID_CLEARBLOCK 0x05 /*!< 清除阻塞 ........... */
#define OS_SVID_SETBLOCK 0x06 /*!< 设置阻塞 ........... */
#define OS_SVID_SETTASKPRI 0x07 /*!< 设置任务优先级 ..... */
#define OS_SVID_WRITEBINARY 0x08 /*!< 写二值信号量 ....... */
#define OS_SVID_GIVESEMAPH 0x09 /*!< 给予计数信号量 ..... */
#define OS_SVID_SENDFETION 0x0A /*!< 发送飞信 ........... */
#define OS_SVID_SENDMAIL 0x0B /*!< 发送邮件 ........... */
#define OS_SVID_SENDMSG 0x0C /*!< 发送消息 ........... */
#define OS_SVID_TIMINT 0x0D /*!< 定时中断 ........... */
#define OS_SVID_TIMQRY 0x0E /*!< 定时查询 ........... */
#define OS_SVID_WRITEGROUP 0x0F /*!< 写标志组 ........... */
#define OS_SVID_WRITEGVAR 0x10 /*!< 写全局变量 ......... */
#define OS_SVID_PENDSVC 0x11 /*!< 挂起服务调用 ....... */
#define OS_SVID_END 0x12
/*
* ECODE(错误码)
*/
#define OS_ECODE_NOERROR 0x00 /*!< 无错误 ............. */
#define OS_ECODE_TASKSTARTED 0x0D /*!< 任务已启动 ......... */
#define OS_ECODE_TASKSUSPENDED 0x0E /*!< 任务已挂起 ......... */
#define OS_ECODE_TASKSTOPPED 0x0F /*!< 任务已停止 ......... */
#define OS_ECODE_TASKDELETED 0x10 /*!< 任务已删除 ......... */
#define OS_ECODE_TASKNOTSTARTED 0x10 /*!< 任务未启动 ......... */
#define OS_ECODE_TASKNOTBLOCKED 0x11 /*!< 任务未阻塞 ......... */
#define OS_ECODE_TASKNOTSUSPENDED 0x12 /*!< 任务未挂起 ......... */
#define OS_ECODE_TASKPRIUNCHANGED 0x13 /*!< 任务优先级未改变 ... */
#define OS_ECODE_OVERFLOW_MSGQUEUE 0x21 /*!< 消息队列溢出 ....... */
#define OS_ECODE_OVERFLOW_TASKQUEUE 0x22 /*!< 任务队列溢出 ....... */
#define OS_ECODE_OVERFLOW_TASKSTACK 0x23 /*!< 任务栈溢出 ......... */
#define OS_ECODE_MALLOCFAIL_MSGNODE 0x31 /*!< 消息节点内存分配失败 */
#define OS_ECODE_MALLOCFAIL_TASKNODE 0x32 /*!< 任务节点内存分配失败 */
#define OS_ECODE_MALLOCFAIL_TASKSTACK 0x33 /*!< 任务栈内存分配失败 . */
#define OS_ECODE_DONOTKNOW 0xFF /*!< 未知错误 ........... */
#endif
+697
View File
File diff suppressed because it is too large Load Diff
+63
View File
@@ -0,0 +1,63 @@
/**************************************************************************//**
* @item CosyOS-III Kernel
* @file os_sysidle.c
* @brief 系统空闲任务(Sysidle
* @author 迟凯峰
* @version V2.3.9
* @date 2026.06.20
******************************************************************************/
#include "os_var.h"
#include "os_api.h"
#include "sv_create.h"
#include "sv_task.h"
#include "ur_api.h"
/**
\brief 系统空闲任务
\param[in] 任务名称 Sysidle
\param[in] 任务优先级 0
\param[in] 任务栈大小 SYSCFG_STACKSIZE_SYSIDLE
\param[in] 安全运行时 0
\param[in] 任务名称文本<br>
遗产模式:"Sysidle"<br>
标准/兼容模式:[中文:"系统空闲",英文:"Sysidle"]
\return 无
*/
#if (SYSCFG_DEBUG_LANGUAGE == 0)
#define _taskname "Sysidle"
#else
#define _taskname "\xCF\xB5\xCD\xB3\xBF\xD5\xCF\xD0" /*!< "系统空闲" */
#endif
uCreateTask(Sysidle, 0, SYSCFG_STACKSIZE_SYSIDLE, 0, _taskname)
{
void idle_hook(void);
while(true){
#if (SYSCFG_SOFTRTC == __ENABLED__)
static s_u8_t _RTC_MEM_ year = 0xFF;
if(year != s_rtc.year){
year = s_rtc.year;
s_month2day = year ? ((year & 3) ? 28 : 29) : ((s_rtc.yeah & 3) ? 28 : 29);
}
#endif
#if (SYSCFG_SAFERUNTIME == __ENABLED__)
s_timeout_sign = false;
#endif
#if (SYSCFG_IDLEHOOK == __ENABLED__)
idle_hook();
#endif
#if (SYSCFG_DEBUGGING == __ENABLED__) && (MCUCFG_TASKSTACK_MODE & __MSP__)
if(true){
m_stacklen_t len = mMainStack_Check();
if(m_stacklen_max < len){
m_stacklen_max = len;
}
}
#endif
#if (SYSCFG_LOWPOWERMODE == __ENABLED__)
mCosyOS_IDLE();
#endif
OS_NOP(4);
}
}
#undef _taskname
+694
View File
File diff suppressed because it is too large Load Diff
+937
View File
File diff suppressed because it is too large Load Diff
+2017
View File
File diff suppressed because it is too large Load Diff