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

📄 ssp_test.c

📁 abstract rtos
💻 C
字号:
#include "syscfg.h"#if (AOS_INCLUDE_SSP_TEST == TRUE)#ifdef __cplusplusextern "C"{#endif#include "aos.h"#include "ssp_test.h"#if (AOS_INCLUDE_SSP_TEST_TMR== TRUE)TMR pTmrMsgLoop[TEST_TMR_NUM];TMR pTmrMsgNoLoop[TEST_TMR_NUM];TMR pTmrCallBackLoop[TEST_TMR_NUM];TMR pTmrCallBackNoLoop[TEST_TMR_NUM];#endif#if (AOS_INCLUDE_SSP_TEST_TASK == TRUE)TMR pTmrTask;TMR pTmrTask1;U32 gulTestTaskID[TEST_TASK_NUM];U32 gulTestTaskArg[TEST_TASK_NUM];U32 gulTestTaskRunNum[TEST_TASK_NUM];U32 gulSuspend = 1;#endif#if (AOS_INCLUDE_SSP_TEST_MSG == TRUE)TMR pTmrMsg;U32 task1,task2;U32 gulSendMsgNum1    = 0;U32 gulSendMsgNum2    = 0;U32 gulReceiveMsgNum1 = 0;U32 gulReceiveMsgNum2 = 0;#endif#if (AOS_INCLUDE_SSP_TEST_QUE == TRUE)TMR pTmrQue,pTmrQue2;U32 gulQueFifo[TEST_QUE_NUM];U32 gulQuePrio[TEST_QUE_NUM];U32 gulQue = 0;U32 gulQueTaskId;U32 gulQueMsgSend = 0;#endifU32 aos_test_init( START_ORDER_E order ){    U32 i;    U32 ulRet;    S8  szBuf[AOS_NAME_LEN+1];        switch( order )    {        case STARTUP_INITIAL:            #if (AOS_INCLUDE_SSP_TEST_TMR== TRUE)            for(i = 0;i < TEST_TMR_NUM;i++)            {                aos_timer_start(pTmrMsgLoop+i,MPE_TEST,(i+1)*1000,i,i,AOS_TIMER_LOOP);                aos_timer_start(pTmrMsgNoLoop+i,MPE_TEST,(i+1)*100,i,i,AOS_TIMER_NO_LOOP);                aos_callbacktimer_start(pTmrCallBackLoop+i,MPE_TEST,(i+1)*100,i,i,aos_test_tmr_callback,AOS_TIMER_LOOP);                aos_callbacktimer_start(pTmrCallBackNoLoop+i,MPE_TEST,(i+1)*100,i,i,aos_test_tmr_callback,AOS_TIMER_NO_LOOP);            }            #endif            #if (AOS_INCLUDE_SSP_TEST_TASK == TRUE)            for(i = 1;i < TEST_TASK_NUM;i++)            {                aos_sprintf(szBuf,"test%d",i);                gulTestTaskArg[i] = i;                ulRet = aos_task_create(szBuf,i*1024,                                        TASK_PRIO_NORMAL,                                        AOS_TASK_NOPREEMPT,                                        aos_test_task_entry,                                        (void *)(gulTestTaskArg+i),                                        gulTestTaskID+i);                if(ulRet != AOS_SUCC)                {                    return AOS_FAIL;                }            }            aos_timer_start(&pTmrTask,MPE_TEST,10000,1,0,AOS_TIMER_LOOP);            aos_callbacktimer_start(&pTmrTask1, MPE_TEST,5000,2,0,aos_test_task_timer_callback,AOS_TIMER_LOOP);            #endif            #if (AOS_INCLUDE_SSP_TEST_MSG == TRUE)            ulRet = aos_task_create("task1",10*1024,                                    TASK_PRIO_NORMAL,                                    AOS_TASK_NOPREEMPT,                                    aos_test_task1_entry,                                    (void *)NULL,                                    &task1);            if(ulRet != AOS_SUCC)            {                return AOS_FAIL;            }                        ulRet = aos_task_create("task2",10*1024,                                    TASK_PRIO_HIGHEST,                                    AOS_TASK_NOPREEMPT,                                    aos_test_task2_entry,                                    (void *)NULL,                                    &task2);            if(ulRet != AOS_SUCC)            {                return AOS_FAIL;            }            aos_callbacktimer_start(&pTmrMsg,MPE_TEST,1000,1,0,aos_test_msg_callback,AOS_TIMER_LOOP);            #endif            #if (AOS_INCLUDE_SSP_TEST_QUE == TRUE)            for(i = 0;i < TEST_QUE_NUM;i++)            {                aos_sprintf(szBuf,"que%d",i);                aos_mq_create(szBuf,AOS_FIFO,TEST_QUE_MSG_NUM,TEST_QUE_MSG_SIZE,gulQueFifo+i);            }            aos_callbacktimer_start(&pTmrQue, MPE_TEST,100,1,0,aos_test_que_callback,AOS_TIMER_LOOP);            aos_callbacktimer_start(&pTmrQue2, MPE_TEST,5000,1,0,aos_test_que_callback2,AOS_TIMER_LOOP);            ulRet = aos_task_create("task1",10*1024,                                    TASK_PRIO_NORMAL,                                    AOS_TASK_NOPREEMPT,                                    aos_test_que_task_entry,                                    (void *)NULL,                                    &gulQueTaskId);            if(ulRet != AOS_SUCC)            {                return AOS_FAIL;            }                        #endif            break;        case STARTUP_LOAD_DATA:            break;        case STARTUP_GO:            break;        default:            break;    }        return AOS_SUCC;}VOID aos_test_msg_proc(MSG_S * msg, VOID * pvMsgBuf){    TIMER_MSG_S *pTmrMsg;        if (msg == NULL)    {        return;    }    if(msg->pvMsgBuf == NULL)    {        return;    }        if(msg->dstMpe != MPE_TEST)    {        return;    }        if(msg->dstProcessorId != LOCAL_PROCESSOR_ID)    {        return;    }    switch (msg->srcMpe)    {        case MPE_TIMER:            pTmrMsg = (TIMER_MSG_S *)pvMsgBuf;                        #if (AOS_INCLUDE_SSP_TEST_TMR == TRUE)            aos_printf(MPE_TEST,"timer:%d timeout!!!\r\n",pTmrMsg->ulTimerName);            #endif            #if (AOS_INCLUDE_SSP_TEST_TASK == TRUE)            aos_printf(MPE_TEST,"timer:%u timeout!!!\r\n",pTmrMsg->ulTimerName);            {                U32 i;                for(i=0;i<0x400000;i++);            }            aos_printf(MPE_TEST,"timer:%u run over!!!\r\n",pTmrMsg->ulTimerName);            #endif                        break;                    case MPE_TEST:            #if(AOS_INCLUDE_SSP_TEST_TASK == TRUE)            #endif                        #if(AOS_INCLUDE_SSP_TEST_MSG == TRUE)            if(*(U32 *)pvMsgBuf == MSG_PRIO_NORMAL)            {                gulReceiveMsgNum1 ++;                if((gulReceiveMsgNum1 % TEST_MSG_NUM) == 0)                {                }            }            if(*(U32 *)pvMsgBuf == MSG_PRIO_HIGH)            {                gulReceiveMsgNum2 ++;                if((gulReceiveMsgNum2 % TEST_MSG_NUM) == 0)                {                }            }            #endif                        break;        default:            AOS_ASSERT(0);            break;    }}#if (AOS_INCLUDE_SSP_TEST_TMR== TRUE)VOID aos_test_tmr_callback(U32 ulTmrName,U32 ulPara){    aos_printf(MPE_TEST,"callback timer %d timeout with para %d !!!",ulTmrName,ulPara);}#endif#if (AOS_INCLUDE_SSP_TEST_TASK == TRUE)void aos_test_task_entry(void *pArg){    U32 i = *(U32 *)pArg;    S8  szBuf[AOS_NAME_LEN+1];        for(;;)    {        aos_task_name(gulTestTaskID[i],szBuf);        aos_task_delay(1000);    }}VOID aos_cmd_show_task(U32 argc);VOID aos_cmd_show_performance(U32 argc);VOID aos_cmd_show_spy(U32 argc);VOID aos_cmd_show_exception(U32 argc);void aos_test_task_timer_callback(U32 ulTmrName,U32 ulPara){    static U32 ulRet = 0;    MSG_S Msg;    if(ulRet == 1)    {        aos_cmd_show_spy(2);    }    else    {        aos_cmd_show_exception(2);    }    #if 0    aos_printf(MPE_TEST,"timer %d timeout!!!",ulTmrName);        Msg.pvMsgBuf = aos_msg_alloc(MPE_TEST,4);    if(Msg.pvMsgBuf == NULL)    {        return;    }    *(U32 *)(Msg.pvMsgBuf) = ulRet++;    Msg.srcMpe = MPE_TEST;    Msg.dstMpe = MPE_TEST;    Msg.dstProcessorId = LOCAL_PROCESSOR_ID;    Msg.srcProcessorId = LOCAL_PROCESSOR_ID;    Msg.msgPrio = MSG_PRIO_NORMAL;    Msg.ulSize = 4;        aos_msg_send(&Msg);    #endif}#endif#if (AOS_INCLUDE_SSP_TEST_MSG == TRUE)void aos_test_task1_entry(void *pArg){    U32   ulRet;    MSG_S msg;    void  *pData;        for(;;)    {        pData = aos_msg_alloc(MPE_TEST,TEST_MSG_LEN);        if(pData != NULL)        {            *(U32 *)pData = MSG_PRIO_NORMAL;            msg.srcProcessorId = LOCAL_PROCESSOR_ID;            msg.dstProcessorId = LOCAL_PROCESSOR_ID;            msg.srcMpe         = MPE_TEST;            msg.dstMpe         = MPE_TEST;            msg.msgPrio        = MSG_PRIO_NORMAL;            msg.ulSize         = TEST_MSG_LEN;            msg.pvMsgBuf       = pData;            ulRet = aos_msg_send(&msg);            if(ulRet == AOS_SUCC)            {                gulSendMsgNum1 ++;            }                        if((gulSendMsgNum1 % TEST_MSG_NUM) == 0)            {            }        }        aos_task_delay(10);    }    (void)pArg;}void aos_test_task2_entry(void *pArg){    U32   ulRet;    MSG_S msg;    void  *pData;        for(;;)    {        pData = aos_msg_alloc(MPE_TEST,TEST_MSG_LEN);        if(pData != NULL)        {            *(U32 *)pData = MSG_PRIO_HIGH;            msg.srcProcessorId = LOCAL_PROCESSOR_ID;            msg.dstProcessorId = LOCAL_PROCESSOR_ID;            msg.srcMpe         = MPE_TEST;            msg.dstMpe         = MPE_TEST;            msg.msgPrio        = MSG_PRIO_HIGH;            msg.ulSize         = TEST_MSG_LEN;            msg.pvMsgBuf       = pData;            ulRet = aos_msg_send(&msg);            if(ulRet == AOS_SUCC)            {                gulSendMsgNum2 ++;            }                        if((gulSendMsgNum2 % TEST_MSG_NUM) == 0)            {            }        }        aos_task_delay(10);    }    (void)pArg;}void aos_test_msg_callback(U32 ulTmrName,U32 ulPara){    aos_printf(MPE_TEST,"\r\ntask1 send normal msg %d\r\ntask2 send high msg %d\r\nmpe_test receive normal msg %d\r\nmpe_test receive high msg %d\r\n",                        gulSendMsgNum1,gulSendMsgNum2,gulReceiveMsgNum1,gulReceiveMsgNum2);}#endif#if (AOS_INCLUDE_SSP_TEST_QUE == TRUE)void aos_test_que_callback(U32 ulTmrName,U32 ulPara){    U32 i;    U32 ulRet;    U8  *pData;        for(i = 0;i < TEST_QUE_NUM;i++)    {        if(gulQueFifo[i] != U32_BUTT)        {            pData = (U8 *)&i;            if(pData != NULL)            {                ulRet = aos_mq_send(gulQueFifo[i], pData,4,1);                if(ulRet == AOS_SUCC)                {                    if(i == 0)                    {                        gulQueMsgSend++;                    }                }            }        }    }}void aos_test_que_callback2(U32 ulTmrName,U32 ulPara){    if(gulQue < TEST_QUE_NUM)    {    }}void aos_test_que_task_entry(void *pArg){    U32 ulMsgCount = 0;    U32 ulMsg;    U32 ulRet;        for(;;)    {        ulRet = aos_mq_receive(gulQueFifo[0],(U8 *)&ulMsg,4,10);        if(ulRet == U32_BUTT)        {            continue;        }        ulMsgCount++;        if((ulMsgCount % (TEST_QUE_MSG_NUM/10)) == 0)        {            aos_printf(MPE_TEST,"task1 receive msg %d,timer send msg %d",ulMsgCount,gulQueMsgSend);        }    }}#endif#ifdef __cplusplus}#endif#endif

⌨️ 快捷键说明

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