[求助] ucosii移植的问题

chenbingjy   2024-4-30 19:06 楼主

我学习ucosii,试图把ucosii移植到51单片机上。

#if OS_TASK_CREATE_EN > 0u
INT8U  OSTaskCreate (void   (*task)(void *p_arg),
                     void  idata  *p_arg,
                     OS_STK idata *ptos,
                     INT8U    prio)reentrant
{
    OS_STK  idata  *psp;
    INT8U      err;
//#if OS_CRITICAL_METHOD == 3u                 /* Allocate storage for CPU status register               */
//    OS_CPU_SR  cpu_sr = 0u;
//#endif



#if OS_ARG_CHK_EN > 0u
    if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable range           */
        return (OS_PRIO_INVALID);
    }
#endif
    OS_ENTER_CRITICAL();
    if (OSIntNesting > 0u) {                 /* Make sure we don't create the task from within an ISR  */
        OS_EXIT_CRITICAL();
        //return (OS_TASK_CREATE_ISR);
		return (OS_TASK_DEL_ERR);
    }
    if (OSTCBPrioTbl[prio] == (OS_TCB idata *)0) { /* Make sure task doesn't already exist at this priority  */
        OSTCBPrioTbl[prio] = OS_TCB_RESERVED;/* Reserve the priority to prevent others from doing ...  */
                                             /* ... the same thing until task is created.              */
        OS_EXIT_CRITICAL();
        psp = OSTaskStkInit(task, p_arg, ptos, 0u);             /* Initialize the task's stack         */
        err = OS_TCBInit(prio, psp, (OS_STK *)0, 0u, 0u, (void *)0, 0u);
        if (err == OS_ERR_NONE) {
            if (OSRunning == OS_TRUE) {      /* Find highest priority task if multitasking has started */
                OS_Sched();
            }
        } else {
            OS_ENTER_CRITICAL();
            OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others                 */
            OS_EXIT_CRITICAL();
        }
        return (err);
    }
    OS_EXIT_CRITICAL();
    return (OS_ERR_PRIO_EXIST);
}
#endif
#if OS_TASK_CREATE_EN > 0u
INT8U         OSTaskCreate            (void           (*task)(void *p_arg),
                                       void        idata    *p_arg,
                                       OS_STK      idata    *ptos,
                                       INT8U            prio)reentrant;
#endif
#define task1prio	2
#define task2prio	4
sbit P10 =P1^0;
sbit P11 =P1^1;

INT8U data task1stk[stksize];
INT8U idata task2stk[stksize];

void max(void)reentrant ;


void task1(void);
void task2(void);

void main(void)
{
	Time_Init ();
	OSInit();
	OSTaskCreate(task1,(void* )0,task1stk,task1prio);
	//OSTaskCreate(task1,(void * )0,&task1stk[stksize-1],2);
	OSTaskCreate(task2,(void * )0,task2stk,task2prio);
	OSStart();
	

}

void task1(void) 
{


while(1)
	
{
	P10 = !P10;
	//max();
	OSTimeDlyHMSM(0,0,1,0);

}

}

void task2(void) 
{

while(1)
	
{
	
	P11 = !P11;
	OSTimeDlyHMSM(0,0,2,0);

}

}

void max(void)reentrant
{
 INT32U i;
	i++;

}

可是编译有两个不对劲的警告

1710053071881.jpg
产生警告的语句如下:
OSTaskCreate(task1,(void* )0,task1stk,task1prio);
	//OSTaskCreate(task1,(void * )0,&task1stk[stksize-1],2);
	OSTaskCreate(task2,(void * )0,task2stk,task2prio);

 

请问高手,哪里出了问题?如何解决?谢谢!

 

为江山踏坏了乌骓马,为社稷拉断了宝雕弓。

回复评论 (3)

支持楼主,不过咱也不知道是什么原因,期待大佬能提供答案

点赞  2024-4-30 22:08

没玩过。。。。但看楼主截图上,不是说main.c的37行、39行问题吗

pointer to differenct objects

指向不同对象的指针,意思是,你的指针指向的类型不一致?

点赞  2024-5-7 09:57

没有盲移植过,都是别人移植成功了,才自己拿着别人的代码移植,里面有一段代码非常重要,牵涉到内核 入栈出栈,内存保护的,还有一个定时器也非常重要。

点赞  2024-5-7 14:19
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复