/****************************************************************************** ** Function: CFE_PSP_DeleteOSResources() ** ** Purpose: ** Clean up any OS resources when exiting from the cFE ** ** Arguments: ** (none) ** ** Return: ** (none) */ void CFE_PSP_DeleteOSResources (void) { uint32 i; int32 ReturnCode; for ( i = 0; i < OS_MAX_TASKS; i++) ReturnCode = OS_TaskDelete(i); printf("CFE_PSP: Deleted all Tasks in system\n"); for ( i = 0; i < OS_MAX_BIN_SEMAPHORES; i++ ) ReturnCode = OS_BinSemDelete(i); printf("CFE_PSP: Deleted all Binary Semaphores in system\n"); for ( i = 0; i < OS_MAX_COUNT_SEMAPHORES; i++ ) ReturnCode = OS_CountSemDelete(i); printf("CFE_PSP: Deleted all Counting Semaphores in system\n"); for ( i = 0; i < OS_MAX_MUTEXES; i++ ) ReturnCode = OS_MutSemDelete(i); printf("CFE_PSP: Deleted all Mutexes in system\n"); for ( i = 0; i < OS_MAX_QUEUES; i++ ) ReturnCode = OS_QueueDelete(i); printf("CFE_PSP: Deleted all Queues in system\n"); for ( i = 0; i < OS_MAX_TIMERS; i++ ) ReturnCode = OS_TimerDelete(i); printf("CFE_PSP: Deleted all Timers in system\n"); printf("CFE_PSP: NOTE: After quitting the cFE with a Control-C signal, it MUST be started next time\n"); printf(" with a Poweron Reset ( --reset PO ). \n"); }
static void test_001_004_execute(void) { uint32 tid; /* [1.4.1] Creating a task executing an infinite loop.*/ test_set_step(1); { int32 err; err = OS_TaskCreate(&tid, "deletable task", test_task_delete, (uint32 *)wa_test1, sizeof wa_test1, TASKS_BASE_PRIORITY, 0); test_assert(err == OS_SUCCESS, "deletable task creation failed"); } /* [1.4.2] Letting the task run for a while then deleting it. A check is performed on the correct execution of the delete handler.*/ test_set_step(2); { int32 err; (void) OS_TaskDelay(50); err = OS_TaskDelete(tid); test_assert(err == OS_SUCCESS, "delete failed"); test_assert_sequence("ABC", "events order violation"); } }
/*----------------------------------------------------------------------------*/ void Test_OS_TaskDelete_Success(void) { int32 expected = OS_SUCCESS; int32 actual = 99; /* Setup Inputs */ uint32 task_id = 6; OsApi_Adaptor_setTaskTableEntry(task_id, FALSE, 1, "testTask", 2, 3, 4, deleteFnc); OsApi_SetReturnCode(OSAPI_TASKDELETE_INDEX, VCS_OK, 1); /* Execute Test */ actual = OS_TaskDelete(task_id); /* Verify Outputs */ osTaskRecord_ptr = OsApi_Adaptor_getTaskTableEntry(task_id); UtAssert_True(actual == expected, "actual == OS_SUCCESS"); UtAssert_StrCmp("", osTaskRecord_ptr->name, "task name == expected"); UtAssert_True(osTaskRecord_ptr->free == TRUE, "task entry is free"); UtAssert_True(osTaskRecord_ptr->id == UNINITIALIZED, "task id == expected"); UtAssert_True(osTaskRecord_ptr->creator == UNINITIALIZED, "creator ID == input"); UtAssert_True(osTaskRecord_ptr->stack_size == UNINITIALIZED, "stack size == input"); UtAssert_True(osTaskRecord_ptr->priority == UNINITIALIZED, "priority == input"); UtAssert_True(osTaskRecord_ptr->delete_hook_pointer == NULL, "priority == input"); /* Verify Semaphore Usage */ UtAssert_True(getNSemTake(OS_TASK_TABLE_SEM) >= 1, "semaphore taken >1"); UtAssert_True(getNSemTake(OS_TASK_TABLE_SEM) == getNSemGive(OS_TASK_TABLE_SEM), "nSemTake == nSemGive"); }
Status OS_ShellCmdMMPlayHandler(const U32 argc, ConstStrP argv[]) { static OS_QueueHd mmplay_stdin_qhd; const char* file_path_str_p = (char*)argv[0]; OS_SignalId signal_id = OS_SIG_UNDEF; Status s = S_UNDEF; if (0 == OS_StrCmp("play", file_path_str_p)) { signal_id = OS_SIG_MMPLAY_PLAY; } else if (!OS_StrCmp("pause", file_path_str_p)) { signal_id = OS_SIG_MMPLAY_PAUSE; } else if (!OS_StrCmp("resume",file_path_str_p)) { signal_id = OS_SIG_MMPLAY_RESUME; } else if (!OS_StrCmp("stop", file_path_str_p)) { signal_id = OS_SIG_MMPLAY_STOP; } else if (!OS_StrCmp("seek", file_path_str_p)) { signal_id = OS_SIG_MMPLAY_SEEK; } else { IF_OK(s = OS_TaskCreate(file_path_str_p, &task_mmplay_cfg, &mmplay_thd)) { mmplay_stdin_qhd = OS_TaskStdInGet(mmplay_thd); if (OS_NULL == mmplay_stdin_qhd) { OS_TaskDelete(mmplay_thd); s = S_INVALID_QUEUE; } } }
static void test_001_003_execute(void) { /* [1.3.1] OS_TaskDelete() is invoked with task_id set to -1, an error is expected.*/ test_set_step(1); { int32 err; err = OS_TaskDelete((uint32)-1); test_assert(err == OS_ERR_INVALID_ID, "wrong task id not detected"); } }
/*----------------------------------------------------------------------------*/ void Test_OS_TaskDelete_IdInvalid(void) { int32 expected = OS_ERR_INVALID_ID; int32 actual = 99; /* Setup Inputs */ uint32 task_id = OS_MAX_TASKS; /* Execute Test */ actual = OS_TaskDelete(task_id); /* Verify Outputs */ UtAssert_True(actual == expected, "actual == OS_ERR_INVALID_ID"); /* Verify Semaphore Usage */ UtAssert_True(getNSemTake(OS_TASK_TABLE_SEM) == 1, "semaphore taken once"); UtAssert_True(getNSemTake(OS_TASK_TABLE_SEM) == getNSemGive(OS_TASK_TABLE_SEM), "nSemTake == nSemGive"); }
/*----------------------------------------------------------------------------*/ void Test_OS_TaskDelete_IdIsFree(void) { int32 expected = OS_ERR_INVALID_ID; int32 actual = 99; /* Setup Inputs */ uint32 task_id = OS_MAX_TASKS - 1; OsApi_Adaptor_setTaskTableEntry(task_id, TRUE, 1, "testTask", 2, 3, 4, deleteFnc); /* Execute Test */ actual = OS_TaskDelete(task_id); /* Verify Outputs */ UtAssert_True(actual == expected, "actual == OS_ERR_INVALID_ID"); /* Verify Semaphore Usage */ UtAssert_True(getNSemTake(OS_TASK_TABLE_SEM) == 1, "semaphore taken once"); UtAssert_True(getNSemTake(OS_TASK_TABLE_SEM) == getNSemGive(OS_TASK_TABLE_SEM), "nSemTake == nSemGive"); }
/*----------------------------------------------------------------------------*/ void Test_OS_TaskDelete_Error(void) { int32 expected = OS_ERROR; int32 actual = 99; /* Setup Inputs */ uint32 task_id = 13; OsApi_SetReturnCode(OSAPI_TASKDELETE_INDEX, VCS_ERROR, 1); /* Execute Test */ actual = OS_TaskDelete(task_id); /* Verify Outputs */ UtAssert_True(actual == expected, "actual == OS_ERROR"); /* Verify Semaphore Usage */ UtAssert_True(getNSemTake(OS_TASK_TABLE_SEM) >= 1, "semaphore taken >1"); UtAssert_True(getNSemTake(OS_TASK_TABLE_SEM) == getNSemGive(OS_TASK_TABLE_SEM), "nSemTake == nSemGive"); }
/*----------------------------------------------------------------------------*/ void Test_OS_TaskDelete_DelHookCall(void) { int32 expected = OS_SUCCESS; int32 actual = 99; /* Setup Inputs */ uint32 task_id = 8; OsApi_Adaptor_setTaskTableEntry(task_id, FALSE, 1, "testTask", 2, 3, 4, deleteFnc); deleteFncCalled = FALSE; OsApi_SetReturnCode(OSAPI_TASKDELETE_INDEX, VCS_OK, 1); /* Execute Test */ actual = OS_TaskDelete(task_id); /* Verify Outputs */ UtAssert_True(actual == expected, "actual == OS_SUCCESS"); UtAssert_True(deleteFncCalled == TRUE, "delete function hook called"); /* Verify Semaphore Usage */ UtAssert_True(getNSemTake(OS_TASK_TABLE_SEM) == 1, "semaphore taken once"); UtAssert_True(getNSemTake(OS_TASK_TABLE_SEM) == getNSemGive(OS_TASK_TABLE_SEM), "nSemTake == nSemGive"); }
void QSYS_Init(void) { u8 *ptr1; u8 *ptr2; // FIL *ptr3; OS_CPU_SysTickInit();//Initialize the SysTick. #if OS_USE_UCOS CPU_IntSrcPrioSet(CPU_INT_PENDSV,15); CPU_IntSrcPrioSet(CPU_INT_SYSTICK,15); #endif SetupHardware(); Debug("sizeof(INPUT_EVENT)=%d\n\r",sizeof(INPUT_EVENT));//for debug by karlno Debug("sizeof(PAGE_ATTRIBUTE)=%d\n\r",sizeof(PAGE_ATTRIBUTE));//for debug by karlno Debug("sizeof(IMG_BUTTON_OBJ)=%d\n\r",sizeof(IMG_BUTTON_OBJ));//for debug by karlno Debug("sizeof(CHAR_BUTTON_OBJ)=%d\n\r",sizeof(CHAR_BUTTON_OBJ));//for debug by karlno Debug("sizeof(MUSIC_EVENT)=%d\n\r",sizeof(MUSIC_EVENT));//for debug by karlno //Debug("sizeof(QSYS_MSG_BOX)=%d\n\r",sizeof(QSYS_MSG_BOX));//for debug by karlno if(SysEvt_MaxNum>32) { Debug("Error:SysEvt_MaxNum(%d) is too big!!!\n\r",SysEvt_MaxNum); Q_ErrorStopScreen("Error:SysEvt_MaxNum is too big!!!\n\r"); } gLCD_Mutex=OS_MutexCreate(); //创建触摸输入中断发生信号量 gTouchHandler_Sem=OS_SemaphoreCreate(0); gAllowTchHandler_Sem=OS_SemaphoreCreate(0); gVsDreq_Sem=OS_SemaphoreCreate(0); gRfRecvHandler_Sem=OS_SemaphoreCreate(0); //创建事件传递数据 gInputHandler_Queue=OS_MsgBoxCreate("Input Event",sizeof(INPUT_EVENT),16); gMusicHandler_Queue=OS_MsgBoxCreate("MusicKV Event",sizeof(MUSIC_EVENT),8); #if 0//debug OS_TaskCreate((void (*) (void *)) T1_Task,(void *) 0, (OS_STK *) &T1_TaskStack[OS_MINIMAL_STACK_SIZE - 1],T1_TASK_pRIORITY); //OS_TaskCreate(T2_Task , ( signed OS_CHAR * ) "T2 Handler", OS_MINI_STACK_SIZE, NULL, MUSIC_HANDLER_TASK_PRIORITY, NULL ); OS_TaskDelete(SYSTEM_TASK_PRIORITY); #endif #if 1 //首次下载完成后可关闭此处代码,防止误下载 Debug("\n\r-------------------SPI FLASH DOWNLOAD FROM SD------------------\n\r"); ptr1=(u8 *)Q_Mallco(CfgFileSize); ptr2=(u8 *)Q_Mallco(SPI_FLASH_PAGE_SIZE); SpiFlashDownFromSD(FALSE,"System/Down.cfg",ptr1,ptr2); Q_Free(ptr2); Q_Free(ptr1); Debug("-------------------SPI FLASH DOWNLOAD FROM SD------------------\n\r\n\r"); #endif Debug("----------------DATABASE SETTING INITIALIZATION----------------\n\r"); DB_Init(); Debug("----------------DATABASE SETTING INITIALIZATION----------------\n\r\n\r"); RTC_SetUp(); Gui_Init(); //图像库初始化 Gui_SetBgLight(Q_DB_GetValue(Setting_BgLightScale,NULL));//设置背光亮度 OS_TaskCreate(MusicHandler_Task,"Music",OS_MINIMAL_STACK_SIZE*8,NULL,MUSIC_TASK_PRIORITY,&MusicHandler_Task_Handle); OS_TaskCreate(TouchHandler_Task,"Touch",OS_MINIMAL_STACK_SIZE*3,NULL,TOUCH_TASK_PRIORITY,&TouchHandler_Task_Handle); OS_TaskCreate(KeysHandler_Task,"Keys",OS_MINIMAL_STACK_SIZE*2,NULL,KEYS_TASK_PRIORITY,&KeysHandler_Task_Handle); OS_TaskCreate(QWebHandler_Task,"QWeb",OS_MINIMAL_STACK_SIZE*8,NULL,RF_DATA_TASK_PRIORITY,&QWebHandler_Task_Handle); OS_TaskDelay(100); OS_TaskStkCheck(FALSE); if(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_2)==0) //如果没按下Key-PE2,就正常启动串口中断 { #if !QXW_RELEASE_VER//for debug USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);//release版本请关掉此句,免得不懂的用户说板卡老死机。 USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); #endif } }