コード例 #1
0
ファイル: osapi_testcase_tasks.c プロジェクト: billvb/osal
/*----------------------------------------------------------------------------*/
void Test_OS_TaskCreate_SpawnError(void)
{
    int32 expected = OS_ERROR;
    int32 actual   = 99;

    /* Setup Inputs */
    uint32 task_id    = 1;
    char *task_name   = "test";
    uint32 stack      = 1;
    uint32 stack_size = 1;
    uint32 priority   = 1;
    uint32 flags      = OS_FP_ENABLED;

    OsApi_Adaptor_setTaskTableEntry(0, TRUE, 0, "", 0, 0, 0, NULL);
    OsApi_SetReturnCode(OSAPI_TASKSPAWN_INDEX, VCS_ERROR, 1);

    /* Execute Test */
    actual = OS_TaskCreate(&task_id, task_name, dummyFnc, &stack, stack_size, priority, flags);

    /* Verify Outputs */
    UtAssert_True(actual == expected, "actual == OS_ERROR");
    UtAssert_True(OsApi_Adaptor_getTaskTableEntry(0)->free == TRUE,
                  "task table entry still free");

    /* 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");
}
コード例 #2
0
ファイル: osapi_testcase_tasks.c プロジェクト: billvb/osal
/*----------------------------------------------------------------------------*/
void Test_OS_TaskCreate_NameTooLong(void)
{
    int32 expected = OS_ERR_NAME_TOO_LONG;
    int32 actual   = 99;

    /* Setup Inputs */
    uint32 task_id    = 1;
    char *task_name   = "test";
    uint32 stack      = 1;
    uint32 stack_size = 1;
    uint32 priority   = 1;
    uint32 flags      = 1;

    OsApi_SetReturnCode(OSAPI_STRLEN_INDEX, OS_MAX_API_NAME, 1);

    /* Execute Test */
    actual = OS_TaskCreate(&task_id, task_name, dummyFnc, &stack, stack_size, priority, flags);

    /* Verify Outputs */
    UtAssert_True(actual == expected, "actual == OS_ERR_NAME_TOO_LONG");

    /* Verify Semaphore Usage */
    UtAssert_True(getNSemTake(OS_TASK_TABLE_SEM) == getNSemGive(OS_TASK_TABLE_SEM),
                  "nSemTake == nSemGive");
    UtAssert_True(getNSemTake(OS_TASK_TABLE_SEM) == 0, "No OS_TASK_TABLE_SEM taken");
}
コード例 #3
0
ファイル: osapi_testcase_tasks.c プロジェクト: billvb/osal
/*----------------------------------------------------------------------------*/
void Test_OS_TaskCreate_NameTaken(void)
{
    int32 expected = OS_ERR_NAME_TAKEN;
    int32 actual   = 99;

    /* Setup Inputs */
    uint32 task_id    = 1;
    char *task_name   = "test";
    uint32 stack      = 1;
    uint32 stack_size = 1;
    uint32 priority   = 1;
    uint32 flags      = 1;

    OsApi_Adaptor_setTaskTableEntry(0, TRUE, 0, "", 0, 0, 0, NULL);
    OsApi_Adaptor_setTaskTableEntry(1, FALSE, 0, "bad_task_name", 0, 0, 0, NULL);
    OsApi_Adaptor_setTaskTableEntry(OS_MAX_TASKS - 1, FALSE, 0, task_name, 0, 0, 0, NULL);

    /* Execute Test */
    actual = OS_TaskCreate(&task_id, task_name, dummyFnc, &stack, stack_size, priority, flags);

    /* Verify Outputs */
    UtAssert_True(actual == expected, "actual == OS_ERR_NAME_TAKEN");

    /* 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");
}
コード例 #4
0
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");
  }
}
コード例 #5
0
ファイル: main.c プロジェクト: sdalu/ChibiOS
/*
 * Application entry point.
 */
int main(void) {
  uint32 blinker_id;

  /* HAL initialization, this also initializes the configured device drivers
     and performs the board-specific initializations.*/
  halInit();

  /* OS initialization.*/
  (void) OS_API_Init();

  /* Activates the serial driver 2 using the driver default configuration.
    PA2(TX) and PA3(RX) are routed to USART2.*/
  sdStart(&SD2, NULL);
  palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
  palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));

  /* Starting the blinker thread.*/
  (void) OS_TaskCreate(&blinker_id, "blinker", blinker,
                       (uint32 *)wa_blinker, sizeof wa_blinker,
                       128, 0);

  /* In the ChibiOS/RT OSAL implementation the main() function is an
     usable thread with priority 128 (NORMALPRIO), here we just sleep
     in a loop printing a message on the serial port.*/
  while (true) {
    sdWrite(&SD2, (uint8_t *)"Hello World!\r\n", 14);
    OS_TaskDelay(500);
  }
}
コード例 #6
0
ファイル: main.c プロジェクト: ChibiOS/ChibiOS
/*
 * Application entry point.
 */
int main(void) {
  uint32 blinker_id;

  /* HAL initialization, this also initializes the configured device drivers
     and performs the board-specific initializations.*/
  halInit();

  /* OS initialization.*/
  (void) OS_API_Init();

  /* Activates the serial driver 1 using the driver default configuration.*/
  sdStart(&SD1, NULL);

  /* ARD_D13 is programmed as output (board LED).*/
  palClearLine(LINE_ARD_D13);
  palSetLineMode(LINE_ARD_D13, PAL_MODE_OUTPUT_PUSHPULL);

  /* Starting the blinker thread.*/
  (void) OS_TaskCreate(&blinker_id, "blinker", blinker,
                       (uint32 *)wa_blinker, sizeof wa_blinker,
                       128, 0);

  /* In the ChibiOS/RT OSAL implementation the main() function is an
     usable thread with priority 128 (NORMALPRIO), here we just sleep
     waiting for a button event, then the test suite is executed.*/
  while (true) {
    if (palReadLine(LINE_BUTTON_USER))
      test_execute((BaseSequentialStream *)&SD1, &nasa_osal_test_suite);
    OS_TaskDelay(500);
  }
}
コード例 #7
0
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;
            }
        }
    }
コード例 #8
0
void setup()
{
	eBoxInit();
	OS_Init();
	
	uart1.begin(9600);
	uart1.printf("\r\nuart1 9600 ok!");
	
		uart1.printf("\r\nos初始化!");

	OS_TaskCreate(task_1,&TASK_1_STK[TASK_1_STK_SIZE-1],TASK1_PRIO);
	OS_TaskCreate(task_2,&TASK_2_STK[TASK_2_STK_SIZE-1],TASK2_PRIO);
	OS_TaskCreate(task_3,&TASK_3_STK[TASK_3_STK_SIZE-1],TASK3_PRIO);
	uart1.printf("\r\nos创建任务成功");

	OS_Start();

}
コード例 #9
0
void OS_Application_Startup(void)
{
   uint32             status;

   OS_API_Init();

   OS_printf("OS Application Startup\n");

   status = OS_QueueCreate( &msgq_id, "MsgQ", MSGQ_DEPTH, MSGQ_SIZE, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Message Queue\n");
   }

   /*
   ** Create a timer
   */
   status = OS_TimerCreate(&timer_id, "Timer 1", &timer_accuracy, &(TimerFunction));
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating OS Timer\n");
   }
   else
   {
      OS_printf("Timer ID = %d\n", (int)timer_id);
      OS_printf("Timer Accuracy = %d microseconds \n",(int)timer_accuracy);
   }

   /*
   ** Create the "consumer" task.
   */
   status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 1\n");
   }
   else
   {
      OS_printf("Created Task 1\n");
   }

   /*
   ** Start the timer
   */
   status  =  OS_TimerSet(timer_id, timer_start, timer_interval);
   if ( status != OS_SUCCESS )
   {
       OS_printf("Error calling OS_TimerSet: ID = %d\n", (int)timer_id);
   }
   else
   {
       OS_printf("Timer programmed\n");
   }

}
コード例 #10
0
ファイル: example1.c プロジェクト: gpgreen/osal-beagleboard
void OS_Application_Startup(void)
{
  uint32 status;
  printf("********If You see this, we got into OS_Application_Startup****\n");

  status = OS_QueueCreate( &msgq_id, "MsgQ", MSGQ_DEPTH, MSGQ_SIZE, 0);
  if ( status != OS_SUCCESS )
  {
     printf("Error creating Message Queue\n");
  }

  status = OS_MutSemCreate( &mutex_id, "Mutex", 0);
  if ( status != OS_SUCCESS )
  {
     printf("Error creating mutex\n");
  }
  else
  {
     printf("MutexSem ID = %d\n",mutex_id);
  }

  status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0);
  if ( status != OS_SUCCESS )
  {
     printf("Error creating Task 1\n");
  }

  status = OS_TaskCreate( &task_2_id, "Task 2", task_2, task_2_stack, TASK_2_STACK_SIZE, TASK_2_PRIORITY, 0);
  if ( status != OS_SUCCESS )
  {
     printf("Error creating Task 2\n");
  }

  status = OS_TaskCreate( &task_3_id, "Task 3", task_3, task_3_stack, TASK_3_STACK_SIZE, TASK_3_PRIORITY, 0);
  if ( status != OS_SUCCESS )
  {
     printf("Error creating Task 3\n");
  }


}
コード例 #11
0
ファイル: task.c プロジェクト: ahmedeng165/ercos
/*
 * Function: void OS_TCBInit(void)
 *
 * This function initializes all the Thread Control Blocks to the init state
 */
