/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance3(void) { StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5; SCHEDULING_CHECK_INIT(8); result_inst_1 = WaitEvent(t1_event1); SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OK, result_inst_1); SCHEDULING_CHECK_INIT(9); result_inst_2 = ClearEvent(t1_event1); SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK, result_inst_2); SCHEDULING_CHECK_INIT(10); result_inst_3 = StopScheduleTable(sched1); SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OK, result_inst_3); SCHEDULING_CHECK_INIT(11); result_inst_4 = SetEvent(t3, t3_event1); SCHEDULING_CHECK_AND_EQUAL_INT(13,E_OK, result_inst_4); SCHEDULING_CHECK_INIT(14); result_inst_5 = ActivateTask(t4); SCHEDULING_CHECK_AND_EQUAL_INT(14,E_OK, result_inst_5); while(1); /* --> Protection Hook */ }
int main(void) { SystemInit(); /*Initialize Erika related stuffs*/ EE_system_init(); /*Initialize systick */ EE_systick_set_period(MILLISECONDS_TO_TICKS(1, SystemCoreClock)); EE_systick_enable_int(); EE_systick_start(); console_init(); stop = 0; calcRawSpeed(); initState(kwips_rawspeed, initAlarms, initFreq, initKWPP); do { ch = readCharUSART(); } while (ch != 't'); ActivateTask(SuperTask); StartOS(OSDEFAULTAPPMODE); /* Forever loop: background activities (if any) should go here */ for (;;) { } }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t2_instance(void) { StatusType result_inst_1, result_inst_2, result_inst_3; SCHEDULING_CHECK_INIT(2); result_inst_1 = ActivateTask(t1); SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OK , result_inst_1); SCHEDULING_CHECK_INIT(3); result_inst_2 = ActivateTask(t3); SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OK , result_inst_2); SCHEDULING_CHECK_INIT(4); result_inst_3 = TerminateTask(); SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OK , result_inst_3); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance(void) { StatusType result_inst_1,result_inst_2,result_inst_3; SCHEDULING_CHECK_INIT(1); result_inst_1 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(1,E_OK , result_inst_1); SCHEDULING_CHECK_INIT(2); result_inst_2 = ActivateTask(t3); SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OK , result_inst_2); SCHEDULING_CHECK_INIT(3); result_inst_3 = Schedule(); SCHEDULING_CHECK_AND_EQUAL_INT(5,E_OK , result_inst_3); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance(void) { StatusType result_inst; SCHEDULING_CHECK_INIT(1); result_inst = ActivateTask(t3); SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OK , result_inst); }
void vDemoApp2_Init(unsigned portBASE_TYPE uxPriority) { DEMO_TaskToken = ActivateTask(TASK_DEMO_APP_2, "DemoApp2", APP_TASK_TYPE, uxPriority, APP_STACK_SIZE, vDemoTask); }
void vCommsDemo_Init(unsigned portBASE_TYPE uxPriority) { COMMS_DEMO_TaskToken = ActivateTask(TASK_COMMS_DEMO, "Comms_demo", APP_TASK_TYPE, uxPriority, 4*APP_STACK_SIZE, vCommsDemoTask); }
void vModemDemo_Init(unsigned portBASE_TYPE uxPriority) { DEMO_TaskToken = ActivateTask(TASK_MODEM_DEMO, "modem_demo", APP_TASK_TYPE, uxPriority, APP_STACK_SIZE, vDemoTask); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance(void) { StatusType result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9; TaskStateType result_inst_3_5; SCHEDULING_CHECK_INIT(1); result_inst_2 = ActivateTask(INVALID_TASK); SCHEDULING_CHECK_AND_EQUAL_INT(1,E_OS_ID, result_inst_2); SCHEDULING_CHECK_INIT(2); result_inst_3 = GetTaskState(INVALID_TASK,&result_inst_3_5); SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OS_ID, result_inst_3); SCHEDULING_CHECK_INIT(3); result_inst_4 = ChainTask(INVALID_TASK); SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OS_ID, result_inst_4); SCHEDULING_CHECK_INIT(4); result_inst_5 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OK, result_inst_5); SCHEDULING_CHECK_INIT(9); result_inst_6 = GetResource(RES_SCHEDULER); SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK, result_inst_6); SCHEDULING_CHECK_INIT(10); result_inst_7 = TerminateTask(); SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OS_RESOURCE, result_inst_7); SCHEDULING_CHECK_INIT(11); result_inst_8 = ChainTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(11,E_OS_RESOURCE, result_inst_8); SCHEDULING_CHECK_INIT(12); result_inst_9 = ReleaseResource(RES_SCHEDULER); SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OK, result_inst_9); tpl_send_it1(); SCHEDULING_CHECK_STEP(17); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t2_instance(void) { StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4; SCHEDULING_CHECK_INIT(5); result_inst_1 = ActivateTask(t1); SCHEDULING_CHECK_AND_EQUAL_INT(5,E_OS_LIMIT, result_inst_1); SCHEDULING_CHECK_INIT(6); result_inst_2 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OS_LIMIT, result_inst_2); SCHEDULING_CHECK_INIT(7); result_inst_3 = ChainTask(t1); SCHEDULING_CHECK_AND_EQUAL_INT(7,E_OS_LIMIT, result_inst_3); SCHEDULING_CHECK_INIT(8); result_inst_4 = TerminateTask(); SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OK, result_inst_4); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_callback_instance(void) { StatusType result_inst_1; SCHEDULING_CHECK_INIT(2); result_inst_1 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OK, result_inst_1); }
void vIntFlash_Init(unsigned portBASE_TYPE uxPriority) { Flash_TaskToken = ActivateTask(TASK_MEM_INT_FLASH, "IntFlash", SEV_TASK_TYPE, uxPriority, SERV_STACK_SIZE, vIntFlashTask); vActivateQueue(Flash_TaskToken, FLASH_Q_SIZE); }
void __attribute__((__interrupt__)) _INT0Interrupt(void) { TaskStateType State; EnterISR(); IEC0bits.INT0IE = 0; GetTaskState(TASK2_ID, &State); if (State == SUSPENDED) ActivateTask(TASK2_ID); LeaveISR(); }
int main(int argc, char* argv[]) { WaitEvent(&Event1); WaitEvent(&Event2); WaitEvent(&Event3); ActivateTask(&Task1); ActivateTask(&Task2); ActivateTask(&Task3); SetRelAlarm(&Alarm1); SetRelAlarm(&Alarm2); #ifdef WRONG WaitEvent(&Alarm1); ActivateTask(&Event3); SetRelAlarm(&Task3); #endif // WRONG return 0; }
/********************************************************************** * Parse the chained list of alarms (timer & counter). * Increment timer only. * Check if alarm event has to be treated according to AlarmTickValue * and CurrentTickValue. * Do it for number of cycle positive or null. * Check if a task or event has to be activated. * If a task is waiting the event, clear the event and wait flags * (cf event.c) and set the task READY. * Call the SCHEDULER at the end. * * @return void **********************************************************************/ void AddOneTick (void) { unsigned char index; /* To setup 1 tick at 1ms */ /*TMR0H = Tmr0.bt[1];*/ /*TMR0L = Tmr0.bt[0];*/ /* To setup 1 tick at 1ms (improved no-drag version) */ union Timers tmr; /* Temp for holding timer value */ tmr.bt[0] = TMR0L; /* Read TMR0 */ tmr.bt[1] = TMR0H; tmr.lt += Tmr0.lt; /* Add offset value to TMR0 */ TMR0H = tmr.bt[1]; TMR0L = tmr.bt[0]; /* Update TMR0 */ INTCONbits.TMR0IF = 0; Counter_kernel.CounterValue++; global_counter++; for (index = 0; index < ALARMNUMBER; index++) { if (Alarm_list[index].State == OFF) continue; if (Alarm_list[index].ptrCounter->CounterValue == Alarm_list[index].AlarmValue) { if (Alarm_list[index].Cycle == 0) Alarm_list[index].State = OFF; else { Alarm_list[index].AlarmValue = \ Alarm_list[index].ptrCounter->CounterValue + \ Alarm_list[index].Cycle; } if (Alarm_list[index].EventToPost != 0) SetEvent(Alarm_list[index].TaskID2Activate, Alarm_list[index].EventToPost); if ((Alarm_list[index].TaskID2Activate != 0) && (Alarm_list[index].EventToPost == 0)) ActivateTask(Alarm_list[index].TaskID2Activate); if (Alarm_list[index].CallBack != 0) Alarm_list[index].CallBack(); } } kernelState |= SERVICES; return; }
void vGpioDemo_Init(unsigned portBASE_TYPE uxPriority) { DEMO_TaskToken = ActivateTask(TASK_GPIO_DEMO, "gpio_demo", APP_TASK_TYPE, uxPriority, APP_STACK_SIZE, vDemoTask); // initialise the port direction setGPIOOutput(); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance2(void) { StatusType result_inst_1, result_inst_2; SCHEDULING_CHECK_INIT(7); result_inst_1 = ActivateTask(t1); SCHEDULING_CHECK_AND_EQUAL_INT(7,E_OK , result_inst_1); SCHEDULING_CHECK_INIT(8); result_inst_2 = TerminateTask(); SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OK , result_inst_2); }
void StartupHook(void) { StatusType ret; Sequence(0); /* \treq EH_06 nmf B1B2E1E2 se Check StartupHook: Start OS * * \result StartupHook is called after initialisation of OS */ ret = ActivateTask(Task1); ASSERT(EH_06, ret != E_OK); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance(void) { StatusType result_inst_1,result_inst_2,result_inst_3,result_inst_4,result_inst_5,result_inst_6, result_inst_7; SCHEDULING_CHECK_INIT(1); result_inst_1 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(1,E_OK , result_inst_1); SCHEDULING_CHECK_INIT(2); result_inst_2 = ActivateTask(t3); SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OK , result_inst_2); SCHEDULING_CHECK_INIT(3); result_inst_3 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OK , result_inst_3); SCHEDULING_CHECK_INIT(4); result_inst_4 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OK , result_inst_4); SCHEDULING_CHECK_INIT(5); result_inst_5 = ActivateTask(t3); SCHEDULING_CHECK_AND_EQUAL_INT(5,E_OK , result_inst_5); SCHEDULING_CHECK_INIT(6); result_inst_6 = ActivateTask(t3); SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OK , result_inst_6); SCHEDULING_CHECK_INIT(7); result_inst_7 = TerminateTask(); SCHEDULING_CHECK_AND_EQUAL_INT(7,E_OK , result_inst_7); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance(void) { StatusType result_inst_1, result_inst_2; SCHEDULING_CHECK_INIT(1); result_inst_1 = ActivateTask(t1); SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OS_LIMIT , result_inst_1); SCHEDULING_CHECK_INIT(4); result_inst_2 = ChainTask(t1); SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OK , result_inst_2); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t2_instance(void) { StatusType result_inst_1,result_inst_2,result_inst_3,result_inst_4,result_inst_5; SCHEDULING_CHECK_INIT(3); result_inst_1 = ActivateTask(t1); SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OS_LIMIT , result_inst_1); SCHEDULING_CHECK_INIT(4); result_inst_2 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OS_LIMIT , result_inst_2); SCHEDULING_CHECK_INIT(5); result_inst_3 = WaitEvent(Event2); SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OK , result_inst_3); SCHEDULING_CHECK_INIT(11); result_inst_4 = ChainTask(t1); SCHEDULING_CHECK_AND_EQUAL_INT(11,E_OS_LIMIT , result_inst_4); SCHEDULING_CHECK_INIT(12); result_inst_5 = TerminateTask(); SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OK , result_inst_5); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance(void) { StatusType result_inst_1, result_inst_2; int t1_instance = posttask_instance/2; int test_start = t1_instance * 4; SCHEDULING_CHECK_INIT(test_start + 1); result_inst_1 = ActivateTask(t1); SCHEDULING_CHECK_AND_EQUAL_INT(test_start + 3,E_OS_LIMIT , result_inst_1); SCHEDULING_CHECK_INIT(test_start + 4); result_inst_2 = ChainTask(t1); SCHEDULING_CHECK_AND_EQUAL_INT(test_start + 4,E_OK , result_inst_2); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t2_instance(void) { StatusType result_inst_1,result_inst_2, result_inst_3; SCHEDULING_CHECK_INIT(1); result_inst_1 = ActivateTask(t1); SCHEDULING_CHECK_AND_EQUAL_INT(1,E_OK , result_inst_1); SCHEDULING_CHECK_INIT(2); result_inst_2 = WaitEvent(Event2); SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK , result_inst_2); SCHEDULING_CHECK_INIT(10); result_inst_3 = TerminateTask(); SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OK , result_inst_3); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t2_instance(void) { StatusType result_inst_1, result_inst_2, result_inst_3; SCHEDULING_CHECK_INIT(13); result_inst_1 = GetResource(Resource1); SCHEDULING_CHECK_AND_EQUAL_INT(13,E_OK, result_inst_1); SCHEDULING_CHECK_INIT(14); result_inst_2 = GetResource(Resource2); SCHEDULING_CHECK_AND_EQUAL_INT(14,E_OK, result_inst_2); SCHEDULING_CHECK_INIT(15); result_inst_3 = ActivateTask(t1); SCHEDULING_CHECK_AND_EQUAL_INT(15,E_OK, result_inst_3); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t2_instance(void) { StatusType result_inst_2,result_inst_3, result_inst_4; EventMaskType result_inst_1; SCHEDULING_CHECK_INIT(2); result_inst_2 = GetEvent(t2, &result_inst_1); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(2,E_OK , result_inst_1); SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OK , result_inst_2); SCHEDULING_CHECK_INIT(3); result_inst_3 = ActivateTask(t3); SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OK , result_inst_3); SCHEDULING_CHECK_INIT(4); result_inst_4 = TerminateTask(); SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OK , result_inst_4); }
int main(void) { char start_char; uint16_t n_chars; /* Clock setup */ InitClock(); /* Program Timer 1 to raise interrupts */ T1_program(); /* Init leds */ EE_leds_init(); EE_demoboard_leds_init(); console_init(); USART_printf("Hello From Erika RTOS, press t to run the benchmark \r\n"); //calcRawSpeed(); do{ readChar(&start_char); }while(start_char != 't'); //USART_printf("T ok \r\n"); stop = 0; uint8_t i; calcRawSpeed(); initState(kwips_rawspeed, initAlarms, initFreq, initKWPP); //for(i=0; i<9999; i++){} ActivateTask(SuperTask); //for(i=0; i<9999; i++){} StartOS(OSDEFAULTAPPMODE); /* Forever loop: background activities (if any) should go here */ for (;;); return 0; }
/***************************************************************************************************** * Function: SchM_OsTick * * Description: Callback handled once an interrupt is generated by Channel 0. * * Caveats: Non Reentrant *****************************************************************************************************/ void SchM_OsTick(void) { u8 Task_Index = 0; Status_Type StatusErrorResult = E_OK; _FEED_COP(); //SchM_OSTickEnabled = SCHM_OSTICK_ENABLED; for(Task_Index=0;Task_Index < TaskConfigInitial[0U].TaskNumberConfig;Task_Index++) { if((SchM_OSTickCounter & TaskConfigInitial->ptr_Task[Task_Index].Mask) == TaskConfigInitial->ptr_Task[Task_Index].Offset) { StatusErrorResult = ActivateTask(((TaskType)TaskConfigInitial->ptr_Task[Task_Index].Task_ID)); } } SchM_OSTickCounter ++; }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t2_instance(void) { StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4; SCHEDULING_CHECK_INIT(1); result_inst_1 = WaitEvent(Event2); SCHEDULING_CHECK_AND_EQUAL_INT(5,E_OK, result_inst_1); SCHEDULING_CHECK_INIT(6); result_inst_2 = ClearEvent(Event2); SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OK, result_inst_2); SCHEDULING_CHECK_INIT(7); result_inst_3 = ActivateTask(t4); SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OK, result_inst_3); SCHEDULING_CHECK_INIT(11); result_inst_4 = TerminateTask(); SCHEDULING_CHECK_AND_EQUAL_INT(11,E_OK, result_inst_4); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t2_instance(void) { StatusType result_inst_1, result_inst_3, result_inst_4, result_inst_5; EventMaskType result_inst_2; SCHEDULING_CHECK_INIT(1); result_inst_1 = ActivateTask(t1); SCHEDULING_CHECK_AND_EQUAL_INT(1,E_OK, result_inst_1); SCHEDULING_CHECK_INIT(2); result_inst_3 = GetEvent(t1,&result_inst_2); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(2, 0 , result_inst_2); SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OK, result_inst_3); SCHEDULING_CHECK_INIT(3); result_inst_4 = WaitEvent(Event2); SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OK, result_inst_4); SCHEDULING_CHECK_INIT(11); result_inst_5 = TerminateTask(); SCHEDULING_CHECK_AND_EQUAL_INT(11,E_OK, result_inst_5); }
void vCommand_Init(unsigned portBASE_TYPE uxPriority) { unsigned portSHORT usIndex; //initialise management arrary for (usIndex = 0; usIndex < NUM_TASKID; usIndex++) { xTaskQueueHandles[usIndex] = NULL; TaskTokens[usIndex].pcTaskName = NULL; TaskTokens[usIndex].enRetVal = 0; } ActivateTask(TASK_COMMAND, "Command", SEV_TASK_TYPE, uxPriority, SERV_STACK_SIZE, vCommandTask); vActivateQueue(&TaskTokens[TASK_COMMAND], CMD_Q_SIZE); vSemaphoreCreateBinary(initMutex); }