Freertos api

Solo disponible en BuenasTareas
  • Páginas : 29 (7210 palabras )
  • Descarga(s) : 0
  • Publicado : 28 de noviembre de 2010
Leer documento completo
Vista previa del texto
FreeRTOS API
1.1 Task Creation ................................................................................................................ 2 1.2 Task Control.................................................................................................................. 4 1.3 TaskUtilities............................................................................................................... 12 1.4 Kernel Control ............................................................................................................ 14 1.4 Queue Management .................................................................................................... 19 1.5 Semaphores .................................................................................................................28

Literatur: http://www.freertos.org/index.html?http://www.freertos.org/a00106.html

NTA-Isny

FreeRTOS-API V1.1

1

1.1 Task Creation
Modules • xTaskCreate • vTaskDelete Detailed Description xTaskHandle task. h Type by which tasks are referenced. For example, a call to xTaskCreate returns (via a pointer parameter) an xTaskHandle variable that can then be used as a parameter tovTaskDelete to delete the task. xTaskCreate task. h portBASE_TYPE xTaskCreate( pdTASK_CODE pvTaskCode, const portCHAR * const pcName, unsigned portSHORT usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pvCreatedTask ); Create a new task and add it to the list of tasks that are ready to run. Parameters: pvTaskCode pcName Comment Pointer to the task entry function. Tasksmust be implemented to never return (i.e. continuous loop). A descriptive name for the task. This is mainly used to facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN. The size of the task stack specified as the number of variables the stack can hold - not the number of bytes. For example, if the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes will be allocatedfor stack storage. The stack depth multiplied by the stack width must not exceed the maximum value that can be contained in a variable of type size_t. Pointer that will be used as the parameter for the task being created. The priority at which the task should run. Used to pass back a handle by which the created task can be referenced.

usStackDepth

pvParameters uxPriority pvCreatedTaskReturns: pdPASS

Comment if the task was successfully created and added to a ready list, otherwise an error code defined in the file projdefs.h

NTA-Isny

FreeRTOS-API V1.1

2

Example usage: // Task to be created. void vTaskCode( void * pvParameters ) { for( ;; ) { // Task code goes here. } } // Function that creates a task. void vOtherFunction( void ) { static unsigned charucParameterToPass; xTaskHandle xHandle; //Create the task, storing the handle. //Note that the passed parameter ucParameterToPass //must exist for the lifetime of the task, so in this case is //declared static. If it was just an //an automatic stack variable it might no longer exist, or at //least have been corrupted, by the time //the new time attempts to access it. xTaskCreate( vTaskCode, "NAME", STACK_SIZE,&ucParameterToPass, tskIDLE_PRIORITY, &xHandle ); // Use the handle to delete the task. vTaskDelete( xHandle ); }

vTaskDelete task. h void vTaskDelete( xTaskHandle pxTask ); INCLUDE_vTaskDelete must be defined as 1 for this function to be available. See the configuration section for more information. Remove a task from the RTOS real time kernels management. The task being deleted will beremoved from all ready, blocked, suspended and event lists. NOTE: The idle task is responsible for freeing the kernel allocated memory from tasks that have been deleted. It is therefore important that the idle task is not starved of microcontroller processing time if your application makes any calls to vTaskDelete (). Memory allocated by the task code is not automatically freed, and should be freed...
tracking img