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,起到一个什么作 ...
感谢两位老师的指点,我再理解理解,
380091044
发表于 2024-2-4 13:34:40
380091044 发表于 2024-2-4 11:41
// ==== LOGO ============ 图片中的这个循环函数,写LOGO 是啥意思?
我以为你就是原作者,感谢老师
380091044
发表于 2024-2-4 13:36:40
tzz1983 发表于 2024-2-4 12:58
这代码不像COsyOS的风格呀, 你应该看的是uCOS的代码吧
OSTaskCreate函数的原型为:
太感谢您了,收益很大,
380091044
发表于 2024-2-4 13:38:26
tzz1983 发表于 2024-2-4 12:58
这代码不像COsyOS的风格呀, 你应该看的是uCOS的代码吧
OSTaskCreate函数的原型为:
我看的是uCOSII-STC8-V1.06,刚开始,很懵逼,感谢老师指点。
380091044
发表于 2024-2-4 13:41:05
380091044 发表于 2024-2-4 11:41
// ==== LOGO ============ 图片中的这个循环函数,写LOGO 是啥意思?
这个循环对P2这样操作,有啥作用?不是太清楚
380091044
发表于 2024-2-4 13:45:29
CosyOS 发表于 2024-2-4 12:53
putchar用于printf的串口重定向,putchar中返回的c就是传入的c。至于为何要返回,我也不清楚。但由于keil ...
感谢老师,我知道,它有啥用就好了,能应用就行,还没有深究的能力,