CosyOS
发表于 2024-2-2 15:01:17
tzz1983 发表于 2024-2-2 14:17
@CosyOS, 我来踩贴了哦, , 上次看过CosyOS距离现在应该有几个月了, 刚才又下载来看了一下, 感觉确实很不错 ...
你的建议我懂得,以后我会陆续添加更为详细的注释。
其实我个人是非常讨厌注释的,看到注释就不爽,很好的代码全被注释搞砸了{:4_165:}
380091044
发表于 2024-2-2 16:35:48
CosyOS 发表于 2024-2-2 15:01
你的建议我懂得,以后我会陆续添加更为详细的注释。
其实我个人是非常讨厌注释的,看到注释就不爽,很好 ...
对于已经入门的,其实没必要;对于未入门或是想入门的,那是必须的,推广就应该让这些想入门的能看懂,看不懂,就没法接着用,赞同楼上说法,可以快速推广,点赞!!
380091044
发表于 2024-2-2 16:37:12
tzz1983 发表于 2024-2-2 14:05
这个警告不影响使用.
警告的翻译是: 存在不可能执行到的代码,如下所示OS空闲任务代码, 其中 for(;;) 编 ...
感谢指点,我会深入研究一下,
380091044
发表于 2024-2-2 16:55:21
感谢老师指点,警告等级降低一级,果然看着舒服多了。
380091044
发表于 2024-2-4 11:15:01
char putchar(char c)//putchar代表输出一个字符 发送完一个字符C后,最后返回的还是C,起到一个什么作用?请老师指点一下
380091044
发表于 2024-2-4 11:38:05
老师:图片中的( void * )&aa和&Task_STK_A分别是任务参数传递和任务堆栈栈顶指针对吗?
380091044
发表于 2024-2-4 11:41:15
// ==== LOGO ============ 图片中的这个循环函数,写LOGO 是啥意思?
CosyOS
发表于 2024-2-4 12:53:54
本帖最后由 CosyOS 于 2024-2-4 13:01 编辑
380091044 发表于 2024-2-4 11:15
char putchar(char c)//putchar代表输出一个字符 发送完一个字符C后,最后返回的还是C,起到一个什么作 ...
putchar用于printf的串口重定向,putchar中返回的c就是传入的c。至于为何要返回,我也不清楚。但由于keil标准库(stdio.h)中就是这么声明的putchar,所以我们重定义puchar时也需这么定义。
不过你有兴趣的化,可以把stdio.h中putchar的声明改为 extern void putchar(char);,再重定义putchar函数为 void putchar(char) {...},并注释掉返回值,看printf能否正常打印输出???
tzz1983
发表于 2024-2-4 12:58:02
380091044 发表于 2024-2-4 11:38
老师:图片中的( void * )&aa和&Task_STK_A分别是任务参数传递和任务堆栈栈顶指针对吗?
...
这代码不像COsyOS的风格呀, 你应该看的是uCOS的代码吧
OSTaskCreate函数的原型为:
INT8UOSTaskCreate (void (*task)(void *p_arg),
void *p_arg,
OS_STK*ptos,
INT16U stk_size,
INT8U prio)large reentrant
5个参数: @task 对应任务函数名
@p_arg 对应要传给任务函数的数据指针
@ptos 任务栈栈顶
@stk_size 指定任务栈大小
@prio指定任务优先级
告诉你一个学习方法, 在函数名字上鼠标右键弹出菜单选择"Go To Definition xxxx"即可跳转的函数这义处, 此处可看到该函数的具体信息, 函数前有函数相关的说明如下, 如果英文不行, 可以用翻译看, 学习一样东西是师傅领进门, 修行靠个人
/*
*********************************************************************************************************
* CREATE A TASK
*
* Description: This function is used to have uC/OS-II manage the execution of a task.Tasks can either
* be created prior to the start of multitasking or by a running task.A task cannot be
* created by an ISR.
*
* Arguments: task is a pointer to the task's code
*
* p_arg is a pointer to an optional data area which can be used to pass parameters to
* the task when the task first executes.Where the task is concerned it thinks
* it was invoked and passed the argument 'p_arg' as follows:
*
* void Task (void *p_arg)
* {
* for (;;) {
* Task code;
* }
* }
*
* ptos is a pointer to the task's top of stack.If the configuration constant
* OS_STK_GROWTH is set to 1, the stack is assumed to grow downward (i.e. from high
* memory to low memory).'pstk' will thus point to the highest (valid) memory
* location of the stack.If OS_STK_GROWTH is set to 0, 'pstk' will point to the
* lowest memory location of the stack and the stack will grow with increasing
* memory locations.
*
* prio is the task's priority.A unique priority MUST be assigned to each task and the
* lower the number, the higher the priority.
*
* Returns : OS_ERR_NONE if the function was successful.
* OS_ERR_PRIO_EXIST if the task priority already exist
* (each task MUST have a unique priority).
* OS_ERR_PRIO_INVALID if the priority you specify is higher that the maximum
* allowed (i.e. >= OS_LOWEST_PRIO)
* OS_ERR_TASK_CREATE_ISR if you tried to create a task from an ISR.
* OS_ERR_ILLEGAL_CREATE_RUN_TIMEif you tried to create a task after safety critical
* operation started.
*********************************************************************************************************
*/
#if OS_TASK_CREATE_EN > 0u
INT8UOSTaskCreate (void (*task)(void *p_arg),
void *p_arg,
OS_STK*ptos,
INT16U stk_size,
INT8U prio) large reentrant
380091044
发表于 2024-2-4 13:33:43
380091044 发表于 2024-2-4 11:15
char putchar(char c)//putchar代表输出一个字符 发送完一个字符C后,最后返回的还是C,起到一个什么作 ...
感谢两位老师的指点,我再理解理解,