IAR PowerPac RTOS User Guide
IAR PowerPac RTOS User Guide
IAR PowerPac RTOS User Guide
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Task routinesExampleThe following example is delivered in the Samples folder of <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong>./*------------------------------------------------------------------File : Main_TaskEx.cPurpose : Sample program for <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> using OC_CREATETASK_EX--------- END-OF-HEADER --------------------------------------------*/#include "<strong>RTOS</strong>.h"OS_STACKPTR int StackHP[128], StackLP[128]; /* Task stacks */OS_TASK TCBHP, TCBLP; /* Task-control-blocks *//********************************************************************/static void TaskEx(void* pData) {while (1) {OS_Delay ((OS_TIME) pData);}}/*********************************************************************** main**********************************************************************/int main(void) {OS_IncDI(); /* Initially disable interrupts */OS_InitKern(); /* initialize OS */OS_InitHW(); /* initialize Hardware for OS *//* You need to create at least one task before calling OS_Start() */OS_CREATETASK_EX(&TCBHP, "HP Task", TaskEx, 100, StackHP, (void*) 50);OS_CREATETASK_EX(&TCBLP, "LP Task", TaskEx, 50, StackLP, (void*) 200);OS_SendString("Start project will start multitasking !\n");OS_Start(); /* Start multitasking */return 0;}OS_CreateTaskEx()DescriptionCreates a task and passes a parameter to the task.Prototypevoid OS_CreateTaskEx (OS_TASK* pTask,char*pName,unsigned char Priority,voidRoutine* pRoutine,void*pStack,unsigned StackSize,unsigned char TimeSlice,void*pContext);)ParameterDescriptionpTaskPointer to a data structure of type OS_TASK which will be used as the task control block (andreference) for this task.pNamePointer to the name of the task. Can be NULL (or 0) if not used.PriorityPriority of the task. Must be within the following range:1