?? test.c
字號:
////這份代碼主要是測試了接口函數不使用任務函數實現的情況下,只是定時地等待實現具體功能
////的任務函數對某些全局變量的修改之后,程序仍然能達到想達到的目的;在程序中,使用全局變量
////做為協議棧的接口函數和實現具體功能的任務函數之間的通信方式
//#include <includes.h>
//
//
//
//#define TASK_STK_SIZE 128
//#define TASK_START_PRIO 5
//
//
//
//typedef struct{
//
// INT8U para1;
// INT8U para2;
//}TEST_PARAMETERS;
//TEST_PARAMETERS testParameters;
//
//OS_STK AppStartTaskStk[TASK_STK_SIZE];
//OS_STK taskScanTaskStk[TASK_STK_SIZE];
//
//OS_STK testATaskStk[TASK_STK_SIZE];
//OS_STK testBTaskStk[TASK_STK_SIZE];
//
//OS_STK funATaskStk[TASK_STK_SIZE];
//OS_STK funBTaskStk[TASK_STK_SIZE];
//
//OS_STK wrapFunATaskStk[TASK_STK_SIZE];
//INT16S key;//用于退出的鍵
//char * s;
//INT8U err;
//char *ss;
//
//
//
//static void AppStartTask(void *p_arg);
//
//static void taskScan(void *p_arg);
//
//
//void testA(void *pTaskNum);
//void testB(void *pTaskNum);
////void funA(void *pTaskNum);
//INT8U funA(INT8U para1,INT8U para2);
////void funA();
//int funB();
////void funB(void *pTaskNum);
//
//
////void wrapNlmeFormNetworkTask(void *pTaskNum);
////void mlmeScanEmulation(void *pTaskNum);
////void nwkFormProcedure();
////void mscScanProcedureEmulation();
//INT8U scanStatus=0;
//
//void wrapFunA(void *pTaskNum);
//void wrapFunB(void *pTaskNum);
//
//volatile int testVariable=0;
//BOOLEAN testAReturn;
//BOOLEAN testBReturn;
//
//// 信號量句柄
//OS_EVENT *scanStatusSem=NULL;
//OS_EVENT *returnValueFromFunBSem=NULL;
//
//OS_EVENT *scanMessageBox=NULL;
//OS_EVENT *formNetworkMessageBox=NULL;
//OS_EVENT *scanReturnMessageBox=NULL;
//OS_EVENT *commonMessageBox=NULL;
//
//
//
//
//volatile int returnValueOfFunB=100;
//volatile int testValue;
//
//#if OS_VIEW_MODULE > 0
//static void AppTerminalRx(INT8U rx_data);
//#endif
//
//
//
//void main(int argc, char *argv[])
//{
// INT8U err;
//
//
//#if 0
// BSP_IntDisAll(); /* For an embedded target, disable all interrupts until we are ready to accept them */
//#endif
//
// OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel" */
// OSTaskCreateExt(AppStartTask,
// (void *)0,
// (OS_STK *)&AppStartTaskStk[TASK_STK_SIZE-1],
// TASK_START_PRIO,
// TASK_START_PRIO,
// (OS_STK *)&AppStartTaskStk[0],
// TASK_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, (INT8U *)"Start Task", &err);
//#endif
//
//#if OS_TASK_NAME_SIZE > 14
// OSTaskNameSet(OS_IDLE_PRIO, (INT8U *)"uC/OS-II Idle", &err);
//#endif
//
//#if (OS_TASK_NAME_SIZE > 14) && (OS_TASK_STAT_EN > 0)
// OSTaskNameSet(OS_STAT_PRIO, "uC/OS-II Stat", &err);
//#endif
// OSStart(); /* Start multitasking (i.e. give control to uC/OS-II) */
//}
///*$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()'.
//* Notes : 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 AppStartTask (void *p_arg)
//{
// p_arg = p_arg;
//
//#if 0
// BSP_Init(); /* For embedded targets, initialize BSP functions */
//#endif
//
//
//#if OS_TASK_STAT_EN > 0
// OSStatInit(); /* Determine CPU capacity */
//#endif
// //OSTaskCreateExt(nlmeFormNetEmulation,
// // (void *)&testParameters, //this is the parameter
// // (OS_STK *)&funATaskStk[TASK_STK_SIZE-1],
// // TASK_START_PRIO+7,
// // TASK_START_PRIO+7,
// // (OS_STK *)&funATaskStk[0],
// // TASK_STK_SIZE,
// // (void *)0,
// // OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
// OSTaskCreateExt(wrapFunA,
// (void *)&testParameters, //this is the parameter
// (OS_STK *)&wrapFunATaskStk[TASK_STK_SIZE-1],
// TASK_START_PRIO+7,
// TASK_START_PRIO+7,
// (OS_STK *)&wrapFunATaskStk[0],
// TASK_STK_SIZE,
// (void *)0,
// OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
// for(;;)
// {
// //如果按下esc鍵,則退出ucOS
// if(PC_GetKey(&key)==TRUE)
// {
// if(key==0x1B)
// {
// PC_DOSReturn();
// }
// }
// //OS_Printf("Delay 1 second and print\n");
// OSTimeDlyHMSM(0,0,3,0);
// }
//}
//
//
////void nlmeFormNetEmulation(void *pTaskNum)
////{
//// UINT8 testANum;
//// DWORD rc;
//// INT8U err;
//// printf("nlmeFormNetEmulation starts!\n");
//// //請求組網消息郵箱
//// for(;;)
//// {
//// /// ss=OSMboxPend(formNetworkMessageBox,10,&err);
//// nwkFormProcedure();
//// ss=OSMboxPend(commonMessageBox,10,&err);
//// if(err==OS_NO_ERR)
//// break;
//// else
//// {
//// OSTimeDlyHMSM(0,0,1,0);
//// continue;
//// }
//// }
//// printf("nlmeFormNetEmulation end!\n");
//// OSTaskDel(TASK_START_PRIO+6);
//// OSTaskDel(TASK_START_PRIO+7);
////}
////
////void nwkFormProcedure()
////{
////
//// OSTaskCreateExt(mlmeScanEmulation,
//// (void *)0, //this is the parameter
//// (OS_STK *)&funBTaskStk[TASK_STK_SIZE-1],
//// TASK_START_PRIO+6,
//// TASK_START_PRIO+6,
//// (OS_STK *)&funBTaskStk[0],
//// TASK_STK_SIZE,
//// (void *)0,
//// OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
//// printf("\nnwkFormProcedure!\n");
////
////}
////
////void mlmeScanEmulation(void *pTaskNum)
////{
//// printf("mlmeScanEmulation starts!\n");
//// mscScanProcedureEmulation();
//// for(;;)
//// {
//// //mscScanProcedureEmulation();
//// printf("mlmeScanEmulation completes");
//// OSMboxPost(commonMessageBox,&scanStatus);
//// OSTimeDlyHMSM(0,0,1,0);
//// //OSTaskDel(TASK_START_PRIO+6);
//// }
////
////}
////
////// scanMessageBox=OSMboxCreate((void *)0); //創建信道掃描消息郵箱
//////formNetworkMessageBox=OSMboxCreate((void *)0); //創建組網消息郵箱
//////scanReturnMessageBox=OSMboxCreate((void *)0); //創建掃描函數和組網任務函數之間進行通信的郵箱
////// //commonMessageBox=OSMboxCreate((void *)0); //創建公共消息郵箱,負責在所有的任務之間進行通信
//////testParameters.para1=1;
//////testParameters.para2=2;
////
////void mscScanProcedureEmulation()
////{
////
//// scanStatus=1;
//// printf("mscScanProcedureEmulation completes!\n");
//// //OSMboxPost(formNetworkMessageBox,&scanStatus);
////}
//
//
////
////void testA(void *pTaskNum) //emulates nwkFormNetworkProcedure
////{
//// BYTE i;
//// INT8U err;
//// OS_Printf("testA!\n");
//// // returnValueOfFunB=funB();
//// OSTaskCreateExt(funB,
//// (void *)0,
//// (OS_STK *)&funBTaskStk[TASK_STK_SIZE-1],
//// TASK_START_PRIO+4,
//// TASK_START_PRIO+4,
//// (OS_STK *)&funBTaskStk[0],
//// TASK_STK_SIZE,
//// (void *)0,
//// OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
////
////
////
//// //請求組網消息郵箱
//// for(;;)
//// {
//// ///ss=OSMboxPend(scanReturnMessageBox,10,&err);
//// ss=OSMboxPend(commonMessageBox,10,&err);
//// if(err==OS_NO_ERR)
//// {
//// printf("testA completes!\n");
//// s='c';
//// OSMboxPost(commonMessageBox,s);
////
//// OSTimeDlyHMSM(0,0,1,0);
//// break;
//// }
//// else
//// {
//// OSTimeDlyHMSM(0,0,1,0);
//// printf("No message in scanReturnMessageBox!\n");
//// continue;
//// }
//// }
//// ///OSMboxPost(formNetworkMessageBox,s);
////
//// OSTaskDel(TASK_START_PRIO+5);
//// printf("here?");
////
////
////}
////
////
////void testB(void *pTaskNum)
////{
//// BYTE i;
//// INT8U err;
//// printf("testB starts!\n");
//// for(;;)
//// {
//// testVariable=1;
//// //sprintf(s,"%d",testVariable);
//// //s='s';
//// ///OSMboxPost(scanMessageBox,&testVariable);
//// OSMboxPost(commonMessageBox,&testVariable);
//// printf("testB completes!\n");
//// //OSTimeDlyHMSM(0,0,1,0);
//// break;
//// }
//// OSTimeDlyHMSM(0,0,1,0);
//// OSTaskDel(TASK_START_PRIO+3); //TASK_START_PRIO+3 is the task testB's prority!
////}
////
////
////
//////void funA() //emulate nlmeFormNetworkRequest
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -