update CosyOS内核文件.

Signed-off-by: 零中断延迟的RTOS <cosyos@139.com>
This commit is contained in:
零中断延迟的RTOS
2023-10-20 13:37:26 +00:00
committed by Gitee
parent fbb679f450
commit 75928ac3ab
13 changed files with 2734 additions and 0 deletions
+137
View File
@@ -0,0 +1,137 @@
/**************************************************************************//**
* @item CosyOS-II Kernel
* @file os_debug.c
* @brief DEBUG接口(串口发送和接收解析)
* @author 迟凯峰
* @version V1.0.0
* @date 2023.10.20
******************************************************************************/
#include "os_link.h"
#if SYSCFG_DEBUGGING == __ENABLED__
#if SYSCFG_MCUCORE == 8051
static char* _strncpy_(char* src, const char* sub, size_t n)
{
if(src == NULL || sub == NULL || !*sub || !n){
return src;
}
else{
char* str = src;
do{
*str++ = *sub;
if(!*sub++){
return src;
}
}while(--n);
*str = '\0';
return src;
}
}
static char _strncmp_(const char* src, const char* sub, size_t n)
{
if(src == NULL || sub == NULL){
return 1;
}
do{
if(*src++ == *sub){
if(!*sub++){
return 0;
}
}
else{
return 1;
}
}while(--n);
return 0;
}
static int _atoi_(const char* str)
{
if(str == NULL || !*str){
return 0;
}
else{
int a = 0;
int k = 1;
s_u8_t i = s_strlen(str);
while(i--){
if(str[i] >= '0' && str[i] <= '9'){
a += (str[i] - '0') * k;
k *= 10;
}
else if(str[i] == '+'){
return a;
}
else if(str[i] == '-'){
return -a;
}
else{
return 0;
}
}
return a;
}
}
#else
#define _strncpy_ strncpy
#define _strncmp_ strncmp
#define _atoi_ atoi
#endif
static void _debug_recv_(void)
{
#define hptr s_debug_recvbuff
s_u16_t temp;
char strtmp[8];
char _XDATA_MEM_ *mptr = hptr;
char _XDATA_MEM_ *tptr = hptr + s_strlen(hptr) - 2;
if(!s_strcmp(tptr, "\r\n")){
if(!s_strcmp(hptr, "taskmgr\r\n")){
uGiveBin(s_taskmgr_binary);
}
else if(!s_strcmp(hptr, "exit\r\n")){
uLockBin(s_taskmgr_binary);
}
else if(!_strncmp_(hptr, "taskmgr /s=", 11)){
mptr += 11;
_strncpy_(strtmp, mptr, tptr - mptr);
strtmp[tptr - mptr] = '\0';
temp = _atoi_(strtmp);
if(temp >= 50 && temp <= 5000){
muEnterCritical;
s_timqry_reload[OS_TMID_TASKMGR] = (1000UL * temp) / SYSCFG_SYSTICKCYCLE;
muExitCritical;
}
}
}
#undef hptr
}
uCreateTask_TimInt(OS_TMID_DEBUGGER, false, Debugger, SYSCFG_TASKPRIORITY - 1, MCUCFG_STACKSIZE_DEBUGGER, 0, 0)
{
s_debug_recvptr[0] = '\0';
_debug_recv_();
s_debug_recvptr = s_debug_recvbuff;
uSuspendTasking;
uEndTasking;
}
uCreateHook_TimQry(OS_TMID_DEBUGHOOK, s_debug_sendtype, false, debug_hook)
{
if(s_debug_sendtype & OS_DEBUG_SEND_CMDLINE){
s_debug_sendtype &= ~OS_DEBUG_SEND_CMDLINE;
s_debug_sendptr = s_cmdline_sendbuff;
SYSCFG_DEBUGSEND;
}
else if(s_debug_sendtype & OS_DEBUG_SEND_TASKMGR){
s_debug_sendtype &= ~OS_DEBUG_SEND_TASKMGR;
s_debug_sendptr = s_taskmgr_sendbuff;
SYSCFG_DEBUGSEND;
}
}
#endif