void OS_TCBInit(void)
{
    int i;

    OS_ListReset(&tcb_list);

    /* Assure that the priority of the task 0 is 0. This is important if ERCOS
     * is linked to C++ stuff; constructors (called from OS_CPPInit) may do
     * system calls and the task 0 will store the context of OS_Start function
     * before the first official dispatch (at the end of the function). Until
     * now, priority was 0 because task_table is allocated in the bss which is
     * zeroed at startup time (!!) */
    task_table[0].priority = 0;

    for (i = MAIN_THREAD_TID; i < CONFIG_ERCOS_MAX_THREADS; ++i)
    {
        /*  Init the thread status  */
        task_table[i].status = 0;

        /*  Traps off, set S, PS and FP unit    */
        //task_table[i].context.psr = 0x000010c0;

        /*  Init the thread identifier  */
        task_table[i].tid = i;

        /*  Reset all the nodes associated with each thread */
        OS_ListNodeReset(&task_table[i].node);
        OS_ListNodeReset(&task_table[i].time_node);
        OS_ListNodeReset(&task_table[i].resource_node);

        /*  Add the TCB into the free TCBs queue   */
        OS_ListAppend(&tcb_list, &task_table[i].node);
    }

    /* create the idle task, with the minimum priority */
    OS_TaskCreate (NULL, 0x600, OS_IdleTask, NULL, SCHED_MIN_PRIORITY);

    /* create the main task, with the maximum priority */
    OS_TaskCreate (NULL, CONFIG_ERCOS_MAIN_STACK_SIZE, (void *) main, NULL, SCHED_MAX_PRIORITY);
}
コード例 #12
0
static void nasa_osal_test_002_003_execute(void) {
  uint32 tid;
  unsigned i;

  /* [2.3.1] Creataing a queue with depth 4 and message size 20.*/
  test_set_step(1);
  {
    int32 err;

    err = OS_QueueCreate(&qid, "test queue", 4, MESSAGE_SIZE, 0);
    test_assert(err == OS_SUCCESS, "queue creation failed");
  }

  /* [2.3.2] Creating the writer task.*/
  test_set_step(2);
  {
    int32 err;

    err = OS_TaskCreate(&tid,
                        "writer task",
                        test_task_writer,
                        (uint32 *)wa_test1,
                        sizeof wa_test1,
                        TASKS_BASE_PRIORITY,
                        0);
    test_assert(err == OS_SUCCESS, "writer task creation failed");
  }

  /* [2.3.3] Reading messages from the writer task.*/
  test_set_step(3);
  {
    for (i = 0; i < WRITER_NUM_MESSAGES; i++) {
      int32 err;
      char data[MESSAGE_SIZE];
      uint32 copied;

      err = OS_QueueGet(qid, data, MESSAGE_SIZE, &copied, OS_Milli2Ticks(200));
      test_assert(err == OS_SUCCESS, "timed out");
      test_assert(strncmp(data, "Hello World", sizeof (data)) == 0,
                  "wrong message");
    }
  }

  /* [2.3.4] Waiting for task termination then checking for errors.*/
  test_set_step(4);
  {
    (void) OS_TaskWait(tid);
    tid = 0;
    test_assert_sequence("", "queue write errors occurred");
  }
}
コード例 #13
0
ファイル: osapi_testcase_tasks.c プロジェクト: billvb/osal
/*----------------------------------------------------------------------------*/
void Test_OS_TaskCreate_FpNotEnabled(void)
{
    int32 expected = OS_SUCCESS;
    int32 actual   = 99;

    /* Setup Inputs */
    uint32 taskIdIdx   = 7;
    uint32 task_id     = 5;
    char *task_name    = "test";
    uint32 stack       = 4;
    uint32 stack_size  = 3;
    uint32 priority    = 2;
    uint32 flags       = 0;
    uint32 taskSpawnId = 101;
    uint32 creatorId   = 15;
    uint32 creatorIndex = 5;

    OsApi_Adaptor_setTaskTableEntry(taskIdIdx, TRUE, 0, "", 0, 0, 0, NULL);
    OsApi_SetReturnCode(OSAPI_TASKSPAWN_INDEX, taskSpawnId, 1);
    OsApi_SetReturnCode(OSAPI_TASKIDSELF_INDEX, creatorId, 1);
    OsApi_Adaptor_setTaskTableEntry(creatorIndex, FALSE, creatorId, "", 0, 0, 0, NULL);

    /* Execute Test */
    actual = OS_TaskCreate(&task_id, task_name, dummyFnc, &stack, stack_size, priority, flags);

    /* Verify Outputs */
    osTaskRecord_ptr = OsApi_Adaptor_getTaskTableEntry(taskIdIdx);
    UtAssert_True(actual == expected, "actual == OS_SUCCESS");
    UtAssert_True(getTaskSpawnFlags() == 0, "taskSpawn called with expected flags");
    UtAssert_StrCmp(task_name, osTaskRecord_ptr->name, "task name == expected");
    UtAssert_True(osTaskRecord_ptr->free == FALSE, "task entry not free");
    UtAssert_True(osTaskRecord_ptr->id == taskSpawnId, "task id == expected");
    UtAssert_True(task_id == taskIdIdx, "input task id == expected");
    UtAssert_True(osTaskRecord_ptr->creator == creatorIndex, "creator ID == input");
    UtAssert_True(osTaskRecord_ptr->stack_size == stack_size, "stack size == input");
    UtAssert_True(osTaskRecord_ptr->priority == priority, "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");
}
コード例 #14
0
ファイル: ut_oscore_test_arinc653.c プロジェクト: billvb/osal
void UT_main()
{
    uint32 tId=0, stackPtr=0;
    RETURN_CODE_TYPE arincRet=NO_ERROR;

    UT_os_setup(UT_OS_LOG_FILENAME);

    /* UT_OS_LOG_OFF, UT_OS_LOG_MINIMAL, UT_OS_LOG_MODERATE, UT_OS_LOG_EVERYTHING */
    UT_os_set_log_verbose(UT_OS_LOG_EVERYTHING);

    UT_OS_LOG_MACRO("OSAL Unit Test Output File for ARINC653-implementation of oscore APIs\n")

    UT_os_apiinit_test();

    OS_TaskCreate(&tId, "ut_oscore",
                            (osal_task_entry)&UT_os_core_tests,
                            &stackPtr, 0x2000, 110, 0);

    SET_PARTITION_MODE(NORMAL, &arincRet);
}
コード例 #15
0
/*****************************************************************************//**
* @brief Initialize the Task that schedules and handles communication with 
*    Servers on the internet.  
*
* @param none.
* @return nothing.
* @author Neal Shurmantine
* @version
* 04/18/2015    Created
*******************************************************************************/
void RMT_InitRemoteServers(void)
{
    strcpy(RMT_DomainAddress,REMOTE_SERVER_CONSUMER_DOMAIN);
    retrieveRegistrationData();
    RMT_RemoteServerTaskId = OS_TaskCreate(RMT_REMOTE_SERVER_TASK_NUM, 0);
    SCH_ScheduleEventPostSeconds(RMT_CHECK_REMOTE_CONNECT_INTERVAL_START, RMT_check_remote_connect_now);
    RMT_TimeServerTokenSeconds = NULL_TOKEN;
    RMT_TimeServerTokenDaily = NULL_TOKEN;

//    RMT_DailyFWCheckTime.hour = RMT_FW_UPDATE_CHECK_HOUR;
//    RMT_DailyFWCheckTime.minute = RMT_FW_UPDATE_CHECK_MINUTE + SCH_Randomize(RMT_RANDOMIZE_MINUTES);
//    RMT_DailyFWCheckTime.second = SCH_Randomize(60);

    RMT_DailyTimeCheckTime.hour = RMT_TIME_CHECK_HOUR;
    RMT_DailyTimeCheckTime.minute = RMT_TIME_CHECK_MINUTE + SCH_Randomize(RMT_RANDOMIZE_MINUTES);
    RMT_DailyTimeCheckTime.second = SCH_Randomize(60);

    SCH_InitTimeVariables();
    FWU_FirmwareUpdateInit();
}
コード例 #16
0
ファイル: osapi_testcase_tasks.c プロジェクト: billvb/osal
/*----------------------------------------------------------------------------*/
void Test_OS_TaskCreate_PriorityError(void)
{
    int32 expected = OS_ERR_INVALID_PRIORITY;
    int32 actual   = 99;

    /* Setup Inputs */
    uint32 task_id    = 1;
    char *task_name   = "test";
    uint32 stack      = 1;
    uint32 stack_size = 1;
    uint32 priority   = MAX_PRIORITY + 1;
    uint32 flags      = 1;

    /* Execute Test */
    actual = OS_TaskCreate(&task_id, task_name, dummyFnc, &stack, stack_size, priority, flags);

    /* Verify Outputs */
    UtAssert_True(actual == expected, "actual == OS_ERR_INVALID_PRIORITY");

    /* Verify Semaphore Usage */
    UtAssert_True(getNSemTake(OS_TASK_TABLE_SEM) == getNSemGive(OS_TASK_TABLE_SEM),
                  "nSemTake == nSemGive");
    UtAssert_True(getNSemTake(OS_TASK_TABLE_SEM) == 0, "No OS_TASK_TABLE_SEM taken");
}
コード例 #17
0
ファイル: osapi_testcase_tasks.c プロジェクト: billvb/osal
/*----------------------------------------------------------------------------*/
void Test_OS_TaskCreate_NoFreeIds(void)
{
    int32 expected = OS_ERR_NO_FREE_IDS;
    int32 actual   = 99;

    /* Setup Inputs */
    uint32 task_id    = 1;
    char *task_name   = "test";
    uint32 stack      = 1;
    uint32 stack_size = 1;
    uint32 priority   = 1;
    uint32 flags      = 1;

    /* Execute Test */
    actual = OS_TaskCreate(&task_id, task_name, dummyFnc, &stack, stack_size, priority, flags);

    /* Verify Outputs */
    UtAssert_True(actual == expected, "actual == OS_ERR_NO_FREE_IDS");

    /* 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");
}
コード例 #18
0
ファイル: ctisc.c プロジェクト: sguotao/TestAfinal
BYTE CTISC_Init(void)
{
	AM_ErrorCode_t ret = AM_SUCCESS;
	U32 u32Freq=4000;
	AM_SMC_CardStatus_t tSCIStatus;
	AM_SMC_OpenPara_t para;
	U8  atr_tmp[33]={0};
	int 	atr_recv_count = 33;
	
	S32  taskidSCDetectProcess;
	U32  task_id;
	AM_SMC_Param_t SMCpara;
	
	Global_SC_STATS =CARD_OUT_EVENT;
	atr_recv_count =sizeof(atr_tmp);

	memset(atr_tmp,0,atr_recv_count);
	memset(&para, 0, sizeof(para));
	para.enable_thread = 0;
	
	ret = AM_SMC_Open(g_u8SCIPort, &para);
	if (AM_SUCCESS != ret)
	{
		printf(" HI_UNF_SCI_Init Init error:%08x\n",ret);
		return 1;
	}
#if 0	
	ret =AM_SMC_Active(g_u8SCIPort);
	if (AM_SUCCESS != ret)
	{
		printf(" AM_SMC_Active Init error:%08x\n",ret);
		return 1;
	}
#endif	
	if(sc_callback_func ==NULL)
	{
	//	sc_callback_func = SC_ATR_Notify;
	} 
	
	OS_SemCreate(&Detect_signal, "detectcasingal", 0, 0);
	
	taskidSCDetectProcess = OS_TaskCreate(&task_id, "ScDetectProcess", SMARTCARD_Detect_notify, NULL, NULL, 2048, 8, 0);
	if (  taskidSCDetectProcess != 0 )
	{
		printf( "%s %d> smart card driver: unable to spawn ScDetect process\n",
				__FILE__, 
				__LINE__ );
		//return 1;
	}


#if 0
	ret = AM_SMC_GetCardStatus(g_u8SCIPort,&tSCIStatus);
	if ( ret != AM_SUCCESS )
	{
		printf(" AM_SMC_GetCardStatus  ret %x\n", ret);
		OS_SemSignal( Detect_signal );
		return 1;			
	}
	if(tSCIStatus == AM_SMC_CARD_OUT)
	{
		sc_callback_func(0,1,0,0);
		Global_SC_STATS =CARD_OUT_EVENT;
		printf(" AM_SMC_GetCardStatus CARD_OUT_EVENT  error\n");
		//return 1;
	}
	else
	{
		AM_SMC_GetParam(g_u8SCIPort, &SMCpara);
		pbiinfo("[param---old]\n SMCpara.f[%d]\n SMCpara.d[%d]\n SMCpara.n[%d]\n SMCpara.bwi[%d]\n SMCpara.cwi[%d]\n SMCpara.bgt[%d]\n SMCpara.freq[%d]\n SMCpara.recv_invert[%d]\n SMCpara.recv_lsb_msb[%d]\n SMCpara.recv_no_parity[%d]\n SMCpara.xmit_invert[%d]\n SMCpara.xmit_lsb_msb[%d]\n SMCpara.xmit_retries[%d]\n SMCpara.xmit_repeat_dis[%d]\n", 
			SMCpara.f,
			SMCpara.d,
			SMCpara.n,
			SMCpara.bwi,
			SMCpara.cwi,
			SMCpara.bgt,
			SMCpara.freq,
			SMCpara.recv_invert,
			SMCpara.recv_lsb_msb,
			SMCpara.recv_no_parity,
			SMCpara.xmit_invert,
			SMCpara.xmit_lsb_msb,
			SMCpara.xmit_retries,
			SMCpara.xmit_repeat_dis);
		if(u32Freq)
		{
			SMCpara.freq = u32Freq;
		}
	  AM_SMC_SetParam(g_u8SCIPort, &SMCpara);
	  AM_SMC_GetParam(g_u8SCIPort, &SMCpara);
		  pbiinfo("[param---new]\n SMCpara.f[%d]\n SMCpara.d[%d]\n SMCpara.n[%d]\n SMCpara.bwi[%d]\n SMCpara.cwi[%d]\n SMCpara.bgt[%d]\n SMCpara.freq[%d]\n SMCpara.recv_invert[%d]\n SMCpara.recv_lsb_msb[%d]\n SMCpara.recv_no_parity[%d]\n SMCpara.xmit_invert[%d]\n SMCpara.xmit_lsb_msb[%d]\n SMCpara.xmit_retries[%d]\n SMCpara.xmit_repeat_dis[%d]\n", 
			  SMCpara.f,
			  SMCpara.d,
			  SMCpara.n,
			  SMCpara.bwi,
			  SMCpara.cwi,
			  SMCpara.bgt,
			  SMCpara.freq,
			  SMCpara.recv_invert,
			  SMCpara.recv_lsb_msb,
			  SMCpara.recv_no_parity,
			  SMCpara.xmit_invert,
			  SMCpara.xmit_lsb_msb,
			  SMCpara.xmit_retries,
			  SMCpara.xmit_repeat_dis);
		  
		  ret = AM_SMC_Reset(g_u8SCIPort, atr_tmp, &atr_recv_count);
		  if(ret != AM_SUCCESS)
		  {
			  printf(" AM_SMC_Reset  error\n");
			//  return 1;
		  }
		  else
		  {
			  int ii;
			  pbiinfo("atr====");
			  for(ii=0;ii<atr_recv_count;ii++)
			  {
				  pbiinfo(" 0x%x ",atr_tmp[ii]);
			  }
		  	  sc_callback_func(0,0,atr_tmp,0);			  
			  Global_SC_STATS =CARD_IN_EVENT; 
		  
		  }

	}
#endif
	printf(" TRDRV_SCARD_Initialise	ok");
	OS_SemSignal( Detect_signal );
	return 0;

}
コード例 #19
0
ファイル: bin-sem-test.c プロジェクト: felipeprov/osal
void OS_Application_Startup(void)
{
   uint32             status;
   OS_bin_sem_prop_t  bin_sem_prop;

   OS_printf("OS Application Startup\n");

   /*
   ** Create the binary semaphore
   */
   status = OS_BinSemCreate( &bin_sem_id, "BinSem1", 1, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Binary Sem\n");
   }
   else
   {
      status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop);
      OS_printf("Binary Sem ID = %d, value = %d\n", (int)bin_sem_id, (int)bin_sem_prop.value);
   }

   /*
   ** Create a timer
   */
   status = OS_TimerCreate(&timer_id, "Timer 1", &timer_accuracy, &(TimerFunction));
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating OS Timer\n");
   }
   else
   {
      OS_printf("Timer ID = %d\n", (int)bin_sem_id);
      OS_printf("Timer Accuracy = %d microseconds \n",(int)timer_accuracy);
   }

   /*
   ** Take the semaphore so the value is 0 and the next SemTake call should block
   */
   status = OS_BinSemTake(bin_sem_id);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error calling OS_BinSemTake with bin_sem_id = %d\n",(int)bin_sem_id);
   }
   else
   {
      status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop);
      OS_printf("Initial Binary Sem Take: value = %d\n", (int)bin_sem_prop.value);
   }

   /*
   ** Create the "consumer" task.
   */
   status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_1_STACK_SIZE, TASK_1_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 1\n");
   }
   else
   {
      OS_printf("Created Task 1\n");
   }

   /*
   ** Start the timer
   */
   status  =  OS_TimerSet(timer_id, timer_start, timer_interval);
   if ( status != OS_SUCCESS )
   {
       OS_printf("Error calling OS_TimerSet: ID = %d\n", (int)timer_id);
   }
   else
   {
       OS_printf("Timer programmed\n");
   }

}
コード例 #20
0
ファイル: count-sem-test.c プロジェクト: felipeprov/osal
void OS_Application_Startup(void)
{
   uint32 status;
   int    i;

   OS_printf("OS Application Startup\n");

   /*
   ** Create the Counting semaphore
   */
   status = OS_CountSemCreate( &count_sem_id, "CountSem1", 2, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Count Sem\n");
   }
   else
   {
      OS_printf("Counting Sem ID = %d\n", (int)count_sem_id);
   }

   /*
   ** Take the semaphore so the value is 0 and the next SemTake call should block
   */
   for ( i = 0; i < 2; i++)
   {
      status = OS_CountSemTake(count_sem_id);
      if ( status != OS_SUCCESS )
      {
         OS_printf("Error calling OS_CountSemTake with count_sem_id = %d\n",(int)count_sem_id);
      }
      else
      {
         OS_printf("Take Counting Sem: %d\n",i);
      }
   }

   /*
   ** Create the tasks
   */
   status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_STACK_SIZE, TASK_1_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 1\n");
   }
   else
   {
      OS_printf("Created Task 1\n");
   }

   status = OS_TaskCreate( &task_2_id, "Task 2", task_2, task_2_stack, TASK_STACK_SIZE, TASK_2_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 2\n");
   }
   else
   {
      OS_printf("Created Task 2\n");
   }
 
   status = OS_TaskCreate( &task_3_id, "Task 3", task_3, task_3_stack, TASK_STACK_SIZE, TASK_3_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 3\n");
   }
   else
   {
      OS_printf("Created Task 3\n");
   }

   OS_printf("Main done!\n");

}
コード例 #21
0
/*-------------------------------------------------------------------------
**
**                  Functional Prolog
**
**   Name: CFE_ES_CreateObjects
**
**   Purpose: This function reads the es_object_table and performs all of the
**            application layer initialization.
**----------------------------------------------------------------------------
*/
void  CFE_ES_CreateObjects(void)
{
    int32     ReturnCode;
    boolean   AppSlotFound;
    int16     i;
    int16     j;

    CFE_ES_WriteToSysLog("ES Startup: Starting Object Creation calls.\n");

    for ( i = 0; i < CFE_ES_OBJECT_TABLE_SIZE; i++ )
    {
        switch ( CFE_ES_ObjectTable[i].ObjectType )
        {
            case CFE_ES_DRIVER_TASK:
            case CFE_ES_CORE_TASK:

            /*
            ** Allocate an ES AppTable entry
            */
            AppSlotFound = FALSE;
            for ( j = 0; j < CFE_ES_MAX_APPLICATIONS; j++ )
            {
               if ( CFE_ES_Global.AppTable[j].RecordUsed == FALSE )
               {
                  AppSlotFound = TRUE;
                  break;
               }
            }

            /*
            ** If a slot was found, create the application
            */
            if ( AppSlotFound == TRUE )
            {
            
               CFE_ES_LockSharedData(__func__,__LINE__);

               /*
               ** Allocate and populate the ES_AppTable entry
               */
               CFE_PSP_MemSet ( (void *)&(CFE_ES_Global.AppTable[j]), 0, sizeof(CFE_ES_AppRecord_t));
               CFE_ES_Global.AppTable[j].RecordUsed = TRUE;
               CFE_ES_Global.AppTable[j].Type = CFE_ES_APP_TYPE_CORE;
               
               /*
               ** Fill out the parameters in the AppStartParams sub-structure
               */         
               strncpy((char *)CFE_ES_Global.AppTable[j].StartParams.Name, (char *)CFE_ES_ObjectTable[i].ObjectName, OS_MAX_API_NAME);
               CFE_ES_Global.AppTable[j].StartParams.Name[OS_MAX_API_NAME - 1] = '\0';
               /* EntryPoint field is not valid here for base apps */
               /* FileName is not valid for base apps, either */
               CFE_ES_Global.AppTable[j].StartParams.StackSize = CFE_ES_ObjectTable[i].ObjectSize;
               CFE_ES_Global.AppTable[j].StartParams.StartAddress = (uint32)CFE_ES_ObjectTable[i].FuncPtrUnion.FunctionPtr;
               CFE_ES_Global.AppTable[j].StartParams.ExceptionAction = CFE_ES_APP_EXCEPTION_PROC_RESTART;
               CFE_ES_Global.AppTable[j].StartParams.Priority = CFE_ES_ObjectTable[i].ObjectPriority;
               
               
               /*
               ** Fill out the Task Info
               */
               strncpy((char *)CFE_ES_Global.AppTable[j].TaskInfo.MainTaskName, (char *)CFE_ES_ObjectTable[i].ObjectName, OS_MAX_API_NAME);
               CFE_ES_Global.AppTable[j].TaskInfo.MainTaskName[OS_MAX_API_NAME - 1] = '\0';
               CFE_ES_Global.AppTable[j].TaskInfo.NumOfChildTasks = 0;
               
               /*
               ** Since this is a Core app, the AppStateRecord does not need to be filled out.
               */
               
               
               /*
               ** Create the task
               */
               ReturnCode = OS_TaskCreate(&CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId, /* task id */
                                  CFE_ES_ObjectTable[i].ObjectName,              /* task name */
                                  CFE_ES_ObjectTable[i].FuncPtrUnion.VoidPtr,    /* task function pointer */
                                  NULL,                                          /* stack pointer */
                                  CFE_ES_ObjectTable[i].ObjectSize,              /* stack size */
                                  CFE_ES_ObjectTable[i].ObjectPriority,          /* task priority */
                                  OS_FP_ENABLED);                                /* task options */

               if(ReturnCode != OS_SUCCESS)
               {
                  CFE_ES_Global.AppTable[j].RecordUsed = FALSE;
                  CFE_ES_WriteToSysLog("ES Startup: OS_TaskCreate error creating core App: %s: EC = 0x%08X\n",
                                        CFE_ES_ObjectTable[i].ObjectName, ReturnCode);
      
                                        
                  CFE_ES_UnlockSharedData(__func__,__LINE__);

                  /*
                  ** Delay to allow the message to be read
                  */
                  OS_TaskDelay(CFE_ES_PANIC_DELAY);
      
                  /* 
                  ** cFE Cannot continue to start up.  
                  */
                  CFE_PSP_Panic(CFE_PSP_PANIC_CORE_APP);
                                              
               }
               else
               {
                  CFE_ES_ObjectTable[i].ObjectKey = CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId;

                  /*
                  ** Allocate and populate the CFE_ES_Global.TaskTable entry
                  */
                  if ( CFE_ES_Global.TaskTable[CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId].RecordUsed == TRUE )
                  {
                     CFE_ES_WriteToSysLog("ES Startup: CFE_ES_Global.TaskTable record used error for App: %s, continuing.\n",
                                           CFE_ES_ObjectTable[i].ObjectName);
                  }
                  else
                  {
                     CFE_ES_Global.TaskTable[CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId].RecordUsed = TRUE;
                  }
                  CFE_ES_Global.TaskTable[CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId].AppId = j;
                  CFE_ES_Global.TaskTable[CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId].TaskId = CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId;
                  strncpy((char *)CFE_ES_Global.TaskTable[CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId].TaskName, (char *)CFE_ES_Global.AppTable[j].TaskInfo.MainTaskName, OS_MAX_API_NAME);
                  CFE_ES_Global.TaskTable[CFE_ES_Global.AppTable[j].TaskInfo.MainTaskId].TaskName[OS_MAX_API_NAME - 1] = '\0';

                  CFE_ES_WriteToSysLog("ES Startup: Core App: %s created. App ID: %d\n",
                                       CFE_ES_ObjectTable[i].ObjectName,j);
                                       
                  /*
                  ** Increment the registered App and Registered External Task variables.
                  */
                  CFE_ES_Global.RegisteredTasks++;
                  CFE_ES_Global.RegisteredCoreApps++;
                  
                  CFE_ES_UnlockSharedData(__func__,__LINE__);
                                                                                                      
               }
            }
            else /* appSlot not found -- This should never happen!*/
            {
               CFE_ES_WriteToSysLog("ES Startup: Error, No free application slots available for CORE App!\n");
               /*
               ** Delay to allow the message to be read
               */
               OS_TaskDelay(CFE_ES_PANIC_DELAY);
      
               /* 
               ** cFE Cannot continue to start up.  
               */
               CFE_PSP_Panic(CFE_PSP_PANIC_CORE_APP);
            
            }
            break;

            case CFE_ES_FUNCTION_CALL: /*----------------------------------------------------------*/

               if ( CFE_ES_ObjectTable[i].FuncPtrUnion.FunctionPtr != NULL )
               {
                  CFE_ES_WriteToSysLog("ES Startup: Calling %s\n",CFE_ES_ObjectTable[i].ObjectName);
                  /*
                  ** Call the function
                  */
                  ReturnCode = (*CFE_ES_ObjectTable[i].FuncPtrUnion.FunctionPtr)();
                  if(ReturnCode != CFE_SUCCESS)
                  {
                     CFE_ES_WriteToSysLog("ES Startup: Error returned when calling function: %s: EC = 0x%08X\n",
                                           CFE_ES_ObjectTable[i].ObjectName, ReturnCode);
                                        
                     /*
                     ** Delay to allow the message to be read
                     */
                     OS_TaskDelay(CFE_ES_PANIC_DELAY);
      
                     /* 
                     ** cFE Cannot continue to start up.  
                     */
                     CFE_PSP_Panic(CFE_PSP_PANIC_CORE_APP);
                                              
                  } /* end if */
                  
               }
               else
               {
                  CFE_ES_WriteToSysLog("ES Startup: bad function pointer ( table entry = %d).\n",i);
               }
               break;

            case CFE_ES_NULL_ENTRY: /*-------------------------------------------------------*/
               break;
            default:
               break;
       } /* end switch */

    } /* end for */

    CFE_ES_WriteToSysLog("ES Startup: Finished ES CreateObject table entries.\n");
}
コード例 #22
0
ファイル: SystemInit.c プロジェクト: beartan/q-sys
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
    }
}
コード例 #23
0
static void test_001_001_execute(void) {

  /* [1.1.1] OS_TaskCreate() is invoked with task_id set to NULL, an
     error is expected.*/
  test_set_step(1);
  {
    int32 err;

    err = OS_TaskCreate(NULL,                   /* Error.*/
                        "failing task",
                        test_task1,
                        (uint32 *)wa_test1,
                        sizeof wa_test1,
                        TASKS_BASE_PRIORITY,
                        0);
    test_assert(err == OS_INVALID_POINTER, "NULL not detected");
    test_assert_sequence("", "task executed");
  }

  /* [1.1.2] OS_TaskCreate() is invoked with task_name set to NULL, an
     error is expected.*/
  test_set_step(2);
  {
    int32 err;
    uint32 tid;

    err = OS_TaskCreate(&tid,
                        NULL,                   /* Error.*/
                        test_task1,
                        (uint32 *)wa_test1,
                        sizeof wa_test1,
                        TASKS_BASE_PRIORITY,
                        0);
    test_assert(err == OS_INVALID_POINTER, "NULL not detected");
    test_assert_sequence("", "task executed");
  }

  /* [1.1.3] OS_TaskCreate() is invoked with stack_pointer set to NULL,
     an error is expected.*/
  test_set_step(3);
  {
    int32 err;
    uint32 tid;

    err = OS_TaskCreate(&tid,
                        "failing task",
                        test_task1,
                        (uint32 *)NULL,         /* Error.*/
                        sizeof wa_test1,
                        TASKS_BASE_PRIORITY,
                        0);
    test_assert(err == OS_INVALID_POINTER, "NULL not detected");
    test_assert_sequence("", "task executed");
  }

  /* [1.1.4] OS_TaskCreate() is invoked with a very long task name, an
     error is expected.*/
  test_set_step(4);
  {
    int32 err;
    uint32 tid;

    err = OS_TaskCreate(&tid,
                        "this is a very very long task name", /* Error.*/
                        test_task1,
                        (uint32 *)wa_test1,
                        sizeof wa_test1,
                        TASKS_BASE_PRIORITY,
                        0);
    test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");
    test_assert_sequence("", "task executed");
  }

  /* [1.1.5] OS_TaskCreate() is invoked with priority below and above
     allowed range, an error is expected.*/
  test_set_step(5);
  {
    int32 err;
    uint32 tid;

    err = OS_TaskCreate(&tid,
                        "failing task",
                        test_task1,
                        (uint32 *)wa_test1,
                        sizeof wa_test1,
                        0,                      /* Error.*/
                        0);
    test_assert(err == OS_ERR_INVALID_PRIORITY, "priority error not detected");
    test_assert_sequence("", "task executed");

    err = OS_TaskCreate(&tid,
                       "failing task",
                       test_task1,
                       (uint32 *)wa_test1,
                       sizeof wa_test1,
                       256,                     /* Error.*/
                       0);
    test_assert(err == OS_ERR_INVALID_PRIORITY, "priority error not detected");
    test_assert_sequence("", "task executed");
  }

  /* [1.1.6] OS_TaskCreate() is invoked with a stack size below
     minimum, an error is expected.*/
  test_set_step(6);
  {
    int32 err;
    uint32 tid;

    err = OS_TaskCreate(&tid,
                        "failing task",
                        test_task1,
                        (uint32 *)wa_test1,
                        16,                     /* Error.*/
                        TASKS_BASE_PRIORITY,
                        0);
    test_assert(err == OS_INVALID_INT_NUM, "stack insufficient size not detected");
    test_assert_sequence("", "task executed");
  }

  /* [1.1.7] OS_TaskCreate() is invoked twice with duplicated name and
     then duplicated stack, an error is expected in both cases.*/
  test_set_step(7);
  {
    int32 err;
    uint32 tid;

    err = OS_TaskCreate(&tid,
                        "running task",
                        test_task1,
                        (uint32 *)wa_test1,
                        sizeof wa_test1,
                        TASKS_BASE_PRIORITY,
                        0);
    test_assert(err == OS_SUCCESS, "task creation failed");

    err = OS_TaskCreate(&tid,
                        "running task",
                        test_task2,
                        (uint32 *)wa_test2,
                        sizeof wa_test2,
                        TASKS_BASE_PRIORITY,
                        0);
    test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected");

    err = OS_TaskCreate(&tid,
                        "conflicting task",
                        test_task1,
                        (uint32 *)wa_test1,
                        sizeof wa_test1,
                        TASKS_BASE_PRIORITY,
                        0);
    test_assert(err == OS_ERR_NO_FREE_IDS, "stack conflict not detected");

    err = OS_TaskWait(tid);
    test_assert(err == OS_SUCCESS, "wait failed");
    test_assert_sequence("A", "task not executed");

    err = OS_TaskCreate(&tid,
                        "running task",
                        test_task1,
                        (uint32 *)wa_test1,
                        sizeof wa_test1,
                        TASKS_BASE_PRIORITY,
                        0);
    test_assert(err == OS_SUCCESS, "task creation failed");

    err = OS_TaskWait(tid);
    test_assert(err == OS_SUCCESS, "wait failed");
    test_assert_sequence("A", "task not executed");
  }
}
コード例 #24
0
static void test_001_002_execute(void) {

  /* [1.2.1] Four tasks are created in priority order from low to
     high.*/
  test_set_step(1);
  {
    int32 err;
    uint32 tid1, tid2, tid3, tid4;

    err = OS_TaskCreate(&tid4,
                        "running task 4",
                        test_task4,
                        (uint32 *)wa_test4,
                        sizeof wa_test4,
                        TASKS_BASE_PRIORITY - 0,
                        0);
    test_assert(err == OS_SUCCESS, "task 4 creation failed");

    err = OS_TaskCreate(&tid3,
                        "running task 3",
                        test_task3,
                        (uint32 *)wa_test3,
                        sizeof wa_test3,
                        TASKS_BASE_PRIORITY - 1,
                        0);
    test_assert(err == OS_SUCCESS, "task 3 creation failed");

    err = OS_TaskCreate(&tid2,
                        "running task 2",
                        test_task2,
                        (uint32 *)wa_test2,
                        sizeof wa_test2,
                        TASKS_BASE_PRIORITY - 2,
                        0);
    test_assert(err == OS_SUCCESS, "task 2 creation failed");

    err = OS_TaskCreate(&tid1,
                        "running task 1",
                        test_task1,
                        (uint32 *)wa_test1,
                        sizeof wa_test1,
                        TASKS_BASE_PRIORITY - 3,
                        0);
    test_assert(err == OS_SUCCESS, "task 1 creation failed");
  }

  /* [1.2.2] Tasks are made runnable atomically and their execution
     order tested.*/
  test_set_step(2);
  {
    OS_TaskDelay(5);
    test_assert_sequence("ABCD", "task order violation");
  }

  /* [1.2.3] Four tasks are created in priority order from high to
     low.*/
  test_set_step(3);
  {
    int32 err;
    uint32 tid1, tid2, tid3, tid4;

    err = OS_TaskCreate(&tid1,
                        "running task 1",
                        test_task1,
                        (uint32 *)wa_test1,
                        sizeof wa_test1,
                        TASKS_BASE_PRIORITY - 3,
                        0);
    test_assert(err == OS_SUCCESS, "task 1 creation failed");

    err = OS_TaskCreate(&tid2,
                        "running task 2",
                        test_task2,
                        (uint32 *)wa_test2,
                        sizeof wa_test2,
                        TASKS_BASE_PRIORITY - 2,
                        0);
    test_assert(err == OS_SUCCESS, "task 2 creation failed");

    err = OS_TaskCreate(&tid3,
                        "running task 3",
                        test_task3,
                        (uint32 *)wa_test3,
                        sizeof wa_test3,
                        TASKS_BASE_PRIORITY - 1,
                        0);
    test_assert(err == OS_SUCCESS, "task 3 creation failed");

    err = OS_TaskCreate(&tid4,
                        "running task 4",
                        test_task4,
                        (uint32 *)wa_test4,
                        sizeof wa_test4,
                        TASKS_BASE_PRIORITY - 0,
                        0);
    test_assert(err == OS_SUCCESS, "task 4 creation failed");
  }

  /* [1.2.4] Tasks are made runnable atomically and their execution
     order tested.*/
  test_set_step(4);
  {
    OS_TaskDelay(5);
    test_assert_sequence("ABCD", "task order violation");
  }

  /* [1.2.5] Four tasks are created in an not ordered way.*/
  test_set_step(5);
  {
    int32 err;
    uint32 tid1, tid2, tid3, tid4;

    err = OS_TaskCreate(&tid2,
                        "running task 2",
                        test_task2,
                        (uint32 *)wa_test2,
                        sizeof wa_test2,
                        TASKS_BASE_PRIORITY - 2,
                        0);
    test_assert(err == OS_SUCCESS, "task 2 creation failed");

    err = OS_TaskCreate(&tid1,
                        "running task 1",
                        test_task1,
                        (uint32 *)wa_test1,
                        sizeof wa_test1,
                        TASKS_BASE_PRIORITY - 3,
                        0);
    test_assert(err == OS_SUCCESS, "task 1 creation failed");

    err = OS_TaskCreate(&tid4,
                        "running task 4",
                        test_task4,
                        (uint32 *)wa_test4,
                        sizeof wa_test4,
                        TASKS_BASE_PRIORITY - 0,
                        0);
    test_assert(err == OS_SUCCESS, "task 4 creation failed");

    err = OS_TaskCreate(&tid3,
                        "running task 3",
                        test_task3,
                        (uint32 *)wa_test3,
                        sizeof wa_test3,
                        TASKS_BASE_PRIORITY - 1,
                        0);
    test_assert(err == OS_SUCCESS, "task 3 creation failed");
  }

  /* [1.2.6] Tasks are made runnable atomically and their execution
     order tested.*/
  test_set_step(6);
  {
    OS_TaskDelay(5);
    test_assert_sequence("ABCD", "task order violation");
  }
}
コード例 #25
0
/*
** Main function
*/
void OS_Application_Startup(void)
{
   uint32 status;
   OS_bin_sem_prop_t  bin_sem_prop;

   OS_API_Init();

   OS_printf("OS Application Startup\n");

   /*
   ** Create the binary semaphore
   */
   status = OS_BinSemCreate( &bin_sem_id, "BinSem1", 1, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Binary Sem\n");
   }
   else
   {
      status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop);
      OS_printf("Binary Sem ID = %d, value = %d\n", (int)bin_sem_id, (int)bin_sem_prop.value);
   }

   /*
   ** Take the semaphore so the value is 0 and the next SemTake call should block
   */
   status = OS_BinSemTake(bin_sem_id);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error calling OS_BinSemTake with bin_sem_id = %d\n",(int)bin_sem_id);
   }
   else
   {
      status = OS_BinSemGetInfo (bin_sem_id, &bin_sem_prop);
      OS_printf("Initial Binary Sem Take: value = %d\n", (int)bin_sem_prop.value);
   }

   /*
   ** Create the tasks
   */
   status = OS_TaskCreate( &task_1_id, "Task 1", task_1, task_1_stack, TASK_STACK_SIZE, TASK_1_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 1\n");
   }
   else
   {
      OS_printf("Created Task 1\n");
   }

   status = OS_TaskCreate( &task_2_id, "Task 2", task_2, task_2_stack, TASK_STACK_SIZE, TASK_2_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 2\n");
   }
   else
   {
      OS_printf("Created Task 2\n");
   }
 
   status = OS_TaskCreate( &task_3_id, "Task 3", task_3, task_3_stack, TASK_STACK_SIZE, TASK_3_PRIORITY, 0);
   if ( status != OS_SUCCESS )
   {
      OS_printf("Error creating Task 3\n");
   }
   else
   {
      OS_printf("Created Task 3\n");
   }

   /* 
   ** Delay, then release the semaphore
   */
   OS_TaskDelay(2000); 

   status = OS_BinSemFlush(bin_sem_id);

   OS_printf("Main done!\n");

}