⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 massapp.c

📁 uCOS在PIC芯片中的移植:以PIC24HJ64GP210为例进行uCOS在Microchip芯片中的移植
💻 C
字号:
/*
*********************************************************************************************************
*                                               uC/OS-II
*                                         The Real-Time Kernel
*
*                             (c) Copyright 1998-2005, Micrium, Weston, FL
*                                          All Rights Reserved
*
*
*                                      Microchip Application Code
*
* File : MassApp.C
* By   : tbh080602
*********************************************************************************************************
*/
#include <includes.h>

/*
*********************************************************************************************************
*                                                CONSTANTS
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                                VARIABLES
*********************************************************************************************************
*/
OS_STK        AppStartTaskStk[APP_TASK_START_STK_SIZE];

OS_EVENT *MboxRx_Finish,*MboxTx_Finish,*MboxCN_Width,*MboxCmd_TechStart,
        *MboxTech_Finish,*MboxTech_SurMove,*MboxTech_Momi,*MboxTech_Tataki,
        *MboxSurMove_Nose,*MboxMomi_Finish,*MboxTataki_Finish,*MboxUD_Sur,*MboxFB_Sur;

//INT8U MsgCN_Width;//电平变化中断处理向揉捏处理任务发送的宽度通知,取值与手技指令中的相关取值相同
MSG_TECH_SUR_STRUCT MsgTech_SurMove;//手技处理任务向升降出退任务发送的升降出退命令
MSG_SUR_TECH_STRUCT MsgSurMove_Nose;//升降出退任务向手技处理任务发送升降出退状态通知
MSG_TECH_MOMI_STRUCT MsgTech_Momi;//手技处理任务向揉捏处理任务发送揉捏命令
MSG_TECH_TATAKI_STRUCT MsgTech_Tataki;//手技处理任务向捶打处理任务发送捶打命令

/*
*********************************************************************************************************
*                                            FUNCTION PROTOTYPES
*********************************************************************************************************
*/

static  void  AppStartTask(void *p_arg);

#if OS_VIEW_MODULE > 0
static  void  AppTerminalRx(INT8U rx_data);
#endif

/*
*********************************************************************************************************
*                                                main()
*
* Description : This is the standard entry point for C code.  It is assumed that your code will call
*               main() once you have performed all necessary 68HC12 and C initialization.
* Arguments   : none
*********************************************************************************************************
*/

INT16S  main (void)
{

    BSP_IntDisAll();                                                    /* Disable all interrupts until we are ready to accept them */

    OSInit();                                                           /* Initialize "uC/OS-II, The Real-Time Kernel"              */

    OSTaskCreateExt(AppStartTask,
                    (void *)0,
                    (OS_STK *)&AppStartTaskStk[0],
                    APP_TASK_START_PRIO,
                    APP_TASK_START_PRIO,
                    (OS_STK *)&AppStartTaskStk[APP_TASK_START_STK_SIZE-1],
                    APP_TASK_START_STK_SIZE,
                    (void *)0,
                    OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);

#if OS_TASK_NAME_SIZE > 11
    OSTaskNameSet(APP_TASK_START_PRIO, "AppStartTask", &Err);
#endif

    OSStart();                                                          /* Start multitasking (i.e. give control to uC/OS-II)       */

	return (-1);                                                        /* Return an error - This line of code is unreachable       */
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                          STARTUP TASK
*
* Description : This is an example of a startup task.  As mentioned in the book's text, you MUST
*               initialize the ticker only once multitasking has started.
* Arguments   : p_arg   is the argument passed to 'AppStartTask()' by 'OSTaskCreate()'.
* Mboxs       : 1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                  used.  The compiler should not generate any code for this statement.
*               2) Interrupts are enabled once the task start because the I-bit of the CCR register was
*                  set to 0 by 'OSTaskCreate()'.
*********************************************************************************************************
*/
//void Test(INT8U (*prog1)(INT8U),INT8U *prog2(INT8U),INT8U prog3(),void *prog4(),INT8U prog5(INT8U))
//{
//	INT8U b;
//	b=(*prog1)(2);
//	b=(*prog2)(2);//warning: assignment makes integer from pointer without a cast	
//	b=(*prog3)(8);
//	b=(*prog4)(8);//warning: assignment makes integer from pointer without a cast
//	b=(*prog5)(2);
//	b=prog1(2);
//	b=prog2(2);//warning: assignment makes integer from pointer without a cast
//	b=prog3(8);
//	b=prog4(8);//warning: assignment makes integer from pointer without a cast
//	b=prog5(2);
//	//b=*prog1(2);//error: invalid type argument of 'unary *'
//	b=*prog2(2);//AS b=*(prog2(8))
//	//b=*prog3(8);//error: invalid type argument of 'unary *'
//	//b=*prog4(8);//error: void value not ignored as it ought to be
//	//b=*prog5(2);//error: invalid type argument of 'unary *'
//}
//INT8U test1(INT8U i)
//{
//	return(++i);
//}
//INT8U test2(INT8U i)
//{
//	return(i++);
//}
//void test3(INT8U *i,INT8U *j)
//{
//	*i=*j;
//}

static  void  AppStartTask (void *p_arg)
{
    (void)p_arg;

    BSP_Init();                                                         /* Initialize BSP functions                                 */

#if OS_TASK_STAT_EN > 0
    OSStatInit();                                                       /* Determine CPU capacity  */
#endif

#if OS_VIEW_MODULE > 0
    OSView_Init();
    OSView_TerminalRxSetCallback(AppTerminalRx);
#endif

    
    MboxRx_Finish=OSMboxCreate((void*)0);//接收中断处理向指令处理任务发送本数据包接收完成通知的邮箱
    OSEventNameSet(MboxRx_Finish,(INT8U *)"Rx_Cmd",&Err);
    MboxTx_Finish=OSMboxCreate((void*)1);//发送中断处理向指令处理任务发送本数据包发送完成通知的邮箱,由于复位时不需等待发送中断发送信息,故应初始化为非空
    OSEventNameSet(MboxTx_Finish,(INT8U *)"Tx_Cmd",&Err);
    MboxCN_Width=OSMboxCreate((void*)0);//电平变化中断处理向揉捏处理任务发送宽度通知的邮箱
    OSEventNameSet(MboxCN_Width,(INT8U *)"CN_Momi",&Err);
    MboxCmd_TechStart=OSMboxCreate((void*)0);//指令处理任务向手技处理任务发送手技开始命令的邮箱
    OSEventNameSet(MboxCmd_TechStart,(INT8U *)"Cmd_Tech",&Err);
    MboxTech_Finish=OSMboxCreate((void*)0);//手技处理任务向指令处理任务发送手技完成通知的邮箱(预留.不能在指令处理中等待手技完成,因为要实时相应接收的其它指令)
    OSEventNameSet(MboxTech_Finish,(INT8U *)"Tech_Finish",&Err);
    MboxTech_SurMove=OSMboxCreate((void*)0);//手技处理任务向升降出退任务发送升降出退命令的邮箱
    OSEventNameSet(MboxTech_SurMove,(INT8U *)"Tech_Sur",&Err);
    MboxTech_Momi=OSMboxCreate((void*)0);//手技处理任务向揉捏处理任务发送揉捏命令的邮箱
    OSEventNameSet(MboxTech_Momi,(INT8U *)"Tech_Momi",&Err);
    MboxTech_Tataki=OSMboxCreate((void*)0);//手技处理任务向捶打处理任务发送捶打命令的邮箱
    OSEventNameSet(MboxTech_Tataki,(INT8U *)"Tech_Tataki",&Err);
    MboxSurMove_Nose=OSMboxCreate((void*)0);//升降出退任务向手技处理任务发送升降出退状态通知的邮箱
    OSEventNameSet(MboxSurMove_Nose,(INT8U *)"Sur_Tech",&Err);
    MboxMomi_Finish=OSMboxCreate((void*)0);//揉捏处理任务向手技处理任务发送揉捏完成通知的邮箱
    OSEventNameSet(MboxMomi_Finish,(INT8U *)"Momi_Tech",&Err);
    MboxTataki_Finish=OSMboxCreate((void*)0);//捶打处理任务向手技处理任务发送捶打完成通知的邮箱
    OSEventNameSet(MboxTataki_Finish,(INT8U *)"Tataki_Tech",&Err);
    MboxUD_Sur=OSMboxCreate((void*)0);
    OSEventNameSet(MboxUD_Sur,(INT8U *)"UD_Sur",&Err);
    MboxFB_Sur=OSMboxCreate((void*)0);
    OSEventNameSet(MboxFB_Sur,(INT8U *)"FB_Sur",&Err);
    
    MASS_TXSTART((INT8U*)"#4\n"); //发送复位字符
    //TaskStartCreateTasks();
    {
//	static int a=10,b=1,c=0,d=0,*adr=(int*)0x1000;
//    c=a+++b;
//    d=a++;
//    *adr=0xaaaa;

//		SETUP_MOMI_CW(10);
//		OSTimeDlyHMSM(0, 0, 0, 100);    
//		SETUP_MOMI_CW(TECH_SPEED_STOP);
//		OSTimeDlyHMSM(0, 0, 0, 100);    
//		SETUP_MOMI_CW(10);
//		OSTimeDlyHMSM(0, 0, 0, 100);    
//		SETUP_MOMI_CW(TECH_SPEED_STOP);
//		OSTimeDlyHMSM(0, 0, 0, 100);    
//		SETUP_MOMI_CCW(10);
//		OSTimeDlyHMSM(0, 0, 0, 100);    
//		SETUP_MOMI_CCW(3);
//		OSTimeDlyHMSM(0, 0, 0, 100);    
//		SETUP_MOMI_CW(10);

//		Test(test1,test2,test1,test2,test1);//warning: passing argument 2,3,4 of 'Test' from incompatible pointer type

		//INT16U a=TtkKeepTimeTab[8];
		//INT16U t=TICKS(a);
//		INT8U *a,b=100;
//		INT16S c=0x8266;
//    	b =  (INT8U)(((INT32U)c >> 16) & 0x7F);
		//test3(a,&b);
    }    
    CmdAnalyse ();
}
/*
*********************************************************************************************************
*                                      TERMINAL WINDOW CALLBACK
*********************************************************************************************************
*/


#if OS_VIEW_MODULE > 0
static  void  AppTerminalRx (INT8U rx_data)
{
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -