Francisco Paez / freertos

Dependents:   frdm_k64f_freertos_lib

Committer:
fep
Date:
Wed May 31 02:27:10 2017 +0000
Revision:
0:62cd296ba2a7
FreeRTOS v9.0.0 for Cortex-M4F (FRDM-K64F and others...)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fep 0:62cd296ba2a7 1 /*
fep 0:62cd296ba2a7 2 FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
fep 0:62cd296ba2a7 3 All rights reserved
fep 0:62cd296ba2a7 4
fep 0:62cd296ba2a7 5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
fep 0:62cd296ba2a7 6
fep 0:62cd296ba2a7 7 This file is part of the FreeRTOS distribution.
fep 0:62cd296ba2a7 8
fep 0:62cd296ba2a7 9 FreeRTOS is free software; you can redistribute it and/or modify it under
fep 0:62cd296ba2a7 10 the terms of the GNU General Public License (version 2) as published by the
fep 0:62cd296ba2a7 11 Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
fep 0:62cd296ba2a7 12
fep 0:62cd296ba2a7 13 ***************************************************************************
fep 0:62cd296ba2a7 14 >>! NOTE: The modification to the GPL is included to allow you to !<<
fep 0:62cd296ba2a7 15 >>! distribute a combined work that includes FreeRTOS without being !<<
fep 0:62cd296ba2a7 16 >>! obliged to provide the source code for proprietary components !<<
fep 0:62cd296ba2a7 17 >>! outside of the FreeRTOS kernel. !<<
fep 0:62cd296ba2a7 18 ***************************************************************************
fep 0:62cd296ba2a7 19
fep 0:62cd296ba2a7 20 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
fep 0:62cd296ba2a7 21 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
fep 0:62cd296ba2a7 22 FOR A PARTICULAR PURPOSE. Full license text is available on the following
fep 0:62cd296ba2a7 23 link: http://www.freertos.org/a00114.html
fep 0:62cd296ba2a7 24
fep 0:62cd296ba2a7 25 ***************************************************************************
fep 0:62cd296ba2a7 26 * *
fep 0:62cd296ba2a7 27 * FreeRTOS provides completely free yet professionally developed, *
fep 0:62cd296ba2a7 28 * robust, strictly quality controlled, supported, and cross *
fep 0:62cd296ba2a7 29 * platform software that is more than just the market leader, it *
fep 0:62cd296ba2a7 30 * is the industry's de facto standard. *
fep 0:62cd296ba2a7 31 * *
fep 0:62cd296ba2a7 32 * Help yourself get started quickly while simultaneously helping *
fep 0:62cd296ba2a7 33 * to support the FreeRTOS project by purchasing a FreeRTOS *
fep 0:62cd296ba2a7 34 * tutorial book, reference manual, or both: *
fep 0:62cd296ba2a7 35 * http://www.FreeRTOS.org/Documentation *
fep 0:62cd296ba2a7 36 * *
fep 0:62cd296ba2a7 37 ***************************************************************************
fep 0:62cd296ba2a7 38
fep 0:62cd296ba2a7 39 http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
fep 0:62cd296ba2a7 40 the FAQ page "My application does not run, what could be wrong?". Have you
fep 0:62cd296ba2a7 41 defined configASSERT()?
fep 0:62cd296ba2a7 42
fep 0:62cd296ba2a7 43 http://www.FreeRTOS.org/support - In return for receiving this top quality
fep 0:62cd296ba2a7 44 embedded software for free we request you assist our global community by
fep 0:62cd296ba2a7 45 participating in the support forum.
fep 0:62cd296ba2a7 46
fep 0:62cd296ba2a7 47 http://www.FreeRTOS.org/training - Investing in training allows your team to
fep 0:62cd296ba2a7 48 be as productive as possible as early as possible. Now you can receive
fep 0:62cd296ba2a7 49 FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
fep 0:62cd296ba2a7 50 Ltd, and the world's leading authority on the world's leading RTOS.
fep 0:62cd296ba2a7 51
fep 0:62cd296ba2a7 52 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
fep 0:62cd296ba2a7 53 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
fep 0:62cd296ba2a7 54 compatible FAT file system, and our tiny thread aware UDP/IP stack.
fep 0:62cd296ba2a7 55
fep 0:62cd296ba2a7 56 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
fep 0:62cd296ba2a7 57 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
fep 0:62cd296ba2a7 58
fep 0:62cd296ba2a7 59 http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
fep 0:62cd296ba2a7 60 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
fep 0:62cd296ba2a7 61 licenses offer ticketed support, indemnification and commercial middleware.
fep 0:62cd296ba2a7 62
fep 0:62cd296ba2a7 63 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
fep 0:62cd296ba2a7 64 engineered and independently SIL3 certified version for use in safety and
fep 0:62cd296ba2a7 65 mission critical applications that require provable dependability.
fep 0:62cd296ba2a7 66
fep 0:62cd296ba2a7 67 1 tab == 4 spaces!
fep 0:62cd296ba2a7 68 */
fep 0:62cd296ba2a7 69
fep 0:62cd296ba2a7 70
fep 0:62cd296ba2a7 71 #ifndef INC_TASK_H
fep 0:62cd296ba2a7 72 #define INC_TASK_H
fep 0:62cd296ba2a7 73
fep 0:62cd296ba2a7 74 #ifndef INC_FREERTOS_H
fep 0:62cd296ba2a7 75 #error "include FreeRTOS.h must appear in source files before include task.h"
fep 0:62cd296ba2a7 76 #endif
fep 0:62cd296ba2a7 77
fep 0:62cd296ba2a7 78 #include "list.h"
fep 0:62cd296ba2a7 79
fep 0:62cd296ba2a7 80 #ifdef __cplusplus
fep 0:62cd296ba2a7 81 extern "C" {
fep 0:62cd296ba2a7 82 #endif
fep 0:62cd296ba2a7 83
fep 0:62cd296ba2a7 84 /*-----------------------------------------------------------
fep 0:62cd296ba2a7 85 * MACROS AND DEFINITIONS
fep 0:62cd296ba2a7 86 *----------------------------------------------------------*/
fep 0:62cd296ba2a7 87
fep 0:62cd296ba2a7 88 #define tskKERNEL_VERSION_NUMBER "V9.0.0"
fep 0:62cd296ba2a7 89 #define tskKERNEL_VERSION_MAJOR 9
fep 0:62cd296ba2a7 90 #define tskKERNEL_VERSION_MINOR 0
fep 0:62cd296ba2a7 91 #define tskKERNEL_VERSION_BUILD 0
fep 0:62cd296ba2a7 92
fep 0:62cd296ba2a7 93 /**
fep 0:62cd296ba2a7 94 * task. h
fep 0:62cd296ba2a7 95 *
fep 0:62cd296ba2a7 96 * Type by which tasks are referenced. For example, a call to xTaskCreate
fep 0:62cd296ba2a7 97 * returns (via a pointer parameter) an TaskHandle_t variable that can then
fep 0:62cd296ba2a7 98 * be used as a parameter to vTaskDelete to delete the task.
fep 0:62cd296ba2a7 99 *
fep 0:62cd296ba2a7 100 * \defgroup TaskHandle_t TaskHandle_t
fep 0:62cd296ba2a7 101 * \ingroup Tasks
fep 0:62cd296ba2a7 102 */
fep 0:62cd296ba2a7 103 typedef void * TaskHandle_t;
fep 0:62cd296ba2a7 104
fep 0:62cd296ba2a7 105 /*
fep 0:62cd296ba2a7 106 * Defines the prototype to which the application task hook function must
fep 0:62cd296ba2a7 107 * conform.
fep 0:62cd296ba2a7 108 */
fep 0:62cd296ba2a7 109 typedef BaseType_t (*TaskHookFunction_t)( void * );
fep 0:62cd296ba2a7 110
fep 0:62cd296ba2a7 111 /* Task states returned by eTaskGetState. */
fep 0:62cd296ba2a7 112 typedef enum
fep 0:62cd296ba2a7 113 {
fep 0:62cd296ba2a7 114 eRunning = 0, /* A task is querying the state of itself, so must be running. */
fep 0:62cd296ba2a7 115 eReady, /* The task being queried is in a read or pending ready list. */
fep 0:62cd296ba2a7 116 eBlocked, /* The task being queried is in the Blocked state. */
fep 0:62cd296ba2a7 117 eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
fep 0:62cd296ba2a7 118 eDeleted, /* The task being queried has been deleted, but its TCB has not yet been freed. */
fep 0:62cd296ba2a7 119 eInvalid /* Used as an 'invalid state' value. */
fep 0:62cd296ba2a7 120 } eTaskState;
fep 0:62cd296ba2a7 121
fep 0:62cd296ba2a7 122 /* Actions that can be performed when vTaskNotify() is called. */
fep 0:62cd296ba2a7 123 typedef enum
fep 0:62cd296ba2a7 124 {
fep 0:62cd296ba2a7 125 eNoAction = 0, /* Notify the task without updating its notify value. */
fep 0:62cd296ba2a7 126 eSetBits, /* Set bits in the task's notification value. */
fep 0:62cd296ba2a7 127 eIncrement, /* Increment the task's notification value. */
fep 0:62cd296ba2a7 128 eSetValueWithOverwrite, /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */
fep 0:62cd296ba2a7 129 eSetValueWithoutOverwrite /* Set the task's notification value if the previous value has been read by the task. */
fep 0:62cd296ba2a7 130 } eNotifyAction;
fep 0:62cd296ba2a7 131
fep 0:62cd296ba2a7 132 /*
fep 0:62cd296ba2a7 133 * Used internally only.
fep 0:62cd296ba2a7 134 */
fep 0:62cd296ba2a7 135 typedef struct xTIME_OUT
fep 0:62cd296ba2a7 136 {
fep 0:62cd296ba2a7 137 BaseType_t xOverflowCount;
fep 0:62cd296ba2a7 138 TickType_t xTimeOnEntering;
fep 0:62cd296ba2a7 139 } TimeOut_t;
fep 0:62cd296ba2a7 140
fep 0:62cd296ba2a7 141 /*
fep 0:62cd296ba2a7 142 * Defines the memory ranges allocated to the task when an MPU is used.
fep 0:62cd296ba2a7 143 */
fep 0:62cd296ba2a7 144 typedef struct xMEMORY_REGION
fep 0:62cd296ba2a7 145 {
fep 0:62cd296ba2a7 146 void *pvBaseAddress;
fep 0:62cd296ba2a7 147 uint32_t ulLengthInBytes;
fep 0:62cd296ba2a7 148 uint32_t ulParameters;
fep 0:62cd296ba2a7 149 } MemoryRegion_t;
fep 0:62cd296ba2a7 150
fep 0:62cd296ba2a7 151 /*
fep 0:62cd296ba2a7 152 * Parameters required to create an MPU protected task.
fep 0:62cd296ba2a7 153 */
fep 0:62cd296ba2a7 154 typedef struct xTASK_PARAMETERS
fep 0:62cd296ba2a7 155 {
fep 0:62cd296ba2a7 156 TaskFunction_t pvTaskCode;
fep 0:62cd296ba2a7 157 const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
fep 0:62cd296ba2a7 158 uint16_t usStackDepth;
fep 0:62cd296ba2a7 159 void *pvParameters;
fep 0:62cd296ba2a7 160 UBaseType_t uxPriority;
fep 0:62cd296ba2a7 161 StackType_t *puxStackBuffer;
fep 0:62cd296ba2a7 162 MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ];
fep 0:62cd296ba2a7 163 } TaskParameters_t;
fep 0:62cd296ba2a7 164
fep 0:62cd296ba2a7 165 /* Used with the uxTaskGetSystemState() function to return the state of each task
fep 0:62cd296ba2a7 166 in the system. */
fep 0:62cd296ba2a7 167 typedef struct xTASK_STATUS
fep 0:62cd296ba2a7 168 {
fep 0:62cd296ba2a7 169 TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */
fep 0:62cd296ba2a7 170 const char *pcTaskName; /* A pointer to the task's name. This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
fep 0:62cd296ba2a7 171 UBaseType_t xTaskNumber; /* A number unique to the task. */
fep 0:62cd296ba2a7 172 eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */
fep 0:62cd296ba2a7 173 UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */
fep 0:62cd296ba2a7 174 UBaseType_t uxBasePriority; /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */
fep 0:62cd296ba2a7 175 uint32_t ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See http://www.freertos.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */
fep 0:62cd296ba2a7 176 StackType_t *pxStackBase; /* Points to the lowest address of the task's stack area. */
fep 0:62cd296ba2a7 177 uint16_t usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */
fep 0:62cd296ba2a7 178 } TaskStatus_t;
fep 0:62cd296ba2a7 179
fep 0:62cd296ba2a7 180 /* Possible return values for eTaskConfirmSleepModeStatus(). */
fep 0:62cd296ba2a7 181 typedef enum
fep 0:62cd296ba2a7 182 {
fep 0:62cd296ba2a7 183 eAbortSleep = 0, /* A task has been made ready or a context switch pended since portSUPPORESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */
fep 0:62cd296ba2a7 184 eStandardSleep, /* Enter a sleep mode that will not last any longer than the expected idle time. */
fep 0:62cd296ba2a7 185 eNoTasksWaitingTimeout /* No tasks are waiting for a timeout so it is safe to enter a sleep mode that can only be exited by an external interrupt. */
fep 0:62cd296ba2a7 186 } eSleepModeStatus;
fep 0:62cd296ba2a7 187
fep 0:62cd296ba2a7 188 /**
fep 0:62cd296ba2a7 189 * Defines the priority used by the idle task. This must not be modified.
fep 0:62cd296ba2a7 190 *
fep 0:62cd296ba2a7 191 * \ingroup TaskUtils
fep 0:62cd296ba2a7 192 */
fep 0:62cd296ba2a7 193 #define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U )
fep 0:62cd296ba2a7 194
fep 0:62cd296ba2a7 195 /**
fep 0:62cd296ba2a7 196 * task. h
fep 0:62cd296ba2a7 197 *
fep 0:62cd296ba2a7 198 * Macro for forcing a context switch.
fep 0:62cd296ba2a7 199 *
fep 0:62cd296ba2a7 200 * \defgroup taskYIELD taskYIELD
fep 0:62cd296ba2a7 201 * \ingroup SchedulerControl
fep 0:62cd296ba2a7 202 */
fep 0:62cd296ba2a7 203 #define taskYIELD() portYIELD()
fep 0:62cd296ba2a7 204
fep 0:62cd296ba2a7 205 /**
fep 0:62cd296ba2a7 206 * task. h
fep 0:62cd296ba2a7 207 *
fep 0:62cd296ba2a7 208 * Macro to mark the start of a critical code region. Preemptive context
fep 0:62cd296ba2a7 209 * switches cannot occur when in a critical region.
fep 0:62cd296ba2a7 210 *
fep 0:62cd296ba2a7 211 * NOTE: This may alter the stack (depending on the portable implementation)
fep 0:62cd296ba2a7 212 * so must be used with care!
fep 0:62cd296ba2a7 213 *
fep 0:62cd296ba2a7 214 * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL
fep 0:62cd296ba2a7 215 * \ingroup SchedulerControl
fep 0:62cd296ba2a7 216 */
fep 0:62cd296ba2a7 217 #define taskENTER_CRITICAL() portENTER_CRITICAL()
fep 0:62cd296ba2a7 218 #define taskENTER_CRITICAL_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()
fep 0:62cd296ba2a7 219
fep 0:62cd296ba2a7 220 /**
fep 0:62cd296ba2a7 221 * task. h
fep 0:62cd296ba2a7 222 *
fep 0:62cd296ba2a7 223 * Macro to mark the end of a critical code region. Preemptive context
fep 0:62cd296ba2a7 224 * switches cannot occur when in a critical region.
fep 0:62cd296ba2a7 225 *
fep 0:62cd296ba2a7 226 * NOTE: This may alter the stack (depending on the portable implementation)
fep 0:62cd296ba2a7 227 * so must be used with care!
fep 0:62cd296ba2a7 228 *
fep 0:62cd296ba2a7 229 * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL
fep 0:62cd296ba2a7 230 * \ingroup SchedulerControl
fep 0:62cd296ba2a7 231 */
fep 0:62cd296ba2a7 232 #define taskEXIT_CRITICAL() portEXIT_CRITICAL()
fep 0:62cd296ba2a7 233 #define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x )
fep 0:62cd296ba2a7 234 /**
fep 0:62cd296ba2a7 235 * task. h
fep 0:62cd296ba2a7 236 *
fep 0:62cd296ba2a7 237 * Macro to disable all maskable interrupts.
fep 0:62cd296ba2a7 238 *
fep 0:62cd296ba2a7 239 * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS
fep 0:62cd296ba2a7 240 * \ingroup SchedulerControl
fep 0:62cd296ba2a7 241 */
fep 0:62cd296ba2a7 242 #define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS()
fep 0:62cd296ba2a7 243
fep 0:62cd296ba2a7 244 /**
fep 0:62cd296ba2a7 245 * task. h
fep 0:62cd296ba2a7 246 *
fep 0:62cd296ba2a7 247 * Macro to enable microcontroller interrupts.
fep 0:62cd296ba2a7 248 *
fep 0:62cd296ba2a7 249 * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS
fep 0:62cd296ba2a7 250 * \ingroup SchedulerControl
fep 0:62cd296ba2a7 251 */
fep 0:62cd296ba2a7 252 #define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS()
fep 0:62cd296ba2a7 253
fep 0:62cd296ba2a7 254 /* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is
fep 0:62cd296ba2a7 255 0 to generate more optimal code when configASSERT() is defined as the constant
fep 0:62cd296ba2a7 256 is used in assert() statements. */
fep 0:62cd296ba2a7 257 #define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 )
fep 0:62cd296ba2a7 258 #define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 )
fep 0:62cd296ba2a7 259 #define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 )
fep 0:62cd296ba2a7 260
fep 0:62cd296ba2a7 261
fep 0:62cd296ba2a7 262 /*-----------------------------------------------------------
fep 0:62cd296ba2a7 263 * TASK CREATION API
fep 0:62cd296ba2a7 264 *----------------------------------------------------------*/
fep 0:62cd296ba2a7 265
fep 0:62cd296ba2a7 266 /**
fep 0:62cd296ba2a7 267 * task. h
fep 0:62cd296ba2a7 268 *<pre>
fep 0:62cd296ba2a7 269 BaseType_t xTaskCreate(
fep 0:62cd296ba2a7 270 TaskFunction_t pvTaskCode,
fep 0:62cd296ba2a7 271 const char * const pcName,
fep 0:62cd296ba2a7 272 uint16_t usStackDepth,
fep 0:62cd296ba2a7 273 void *pvParameters,
fep 0:62cd296ba2a7 274 UBaseType_t uxPriority,
fep 0:62cd296ba2a7 275 TaskHandle_t *pvCreatedTask
fep 0:62cd296ba2a7 276 );</pre>
fep 0:62cd296ba2a7 277 *
fep 0:62cd296ba2a7 278 * Create a new task and add it to the list of tasks that are ready to run.
fep 0:62cd296ba2a7 279 *
fep 0:62cd296ba2a7 280 * Internally, within the FreeRTOS implementation, tasks use two blocks of
fep 0:62cd296ba2a7 281 * memory. The first block is used to hold the task's data structures. The
fep 0:62cd296ba2a7 282 * second block is used by the task as its stack. If a task is created using
fep 0:62cd296ba2a7 283 * xTaskCreate() then both blocks of memory are automatically dynamically
fep 0:62cd296ba2a7 284 * allocated inside the xTaskCreate() function. (see
fep 0:62cd296ba2a7 285 * http://www.freertos.org/a00111.html). If a task is created using
fep 0:62cd296ba2a7 286 * xTaskCreateStatic() then the application writer must provide the required
fep 0:62cd296ba2a7 287 * memory. xTaskCreateStatic() therefore allows a task to be created without
fep 0:62cd296ba2a7 288 * using any dynamic memory allocation.
fep 0:62cd296ba2a7 289 *
fep 0:62cd296ba2a7 290 * See xTaskCreateStatic() for a version that does not use any dynamic memory
fep 0:62cd296ba2a7 291 * allocation.
fep 0:62cd296ba2a7 292 *
fep 0:62cd296ba2a7 293 * xTaskCreate() can only be used to create a task that has unrestricted
fep 0:62cd296ba2a7 294 * access to the entire microcontroller memory map. Systems that include MPU
fep 0:62cd296ba2a7 295 * support can alternatively create an MPU constrained task using
fep 0:62cd296ba2a7 296 * xTaskCreateRestricted().
fep 0:62cd296ba2a7 297 *
fep 0:62cd296ba2a7 298 * @param pvTaskCode Pointer to the task entry function. Tasks
fep 0:62cd296ba2a7 299 * must be implemented to never return (i.e. continuous loop).
fep 0:62cd296ba2a7 300 *
fep 0:62cd296ba2a7 301 * @param pcName A descriptive name for the task. This is mainly used to
fep 0:62cd296ba2a7 302 * facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN - default
fep 0:62cd296ba2a7 303 * is 16.
fep 0:62cd296ba2a7 304 *
fep 0:62cd296ba2a7 305 * @param usStackDepth The size of the task stack specified as the number of
fep 0:62cd296ba2a7 306 * variables the stack can hold - not the number of bytes. For example, if
fep 0:62cd296ba2a7 307 * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes
fep 0:62cd296ba2a7 308 * will be allocated for stack storage.
fep 0:62cd296ba2a7 309 *
fep 0:62cd296ba2a7 310 * @param pvParameters Pointer that will be used as the parameter for the task
fep 0:62cd296ba2a7 311 * being created.
fep 0:62cd296ba2a7 312 *
fep 0:62cd296ba2a7 313 * @param uxPriority The priority at which the task should run. Systems that
fep 0:62cd296ba2a7 314 * include MPU support can optionally create tasks in a privileged (system)
fep 0:62cd296ba2a7 315 * mode by setting bit portPRIVILEGE_BIT of the priority parameter. For
fep 0:62cd296ba2a7 316 * example, to create a privileged task at priority 2 the uxPriority parameter
fep 0:62cd296ba2a7 317 * should be set to ( 2 | portPRIVILEGE_BIT ).
fep 0:62cd296ba2a7 318 *
fep 0:62cd296ba2a7 319 * @param pvCreatedTask Used to pass back a handle by which the created task
fep 0:62cd296ba2a7 320 * can be referenced.
fep 0:62cd296ba2a7 321 *
fep 0:62cd296ba2a7 322 * @return pdPASS if the task was successfully created and added to a ready
fep 0:62cd296ba2a7 323 * list, otherwise an error code defined in the file projdefs.h
fep 0:62cd296ba2a7 324 *
fep 0:62cd296ba2a7 325 * Example usage:
fep 0:62cd296ba2a7 326 <pre>
fep 0:62cd296ba2a7 327 // Task to be created.
fep 0:62cd296ba2a7 328 void vTaskCode( void * pvParameters )
fep 0:62cd296ba2a7 329 {
fep 0:62cd296ba2a7 330 for( ;; )
fep 0:62cd296ba2a7 331 {
fep 0:62cd296ba2a7 332 // Task code goes here.
fep 0:62cd296ba2a7 333 }
fep 0:62cd296ba2a7 334 }
fep 0:62cd296ba2a7 335
fep 0:62cd296ba2a7 336 // Function that creates a task.
fep 0:62cd296ba2a7 337 void vOtherFunction( void )
fep 0:62cd296ba2a7 338 {
fep 0:62cd296ba2a7 339 static uint8_t ucParameterToPass;
fep 0:62cd296ba2a7 340 TaskHandle_t xHandle = NULL;
fep 0:62cd296ba2a7 341
fep 0:62cd296ba2a7 342 // Create the task, storing the handle. Note that the passed parameter ucParameterToPass
fep 0:62cd296ba2a7 343 // must exist for the lifetime of the task, so in this case is declared static. If it was just an
fep 0:62cd296ba2a7 344 // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
fep 0:62cd296ba2a7 345 // the new task attempts to access it.
fep 0:62cd296ba2a7 346 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
fep 0:62cd296ba2a7 347 configASSERT( xHandle );
fep 0:62cd296ba2a7 348
fep 0:62cd296ba2a7 349 // Use the handle to delete the task.
fep 0:62cd296ba2a7 350 if( xHandle != NULL )
fep 0:62cd296ba2a7 351 {
fep 0:62cd296ba2a7 352 vTaskDelete( xHandle );
fep 0:62cd296ba2a7 353 }
fep 0:62cd296ba2a7 354 }
fep 0:62cd296ba2a7 355 </pre>
fep 0:62cd296ba2a7 356 * \defgroup xTaskCreate xTaskCreate
fep 0:62cd296ba2a7 357 * \ingroup Tasks
fep 0:62cd296ba2a7 358 */
fep 0:62cd296ba2a7 359 #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
fep 0:62cd296ba2a7 360 BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
fep 0:62cd296ba2a7 361 const char * const pcName,
fep 0:62cd296ba2a7 362 const uint16_t usStackDepth,
fep 0:62cd296ba2a7 363 void * const pvParameters,
fep 0:62cd296ba2a7 364 UBaseType_t uxPriority,
fep 0:62cd296ba2a7 365 TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
fep 0:62cd296ba2a7 366 #endif
fep 0:62cd296ba2a7 367
fep 0:62cd296ba2a7 368 /**
fep 0:62cd296ba2a7 369 * task. h
fep 0:62cd296ba2a7 370 *<pre>
fep 0:62cd296ba2a7 371 TaskHandle_t xTaskCreateStatic( TaskFunction_t pvTaskCode,
fep 0:62cd296ba2a7 372 const char * const pcName,
fep 0:62cd296ba2a7 373 uint32_t ulStackDepth,
fep 0:62cd296ba2a7 374 void *pvParameters,
fep 0:62cd296ba2a7 375 UBaseType_t uxPriority,
fep 0:62cd296ba2a7 376 StackType_t *pxStackBuffer,
fep 0:62cd296ba2a7 377 StaticTask_t *pxTaskBuffer );</pre>
fep 0:62cd296ba2a7 378 *
fep 0:62cd296ba2a7 379 * Create a new task and add it to the list of tasks that are ready to run.
fep 0:62cd296ba2a7 380 *
fep 0:62cd296ba2a7 381 * Internally, within the FreeRTOS implementation, tasks use two blocks of
fep 0:62cd296ba2a7 382 * memory. The first block is used to hold the task's data structures. The
fep 0:62cd296ba2a7 383 * second block is used by the task as its stack. If a task is created using
fep 0:62cd296ba2a7 384 * xTaskCreate() then both blocks of memory are automatically dynamically
fep 0:62cd296ba2a7 385 * allocated inside the xTaskCreate() function. (see
fep 0:62cd296ba2a7 386 * http://www.freertos.org/a00111.html). If a task is created using
fep 0:62cd296ba2a7 387 * xTaskCreateStatic() then the application writer must provide the required
fep 0:62cd296ba2a7 388 * memory. xTaskCreateStatic() therefore allows a task to be created without
fep 0:62cd296ba2a7 389 * using any dynamic memory allocation.
fep 0:62cd296ba2a7 390 *
fep 0:62cd296ba2a7 391 * @param pvTaskCode Pointer to the task entry function. Tasks
fep 0:62cd296ba2a7 392 * must be implemented to never return (i.e. continuous loop).
fep 0:62cd296ba2a7 393 *
fep 0:62cd296ba2a7 394 * @param pcName A descriptive name for the task. This is mainly used to
fep 0:62cd296ba2a7 395 * facilitate debugging. The maximum length of the string is defined by
fep 0:62cd296ba2a7 396 * configMAX_TASK_NAME_LEN in FreeRTOSConfig.h.
fep 0:62cd296ba2a7 397 *
fep 0:62cd296ba2a7 398 * @param ulStackDepth The size of the task stack specified as the number of
fep 0:62cd296ba2a7 399 * variables the stack can hold - not the number of bytes. For example, if
fep 0:62cd296ba2a7 400 * the stack is 32-bits wide and ulStackDepth is defined as 100 then 400 bytes
fep 0:62cd296ba2a7 401 * will be allocated for stack storage.
fep 0:62cd296ba2a7 402 *
fep 0:62cd296ba2a7 403 * @param pvParameters Pointer that will be used as the parameter for the task
fep 0:62cd296ba2a7 404 * being created.
fep 0:62cd296ba2a7 405 *
fep 0:62cd296ba2a7 406 * @param uxPriority The priority at which the task will run.
fep 0:62cd296ba2a7 407 *
fep 0:62cd296ba2a7 408 * @param pxStackBuffer Must point to a StackType_t array that has at least
fep 0:62cd296ba2a7 409 * ulStackDepth indexes - the array will then be used as the task's stack,
fep 0:62cd296ba2a7 410 * removing the need for the stack to be allocated dynamically.
fep 0:62cd296ba2a7 411 *
fep 0:62cd296ba2a7 412 * @param pxTaskBuffer Must point to a variable of type StaticTask_t, which will
fep 0:62cd296ba2a7 413 * then be used to hold the task's data structures, removing the need for the
fep 0:62cd296ba2a7 414 * memory to be allocated dynamically.
fep 0:62cd296ba2a7 415 *
fep 0:62cd296ba2a7 416 * @return If neither pxStackBuffer or pxTaskBuffer are NULL, then the task will
fep 0:62cd296ba2a7 417 * be created and pdPASS is returned. If either pxStackBuffer or pxTaskBuffer
fep 0:62cd296ba2a7 418 * are NULL then the task will not be created and
fep 0:62cd296ba2a7 419 * errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY is returned.
fep 0:62cd296ba2a7 420 *
fep 0:62cd296ba2a7 421 * Example usage:
fep 0:62cd296ba2a7 422 <pre>
fep 0:62cd296ba2a7 423
fep 0:62cd296ba2a7 424 // Dimensions the buffer that the task being created will use as its stack.
fep 0:62cd296ba2a7 425 // NOTE: This is the number of words the stack will hold, not the number of
fep 0:62cd296ba2a7 426 // bytes. For example, if each stack item is 32-bits, and this is set to 100,
fep 0:62cd296ba2a7 427 // then 400 bytes (100 * 32-bits) will be allocated.
fep 0:62cd296ba2a7 428 #define STACK_SIZE 200
fep 0:62cd296ba2a7 429
fep 0:62cd296ba2a7 430 // Structure that will hold the TCB of the task being created.
fep 0:62cd296ba2a7 431 StaticTask_t xTaskBuffer;
fep 0:62cd296ba2a7 432
fep 0:62cd296ba2a7 433 // Buffer that the task being created will use as its stack. Note this is
fep 0:62cd296ba2a7 434 // an array of StackType_t variables. The size of StackType_t is dependent on
fep 0:62cd296ba2a7 435 // the RTOS port.
fep 0:62cd296ba2a7 436 StackType_t xStack[ STACK_SIZE ];
fep 0:62cd296ba2a7 437
fep 0:62cd296ba2a7 438 // Function that implements the task being created.
fep 0:62cd296ba2a7 439 void vTaskCode( void * pvParameters )
fep 0:62cd296ba2a7 440 {
fep 0:62cd296ba2a7 441 // The parameter value is expected to be 1 as 1 is passed in the
fep 0:62cd296ba2a7 442 // pvParameters value in the call to xTaskCreateStatic().
fep 0:62cd296ba2a7 443 configASSERT( ( uint32_t ) pvParameters == 1UL );
fep 0:62cd296ba2a7 444
fep 0:62cd296ba2a7 445 for( ;; )
fep 0:62cd296ba2a7 446 {
fep 0:62cd296ba2a7 447 // Task code goes here.
fep 0:62cd296ba2a7 448 }
fep 0:62cd296ba2a7 449 }
fep 0:62cd296ba2a7 450
fep 0:62cd296ba2a7 451 // Function that creates a task.
fep 0:62cd296ba2a7 452 void vOtherFunction( void )
fep 0:62cd296ba2a7 453 {
fep 0:62cd296ba2a7 454 TaskHandle_t xHandle = NULL;
fep 0:62cd296ba2a7 455
fep 0:62cd296ba2a7 456 // Create the task without using any dynamic memory allocation.
fep 0:62cd296ba2a7 457 xHandle = xTaskCreateStatic(
fep 0:62cd296ba2a7 458 vTaskCode, // Function that implements the task.
fep 0:62cd296ba2a7 459 "NAME", // Text name for the task.
fep 0:62cd296ba2a7 460 STACK_SIZE, // Stack size in words, not bytes.
fep 0:62cd296ba2a7 461 ( void * ) 1, // Parameter passed into the task.
fep 0:62cd296ba2a7 462 tskIDLE_PRIORITY,// Priority at which the task is created.
fep 0:62cd296ba2a7 463 xStack, // Array to use as the task's stack.
fep 0:62cd296ba2a7 464 &xTaskBuffer ); // Variable to hold the task's data structure.
fep 0:62cd296ba2a7 465
fep 0:62cd296ba2a7 466 // puxStackBuffer and pxTaskBuffer were not NULL, so the task will have
fep 0:62cd296ba2a7 467 // been created, and xHandle will be the task's handle. Use the handle
fep 0:62cd296ba2a7 468 // to suspend the task.
fep 0:62cd296ba2a7 469 vTaskSuspend( xHandle );
fep 0:62cd296ba2a7 470 }
fep 0:62cd296ba2a7 471 </pre>
fep 0:62cd296ba2a7 472 * \defgroup xTaskCreateStatic xTaskCreateStatic
fep 0:62cd296ba2a7 473 * \ingroup Tasks
fep 0:62cd296ba2a7 474 */
fep 0:62cd296ba2a7 475 #if( configSUPPORT_STATIC_ALLOCATION == 1 )
fep 0:62cd296ba2a7 476 TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
fep 0:62cd296ba2a7 477 const char * const pcName,
fep 0:62cd296ba2a7 478 const uint32_t ulStackDepth,
fep 0:62cd296ba2a7 479 void * const pvParameters,
fep 0:62cd296ba2a7 480 UBaseType_t uxPriority,
fep 0:62cd296ba2a7 481 StackType_t * const puxStackBuffer,
fep 0:62cd296ba2a7 482 StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
fep 0:62cd296ba2a7 483 #endif /* configSUPPORT_STATIC_ALLOCATION */
fep 0:62cd296ba2a7 484
fep 0:62cd296ba2a7 485 /**
fep 0:62cd296ba2a7 486 * task. h
fep 0:62cd296ba2a7 487 *<pre>
fep 0:62cd296ba2a7 488 BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );</pre>
fep 0:62cd296ba2a7 489 *
fep 0:62cd296ba2a7 490 * xTaskCreateRestricted() should only be used in systems that include an MPU
fep 0:62cd296ba2a7 491 * implementation.
fep 0:62cd296ba2a7 492 *
fep 0:62cd296ba2a7 493 * Create a new task and add it to the list of tasks that are ready to run.
fep 0:62cd296ba2a7 494 * The function parameters define the memory regions and associated access
fep 0:62cd296ba2a7 495 * permissions allocated to the task.
fep 0:62cd296ba2a7 496 *
fep 0:62cd296ba2a7 497 * @param pxTaskDefinition Pointer to a structure that contains a member
fep 0:62cd296ba2a7 498 * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
fep 0:62cd296ba2a7 499 * documentation) plus an optional stack buffer and the memory region
fep 0:62cd296ba2a7 500 * definitions.
fep 0:62cd296ba2a7 501 *
fep 0:62cd296ba2a7 502 * @param pxCreatedTask Used to pass back a handle by which the created task
fep 0:62cd296ba2a7 503 * can be referenced.
fep 0:62cd296ba2a7 504 *
fep 0:62cd296ba2a7 505 * @return pdPASS if the task was successfully created and added to a ready
fep 0:62cd296ba2a7 506 * list, otherwise an error code defined in the file projdefs.h
fep 0:62cd296ba2a7 507 *
fep 0:62cd296ba2a7 508 * Example usage:
fep 0:62cd296ba2a7 509 <pre>
fep 0:62cd296ba2a7 510 // Create an TaskParameters_t structure that defines the task to be created.
fep 0:62cd296ba2a7 511 static const TaskParameters_t xCheckTaskParameters =
fep 0:62cd296ba2a7 512 {
fep 0:62cd296ba2a7 513 vATask, // pvTaskCode - the function that implements the task.
fep 0:62cd296ba2a7 514 "ATask", // pcName - just a text name for the task to assist debugging.
fep 0:62cd296ba2a7 515 100, // usStackDepth - the stack size DEFINED IN WORDS.
fep 0:62cd296ba2a7 516 NULL, // pvParameters - passed into the task function as the function parameters.
fep 0:62cd296ba2a7 517 ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
fep 0:62cd296ba2a7 518 cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
fep 0:62cd296ba2a7 519
fep 0:62cd296ba2a7 520 // xRegions - Allocate up to three separate memory regions for access by
fep 0:62cd296ba2a7 521 // the task, with appropriate access permissions. Different processors have
fep 0:62cd296ba2a7 522 // different memory alignment requirements - refer to the FreeRTOS documentation
fep 0:62cd296ba2a7 523 // for full information.
fep 0:62cd296ba2a7 524 {
fep 0:62cd296ba2a7 525 // Base address Length Parameters
fep 0:62cd296ba2a7 526 { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
fep 0:62cd296ba2a7 527 { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
fep 0:62cd296ba2a7 528 { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
fep 0:62cd296ba2a7 529 }
fep 0:62cd296ba2a7 530 };
fep 0:62cd296ba2a7 531
fep 0:62cd296ba2a7 532 int main( void )
fep 0:62cd296ba2a7 533 {
fep 0:62cd296ba2a7 534 TaskHandle_t xHandle;
fep 0:62cd296ba2a7 535
fep 0:62cd296ba2a7 536 // Create a task from the const structure defined above. The task handle
fep 0:62cd296ba2a7 537 // is requested (the second parameter is not NULL) but in this case just for
fep 0:62cd296ba2a7 538 // demonstration purposes as its not actually used.
fep 0:62cd296ba2a7 539 xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
fep 0:62cd296ba2a7 540
fep 0:62cd296ba2a7 541 // Start the scheduler.
fep 0:62cd296ba2a7 542 vTaskStartScheduler();
fep 0:62cd296ba2a7 543
fep 0:62cd296ba2a7 544 // Will only get here if there was insufficient memory to create the idle
fep 0:62cd296ba2a7 545 // and/or timer task.
fep 0:62cd296ba2a7 546 for( ;; );
fep 0:62cd296ba2a7 547 }
fep 0:62cd296ba2a7 548 </pre>
fep 0:62cd296ba2a7 549 * \defgroup xTaskCreateRestricted xTaskCreateRestricted
fep 0:62cd296ba2a7 550 * \ingroup Tasks
fep 0:62cd296ba2a7 551 */
fep 0:62cd296ba2a7 552 #if( portUSING_MPU_WRAPPERS == 1 )
fep 0:62cd296ba2a7 553 BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 554 #endif
fep 0:62cd296ba2a7 555
fep 0:62cd296ba2a7 556 /**
fep 0:62cd296ba2a7 557 * task. h
fep 0:62cd296ba2a7 558 *<pre>
fep 0:62cd296ba2a7 559 void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );</pre>
fep 0:62cd296ba2a7 560 *
fep 0:62cd296ba2a7 561 * Memory regions are assigned to a restricted task when the task is created by
fep 0:62cd296ba2a7 562 * a call to xTaskCreateRestricted(). These regions can be redefined using
fep 0:62cd296ba2a7 563 * vTaskAllocateMPURegions().
fep 0:62cd296ba2a7 564 *
fep 0:62cd296ba2a7 565 * @param xTask The handle of the task being updated.
fep 0:62cd296ba2a7 566 *
fep 0:62cd296ba2a7 567 * @param xRegions A pointer to an MemoryRegion_t structure that contains the
fep 0:62cd296ba2a7 568 * new memory region definitions.
fep 0:62cd296ba2a7 569 *
fep 0:62cd296ba2a7 570 * Example usage:
fep 0:62cd296ba2a7 571 <pre>
fep 0:62cd296ba2a7 572 // Define an array of MemoryRegion_t structures that configures an MPU region
fep 0:62cd296ba2a7 573 // allowing read/write access for 1024 bytes starting at the beginning of the
fep 0:62cd296ba2a7 574 // ucOneKByte array. The other two of the maximum 3 definable regions are
fep 0:62cd296ba2a7 575 // unused so set to zero.
fep 0:62cd296ba2a7 576 static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =
fep 0:62cd296ba2a7 577 {
fep 0:62cd296ba2a7 578 // Base address Length Parameters
fep 0:62cd296ba2a7 579 { ucOneKByte, 1024, portMPU_REGION_READ_WRITE },
fep 0:62cd296ba2a7 580 { 0, 0, 0 },
fep 0:62cd296ba2a7 581 { 0, 0, 0 }
fep 0:62cd296ba2a7 582 };
fep 0:62cd296ba2a7 583
fep 0:62cd296ba2a7 584 void vATask( void *pvParameters )
fep 0:62cd296ba2a7 585 {
fep 0:62cd296ba2a7 586 // This task was created such that it has access to certain regions of
fep 0:62cd296ba2a7 587 // memory as defined by the MPU configuration. At some point it is
fep 0:62cd296ba2a7 588 // desired that these MPU regions are replaced with that defined in the
fep 0:62cd296ba2a7 589 // xAltRegions const struct above. Use a call to vTaskAllocateMPURegions()
fep 0:62cd296ba2a7 590 // for this purpose. NULL is used as the task handle to indicate that this
fep 0:62cd296ba2a7 591 // function should modify the MPU regions of the calling task.
fep 0:62cd296ba2a7 592 vTaskAllocateMPURegions( NULL, xAltRegions );
fep 0:62cd296ba2a7 593
fep 0:62cd296ba2a7 594 // Now the task can continue its function, but from this point on can only
fep 0:62cd296ba2a7 595 // access its stack and the ucOneKByte array (unless any other statically
fep 0:62cd296ba2a7 596 // defined or shared regions have been declared elsewhere).
fep 0:62cd296ba2a7 597 }
fep 0:62cd296ba2a7 598 </pre>
fep 0:62cd296ba2a7 599 * \defgroup xTaskCreateRestricted xTaskCreateRestricted
fep 0:62cd296ba2a7 600 * \ingroup Tasks
fep 0:62cd296ba2a7 601 */
fep 0:62cd296ba2a7 602 void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 603
fep 0:62cd296ba2a7 604 /**
fep 0:62cd296ba2a7 605 * task. h
fep 0:62cd296ba2a7 606 * <pre>void vTaskDelete( TaskHandle_t xTask );</pre>
fep 0:62cd296ba2a7 607 *
fep 0:62cd296ba2a7 608 * INCLUDE_vTaskDelete must be defined as 1 for this function to be available.
fep 0:62cd296ba2a7 609 * See the configuration section for more information.
fep 0:62cd296ba2a7 610 *
fep 0:62cd296ba2a7 611 * Remove a task from the RTOS real time kernel's management. The task being
fep 0:62cd296ba2a7 612 * deleted will be removed from all ready, blocked, suspended and event lists.
fep 0:62cd296ba2a7 613 *
fep 0:62cd296ba2a7 614 * NOTE: The idle task is responsible for freeing the kernel allocated
fep 0:62cd296ba2a7 615 * memory from tasks that have been deleted. It is therefore important that
fep 0:62cd296ba2a7 616 * the idle task is not starved of microcontroller processing time if your
fep 0:62cd296ba2a7 617 * application makes any calls to vTaskDelete (). Memory allocated by the
fep 0:62cd296ba2a7 618 * task code is not automatically freed, and should be freed before the task
fep 0:62cd296ba2a7 619 * is deleted.
fep 0:62cd296ba2a7 620 *
fep 0:62cd296ba2a7 621 * See the demo application file death.c for sample code that utilises
fep 0:62cd296ba2a7 622 * vTaskDelete ().
fep 0:62cd296ba2a7 623 *
fep 0:62cd296ba2a7 624 * @param xTask The handle of the task to be deleted. Passing NULL will
fep 0:62cd296ba2a7 625 * cause the calling task to be deleted.
fep 0:62cd296ba2a7 626 *
fep 0:62cd296ba2a7 627 * Example usage:
fep 0:62cd296ba2a7 628 <pre>
fep 0:62cd296ba2a7 629 void vOtherFunction( void )
fep 0:62cd296ba2a7 630 {
fep 0:62cd296ba2a7 631 TaskHandle_t xHandle;
fep 0:62cd296ba2a7 632
fep 0:62cd296ba2a7 633 // Create the task, storing the handle.
fep 0:62cd296ba2a7 634 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
fep 0:62cd296ba2a7 635
fep 0:62cd296ba2a7 636 // Use the handle to delete the task.
fep 0:62cd296ba2a7 637 vTaskDelete( xHandle );
fep 0:62cd296ba2a7 638 }
fep 0:62cd296ba2a7 639 </pre>
fep 0:62cd296ba2a7 640 * \defgroup vTaskDelete vTaskDelete
fep 0:62cd296ba2a7 641 * \ingroup Tasks
fep 0:62cd296ba2a7 642 */
fep 0:62cd296ba2a7 643 void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 644
fep 0:62cd296ba2a7 645 /*-----------------------------------------------------------
fep 0:62cd296ba2a7 646 * TASK CONTROL API
fep 0:62cd296ba2a7 647 *----------------------------------------------------------*/
fep 0:62cd296ba2a7 648
fep 0:62cd296ba2a7 649 /**
fep 0:62cd296ba2a7 650 * task. h
fep 0:62cd296ba2a7 651 * <pre>void vTaskDelay( const TickType_t xTicksToDelay );</pre>
fep 0:62cd296ba2a7 652 *
fep 0:62cd296ba2a7 653 * Delay a task for a given number of ticks. The actual time that the
fep 0:62cd296ba2a7 654 * task remains blocked depends on the tick rate. The constant
fep 0:62cd296ba2a7 655 * portTICK_PERIOD_MS can be used to calculate real time from the tick
fep 0:62cd296ba2a7 656 * rate - with the resolution of one tick period.
fep 0:62cd296ba2a7 657 *
fep 0:62cd296ba2a7 658 * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.
fep 0:62cd296ba2a7 659 * See the configuration section for more information.
fep 0:62cd296ba2a7 660 *
fep 0:62cd296ba2a7 661 *
fep 0:62cd296ba2a7 662 * vTaskDelay() specifies a time at which the task wishes to unblock relative to
fep 0:62cd296ba2a7 663 * the time at which vTaskDelay() is called. For example, specifying a block
fep 0:62cd296ba2a7 664 * period of 100 ticks will cause the task to unblock 100 ticks after
fep 0:62cd296ba2a7 665 * vTaskDelay() is called. vTaskDelay() does not therefore provide a good method
fep 0:62cd296ba2a7 666 * of controlling the frequency of a periodic task as the path taken through the
fep 0:62cd296ba2a7 667 * code, as well as other task and interrupt activity, will effect the frequency
fep 0:62cd296ba2a7 668 * at which vTaskDelay() gets called and therefore the time at which the task
fep 0:62cd296ba2a7 669 * next executes. See vTaskDelayUntil() for an alternative API function designed
fep 0:62cd296ba2a7 670 * to facilitate fixed frequency execution. It does this by specifying an
fep 0:62cd296ba2a7 671 * absolute time (rather than a relative time) at which the calling task should
fep 0:62cd296ba2a7 672 * unblock.
fep 0:62cd296ba2a7 673 *
fep 0:62cd296ba2a7 674 * @param xTicksToDelay The amount of time, in tick periods, that
fep 0:62cd296ba2a7 675 * the calling task should block.
fep 0:62cd296ba2a7 676 *
fep 0:62cd296ba2a7 677 * Example usage:
fep 0:62cd296ba2a7 678
fep 0:62cd296ba2a7 679 void vTaskFunction( void * pvParameters )
fep 0:62cd296ba2a7 680 {
fep 0:62cd296ba2a7 681 // Block for 500ms.
fep 0:62cd296ba2a7 682 const TickType_t xDelay = 500 / portTICK_PERIOD_MS;
fep 0:62cd296ba2a7 683
fep 0:62cd296ba2a7 684 for( ;; )
fep 0:62cd296ba2a7 685 {
fep 0:62cd296ba2a7 686 // Simply toggle the LED every 500ms, blocking between each toggle.
fep 0:62cd296ba2a7 687 vToggleLED();
fep 0:62cd296ba2a7 688 vTaskDelay( xDelay );
fep 0:62cd296ba2a7 689 }
fep 0:62cd296ba2a7 690 }
fep 0:62cd296ba2a7 691
fep 0:62cd296ba2a7 692 * \defgroup vTaskDelay vTaskDelay
fep 0:62cd296ba2a7 693 * \ingroup TaskCtrl
fep 0:62cd296ba2a7 694 */
fep 0:62cd296ba2a7 695 void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 696
fep 0:62cd296ba2a7 697 /**
fep 0:62cd296ba2a7 698 * task. h
fep 0:62cd296ba2a7 699 * <pre>void vTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );</pre>
fep 0:62cd296ba2a7 700 *
fep 0:62cd296ba2a7 701 * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available.
fep 0:62cd296ba2a7 702 * See the configuration section for more information.
fep 0:62cd296ba2a7 703 *
fep 0:62cd296ba2a7 704 * Delay a task until a specified time. This function can be used by periodic
fep 0:62cd296ba2a7 705 * tasks to ensure a constant execution frequency.
fep 0:62cd296ba2a7 706 *
fep 0:62cd296ba2a7 707 * This function differs from vTaskDelay () in one important aspect: vTaskDelay () will
fep 0:62cd296ba2a7 708 * cause a task to block for the specified number of ticks from the time vTaskDelay () is
fep 0:62cd296ba2a7 709 * called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed
fep 0:62cd296ba2a7 710 * execution frequency as the time between a task starting to execute and that task
fep 0:62cd296ba2a7 711 * calling vTaskDelay () may not be fixed [the task may take a different path though the
fep 0:62cd296ba2a7 712 * code between calls, or may get interrupted or preempted a different number of times
fep 0:62cd296ba2a7 713 * each time it executes].
fep 0:62cd296ba2a7 714 *
fep 0:62cd296ba2a7 715 * Whereas vTaskDelay () specifies a wake time relative to the time at which the function
fep 0:62cd296ba2a7 716 * is called, vTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
fep 0:62cd296ba2a7 717 * unblock.
fep 0:62cd296ba2a7 718 *
fep 0:62cd296ba2a7 719 * The constant portTICK_PERIOD_MS can be used to calculate real time from the tick
fep 0:62cd296ba2a7 720 * rate - with the resolution of one tick period.
fep 0:62cd296ba2a7 721 *
fep 0:62cd296ba2a7 722 * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
fep 0:62cd296ba2a7 723 * task was last unblocked. The variable must be initialised with the current time
fep 0:62cd296ba2a7 724 * prior to its first use (see the example below). Following this the variable is
fep 0:62cd296ba2a7 725 * automatically updated within vTaskDelayUntil ().
fep 0:62cd296ba2a7 726 *
fep 0:62cd296ba2a7 727 * @param xTimeIncrement The cycle time period. The task will be unblocked at
fep 0:62cd296ba2a7 728 * time *pxPreviousWakeTime + xTimeIncrement. Calling vTaskDelayUntil with the
fep 0:62cd296ba2a7 729 * same xTimeIncrement parameter value will cause the task to execute with
fep 0:62cd296ba2a7 730 * a fixed interface period.
fep 0:62cd296ba2a7 731 *
fep 0:62cd296ba2a7 732 * Example usage:
fep 0:62cd296ba2a7 733 <pre>
fep 0:62cd296ba2a7 734 // Perform an action every 10 ticks.
fep 0:62cd296ba2a7 735 void vTaskFunction( void * pvParameters )
fep 0:62cd296ba2a7 736 {
fep 0:62cd296ba2a7 737 TickType_t xLastWakeTime;
fep 0:62cd296ba2a7 738 const TickType_t xFrequency = 10;
fep 0:62cd296ba2a7 739
fep 0:62cd296ba2a7 740 // Initialise the xLastWakeTime variable with the current time.
fep 0:62cd296ba2a7 741 xLastWakeTime = xTaskGetTickCount ();
fep 0:62cd296ba2a7 742 for( ;; )
fep 0:62cd296ba2a7 743 {
fep 0:62cd296ba2a7 744 // Wait for the next cycle.
fep 0:62cd296ba2a7 745 vTaskDelayUntil( &xLastWakeTime, xFrequency );
fep 0:62cd296ba2a7 746
fep 0:62cd296ba2a7 747 // Perform action here.
fep 0:62cd296ba2a7 748 }
fep 0:62cd296ba2a7 749 }
fep 0:62cd296ba2a7 750 </pre>
fep 0:62cd296ba2a7 751 * \defgroup vTaskDelayUntil vTaskDelayUntil
fep 0:62cd296ba2a7 752 * \ingroup TaskCtrl
fep 0:62cd296ba2a7 753 */
fep 0:62cd296ba2a7 754 void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 755
fep 0:62cd296ba2a7 756 /**
fep 0:62cd296ba2a7 757 * task. h
fep 0:62cd296ba2a7 758 * <pre>BaseType_t xTaskAbortDelay( TaskHandle_t xTask );</pre>
fep 0:62cd296ba2a7 759 *
fep 0:62cd296ba2a7 760 * INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this
fep 0:62cd296ba2a7 761 * function to be available.
fep 0:62cd296ba2a7 762 *
fep 0:62cd296ba2a7 763 * A task will enter the Blocked state when it is waiting for an event. The
fep 0:62cd296ba2a7 764 * event it is waiting for can be a temporal event (waiting for a time), such
fep 0:62cd296ba2a7 765 * as when vTaskDelay() is called, or an event on an object, such as when
fep 0:62cd296ba2a7 766 * xQueueReceive() or ulTaskNotifyTake() is called. If the handle of a task
fep 0:62cd296ba2a7 767 * that is in the Blocked state is used in a call to xTaskAbortDelay() then the
fep 0:62cd296ba2a7 768 * task will leave the Blocked state, and return from whichever function call
fep 0:62cd296ba2a7 769 * placed the task into the Blocked state.
fep 0:62cd296ba2a7 770 *
fep 0:62cd296ba2a7 771 * @param xTask The handle of the task to remove from the Blocked state.
fep 0:62cd296ba2a7 772 *
fep 0:62cd296ba2a7 773 * @return If the task referenced by xTask was not in the Blocked state then
fep 0:62cd296ba2a7 774 * pdFAIL is returned. Otherwise pdPASS is returned.
fep 0:62cd296ba2a7 775 *
fep 0:62cd296ba2a7 776 * \defgroup xTaskAbortDelay xTaskAbortDelay
fep 0:62cd296ba2a7 777 * \ingroup TaskCtrl
fep 0:62cd296ba2a7 778 */
fep 0:62cd296ba2a7 779 BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 780
fep 0:62cd296ba2a7 781 /**
fep 0:62cd296ba2a7 782 * task. h
fep 0:62cd296ba2a7 783 * <pre>UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask );</pre>
fep 0:62cd296ba2a7 784 *
fep 0:62cd296ba2a7 785 * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.
fep 0:62cd296ba2a7 786 * See the configuration section for more information.
fep 0:62cd296ba2a7 787 *
fep 0:62cd296ba2a7 788 * Obtain the priority of any task.
fep 0:62cd296ba2a7 789 *
fep 0:62cd296ba2a7 790 * @param xTask Handle of the task to be queried. Passing a NULL
fep 0:62cd296ba2a7 791 * handle results in the priority of the calling task being returned.
fep 0:62cd296ba2a7 792 *
fep 0:62cd296ba2a7 793 * @return The priority of xTask.
fep 0:62cd296ba2a7 794 *
fep 0:62cd296ba2a7 795 * Example usage:
fep 0:62cd296ba2a7 796 <pre>
fep 0:62cd296ba2a7 797 void vAFunction( void )
fep 0:62cd296ba2a7 798 {
fep 0:62cd296ba2a7 799 TaskHandle_t xHandle;
fep 0:62cd296ba2a7 800
fep 0:62cd296ba2a7 801 // Create a task, storing the handle.
fep 0:62cd296ba2a7 802 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
fep 0:62cd296ba2a7 803
fep 0:62cd296ba2a7 804 // ...
fep 0:62cd296ba2a7 805
fep 0:62cd296ba2a7 806 // Use the handle to obtain the priority of the created task.
fep 0:62cd296ba2a7 807 // It was created with tskIDLE_PRIORITY, but may have changed
fep 0:62cd296ba2a7 808 // it itself.
fep 0:62cd296ba2a7 809 if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
fep 0:62cd296ba2a7 810 {
fep 0:62cd296ba2a7 811 // The task has changed it's priority.
fep 0:62cd296ba2a7 812 }
fep 0:62cd296ba2a7 813
fep 0:62cd296ba2a7 814 // ...
fep 0:62cd296ba2a7 815
fep 0:62cd296ba2a7 816 // Is our priority higher than the created task?
fep 0:62cd296ba2a7 817 if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
fep 0:62cd296ba2a7 818 {
fep 0:62cd296ba2a7 819 // Our priority (obtained using NULL handle) is higher.
fep 0:62cd296ba2a7 820 }
fep 0:62cd296ba2a7 821 }
fep 0:62cd296ba2a7 822 </pre>
fep 0:62cd296ba2a7 823 * \defgroup uxTaskPriorityGet uxTaskPriorityGet
fep 0:62cd296ba2a7 824 * \ingroup TaskCtrl
fep 0:62cd296ba2a7 825 */
fep 0:62cd296ba2a7 826 UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 827
fep 0:62cd296ba2a7 828 /**
fep 0:62cd296ba2a7 829 * task. h
fep 0:62cd296ba2a7 830 * <pre>UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask );</pre>
fep 0:62cd296ba2a7 831 *
fep 0:62cd296ba2a7 832 * A version of uxTaskPriorityGet() that can be used from an ISR.
fep 0:62cd296ba2a7 833 */
fep 0:62cd296ba2a7 834 UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 835
fep 0:62cd296ba2a7 836 /**
fep 0:62cd296ba2a7 837 * task. h
fep 0:62cd296ba2a7 838 * <pre>eTaskState eTaskGetState( TaskHandle_t xTask );</pre>
fep 0:62cd296ba2a7 839 *
fep 0:62cd296ba2a7 840 * INCLUDE_eTaskGetState must be defined as 1 for this function to be available.
fep 0:62cd296ba2a7 841 * See the configuration section for more information.
fep 0:62cd296ba2a7 842 *
fep 0:62cd296ba2a7 843 * Obtain the state of any task. States are encoded by the eTaskState
fep 0:62cd296ba2a7 844 * enumerated type.
fep 0:62cd296ba2a7 845 *
fep 0:62cd296ba2a7 846 * @param xTask Handle of the task to be queried.
fep 0:62cd296ba2a7 847 *
fep 0:62cd296ba2a7 848 * @return The state of xTask at the time the function was called. Note the
fep 0:62cd296ba2a7 849 * state of the task might change between the function being called, and the
fep 0:62cd296ba2a7 850 * functions return value being tested by the calling task.
fep 0:62cd296ba2a7 851 */
fep 0:62cd296ba2a7 852 eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 853
fep 0:62cd296ba2a7 854 /**
fep 0:62cd296ba2a7 855 * task. h
fep 0:62cd296ba2a7 856 * <pre>void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState );</pre>
fep 0:62cd296ba2a7 857 *
fep 0:62cd296ba2a7 858 * configUSE_TRACE_FACILITY must be defined as 1 for this function to be
fep 0:62cd296ba2a7 859 * available. See the configuration section for more information.
fep 0:62cd296ba2a7 860 *
fep 0:62cd296ba2a7 861 * Populates a TaskStatus_t structure with information about a task.
fep 0:62cd296ba2a7 862 *
fep 0:62cd296ba2a7 863 * @param xTask Handle of the task being queried. If xTask is NULL then
fep 0:62cd296ba2a7 864 * information will be returned about the calling task.
fep 0:62cd296ba2a7 865 *
fep 0:62cd296ba2a7 866 * @param pxTaskStatus A pointer to the TaskStatus_t structure that will be
fep 0:62cd296ba2a7 867 * filled with information about the task referenced by the handle passed using
fep 0:62cd296ba2a7 868 * the xTask parameter.
fep 0:62cd296ba2a7 869 *
fep 0:62cd296ba2a7 870 * @xGetFreeStackSpace The TaskStatus_t structure contains a member to report
fep 0:62cd296ba2a7 871 * the stack high water mark of the task being queried. Calculating the stack
fep 0:62cd296ba2a7 872 * high water mark takes a relatively long time, and can make the system
fep 0:62cd296ba2a7 873 * temporarily unresponsive - so the xGetFreeStackSpace parameter is provided to
fep 0:62cd296ba2a7 874 * allow the high water mark checking to be skipped. The high watermark value
fep 0:62cd296ba2a7 875 * will only be written to the TaskStatus_t structure if xGetFreeStackSpace is
fep 0:62cd296ba2a7 876 * not set to pdFALSE;
fep 0:62cd296ba2a7 877 *
fep 0:62cd296ba2a7 878 * @param eState The TaskStatus_t structure contains a member to report the
fep 0:62cd296ba2a7 879 * state of the task being queried. Obtaining the task state is not as fast as
fep 0:62cd296ba2a7 880 * a simple assignment - so the eState parameter is provided to allow the state
fep 0:62cd296ba2a7 881 * information to be omitted from the TaskStatus_t structure. To obtain state
fep 0:62cd296ba2a7 882 * information then set eState to eInvalid - otherwise the value passed in
fep 0:62cd296ba2a7 883 * eState will be reported as the task state in the TaskStatus_t structure.
fep 0:62cd296ba2a7 884 *
fep 0:62cd296ba2a7 885 * Example usage:
fep 0:62cd296ba2a7 886 <pre>
fep 0:62cd296ba2a7 887 void vAFunction( void )
fep 0:62cd296ba2a7 888 {
fep 0:62cd296ba2a7 889 TaskHandle_t xHandle;
fep 0:62cd296ba2a7 890 TaskStatus_t xTaskDetails;
fep 0:62cd296ba2a7 891
fep 0:62cd296ba2a7 892 // Obtain the handle of a task from its name.
fep 0:62cd296ba2a7 893 xHandle = xTaskGetHandle( "Task_Name" );
fep 0:62cd296ba2a7 894
fep 0:62cd296ba2a7 895 // Check the handle is not NULL.
fep 0:62cd296ba2a7 896 configASSERT( xHandle );
fep 0:62cd296ba2a7 897
fep 0:62cd296ba2a7 898 // Use the handle to obtain further information about the task.
fep 0:62cd296ba2a7 899 vTaskGetInfo( xHandle,
fep 0:62cd296ba2a7 900 &xTaskDetails,
fep 0:62cd296ba2a7 901 pdTRUE, // Include the high water mark in xTaskDetails.
fep 0:62cd296ba2a7 902 eInvalid ); // Include the task state in xTaskDetails.
fep 0:62cd296ba2a7 903 }
fep 0:62cd296ba2a7 904 </pre>
fep 0:62cd296ba2a7 905 * \defgroup vTaskGetInfo vTaskGetInfo
fep 0:62cd296ba2a7 906 * \ingroup TaskCtrl
fep 0:62cd296ba2a7 907 */
fep 0:62cd296ba2a7 908 void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 909
fep 0:62cd296ba2a7 910 /**
fep 0:62cd296ba2a7 911 * task. h
fep 0:62cd296ba2a7 912 * <pre>void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );</pre>
fep 0:62cd296ba2a7 913 *
fep 0:62cd296ba2a7 914 * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.
fep 0:62cd296ba2a7 915 * See the configuration section for more information.
fep 0:62cd296ba2a7 916 *
fep 0:62cd296ba2a7 917 * Set the priority of any task.
fep 0:62cd296ba2a7 918 *
fep 0:62cd296ba2a7 919 * A context switch will occur before the function returns if the priority
fep 0:62cd296ba2a7 920 * being set is higher than the currently executing task.
fep 0:62cd296ba2a7 921 *
fep 0:62cd296ba2a7 922 * @param xTask Handle to the task for which the priority is being set.
fep 0:62cd296ba2a7 923 * Passing a NULL handle results in the priority of the calling task being set.
fep 0:62cd296ba2a7 924 *
fep 0:62cd296ba2a7 925 * @param uxNewPriority The priority to which the task will be set.
fep 0:62cd296ba2a7 926 *
fep 0:62cd296ba2a7 927 * Example usage:
fep 0:62cd296ba2a7 928 <pre>
fep 0:62cd296ba2a7 929 void vAFunction( void )
fep 0:62cd296ba2a7 930 {
fep 0:62cd296ba2a7 931 TaskHandle_t xHandle;
fep 0:62cd296ba2a7 932
fep 0:62cd296ba2a7 933 // Create a task, storing the handle.
fep 0:62cd296ba2a7 934 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
fep 0:62cd296ba2a7 935
fep 0:62cd296ba2a7 936 // ...
fep 0:62cd296ba2a7 937
fep 0:62cd296ba2a7 938 // Use the handle to raise the priority of the created task.
fep 0:62cd296ba2a7 939 vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
fep 0:62cd296ba2a7 940
fep 0:62cd296ba2a7 941 // ...
fep 0:62cd296ba2a7 942
fep 0:62cd296ba2a7 943 // Use a NULL handle to raise our priority to the same value.
fep 0:62cd296ba2a7 944 vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
fep 0:62cd296ba2a7 945 }
fep 0:62cd296ba2a7 946 </pre>
fep 0:62cd296ba2a7 947 * \defgroup vTaskPrioritySet vTaskPrioritySet
fep 0:62cd296ba2a7 948 * \ingroup TaskCtrl
fep 0:62cd296ba2a7 949 */
fep 0:62cd296ba2a7 950 void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 951
fep 0:62cd296ba2a7 952 /**
fep 0:62cd296ba2a7 953 * task. h
fep 0:62cd296ba2a7 954 * <pre>void vTaskSuspend( TaskHandle_t xTaskToSuspend );</pre>
fep 0:62cd296ba2a7 955 *
fep 0:62cd296ba2a7 956 * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
fep 0:62cd296ba2a7 957 * See the configuration section for more information.
fep 0:62cd296ba2a7 958 *
fep 0:62cd296ba2a7 959 * Suspend any task. When suspended a task will never get any microcontroller
fep 0:62cd296ba2a7 960 * processing time, no matter what its priority.
fep 0:62cd296ba2a7 961 *
fep 0:62cd296ba2a7 962 * Calls to vTaskSuspend are not accumulative -
fep 0:62cd296ba2a7 963 * i.e. calling vTaskSuspend () twice on the same task still only requires one
fep 0:62cd296ba2a7 964 * call to vTaskResume () to ready the suspended task.
fep 0:62cd296ba2a7 965 *
fep 0:62cd296ba2a7 966 * @param xTaskToSuspend Handle to the task being suspended. Passing a NULL
fep 0:62cd296ba2a7 967 * handle will cause the calling task to be suspended.
fep 0:62cd296ba2a7 968 *
fep 0:62cd296ba2a7 969 * Example usage:
fep 0:62cd296ba2a7 970 <pre>
fep 0:62cd296ba2a7 971 void vAFunction( void )
fep 0:62cd296ba2a7 972 {
fep 0:62cd296ba2a7 973 TaskHandle_t xHandle;
fep 0:62cd296ba2a7 974
fep 0:62cd296ba2a7 975 // Create a task, storing the handle.
fep 0:62cd296ba2a7 976 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
fep 0:62cd296ba2a7 977
fep 0:62cd296ba2a7 978 // ...
fep 0:62cd296ba2a7 979
fep 0:62cd296ba2a7 980 // Use the handle to suspend the created task.
fep 0:62cd296ba2a7 981 vTaskSuspend( xHandle );
fep 0:62cd296ba2a7 982
fep 0:62cd296ba2a7 983 // ...
fep 0:62cd296ba2a7 984
fep 0:62cd296ba2a7 985 // The created task will not run during this period, unless
fep 0:62cd296ba2a7 986 // another task calls vTaskResume( xHandle ).
fep 0:62cd296ba2a7 987
fep 0:62cd296ba2a7 988 //...
fep 0:62cd296ba2a7 989
fep 0:62cd296ba2a7 990
fep 0:62cd296ba2a7 991 // Suspend ourselves.
fep 0:62cd296ba2a7 992 vTaskSuspend( NULL );
fep 0:62cd296ba2a7 993
fep 0:62cd296ba2a7 994 // We cannot get here unless another task calls vTaskResume
fep 0:62cd296ba2a7 995 // with our handle as the parameter.
fep 0:62cd296ba2a7 996 }
fep 0:62cd296ba2a7 997 </pre>
fep 0:62cd296ba2a7 998 * \defgroup vTaskSuspend vTaskSuspend
fep 0:62cd296ba2a7 999 * \ingroup TaskCtrl
fep 0:62cd296ba2a7 1000 */
fep 0:62cd296ba2a7 1001 void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1002
fep 0:62cd296ba2a7 1003 /**
fep 0:62cd296ba2a7 1004 * task. h
fep 0:62cd296ba2a7 1005 * <pre>void vTaskResume( TaskHandle_t xTaskToResume );</pre>
fep 0:62cd296ba2a7 1006 *
fep 0:62cd296ba2a7 1007 * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
fep 0:62cd296ba2a7 1008 * See the configuration section for more information.
fep 0:62cd296ba2a7 1009 *
fep 0:62cd296ba2a7 1010 * Resumes a suspended task.
fep 0:62cd296ba2a7 1011 *
fep 0:62cd296ba2a7 1012 * A task that has been suspended by one or more calls to vTaskSuspend ()
fep 0:62cd296ba2a7 1013 * will be made available for running again by a single call to
fep 0:62cd296ba2a7 1014 * vTaskResume ().
fep 0:62cd296ba2a7 1015 *
fep 0:62cd296ba2a7 1016 * @param xTaskToResume Handle to the task being readied.
fep 0:62cd296ba2a7 1017 *
fep 0:62cd296ba2a7 1018 * Example usage:
fep 0:62cd296ba2a7 1019 <pre>
fep 0:62cd296ba2a7 1020 void vAFunction( void )
fep 0:62cd296ba2a7 1021 {
fep 0:62cd296ba2a7 1022 TaskHandle_t xHandle;
fep 0:62cd296ba2a7 1023
fep 0:62cd296ba2a7 1024 // Create a task, storing the handle.
fep 0:62cd296ba2a7 1025 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
fep 0:62cd296ba2a7 1026
fep 0:62cd296ba2a7 1027 // ...
fep 0:62cd296ba2a7 1028
fep 0:62cd296ba2a7 1029 // Use the handle to suspend the created task.
fep 0:62cd296ba2a7 1030 vTaskSuspend( xHandle );
fep 0:62cd296ba2a7 1031
fep 0:62cd296ba2a7 1032 // ...
fep 0:62cd296ba2a7 1033
fep 0:62cd296ba2a7 1034 // The created task will not run during this period, unless
fep 0:62cd296ba2a7 1035 // another task calls vTaskResume( xHandle ).
fep 0:62cd296ba2a7 1036
fep 0:62cd296ba2a7 1037 //...
fep 0:62cd296ba2a7 1038
fep 0:62cd296ba2a7 1039
fep 0:62cd296ba2a7 1040 // Resume the suspended task ourselves.
fep 0:62cd296ba2a7 1041 vTaskResume( xHandle );
fep 0:62cd296ba2a7 1042
fep 0:62cd296ba2a7 1043 // The created task will once again get microcontroller processing
fep 0:62cd296ba2a7 1044 // time in accordance with its priority within the system.
fep 0:62cd296ba2a7 1045 }
fep 0:62cd296ba2a7 1046 </pre>
fep 0:62cd296ba2a7 1047 * \defgroup vTaskResume vTaskResume
fep 0:62cd296ba2a7 1048 * \ingroup TaskCtrl
fep 0:62cd296ba2a7 1049 */
fep 0:62cd296ba2a7 1050 void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1051
fep 0:62cd296ba2a7 1052 /**
fep 0:62cd296ba2a7 1053 * task. h
fep 0:62cd296ba2a7 1054 * <pre>void xTaskResumeFromISR( TaskHandle_t xTaskToResume );</pre>
fep 0:62cd296ba2a7 1055 *
fep 0:62cd296ba2a7 1056 * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be
fep 0:62cd296ba2a7 1057 * available. See the configuration section for more information.
fep 0:62cd296ba2a7 1058 *
fep 0:62cd296ba2a7 1059 * An implementation of vTaskResume() that can be called from within an ISR.
fep 0:62cd296ba2a7 1060 *
fep 0:62cd296ba2a7 1061 * A task that has been suspended by one or more calls to vTaskSuspend ()
fep 0:62cd296ba2a7 1062 * will be made available for running again by a single call to
fep 0:62cd296ba2a7 1063 * xTaskResumeFromISR ().
fep 0:62cd296ba2a7 1064 *
fep 0:62cd296ba2a7 1065 * xTaskResumeFromISR() should not be used to synchronise a task with an
fep 0:62cd296ba2a7 1066 * interrupt if there is a chance that the interrupt could arrive prior to the
fep 0:62cd296ba2a7 1067 * task being suspended - as this can lead to interrupts being missed. Use of a
fep 0:62cd296ba2a7 1068 * semaphore as a synchronisation mechanism would avoid this eventuality.
fep 0:62cd296ba2a7 1069 *
fep 0:62cd296ba2a7 1070 * @param xTaskToResume Handle to the task being readied.
fep 0:62cd296ba2a7 1071 *
fep 0:62cd296ba2a7 1072 * @return pdTRUE if resuming the task should result in a context switch,
fep 0:62cd296ba2a7 1073 * otherwise pdFALSE. This is used by the ISR to determine if a context switch
fep 0:62cd296ba2a7 1074 * may be required following the ISR.
fep 0:62cd296ba2a7 1075 *
fep 0:62cd296ba2a7 1076 * \defgroup vTaskResumeFromISR vTaskResumeFromISR
fep 0:62cd296ba2a7 1077 * \ingroup TaskCtrl
fep 0:62cd296ba2a7 1078 */
fep 0:62cd296ba2a7 1079 BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1080
fep 0:62cd296ba2a7 1081 /*-----------------------------------------------------------
fep 0:62cd296ba2a7 1082 * SCHEDULER CONTROL
fep 0:62cd296ba2a7 1083 *----------------------------------------------------------*/
fep 0:62cd296ba2a7 1084
fep 0:62cd296ba2a7 1085 /**
fep 0:62cd296ba2a7 1086 * task. h
fep 0:62cd296ba2a7 1087 * <pre>void vTaskStartScheduler( void );</pre>
fep 0:62cd296ba2a7 1088 *
fep 0:62cd296ba2a7 1089 * Starts the real time kernel tick processing. After calling the kernel
fep 0:62cd296ba2a7 1090 * has control over which tasks are executed and when.
fep 0:62cd296ba2a7 1091 *
fep 0:62cd296ba2a7 1092 * See the demo application file main.c for an example of creating
fep 0:62cd296ba2a7 1093 * tasks and starting the kernel.
fep 0:62cd296ba2a7 1094 *
fep 0:62cd296ba2a7 1095 * Example usage:
fep 0:62cd296ba2a7 1096 <pre>
fep 0:62cd296ba2a7 1097 void vAFunction( void )
fep 0:62cd296ba2a7 1098 {
fep 0:62cd296ba2a7 1099 // Create at least one task before starting the kernel.
fep 0:62cd296ba2a7 1100 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
fep 0:62cd296ba2a7 1101
fep 0:62cd296ba2a7 1102 // Start the real time kernel with preemption.
fep 0:62cd296ba2a7 1103 vTaskStartScheduler ();
fep 0:62cd296ba2a7 1104
fep 0:62cd296ba2a7 1105 // Will not get here unless a task calls vTaskEndScheduler ()
fep 0:62cd296ba2a7 1106 }
fep 0:62cd296ba2a7 1107 </pre>
fep 0:62cd296ba2a7 1108 *
fep 0:62cd296ba2a7 1109 * \defgroup vTaskStartScheduler vTaskStartScheduler
fep 0:62cd296ba2a7 1110 * \ingroup SchedulerControl
fep 0:62cd296ba2a7 1111 */
fep 0:62cd296ba2a7 1112 void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1113
fep 0:62cd296ba2a7 1114 /**
fep 0:62cd296ba2a7 1115 * task. h
fep 0:62cd296ba2a7 1116 * <pre>void vTaskEndScheduler( void );</pre>
fep 0:62cd296ba2a7 1117 *
fep 0:62cd296ba2a7 1118 * NOTE: At the time of writing only the x86 real mode port, which runs on a PC
fep 0:62cd296ba2a7 1119 * in place of DOS, implements this function.
fep 0:62cd296ba2a7 1120 *
fep 0:62cd296ba2a7 1121 * Stops the real time kernel tick. All created tasks will be automatically
fep 0:62cd296ba2a7 1122 * deleted and multitasking (either preemptive or cooperative) will
fep 0:62cd296ba2a7 1123 * stop. Execution then resumes from the point where vTaskStartScheduler ()
fep 0:62cd296ba2a7 1124 * was called, as if vTaskStartScheduler () had just returned.
fep 0:62cd296ba2a7 1125 *
fep 0:62cd296ba2a7 1126 * See the demo application file main. c in the demo/PC directory for an
fep 0:62cd296ba2a7 1127 * example that uses vTaskEndScheduler ().
fep 0:62cd296ba2a7 1128 *
fep 0:62cd296ba2a7 1129 * vTaskEndScheduler () requires an exit function to be defined within the
fep 0:62cd296ba2a7 1130 * portable layer (see vPortEndScheduler () in port. c for the PC port). This
fep 0:62cd296ba2a7 1131 * performs hardware specific operations such as stopping the kernel tick.
fep 0:62cd296ba2a7 1132 *
fep 0:62cd296ba2a7 1133 * vTaskEndScheduler () will cause all of the resources allocated by the
fep 0:62cd296ba2a7 1134 * kernel to be freed - but will not free resources allocated by application
fep 0:62cd296ba2a7 1135 * tasks.
fep 0:62cd296ba2a7 1136 *
fep 0:62cd296ba2a7 1137 * Example usage:
fep 0:62cd296ba2a7 1138 <pre>
fep 0:62cd296ba2a7 1139 void vTaskCode( void * pvParameters )
fep 0:62cd296ba2a7 1140 {
fep 0:62cd296ba2a7 1141 for( ;; )
fep 0:62cd296ba2a7 1142 {
fep 0:62cd296ba2a7 1143 // Task code goes here.
fep 0:62cd296ba2a7 1144
fep 0:62cd296ba2a7 1145 // At some point we want to end the real time kernel processing
fep 0:62cd296ba2a7 1146 // so call ...
fep 0:62cd296ba2a7 1147 vTaskEndScheduler ();
fep 0:62cd296ba2a7 1148 }
fep 0:62cd296ba2a7 1149 }
fep 0:62cd296ba2a7 1150
fep 0:62cd296ba2a7 1151 void vAFunction( void )
fep 0:62cd296ba2a7 1152 {
fep 0:62cd296ba2a7 1153 // Create at least one task before starting the kernel.
fep 0:62cd296ba2a7 1154 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
fep 0:62cd296ba2a7 1155
fep 0:62cd296ba2a7 1156 // Start the real time kernel with preemption.
fep 0:62cd296ba2a7 1157 vTaskStartScheduler ();
fep 0:62cd296ba2a7 1158
fep 0:62cd296ba2a7 1159 // Will only get here when the vTaskCode () task has called
fep 0:62cd296ba2a7 1160 // vTaskEndScheduler (). When we get here we are back to single task
fep 0:62cd296ba2a7 1161 // execution.
fep 0:62cd296ba2a7 1162 }
fep 0:62cd296ba2a7 1163 </pre>
fep 0:62cd296ba2a7 1164 *
fep 0:62cd296ba2a7 1165 * \defgroup vTaskEndScheduler vTaskEndScheduler
fep 0:62cd296ba2a7 1166 * \ingroup SchedulerControl
fep 0:62cd296ba2a7 1167 */
fep 0:62cd296ba2a7 1168 void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1169
fep 0:62cd296ba2a7 1170 /**
fep 0:62cd296ba2a7 1171 * task. h
fep 0:62cd296ba2a7 1172 * <pre>void vTaskSuspendAll( void );</pre>
fep 0:62cd296ba2a7 1173 *
fep 0:62cd296ba2a7 1174 * Suspends the scheduler without disabling interrupts. Context switches will
fep 0:62cd296ba2a7 1175 * not occur while the scheduler is suspended.
fep 0:62cd296ba2a7 1176 *
fep 0:62cd296ba2a7 1177 * After calling vTaskSuspendAll () the calling task will continue to execute
fep 0:62cd296ba2a7 1178 * without risk of being swapped out until a call to xTaskResumeAll () has been
fep 0:62cd296ba2a7 1179 * made.
fep 0:62cd296ba2a7 1180 *
fep 0:62cd296ba2a7 1181 * API functions that have the potential to cause a context switch (for example,
fep 0:62cd296ba2a7 1182 * vTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler
fep 0:62cd296ba2a7 1183 * is suspended.
fep 0:62cd296ba2a7 1184 *
fep 0:62cd296ba2a7 1185 * Example usage:
fep 0:62cd296ba2a7 1186 <pre>
fep 0:62cd296ba2a7 1187 void vTask1( void * pvParameters )
fep 0:62cd296ba2a7 1188 {
fep 0:62cd296ba2a7 1189 for( ;; )
fep 0:62cd296ba2a7 1190 {
fep 0:62cd296ba2a7 1191 // Task code goes here.
fep 0:62cd296ba2a7 1192
fep 0:62cd296ba2a7 1193 // ...
fep 0:62cd296ba2a7 1194
fep 0:62cd296ba2a7 1195 // At some point the task wants to perform a long operation during
fep 0:62cd296ba2a7 1196 // which it does not want to get swapped out. It cannot use
fep 0:62cd296ba2a7 1197 // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
fep 0:62cd296ba2a7 1198 // operation may cause interrupts to be missed - including the
fep 0:62cd296ba2a7 1199 // ticks.
fep 0:62cd296ba2a7 1200
fep 0:62cd296ba2a7 1201 // Prevent the real time kernel swapping out the task.
fep 0:62cd296ba2a7 1202 vTaskSuspendAll ();
fep 0:62cd296ba2a7 1203
fep 0:62cd296ba2a7 1204 // Perform the operation here. There is no need to use critical
fep 0:62cd296ba2a7 1205 // sections as we have all the microcontroller processing time.
fep 0:62cd296ba2a7 1206 // During this time interrupts will still operate and the kernel
fep 0:62cd296ba2a7 1207 // tick count will be maintained.
fep 0:62cd296ba2a7 1208
fep 0:62cd296ba2a7 1209 // ...
fep 0:62cd296ba2a7 1210
fep 0:62cd296ba2a7 1211 // The operation is complete. Restart the kernel.
fep 0:62cd296ba2a7 1212 xTaskResumeAll ();
fep 0:62cd296ba2a7 1213 }
fep 0:62cd296ba2a7 1214 }
fep 0:62cd296ba2a7 1215 </pre>
fep 0:62cd296ba2a7 1216 * \defgroup vTaskSuspendAll vTaskSuspendAll
fep 0:62cd296ba2a7 1217 * \ingroup SchedulerControl
fep 0:62cd296ba2a7 1218 */
fep 0:62cd296ba2a7 1219 void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1220
fep 0:62cd296ba2a7 1221 /**
fep 0:62cd296ba2a7 1222 * task. h
fep 0:62cd296ba2a7 1223 * <pre>BaseType_t xTaskResumeAll( void );</pre>
fep 0:62cd296ba2a7 1224 *
fep 0:62cd296ba2a7 1225 * Resumes scheduler activity after it was suspended by a call to
fep 0:62cd296ba2a7 1226 * vTaskSuspendAll().
fep 0:62cd296ba2a7 1227 *
fep 0:62cd296ba2a7 1228 * xTaskResumeAll() only resumes the scheduler. It does not unsuspend tasks
fep 0:62cd296ba2a7 1229 * that were previously suspended by a call to vTaskSuspend().
fep 0:62cd296ba2a7 1230 *
fep 0:62cd296ba2a7 1231 * @return If resuming the scheduler caused a context switch then pdTRUE is
fep 0:62cd296ba2a7 1232 * returned, otherwise pdFALSE is returned.
fep 0:62cd296ba2a7 1233 *
fep 0:62cd296ba2a7 1234 * Example usage:
fep 0:62cd296ba2a7 1235 <pre>
fep 0:62cd296ba2a7 1236 void vTask1( void * pvParameters )
fep 0:62cd296ba2a7 1237 {
fep 0:62cd296ba2a7 1238 for( ;; )
fep 0:62cd296ba2a7 1239 {
fep 0:62cd296ba2a7 1240 // Task code goes here.
fep 0:62cd296ba2a7 1241
fep 0:62cd296ba2a7 1242 // ...
fep 0:62cd296ba2a7 1243
fep 0:62cd296ba2a7 1244 // At some point the task wants to perform a long operation during
fep 0:62cd296ba2a7 1245 // which it does not want to get swapped out. It cannot use
fep 0:62cd296ba2a7 1246 // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
fep 0:62cd296ba2a7 1247 // operation may cause interrupts to be missed - including the
fep 0:62cd296ba2a7 1248 // ticks.
fep 0:62cd296ba2a7 1249
fep 0:62cd296ba2a7 1250 // Prevent the real time kernel swapping out the task.
fep 0:62cd296ba2a7 1251 vTaskSuspendAll ();
fep 0:62cd296ba2a7 1252
fep 0:62cd296ba2a7 1253 // Perform the operation here. There is no need to use critical
fep 0:62cd296ba2a7 1254 // sections as we have all the microcontroller processing time.
fep 0:62cd296ba2a7 1255 // During this time interrupts will still operate and the real
fep 0:62cd296ba2a7 1256 // time kernel tick count will be maintained.
fep 0:62cd296ba2a7 1257
fep 0:62cd296ba2a7 1258 // ...
fep 0:62cd296ba2a7 1259
fep 0:62cd296ba2a7 1260 // The operation is complete. Restart the kernel. We want to force
fep 0:62cd296ba2a7 1261 // a context switch - but there is no point if resuming the scheduler
fep 0:62cd296ba2a7 1262 // caused a context switch already.
fep 0:62cd296ba2a7 1263 if( !xTaskResumeAll () )
fep 0:62cd296ba2a7 1264 {
fep 0:62cd296ba2a7 1265 taskYIELD ();
fep 0:62cd296ba2a7 1266 }
fep 0:62cd296ba2a7 1267 }
fep 0:62cd296ba2a7 1268 }
fep 0:62cd296ba2a7 1269 </pre>
fep 0:62cd296ba2a7 1270 * \defgroup xTaskResumeAll xTaskResumeAll
fep 0:62cd296ba2a7 1271 * \ingroup SchedulerControl
fep 0:62cd296ba2a7 1272 */
fep 0:62cd296ba2a7 1273 BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1274
fep 0:62cd296ba2a7 1275 /*-----------------------------------------------------------
fep 0:62cd296ba2a7 1276 * TASK UTILITIES
fep 0:62cd296ba2a7 1277 *----------------------------------------------------------*/
fep 0:62cd296ba2a7 1278
fep 0:62cd296ba2a7 1279 /**
fep 0:62cd296ba2a7 1280 * task. h
fep 0:62cd296ba2a7 1281 * <PRE>TickType_t xTaskGetTickCount( void );</PRE>
fep 0:62cd296ba2a7 1282 *
fep 0:62cd296ba2a7 1283 * @return The count of ticks since vTaskStartScheduler was called.
fep 0:62cd296ba2a7 1284 *
fep 0:62cd296ba2a7 1285 * \defgroup xTaskGetTickCount xTaskGetTickCount
fep 0:62cd296ba2a7 1286 * \ingroup TaskUtils
fep 0:62cd296ba2a7 1287 */
fep 0:62cd296ba2a7 1288 TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1289
fep 0:62cd296ba2a7 1290 /**
fep 0:62cd296ba2a7 1291 * task. h
fep 0:62cd296ba2a7 1292 * <PRE>TickType_t xTaskGetTickCountFromISR( void );</PRE>
fep 0:62cd296ba2a7 1293 *
fep 0:62cd296ba2a7 1294 * @return The count of ticks since vTaskStartScheduler was called.
fep 0:62cd296ba2a7 1295 *
fep 0:62cd296ba2a7 1296 * This is a version of xTaskGetTickCount() that is safe to be called from an
fep 0:62cd296ba2a7 1297 * ISR - provided that TickType_t is the natural word size of the
fep 0:62cd296ba2a7 1298 * microcontroller being used or interrupt nesting is either not supported or
fep 0:62cd296ba2a7 1299 * not being used.
fep 0:62cd296ba2a7 1300 *
fep 0:62cd296ba2a7 1301 * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR
fep 0:62cd296ba2a7 1302 * \ingroup TaskUtils
fep 0:62cd296ba2a7 1303 */
fep 0:62cd296ba2a7 1304 TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1305
fep 0:62cd296ba2a7 1306 /**
fep 0:62cd296ba2a7 1307 * task. h
fep 0:62cd296ba2a7 1308 * <PRE>uint16_t uxTaskGetNumberOfTasks( void );</PRE>
fep 0:62cd296ba2a7 1309 *
fep 0:62cd296ba2a7 1310 * @return The number of tasks that the real time kernel is currently managing.
fep 0:62cd296ba2a7 1311 * This includes all ready, blocked and suspended tasks. A task that
fep 0:62cd296ba2a7 1312 * has been deleted but not yet freed by the idle task will also be
fep 0:62cd296ba2a7 1313 * included in the count.
fep 0:62cd296ba2a7 1314 *
fep 0:62cd296ba2a7 1315 * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks
fep 0:62cd296ba2a7 1316 * \ingroup TaskUtils
fep 0:62cd296ba2a7 1317 */
fep 0:62cd296ba2a7 1318 UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1319
fep 0:62cd296ba2a7 1320 /**
fep 0:62cd296ba2a7 1321 * task. h
fep 0:62cd296ba2a7 1322 * <PRE>char *pcTaskGetName( TaskHandle_t xTaskToQuery );</PRE>
fep 0:62cd296ba2a7 1323 *
fep 0:62cd296ba2a7 1324 * @return The text (human readable) name of the task referenced by the handle
fep 0:62cd296ba2a7 1325 * xTaskToQuery. A task can query its own name by either passing in its own
fep 0:62cd296ba2a7 1326 * handle, or by setting xTaskToQuery to NULL.
fep 0:62cd296ba2a7 1327 *
fep 0:62cd296ba2a7 1328 * \defgroup pcTaskGetName pcTaskGetName
fep 0:62cd296ba2a7 1329 * \ingroup TaskUtils
fep 0:62cd296ba2a7 1330 */
fep 0:62cd296ba2a7 1331 char *pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
fep 0:62cd296ba2a7 1332
fep 0:62cd296ba2a7 1333 /**
fep 0:62cd296ba2a7 1334 * task. h
fep 0:62cd296ba2a7 1335 * <PRE>TaskHandle_t xTaskGetHandle( const char *pcNameToQuery );</PRE>
fep 0:62cd296ba2a7 1336 *
fep 0:62cd296ba2a7 1337 * NOTE: This function takes a relatively long time to complete and should be
fep 0:62cd296ba2a7 1338 * used sparingly.
fep 0:62cd296ba2a7 1339 *
fep 0:62cd296ba2a7 1340 * @return The handle of the task that has the human readable name pcNameToQuery.
fep 0:62cd296ba2a7 1341 * NULL is returned if no matching name is found. INCLUDE_xTaskGetHandle
fep 0:62cd296ba2a7 1342 * must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available.
fep 0:62cd296ba2a7 1343 *
fep 0:62cd296ba2a7 1344 * \defgroup pcTaskGetHandle pcTaskGetHandle
fep 0:62cd296ba2a7 1345 * \ingroup TaskUtils
fep 0:62cd296ba2a7 1346 */
fep 0:62cd296ba2a7 1347 TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
fep 0:62cd296ba2a7 1348
fep 0:62cd296ba2a7 1349 /**
fep 0:62cd296ba2a7 1350 * task.h
fep 0:62cd296ba2a7 1351 * <PRE>UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );</PRE>
fep 0:62cd296ba2a7 1352 *
fep 0:62cd296ba2a7 1353 * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for
fep 0:62cd296ba2a7 1354 * this function to be available.
fep 0:62cd296ba2a7 1355 *
fep 0:62cd296ba2a7 1356 * Returns the high water mark of the stack associated with xTask. That is,
fep 0:62cd296ba2a7 1357 * the minimum free stack space there has been (in words, so on a 32 bit machine
fep 0:62cd296ba2a7 1358 * a value of 1 means 4 bytes) since the task started. The smaller the returned
fep 0:62cd296ba2a7 1359 * number the closer the task has come to overflowing its stack.
fep 0:62cd296ba2a7 1360 *
fep 0:62cd296ba2a7 1361 * @param xTask Handle of the task associated with the stack to be checked.
fep 0:62cd296ba2a7 1362 * Set xTask to NULL to check the stack of the calling task.
fep 0:62cd296ba2a7 1363 *
fep 0:62cd296ba2a7 1364 * @return The smallest amount of free stack space there has been (in words, so
fep 0:62cd296ba2a7 1365 * actual spaces on the stack rather than bytes) since the task referenced by
fep 0:62cd296ba2a7 1366 * xTask was created.
fep 0:62cd296ba2a7 1367 */
fep 0:62cd296ba2a7 1368 UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1369
fep 0:62cd296ba2a7 1370 /* When using trace macros it is sometimes necessary to include task.h before
fep 0:62cd296ba2a7 1371 FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
fep 0:62cd296ba2a7 1372 so the following two prototypes will cause a compilation error. This can be
fep 0:62cd296ba2a7 1373 fixed by simply guarding against the inclusion of these two prototypes unless
fep 0:62cd296ba2a7 1374 they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration
fep 0:62cd296ba2a7 1375 constant. */
fep 0:62cd296ba2a7 1376 #ifdef configUSE_APPLICATION_TASK_TAG
fep 0:62cd296ba2a7 1377 #if configUSE_APPLICATION_TASK_TAG == 1
fep 0:62cd296ba2a7 1378 /**
fep 0:62cd296ba2a7 1379 * task.h
fep 0:62cd296ba2a7 1380 * <pre>void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );</pre>
fep 0:62cd296ba2a7 1381 *
fep 0:62cd296ba2a7 1382 * Sets pxHookFunction to be the task hook function used by the task xTask.
fep 0:62cd296ba2a7 1383 * Passing xTask as NULL has the effect of setting the calling tasks hook
fep 0:62cd296ba2a7 1384 * function.
fep 0:62cd296ba2a7 1385 */
fep 0:62cd296ba2a7 1386 void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1387
fep 0:62cd296ba2a7 1388 /**
fep 0:62cd296ba2a7 1389 * task.h
fep 0:62cd296ba2a7 1390 * <pre>void xTaskGetApplicationTaskTag( TaskHandle_t xTask );</pre>
fep 0:62cd296ba2a7 1391 *
fep 0:62cd296ba2a7 1392 * Returns the pxHookFunction value assigned to the task xTask.
fep 0:62cd296ba2a7 1393 */
fep 0:62cd296ba2a7 1394 TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1395 #endif /* configUSE_APPLICATION_TASK_TAG ==1 */
fep 0:62cd296ba2a7 1396 #endif /* ifdef configUSE_APPLICATION_TASK_TAG */
fep 0:62cd296ba2a7 1397
fep 0:62cd296ba2a7 1398 #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
fep 0:62cd296ba2a7 1399
fep 0:62cd296ba2a7 1400 /* Each task contains an array of pointers that is dimensioned by the
fep 0:62cd296ba2a7 1401 configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. The
fep 0:62cd296ba2a7 1402 kernel does not use the pointers itself, so the application writer can use
fep 0:62cd296ba2a7 1403 the pointers for any purpose they wish. The following two functions are
fep 0:62cd296ba2a7 1404 used to set and query a pointer respectively. */
fep 0:62cd296ba2a7 1405 void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1406 void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1407
fep 0:62cd296ba2a7 1408 #endif
fep 0:62cd296ba2a7 1409
fep 0:62cd296ba2a7 1410 /**
fep 0:62cd296ba2a7 1411 * task.h
fep 0:62cd296ba2a7 1412 * <pre>BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );</pre>
fep 0:62cd296ba2a7 1413 *
fep 0:62cd296ba2a7 1414 * Calls the hook function associated with xTask. Passing xTask as NULL has
fep 0:62cd296ba2a7 1415 * the effect of calling the Running tasks (the calling task) hook function.
fep 0:62cd296ba2a7 1416 *
fep 0:62cd296ba2a7 1417 * pvParameter is passed to the hook function for the task to interpret as it
fep 0:62cd296ba2a7 1418 * wants. The return value is the value returned by the task hook function
fep 0:62cd296ba2a7 1419 * registered by the user.
fep 0:62cd296ba2a7 1420 */
fep 0:62cd296ba2a7 1421 BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1422
fep 0:62cd296ba2a7 1423 /**
fep 0:62cd296ba2a7 1424 * xTaskGetIdleTaskHandle() is only available if
fep 0:62cd296ba2a7 1425 * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.
fep 0:62cd296ba2a7 1426 *
fep 0:62cd296ba2a7 1427 * Simply returns the handle of the idle task. It is not valid to call
fep 0:62cd296ba2a7 1428 * xTaskGetIdleTaskHandle() before the scheduler has been started.
fep 0:62cd296ba2a7 1429 */
fep 0:62cd296ba2a7 1430 TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1431
fep 0:62cd296ba2a7 1432 /**
fep 0:62cd296ba2a7 1433 * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for
fep 0:62cd296ba2a7 1434 * uxTaskGetSystemState() to be available.
fep 0:62cd296ba2a7 1435 *
fep 0:62cd296ba2a7 1436 * uxTaskGetSystemState() populates an TaskStatus_t structure for each task in
fep 0:62cd296ba2a7 1437 * the system. TaskStatus_t structures contain, among other things, members
fep 0:62cd296ba2a7 1438 * for the task handle, task name, task priority, task state, and total amount
fep 0:62cd296ba2a7 1439 * of run time consumed by the task. See the TaskStatus_t structure
fep 0:62cd296ba2a7 1440 * definition in this file for the full member list.
fep 0:62cd296ba2a7 1441 *
fep 0:62cd296ba2a7 1442 * NOTE: This function is intended for debugging use only as its use results in
fep 0:62cd296ba2a7 1443 * the scheduler remaining suspended for an extended period.
fep 0:62cd296ba2a7 1444 *
fep 0:62cd296ba2a7 1445 * @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures.
fep 0:62cd296ba2a7 1446 * The array must contain at least one TaskStatus_t structure for each task
fep 0:62cd296ba2a7 1447 * that is under the control of the RTOS. The number of tasks under the control
fep 0:62cd296ba2a7 1448 * of the RTOS can be determined using the uxTaskGetNumberOfTasks() API function.
fep 0:62cd296ba2a7 1449 *
fep 0:62cd296ba2a7 1450 * @param uxArraySize The size of the array pointed to by the pxTaskStatusArray
fep 0:62cd296ba2a7 1451 * parameter. The size is specified as the number of indexes in the array, or
fep 0:62cd296ba2a7 1452 * the number of TaskStatus_t structures contained in the array, not by the
fep 0:62cd296ba2a7 1453 * number of bytes in the array.
fep 0:62cd296ba2a7 1454 *
fep 0:62cd296ba2a7 1455 * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in
fep 0:62cd296ba2a7 1456 * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the
fep 0:62cd296ba2a7 1457 * total run time (as defined by the run time stats clock, see
fep 0:62cd296ba2a7 1458 * http://www.freertos.org/rtos-run-time-stats.html) since the target booted.
fep 0:62cd296ba2a7 1459 * pulTotalRunTime can be set to NULL to omit the total run time information.
fep 0:62cd296ba2a7 1460 *
fep 0:62cd296ba2a7 1461 * @return The number of TaskStatus_t structures that were populated by
fep 0:62cd296ba2a7 1462 * uxTaskGetSystemState(). This should equal the number returned by the
fep 0:62cd296ba2a7 1463 * uxTaskGetNumberOfTasks() API function, but will be zero if the value passed
fep 0:62cd296ba2a7 1464 * in the uxArraySize parameter was too small.
fep 0:62cd296ba2a7 1465 *
fep 0:62cd296ba2a7 1466 * Example usage:
fep 0:62cd296ba2a7 1467 <pre>
fep 0:62cd296ba2a7 1468 // This example demonstrates how a human readable table of run time stats
fep 0:62cd296ba2a7 1469 // information is generated from raw data provided by uxTaskGetSystemState().
fep 0:62cd296ba2a7 1470 // The human readable table is written to pcWriteBuffer
fep 0:62cd296ba2a7 1471 void vTaskGetRunTimeStats( char *pcWriteBuffer )
fep 0:62cd296ba2a7 1472 {
fep 0:62cd296ba2a7 1473 TaskStatus_t *pxTaskStatusArray;
fep 0:62cd296ba2a7 1474 volatile UBaseType_t uxArraySize, x;
fep 0:62cd296ba2a7 1475 uint32_t ulTotalRunTime, ulStatsAsPercentage;
fep 0:62cd296ba2a7 1476
fep 0:62cd296ba2a7 1477 // Make sure the write buffer does not contain a string.
fep 0:62cd296ba2a7 1478 *pcWriteBuffer = 0x00;
fep 0:62cd296ba2a7 1479
fep 0:62cd296ba2a7 1480 // Take a snapshot of the number of tasks in case it changes while this
fep 0:62cd296ba2a7 1481 // function is executing.
fep 0:62cd296ba2a7 1482 uxArraySize = uxTaskGetNumberOfTasks();
fep 0:62cd296ba2a7 1483
fep 0:62cd296ba2a7 1484 // Allocate a TaskStatus_t structure for each task. An array could be
fep 0:62cd296ba2a7 1485 // allocated statically at compile time.
fep 0:62cd296ba2a7 1486 pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
fep 0:62cd296ba2a7 1487
fep 0:62cd296ba2a7 1488 if( pxTaskStatusArray != NULL )
fep 0:62cd296ba2a7 1489 {
fep 0:62cd296ba2a7 1490 // Generate raw status information about each task.
fep 0:62cd296ba2a7 1491 uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );
fep 0:62cd296ba2a7 1492
fep 0:62cd296ba2a7 1493 // For percentage calculations.
fep 0:62cd296ba2a7 1494 ulTotalRunTime /= 100UL;
fep 0:62cd296ba2a7 1495
fep 0:62cd296ba2a7 1496 // Avoid divide by zero errors.
fep 0:62cd296ba2a7 1497 if( ulTotalRunTime > 0 )
fep 0:62cd296ba2a7 1498 {
fep 0:62cd296ba2a7 1499 // For each populated position in the pxTaskStatusArray array,
fep 0:62cd296ba2a7 1500 // format the raw data as human readable ASCII data
fep 0:62cd296ba2a7 1501 for( x = 0; x < uxArraySize; x++ )
fep 0:62cd296ba2a7 1502 {
fep 0:62cd296ba2a7 1503 // What percentage of the total run time has the task used?
fep 0:62cd296ba2a7 1504 // This will always be rounded down to the nearest integer.
fep 0:62cd296ba2a7 1505 // ulTotalRunTimeDiv100 has already been divided by 100.
fep 0:62cd296ba2a7 1506 ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;
fep 0:62cd296ba2a7 1507
fep 0:62cd296ba2a7 1508 if( ulStatsAsPercentage > 0UL )
fep 0:62cd296ba2a7 1509 {
fep 0:62cd296ba2a7 1510 sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
fep 0:62cd296ba2a7 1511 }
fep 0:62cd296ba2a7 1512 else
fep 0:62cd296ba2a7 1513 {
fep 0:62cd296ba2a7 1514 // If the percentage is zero here then the task has
fep 0:62cd296ba2a7 1515 // consumed less than 1% of the total run time.
fep 0:62cd296ba2a7 1516 sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );
fep 0:62cd296ba2a7 1517 }
fep 0:62cd296ba2a7 1518
fep 0:62cd296ba2a7 1519 pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );
fep 0:62cd296ba2a7 1520 }
fep 0:62cd296ba2a7 1521 }
fep 0:62cd296ba2a7 1522
fep 0:62cd296ba2a7 1523 // The array is no longer needed, free the memory it consumes.
fep 0:62cd296ba2a7 1524 vPortFree( pxTaskStatusArray );
fep 0:62cd296ba2a7 1525 }
fep 0:62cd296ba2a7 1526 }
fep 0:62cd296ba2a7 1527 </pre>
fep 0:62cd296ba2a7 1528 */
fep 0:62cd296ba2a7 1529 UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1530
fep 0:62cd296ba2a7 1531 /**
fep 0:62cd296ba2a7 1532 * task. h
fep 0:62cd296ba2a7 1533 * <PRE>void vTaskList( char *pcWriteBuffer );</PRE>
fep 0:62cd296ba2a7 1534 *
fep 0:62cd296ba2a7 1535 * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must
fep 0:62cd296ba2a7 1536 * both be defined as 1 for this function to be available. See the
fep 0:62cd296ba2a7 1537 * configuration section of the FreeRTOS.org website for more information.
fep 0:62cd296ba2a7 1538 *
fep 0:62cd296ba2a7 1539 * NOTE 1: This function will disable interrupts for its duration. It is
fep 0:62cd296ba2a7 1540 * not intended for normal application runtime use but as a debug aid.
fep 0:62cd296ba2a7 1541 *
fep 0:62cd296ba2a7 1542 * Lists all the current tasks, along with their current state and stack
fep 0:62cd296ba2a7 1543 * usage high water mark.
fep 0:62cd296ba2a7 1544 *
fep 0:62cd296ba2a7 1545 * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or
fep 0:62cd296ba2a7 1546 * suspended ('S').
fep 0:62cd296ba2a7 1547 *
fep 0:62cd296ba2a7 1548 * PLEASE NOTE:
fep 0:62cd296ba2a7 1549 *
fep 0:62cd296ba2a7 1550 * This function is provided for convenience only, and is used by many of the
fep 0:62cd296ba2a7 1551 * demo applications. Do not consider it to be part of the scheduler.
fep 0:62cd296ba2a7 1552 *
fep 0:62cd296ba2a7 1553 * vTaskList() calls uxTaskGetSystemState(), then formats part of the
fep 0:62cd296ba2a7 1554 * uxTaskGetSystemState() output into a human readable table that displays task
fep 0:62cd296ba2a7 1555 * names, states and stack usage.
fep 0:62cd296ba2a7 1556 *
fep 0:62cd296ba2a7 1557 * vTaskList() has a dependency on the sprintf() C library function that might
fep 0:62cd296ba2a7 1558 * bloat the code size, use a lot of stack, and provide different results on
fep 0:62cd296ba2a7 1559 * different platforms. An alternative, tiny, third party, and limited
fep 0:62cd296ba2a7 1560 * functionality implementation of sprintf() is provided in many of the
fep 0:62cd296ba2a7 1561 * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
fep 0:62cd296ba2a7 1562 * printf-stdarg.c does not provide a full snprintf() implementation!).
fep 0:62cd296ba2a7 1563 *
fep 0:62cd296ba2a7 1564 * It is recommended that production systems call uxTaskGetSystemState()
fep 0:62cd296ba2a7 1565 * directly to get access to raw stats data, rather than indirectly through a
fep 0:62cd296ba2a7 1566 * call to vTaskList().
fep 0:62cd296ba2a7 1567 *
fep 0:62cd296ba2a7 1568 * @param pcWriteBuffer A buffer into which the above mentioned details
fep 0:62cd296ba2a7 1569 * will be written, in ASCII form. This buffer is assumed to be large
fep 0:62cd296ba2a7 1570 * enough to contain the generated report. Approximately 40 bytes per
fep 0:62cd296ba2a7 1571 * task should be sufficient.
fep 0:62cd296ba2a7 1572 *
fep 0:62cd296ba2a7 1573 * \defgroup vTaskList vTaskList
fep 0:62cd296ba2a7 1574 * \ingroup TaskUtils
fep 0:62cd296ba2a7 1575 */
fep 0:62cd296ba2a7 1576 void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
fep 0:62cd296ba2a7 1577
fep 0:62cd296ba2a7 1578 /**
fep 0:62cd296ba2a7 1579 * task. h
fep 0:62cd296ba2a7 1580 * <PRE>void vTaskGetRunTimeStats( char *pcWriteBuffer );</PRE>
fep 0:62cd296ba2a7 1581 *
fep 0:62cd296ba2a7 1582 * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
fep 0:62cd296ba2a7 1583 * must both be defined as 1 for this function to be available. The application
fep 0:62cd296ba2a7 1584 * must also then provide definitions for
fep 0:62cd296ba2a7 1585 * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
fep 0:62cd296ba2a7 1586 * to configure a peripheral timer/counter and return the timers current count
fep 0:62cd296ba2a7 1587 * value respectively. The counter should be at least 10 times the frequency of
fep 0:62cd296ba2a7 1588 * the tick count.
fep 0:62cd296ba2a7 1589 *
fep 0:62cd296ba2a7 1590 * NOTE 1: This function will disable interrupts for its duration. It is
fep 0:62cd296ba2a7 1591 * not intended for normal application runtime use but as a debug aid.
fep 0:62cd296ba2a7 1592 *
fep 0:62cd296ba2a7 1593 * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
fep 0:62cd296ba2a7 1594 * accumulated execution time being stored for each task. The resolution
fep 0:62cd296ba2a7 1595 * of the accumulated time value depends on the frequency of the timer
fep 0:62cd296ba2a7 1596 * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
fep 0:62cd296ba2a7 1597 * Calling vTaskGetRunTimeStats() writes the total execution time of each
fep 0:62cd296ba2a7 1598 * task into a buffer, both as an absolute count value and as a percentage
fep 0:62cd296ba2a7 1599 * of the total system execution time.
fep 0:62cd296ba2a7 1600 *
fep 0:62cd296ba2a7 1601 * NOTE 2:
fep 0:62cd296ba2a7 1602 *
fep 0:62cd296ba2a7 1603 * This function is provided for convenience only, and is used by many of the
fep 0:62cd296ba2a7 1604 * demo applications. Do not consider it to be part of the scheduler.
fep 0:62cd296ba2a7 1605 *
fep 0:62cd296ba2a7 1606 * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the
fep 0:62cd296ba2a7 1607 * uxTaskGetSystemState() output into a human readable table that displays the
fep 0:62cd296ba2a7 1608 * amount of time each task has spent in the Running state in both absolute and
fep 0:62cd296ba2a7 1609 * percentage terms.
fep 0:62cd296ba2a7 1610 *
fep 0:62cd296ba2a7 1611 * vTaskGetRunTimeStats() has a dependency on the sprintf() C library function
fep 0:62cd296ba2a7 1612 * that might bloat the code size, use a lot of stack, and provide different
fep 0:62cd296ba2a7 1613 * results on different platforms. An alternative, tiny, third party, and
fep 0:62cd296ba2a7 1614 * limited functionality implementation of sprintf() is provided in many of the
fep 0:62cd296ba2a7 1615 * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
fep 0:62cd296ba2a7 1616 * printf-stdarg.c does not provide a full snprintf() implementation!).
fep 0:62cd296ba2a7 1617 *
fep 0:62cd296ba2a7 1618 * It is recommended that production systems call uxTaskGetSystemState() directly
fep 0:62cd296ba2a7 1619 * to get access to raw stats data, rather than indirectly through a call to
fep 0:62cd296ba2a7 1620 * vTaskGetRunTimeStats().
fep 0:62cd296ba2a7 1621 *
fep 0:62cd296ba2a7 1622 * @param pcWriteBuffer A buffer into which the execution times will be
fep 0:62cd296ba2a7 1623 * written, in ASCII form. This buffer is assumed to be large enough to
fep 0:62cd296ba2a7 1624 * contain the generated report. Approximately 40 bytes per task should
fep 0:62cd296ba2a7 1625 * be sufficient.
fep 0:62cd296ba2a7 1626 *
fep 0:62cd296ba2a7 1627 * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats
fep 0:62cd296ba2a7 1628 * \ingroup TaskUtils
fep 0:62cd296ba2a7 1629 */
fep 0:62cd296ba2a7 1630 void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
fep 0:62cd296ba2a7 1631
fep 0:62cd296ba2a7 1632 /**
fep 0:62cd296ba2a7 1633 * task. h
fep 0:62cd296ba2a7 1634 * <PRE>BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );</PRE>
fep 0:62cd296ba2a7 1635 *
fep 0:62cd296ba2a7 1636 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
fep 0:62cd296ba2a7 1637 * function to be available.
fep 0:62cd296ba2a7 1638 *
fep 0:62cd296ba2a7 1639 * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
fep 0:62cd296ba2a7 1640 * "notification value", which is a 32-bit unsigned integer (uint32_t).
fep 0:62cd296ba2a7 1641 *
fep 0:62cd296ba2a7 1642 * Events can be sent to a task using an intermediary object. Examples of such
fep 0:62cd296ba2a7 1643 * objects are queues, semaphores, mutexes and event groups. Task notifications
fep 0:62cd296ba2a7 1644 * are a method of sending an event directly to a task without the need for such
fep 0:62cd296ba2a7 1645 * an intermediary object.
fep 0:62cd296ba2a7 1646 *
fep 0:62cd296ba2a7 1647 * A notification sent to a task can optionally perform an action, such as
fep 0:62cd296ba2a7 1648 * update, overwrite or increment the task's notification value. In that way
fep 0:62cd296ba2a7 1649 * task notifications can be used to send data to a task, or be used as light
fep 0:62cd296ba2a7 1650 * weight and fast binary or counting semaphores.
fep 0:62cd296ba2a7 1651 *
fep 0:62cd296ba2a7 1652 * A notification sent to a task will remain pending until it is cleared by the
fep 0:62cd296ba2a7 1653 * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was
fep 0:62cd296ba2a7 1654 * already in the Blocked state to wait for a notification when the notification
fep 0:62cd296ba2a7 1655 * arrives then the task will automatically be removed from the Blocked state
fep 0:62cd296ba2a7 1656 * (unblocked) and the notification cleared.
fep 0:62cd296ba2a7 1657 *
fep 0:62cd296ba2a7 1658 * A task can use xTaskNotifyWait() to [optionally] block to wait for a
fep 0:62cd296ba2a7 1659 * notification to be pending, or ulTaskNotifyTake() to [optionally] block
fep 0:62cd296ba2a7 1660 * to wait for its notification value to have a non-zero value. The task does
fep 0:62cd296ba2a7 1661 * not consume any CPU time while it is in the Blocked state.
fep 0:62cd296ba2a7 1662 *
fep 0:62cd296ba2a7 1663 * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.
fep 0:62cd296ba2a7 1664 *
fep 0:62cd296ba2a7 1665 * @param xTaskToNotify The handle of the task being notified. The handle to a
fep 0:62cd296ba2a7 1666 * task can be returned from the xTaskCreate() API function used to create the
fep 0:62cd296ba2a7 1667 * task, and the handle of the currently running task can be obtained by calling
fep 0:62cd296ba2a7 1668 * xTaskGetCurrentTaskHandle().
fep 0:62cd296ba2a7 1669 *
fep 0:62cd296ba2a7 1670 * @param ulValue Data that can be sent with the notification. How the data is
fep 0:62cd296ba2a7 1671 * used depends on the value of the eAction parameter.
fep 0:62cd296ba2a7 1672 *
fep 0:62cd296ba2a7 1673 * @param eAction Specifies how the notification updates the task's notification
fep 0:62cd296ba2a7 1674 * value, if at all. Valid values for eAction are as follows:
fep 0:62cd296ba2a7 1675 *
fep 0:62cd296ba2a7 1676 * eSetBits -
fep 0:62cd296ba2a7 1677 * The task's notification value is bitwise ORed with ulValue. xTaskNofify()
fep 0:62cd296ba2a7 1678 * always returns pdPASS in this case.
fep 0:62cd296ba2a7 1679 *
fep 0:62cd296ba2a7 1680 * eIncrement -
fep 0:62cd296ba2a7 1681 * The task's notification value is incremented. ulValue is not used and
fep 0:62cd296ba2a7 1682 * xTaskNotify() always returns pdPASS in this case.
fep 0:62cd296ba2a7 1683 *
fep 0:62cd296ba2a7 1684 * eSetValueWithOverwrite -
fep 0:62cd296ba2a7 1685 * The task's notification value is set to the value of ulValue, even if the
fep 0:62cd296ba2a7 1686 * task being notified had not yet processed the previous notification (the
fep 0:62cd296ba2a7 1687 * task already had a notification pending). xTaskNotify() always returns
fep 0:62cd296ba2a7 1688 * pdPASS in this case.
fep 0:62cd296ba2a7 1689 *
fep 0:62cd296ba2a7 1690 * eSetValueWithoutOverwrite -
fep 0:62cd296ba2a7 1691 * If the task being notified did not already have a notification pending then
fep 0:62cd296ba2a7 1692 * the task's notification value is set to ulValue and xTaskNotify() will
fep 0:62cd296ba2a7 1693 * return pdPASS. If the task being notified already had a notification
fep 0:62cd296ba2a7 1694 * pending then no action is performed and pdFAIL is returned.
fep 0:62cd296ba2a7 1695 *
fep 0:62cd296ba2a7 1696 * eNoAction -
fep 0:62cd296ba2a7 1697 * The task receives a notification without its notification value being
fep 0:62cd296ba2a7 1698 * updated. ulValue is not used and xTaskNotify() always returns pdPASS in
fep 0:62cd296ba2a7 1699 * this case.
fep 0:62cd296ba2a7 1700 *
fep 0:62cd296ba2a7 1701 * pulPreviousNotificationValue -
fep 0:62cd296ba2a7 1702 * Can be used to pass out the subject task's notification value before any
fep 0:62cd296ba2a7 1703 * bits are modified by the notify function.
fep 0:62cd296ba2a7 1704 *
fep 0:62cd296ba2a7 1705 * @return Dependent on the value of eAction. See the description of the
fep 0:62cd296ba2a7 1706 * eAction parameter.
fep 0:62cd296ba2a7 1707 *
fep 0:62cd296ba2a7 1708 * \defgroup xTaskNotify xTaskNotify
fep 0:62cd296ba2a7 1709 * \ingroup TaskNotifications
fep 0:62cd296ba2a7 1710 */
fep 0:62cd296ba2a7 1711 BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1712 #define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL )
fep 0:62cd296ba2a7 1713 #define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
fep 0:62cd296ba2a7 1714
fep 0:62cd296ba2a7 1715 /**
fep 0:62cd296ba2a7 1716 * task. h
fep 0:62cd296ba2a7 1717 * <PRE>BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
fep 0:62cd296ba2a7 1718 *
fep 0:62cd296ba2a7 1719 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
fep 0:62cd296ba2a7 1720 * function to be available.
fep 0:62cd296ba2a7 1721 *
fep 0:62cd296ba2a7 1722 * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
fep 0:62cd296ba2a7 1723 * "notification value", which is a 32-bit unsigned integer (uint32_t).
fep 0:62cd296ba2a7 1724 *
fep 0:62cd296ba2a7 1725 * A version of xTaskNotify() that can be used from an interrupt service routine
fep 0:62cd296ba2a7 1726 * (ISR).
fep 0:62cd296ba2a7 1727 *
fep 0:62cd296ba2a7 1728 * Events can be sent to a task using an intermediary object. Examples of such
fep 0:62cd296ba2a7 1729 * objects are queues, semaphores, mutexes and event groups. Task notifications
fep 0:62cd296ba2a7 1730 * are a method of sending an event directly to a task without the need for such
fep 0:62cd296ba2a7 1731 * an intermediary object.
fep 0:62cd296ba2a7 1732 *
fep 0:62cd296ba2a7 1733 * A notification sent to a task can optionally perform an action, such as
fep 0:62cd296ba2a7 1734 * update, overwrite or increment the task's notification value. In that way
fep 0:62cd296ba2a7 1735 * task notifications can be used to send data to a task, or be used as light
fep 0:62cd296ba2a7 1736 * weight and fast binary or counting semaphores.
fep 0:62cd296ba2a7 1737 *
fep 0:62cd296ba2a7 1738 * A notification sent to a task will remain pending until it is cleared by the
fep 0:62cd296ba2a7 1739 * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was
fep 0:62cd296ba2a7 1740 * already in the Blocked state to wait for a notification when the notification
fep 0:62cd296ba2a7 1741 * arrives then the task will automatically be removed from the Blocked state
fep 0:62cd296ba2a7 1742 * (unblocked) and the notification cleared.
fep 0:62cd296ba2a7 1743 *
fep 0:62cd296ba2a7 1744 * A task can use xTaskNotifyWait() to [optionally] block to wait for a
fep 0:62cd296ba2a7 1745 * notification to be pending, or ulTaskNotifyTake() to [optionally] block
fep 0:62cd296ba2a7 1746 * to wait for its notification value to have a non-zero value. The task does
fep 0:62cd296ba2a7 1747 * not consume any CPU time while it is in the Blocked state.
fep 0:62cd296ba2a7 1748 *
fep 0:62cd296ba2a7 1749 * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.
fep 0:62cd296ba2a7 1750 *
fep 0:62cd296ba2a7 1751 * @param xTaskToNotify The handle of the task being notified. The handle to a
fep 0:62cd296ba2a7 1752 * task can be returned from the xTaskCreate() API function used to create the
fep 0:62cd296ba2a7 1753 * task, and the handle of the currently running task can be obtained by calling
fep 0:62cd296ba2a7 1754 * xTaskGetCurrentTaskHandle().
fep 0:62cd296ba2a7 1755 *
fep 0:62cd296ba2a7 1756 * @param ulValue Data that can be sent with the notification. How the data is
fep 0:62cd296ba2a7 1757 * used depends on the value of the eAction parameter.
fep 0:62cd296ba2a7 1758 *
fep 0:62cd296ba2a7 1759 * @param eAction Specifies how the notification updates the task's notification
fep 0:62cd296ba2a7 1760 * value, if at all. Valid values for eAction are as follows:
fep 0:62cd296ba2a7 1761 *
fep 0:62cd296ba2a7 1762 * eSetBits -
fep 0:62cd296ba2a7 1763 * The task's notification value is bitwise ORed with ulValue. xTaskNofify()
fep 0:62cd296ba2a7 1764 * always returns pdPASS in this case.
fep 0:62cd296ba2a7 1765 *
fep 0:62cd296ba2a7 1766 * eIncrement -
fep 0:62cd296ba2a7 1767 * The task's notification value is incremented. ulValue is not used and
fep 0:62cd296ba2a7 1768 * xTaskNotify() always returns pdPASS in this case.
fep 0:62cd296ba2a7 1769 *
fep 0:62cd296ba2a7 1770 * eSetValueWithOverwrite -
fep 0:62cd296ba2a7 1771 * The task's notification value is set to the value of ulValue, even if the
fep 0:62cd296ba2a7 1772 * task being notified had not yet processed the previous notification (the
fep 0:62cd296ba2a7 1773 * task already had a notification pending). xTaskNotify() always returns
fep 0:62cd296ba2a7 1774 * pdPASS in this case.
fep 0:62cd296ba2a7 1775 *
fep 0:62cd296ba2a7 1776 * eSetValueWithoutOverwrite -
fep 0:62cd296ba2a7 1777 * If the task being notified did not already have a notification pending then
fep 0:62cd296ba2a7 1778 * the task's notification value is set to ulValue and xTaskNotify() will
fep 0:62cd296ba2a7 1779 * return pdPASS. If the task being notified already had a notification
fep 0:62cd296ba2a7 1780 * pending then no action is performed and pdFAIL is returned.
fep 0:62cd296ba2a7 1781 *
fep 0:62cd296ba2a7 1782 * eNoAction -
fep 0:62cd296ba2a7 1783 * The task receives a notification without its notification value being
fep 0:62cd296ba2a7 1784 * updated. ulValue is not used and xTaskNotify() always returns pdPASS in
fep 0:62cd296ba2a7 1785 * this case.
fep 0:62cd296ba2a7 1786 *
fep 0:62cd296ba2a7 1787 * @param pxHigherPriorityTaskWoken xTaskNotifyFromISR() will set
fep 0:62cd296ba2a7 1788 * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
fep 0:62cd296ba2a7 1789 * task to which the notification was sent to leave the Blocked state, and the
fep 0:62cd296ba2a7 1790 * unblocked task has a priority higher than the currently running task. If
fep 0:62cd296ba2a7 1791 * xTaskNotifyFromISR() sets this value to pdTRUE then a context switch should
fep 0:62cd296ba2a7 1792 * be requested before the interrupt is exited. How a context switch is
fep 0:62cd296ba2a7 1793 * requested from an ISR is dependent on the port - see the documentation page
fep 0:62cd296ba2a7 1794 * for the port in use.
fep 0:62cd296ba2a7 1795 *
fep 0:62cd296ba2a7 1796 * @return Dependent on the value of eAction. See the description of the
fep 0:62cd296ba2a7 1797 * eAction parameter.
fep 0:62cd296ba2a7 1798 *
fep 0:62cd296ba2a7 1799 * \defgroup xTaskNotify xTaskNotify
fep 0:62cd296ba2a7 1800 * \ingroup TaskNotifications
fep 0:62cd296ba2a7 1801 */
fep 0:62cd296ba2a7 1802 BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1803 #define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
fep 0:62cd296ba2a7 1804 #define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
fep 0:62cd296ba2a7 1805
fep 0:62cd296ba2a7 1806 /**
fep 0:62cd296ba2a7 1807 * task. h
fep 0:62cd296ba2a7 1808 * <PRE>BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );</pre>
fep 0:62cd296ba2a7 1809 *
fep 0:62cd296ba2a7 1810 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
fep 0:62cd296ba2a7 1811 * function to be available.
fep 0:62cd296ba2a7 1812 *
fep 0:62cd296ba2a7 1813 * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
fep 0:62cd296ba2a7 1814 * "notification value", which is a 32-bit unsigned integer (uint32_t).
fep 0:62cd296ba2a7 1815 *
fep 0:62cd296ba2a7 1816 * Events can be sent to a task using an intermediary object. Examples of such
fep 0:62cd296ba2a7 1817 * objects are queues, semaphores, mutexes and event groups. Task notifications
fep 0:62cd296ba2a7 1818 * are a method of sending an event directly to a task without the need for such
fep 0:62cd296ba2a7 1819 * an intermediary object.
fep 0:62cd296ba2a7 1820 *
fep 0:62cd296ba2a7 1821 * A notification sent to a task can optionally perform an action, such as
fep 0:62cd296ba2a7 1822 * update, overwrite or increment the task's notification value. In that way
fep 0:62cd296ba2a7 1823 * task notifications can be used to send data to a task, or be used as light
fep 0:62cd296ba2a7 1824 * weight and fast binary or counting semaphores.
fep 0:62cd296ba2a7 1825 *
fep 0:62cd296ba2a7 1826 * A notification sent to a task will remain pending until it is cleared by the
fep 0:62cd296ba2a7 1827 * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was
fep 0:62cd296ba2a7 1828 * already in the Blocked state to wait for a notification when the notification
fep 0:62cd296ba2a7 1829 * arrives then the task will automatically be removed from the Blocked state
fep 0:62cd296ba2a7 1830 * (unblocked) and the notification cleared.
fep 0:62cd296ba2a7 1831 *
fep 0:62cd296ba2a7 1832 * A task can use xTaskNotifyWait() to [optionally] block to wait for a
fep 0:62cd296ba2a7 1833 * notification to be pending, or ulTaskNotifyTake() to [optionally] block
fep 0:62cd296ba2a7 1834 * to wait for its notification value to have a non-zero value. The task does
fep 0:62cd296ba2a7 1835 * not consume any CPU time while it is in the Blocked state.
fep 0:62cd296ba2a7 1836 *
fep 0:62cd296ba2a7 1837 * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.
fep 0:62cd296ba2a7 1838 *
fep 0:62cd296ba2a7 1839 * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value
fep 0:62cd296ba2a7 1840 * will be cleared in the calling task's notification value before the task
fep 0:62cd296ba2a7 1841 * checks to see if any notifications are pending, and optionally blocks if no
fep 0:62cd296ba2a7 1842 * notifications are pending. Setting ulBitsToClearOnEntry to ULONG_MAX (if
fep 0:62cd296ba2a7 1843 * limits.h is included) or 0xffffffffUL (if limits.h is not included) will have
fep 0:62cd296ba2a7 1844 * the effect of resetting the task's notification value to 0. Setting
fep 0:62cd296ba2a7 1845 * ulBitsToClearOnEntry to 0 will leave the task's notification value unchanged.
fep 0:62cd296ba2a7 1846 *
fep 0:62cd296ba2a7 1847 * @param ulBitsToClearOnExit If a notification is pending or received before
fep 0:62cd296ba2a7 1848 * the calling task exits the xTaskNotifyWait() function then the task's
fep 0:62cd296ba2a7 1849 * notification value (see the xTaskNotify() API function) is passed out using
fep 0:62cd296ba2a7 1850 * the pulNotificationValue parameter. Then any bits that are set in
fep 0:62cd296ba2a7 1851 * ulBitsToClearOnExit will be cleared in the task's notification value (note
fep 0:62cd296ba2a7 1852 * *pulNotificationValue is set before any bits are cleared). Setting
fep 0:62cd296ba2a7 1853 * ulBitsToClearOnExit to ULONG_MAX (if limits.h is included) or 0xffffffffUL
fep 0:62cd296ba2a7 1854 * (if limits.h is not included) will have the effect of resetting the task's
fep 0:62cd296ba2a7 1855 * notification value to 0 before the function exits. Setting
fep 0:62cd296ba2a7 1856 * ulBitsToClearOnExit to 0 will leave the task's notification value unchanged
fep 0:62cd296ba2a7 1857 * when the function exits (in which case the value passed out in
fep 0:62cd296ba2a7 1858 * pulNotificationValue will match the task's notification value).
fep 0:62cd296ba2a7 1859 *
fep 0:62cd296ba2a7 1860 * @param pulNotificationValue Used to pass the task's notification value out
fep 0:62cd296ba2a7 1861 * of the function. Note the value passed out will not be effected by the
fep 0:62cd296ba2a7 1862 * clearing of any bits caused by ulBitsToClearOnExit being non-zero.
fep 0:62cd296ba2a7 1863 *
fep 0:62cd296ba2a7 1864 * @param xTicksToWait The maximum amount of time that the task should wait in
fep 0:62cd296ba2a7 1865 * the Blocked state for a notification to be received, should a notification
fep 0:62cd296ba2a7 1866 * not already be pending when xTaskNotifyWait() was called. The task
fep 0:62cd296ba2a7 1867 * will not consume any processing time while it is in the Blocked state. This
fep 0:62cd296ba2a7 1868 * is specified in kernel ticks, the macro pdMS_TO_TICSK( value_in_ms ) can be
fep 0:62cd296ba2a7 1869 * used to convert a time specified in milliseconds to a time specified in
fep 0:62cd296ba2a7 1870 * ticks.
fep 0:62cd296ba2a7 1871 *
fep 0:62cd296ba2a7 1872 * @return If a notification was received (including notifications that were
fep 0:62cd296ba2a7 1873 * already pending when xTaskNotifyWait was called) then pdPASS is
fep 0:62cd296ba2a7 1874 * returned. Otherwise pdFAIL is returned.
fep 0:62cd296ba2a7 1875 *
fep 0:62cd296ba2a7 1876 * \defgroup xTaskNotifyWait xTaskNotifyWait
fep 0:62cd296ba2a7 1877 * \ingroup TaskNotifications
fep 0:62cd296ba2a7 1878 */
fep 0:62cd296ba2a7 1879 BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1880
fep 0:62cd296ba2a7 1881 /**
fep 0:62cd296ba2a7 1882 * task. h
fep 0:62cd296ba2a7 1883 * <PRE>BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );</PRE>
fep 0:62cd296ba2a7 1884 *
fep 0:62cd296ba2a7 1885 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro
fep 0:62cd296ba2a7 1886 * to be available.
fep 0:62cd296ba2a7 1887 *
fep 0:62cd296ba2a7 1888 * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
fep 0:62cd296ba2a7 1889 * "notification value", which is a 32-bit unsigned integer (uint32_t).
fep 0:62cd296ba2a7 1890 *
fep 0:62cd296ba2a7 1891 * Events can be sent to a task using an intermediary object. Examples of such
fep 0:62cd296ba2a7 1892 * objects are queues, semaphores, mutexes and event groups. Task notifications
fep 0:62cd296ba2a7 1893 * are a method of sending an event directly to a task without the need for such
fep 0:62cd296ba2a7 1894 * an intermediary object.
fep 0:62cd296ba2a7 1895 *
fep 0:62cd296ba2a7 1896 * A notification sent to a task can optionally perform an action, such as
fep 0:62cd296ba2a7 1897 * update, overwrite or increment the task's notification value. In that way
fep 0:62cd296ba2a7 1898 * task notifications can be used to send data to a task, or be used as light
fep 0:62cd296ba2a7 1899 * weight and fast binary or counting semaphores.
fep 0:62cd296ba2a7 1900 *
fep 0:62cd296ba2a7 1901 * xTaskNotifyGive() is a helper macro intended for use when task notifications
fep 0:62cd296ba2a7 1902 * are used as light weight and faster binary or counting semaphore equivalents.
fep 0:62cd296ba2a7 1903 * Actual FreeRTOS semaphores are given using the xSemaphoreGive() API function,
fep 0:62cd296ba2a7 1904 * the equivalent action that instead uses a task notification is
fep 0:62cd296ba2a7 1905 * xTaskNotifyGive().
fep 0:62cd296ba2a7 1906 *
fep 0:62cd296ba2a7 1907 * When task notifications are being used as a binary or counting semaphore
fep 0:62cd296ba2a7 1908 * equivalent then the task being notified should wait for the notification
fep 0:62cd296ba2a7 1909 * using the ulTaskNotificationTake() API function rather than the
fep 0:62cd296ba2a7 1910 * xTaskNotifyWait() API function.
fep 0:62cd296ba2a7 1911 *
fep 0:62cd296ba2a7 1912 * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
fep 0:62cd296ba2a7 1913 *
fep 0:62cd296ba2a7 1914 * @param xTaskToNotify The handle of the task being notified. The handle to a
fep 0:62cd296ba2a7 1915 * task can be returned from the xTaskCreate() API function used to create the
fep 0:62cd296ba2a7 1916 * task, and the handle of the currently running task can be obtained by calling
fep 0:62cd296ba2a7 1917 * xTaskGetCurrentTaskHandle().
fep 0:62cd296ba2a7 1918 *
fep 0:62cd296ba2a7 1919 * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the
fep 0:62cd296ba2a7 1920 * eAction parameter set to eIncrement - so pdPASS is always returned.
fep 0:62cd296ba2a7 1921 *
fep 0:62cd296ba2a7 1922 * \defgroup xTaskNotifyGive xTaskNotifyGive
fep 0:62cd296ba2a7 1923 * \ingroup TaskNotifications
fep 0:62cd296ba2a7 1924 */
fep 0:62cd296ba2a7 1925 #define xTaskNotifyGive( xTaskToNotify ) xTaskGenericNotify( ( xTaskToNotify ), ( 0 ), eIncrement, NULL )
fep 0:62cd296ba2a7 1926
fep 0:62cd296ba2a7 1927 /**
fep 0:62cd296ba2a7 1928 * task. h
fep 0:62cd296ba2a7 1929 * <PRE>void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );
fep 0:62cd296ba2a7 1930 *
fep 0:62cd296ba2a7 1931 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro
fep 0:62cd296ba2a7 1932 * to be available.
fep 0:62cd296ba2a7 1933 *
fep 0:62cd296ba2a7 1934 * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
fep 0:62cd296ba2a7 1935 * "notification value", which is a 32-bit unsigned integer (uint32_t).
fep 0:62cd296ba2a7 1936 *
fep 0:62cd296ba2a7 1937 * A version of xTaskNotifyGive() that can be called from an interrupt service
fep 0:62cd296ba2a7 1938 * routine (ISR).
fep 0:62cd296ba2a7 1939 *
fep 0:62cd296ba2a7 1940 * Events can be sent to a task using an intermediary object. Examples of such
fep 0:62cd296ba2a7 1941 * objects are queues, semaphores, mutexes and event groups. Task notifications
fep 0:62cd296ba2a7 1942 * are a method of sending an event directly to a task without the need for such
fep 0:62cd296ba2a7 1943 * an intermediary object.
fep 0:62cd296ba2a7 1944 *
fep 0:62cd296ba2a7 1945 * A notification sent to a task can optionally perform an action, such as
fep 0:62cd296ba2a7 1946 * update, overwrite or increment the task's notification value. In that way
fep 0:62cd296ba2a7 1947 * task notifications can be used to send data to a task, or be used as light
fep 0:62cd296ba2a7 1948 * weight and fast binary or counting semaphores.
fep 0:62cd296ba2a7 1949 *
fep 0:62cd296ba2a7 1950 * vTaskNotifyGiveFromISR() is intended for use when task notifications are
fep 0:62cd296ba2a7 1951 * used as light weight and faster binary or counting semaphore equivalents.
fep 0:62cd296ba2a7 1952 * Actual FreeRTOS semaphores are given from an ISR using the
fep 0:62cd296ba2a7 1953 * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses
fep 0:62cd296ba2a7 1954 * a task notification is vTaskNotifyGiveFromISR().
fep 0:62cd296ba2a7 1955 *
fep 0:62cd296ba2a7 1956 * When task notifications are being used as a binary or counting semaphore
fep 0:62cd296ba2a7 1957 * equivalent then the task being notified should wait for the notification
fep 0:62cd296ba2a7 1958 * using the ulTaskNotificationTake() API function rather than the
fep 0:62cd296ba2a7 1959 * xTaskNotifyWait() API function.
fep 0:62cd296ba2a7 1960 *
fep 0:62cd296ba2a7 1961 * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
fep 0:62cd296ba2a7 1962 *
fep 0:62cd296ba2a7 1963 * @param xTaskToNotify The handle of the task being notified. The handle to a
fep 0:62cd296ba2a7 1964 * task can be returned from the xTaskCreate() API function used to create the
fep 0:62cd296ba2a7 1965 * task, and the handle of the currently running task can be obtained by calling
fep 0:62cd296ba2a7 1966 * xTaskGetCurrentTaskHandle().
fep 0:62cd296ba2a7 1967 *
fep 0:62cd296ba2a7 1968 * @param pxHigherPriorityTaskWoken vTaskNotifyGiveFromISR() will set
fep 0:62cd296ba2a7 1969 * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
fep 0:62cd296ba2a7 1970 * task to which the notification was sent to leave the Blocked state, and the
fep 0:62cd296ba2a7 1971 * unblocked task has a priority higher than the currently running task. If
fep 0:62cd296ba2a7 1972 * vTaskNotifyGiveFromISR() sets this value to pdTRUE then a context switch
fep 0:62cd296ba2a7 1973 * should be requested before the interrupt is exited. How a context switch is
fep 0:62cd296ba2a7 1974 * requested from an ISR is dependent on the port - see the documentation page
fep 0:62cd296ba2a7 1975 * for the port in use.
fep 0:62cd296ba2a7 1976 *
fep 0:62cd296ba2a7 1977 * \defgroup xTaskNotifyWait xTaskNotifyWait
fep 0:62cd296ba2a7 1978 * \ingroup TaskNotifications
fep 0:62cd296ba2a7 1979 */
fep 0:62cd296ba2a7 1980 void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 1981
fep 0:62cd296ba2a7 1982 /**
fep 0:62cd296ba2a7 1983 * task. h
fep 0:62cd296ba2a7 1984 * <PRE>uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );</pre>
fep 0:62cd296ba2a7 1985 *
fep 0:62cd296ba2a7 1986 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
fep 0:62cd296ba2a7 1987 * function to be available.
fep 0:62cd296ba2a7 1988 *
fep 0:62cd296ba2a7 1989 * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
fep 0:62cd296ba2a7 1990 * "notification value", which is a 32-bit unsigned integer (uint32_t).
fep 0:62cd296ba2a7 1991 *
fep 0:62cd296ba2a7 1992 * Events can be sent to a task using an intermediary object. Examples of such
fep 0:62cd296ba2a7 1993 * objects are queues, semaphores, mutexes and event groups. Task notifications
fep 0:62cd296ba2a7 1994 * are a method of sending an event directly to a task without the need for such
fep 0:62cd296ba2a7 1995 * an intermediary object.
fep 0:62cd296ba2a7 1996 *
fep 0:62cd296ba2a7 1997 * A notification sent to a task can optionally perform an action, such as
fep 0:62cd296ba2a7 1998 * update, overwrite or increment the task's notification value. In that way
fep 0:62cd296ba2a7 1999 * task notifications can be used to send data to a task, or be used as light
fep 0:62cd296ba2a7 2000 * weight and fast binary or counting semaphores.
fep 0:62cd296ba2a7 2001 *
fep 0:62cd296ba2a7 2002 * ulTaskNotifyTake() is intended for use when a task notification is used as a
fep 0:62cd296ba2a7 2003 * faster and lighter weight binary or counting semaphore alternative. Actual
fep 0:62cd296ba2a7 2004 * FreeRTOS semaphores are taken using the xSemaphoreTake() API function, the
fep 0:62cd296ba2a7 2005 * equivalent action that instead uses a task notification is
fep 0:62cd296ba2a7 2006 * ulTaskNotifyTake().
fep 0:62cd296ba2a7 2007 *
fep 0:62cd296ba2a7 2008 * When a task is using its notification value as a binary or counting semaphore
fep 0:62cd296ba2a7 2009 * other tasks should send notifications to it using the xTaskNotifyGive()
fep 0:62cd296ba2a7 2010 * macro, or xTaskNotify() function with the eAction parameter set to
fep 0:62cd296ba2a7 2011 * eIncrement.
fep 0:62cd296ba2a7 2012 *
fep 0:62cd296ba2a7 2013 * ulTaskNotifyTake() can either clear the task's notification value to
fep 0:62cd296ba2a7 2014 * zero on exit, in which case the notification value acts like a binary
fep 0:62cd296ba2a7 2015 * semaphore, or decrement the task's notification value on exit, in which case
fep 0:62cd296ba2a7 2016 * the notification value acts like a counting semaphore.
fep 0:62cd296ba2a7 2017 *
fep 0:62cd296ba2a7 2018 * A task can use ulTaskNotifyTake() to [optionally] block to wait for a
fep 0:62cd296ba2a7 2019 * the task's notification value to be non-zero. The task does not consume any
fep 0:62cd296ba2a7 2020 * CPU time while it is in the Blocked state.
fep 0:62cd296ba2a7 2021 *
fep 0:62cd296ba2a7 2022 * Where as xTaskNotifyWait() will return when a notification is pending,
fep 0:62cd296ba2a7 2023 * ulTaskNotifyTake() will return when the task's notification value is
fep 0:62cd296ba2a7 2024 * not zero.
fep 0:62cd296ba2a7 2025 *
fep 0:62cd296ba2a7 2026 * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.
fep 0:62cd296ba2a7 2027 *
fep 0:62cd296ba2a7 2028 * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's
fep 0:62cd296ba2a7 2029 * notification value is decremented when the function exits. In this way the
fep 0:62cd296ba2a7 2030 * notification value acts like a counting semaphore. If xClearCountOnExit is
fep 0:62cd296ba2a7 2031 * not pdFALSE then the task's notification value is cleared to zero when the
fep 0:62cd296ba2a7 2032 * function exits. In this way the notification value acts like a binary
fep 0:62cd296ba2a7 2033 * semaphore.
fep 0:62cd296ba2a7 2034 *
fep 0:62cd296ba2a7 2035 * @param xTicksToWait The maximum amount of time that the task should wait in
fep 0:62cd296ba2a7 2036 * the Blocked state for the task's notification value to be greater than zero,
fep 0:62cd296ba2a7 2037 * should the count not already be greater than zero when
fep 0:62cd296ba2a7 2038 * ulTaskNotifyTake() was called. The task will not consume any processing
fep 0:62cd296ba2a7 2039 * time while it is in the Blocked state. This is specified in kernel ticks,
fep 0:62cd296ba2a7 2040 * the macro pdMS_TO_TICSK( value_in_ms ) can be used to convert a time
fep 0:62cd296ba2a7 2041 * specified in milliseconds to a time specified in ticks.
fep 0:62cd296ba2a7 2042 *
fep 0:62cd296ba2a7 2043 * @return The task's notification count before it is either cleared to zero or
fep 0:62cd296ba2a7 2044 * decremented (see the xClearCountOnExit parameter).
fep 0:62cd296ba2a7 2045 *
fep 0:62cd296ba2a7 2046 * \defgroup ulTaskNotifyTake ulTaskNotifyTake
fep 0:62cd296ba2a7 2047 * \ingroup TaskNotifications
fep 0:62cd296ba2a7 2048 */
fep 0:62cd296ba2a7 2049 uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2050
fep 0:62cd296ba2a7 2051 /**
fep 0:62cd296ba2a7 2052 * task. h
fep 0:62cd296ba2a7 2053 * <PRE>BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );</pre>
fep 0:62cd296ba2a7 2054 *
fep 0:62cd296ba2a7 2055 * If the notification state of the task referenced by the handle xTask is
fep 0:62cd296ba2a7 2056 * eNotified, then set the task's notification state to eNotWaitingNotification.
fep 0:62cd296ba2a7 2057 * The task's notification value is not altered. Set xTask to NULL to clear the
fep 0:62cd296ba2a7 2058 * notification state of the calling task.
fep 0:62cd296ba2a7 2059 *
fep 0:62cd296ba2a7 2060 * @return pdTRUE if the task's notification state was set to
fep 0:62cd296ba2a7 2061 * eNotWaitingNotification, otherwise pdFALSE.
fep 0:62cd296ba2a7 2062 * \defgroup xTaskNotifyStateClear xTaskNotifyStateClear
fep 0:62cd296ba2a7 2063 * \ingroup TaskNotifications
fep 0:62cd296ba2a7 2064 */
fep 0:62cd296ba2a7 2065 BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
fep 0:62cd296ba2a7 2066
fep 0:62cd296ba2a7 2067 /*-----------------------------------------------------------
fep 0:62cd296ba2a7 2068 * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
fep 0:62cd296ba2a7 2069 *----------------------------------------------------------*/
fep 0:62cd296ba2a7 2070
fep 0:62cd296ba2a7 2071 /*
fep 0:62cd296ba2a7 2072 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
fep 0:62cd296ba2a7 2073 * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
fep 0:62cd296ba2a7 2074 * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
fep 0:62cd296ba2a7 2075 *
fep 0:62cd296ba2a7 2076 * Called from the real time kernel tick (either preemptive or cooperative),
fep 0:62cd296ba2a7 2077 * this increments the tick count and checks if any tasks that are blocked
fep 0:62cd296ba2a7 2078 * for a finite period required removing from a blocked list and placing on
fep 0:62cd296ba2a7 2079 * a ready list. If a non-zero value is returned then a context switch is
fep 0:62cd296ba2a7 2080 * required because either:
fep 0:62cd296ba2a7 2081 * + A task was removed from a blocked list because its timeout had expired,
fep 0:62cd296ba2a7 2082 * or
fep 0:62cd296ba2a7 2083 * + Time slicing is in use and there is a task of equal priority to the
fep 0:62cd296ba2a7 2084 * currently running task.
fep 0:62cd296ba2a7 2085 */
fep 0:62cd296ba2a7 2086 BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2087
fep 0:62cd296ba2a7 2088 /*
fep 0:62cd296ba2a7 2089 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
fep 0:62cd296ba2a7 2090 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
fep 0:62cd296ba2a7 2091 *
fep 0:62cd296ba2a7 2092 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
fep 0:62cd296ba2a7 2093 *
fep 0:62cd296ba2a7 2094 * Removes the calling task from the ready list and places it both
fep 0:62cd296ba2a7 2095 * on the list of tasks waiting for a particular event, and the
fep 0:62cd296ba2a7 2096 * list of delayed tasks. The task will be removed from both lists
fep 0:62cd296ba2a7 2097 * and replaced on the ready list should either the event occur (and
fep 0:62cd296ba2a7 2098 * there be no higher priority tasks waiting on the same event) or
fep 0:62cd296ba2a7 2099 * the delay period expires.
fep 0:62cd296ba2a7 2100 *
fep 0:62cd296ba2a7 2101 * The 'unordered' version replaces the event list item value with the
fep 0:62cd296ba2a7 2102 * xItemValue value, and inserts the list item at the end of the list.
fep 0:62cd296ba2a7 2103 *
fep 0:62cd296ba2a7 2104 * The 'ordered' version uses the existing event list item value (which is the
fep 0:62cd296ba2a7 2105 * owning tasks priority) to insert the list item into the event list is task
fep 0:62cd296ba2a7 2106 * priority order.
fep 0:62cd296ba2a7 2107 *
fep 0:62cd296ba2a7 2108 * @param pxEventList The list containing tasks that are blocked waiting
fep 0:62cd296ba2a7 2109 * for the event to occur.
fep 0:62cd296ba2a7 2110 *
fep 0:62cd296ba2a7 2111 * @param xItemValue The item value to use for the event list item when the
fep 0:62cd296ba2a7 2112 * event list is not ordered by task priority.
fep 0:62cd296ba2a7 2113 *
fep 0:62cd296ba2a7 2114 * @param xTicksToWait The maximum amount of time that the task should wait
fep 0:62cd296ba2a7 2115 * for the event to occur. This is specified in kernel ticks,the constant
fep 0:62cd296ba2a7 2116 * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time
fep 0:62cd296ba2a7 2117 * period.
fep 0:62cd296ba2a7 2118 */
fep 0:62cd296ba2a7 2119 void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2120 void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2121
fep 0:62cd296ba2a7 2122 /*
fep 0:62cd296ba2a7 2123 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
fep 0:62cd296ba2a7 2124 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
fep 0:62cd296ba2a7 2125 *
fep 0:62cd296ba2a7 2126 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
fep 0:62cd296ba2a7 2127 *
fep 0:62cd296ba2a7 2128 * This function performs nearly the same function as vTaskPlaceOnEventList().
fep 0:62cd296ba2a7 2129 * The difference being that this function does not permit tasks to block
fep 0:62cd296ba2a7 2130 * indefinitely, whereas vTaskPlaceOnEventList() does.
fep 0:62cd296ba2a7 2131 *
fep 0:62cd296ba2a7 2132 */
fep 0:62cd296ba2a7 2133 void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2134
fep 0:62cd296ba2a7 2135 /*
fep 0:62cd296ba2a7 2136 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
fep 0:62cd296ba2a7 2137 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
fep 0:62cd296ba2a7 2138 *
fep 0:62cd296ba2a7 2139 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
fep 0:62cd296ba2a7 2140 *
fep 0:62cd296ba2a7 2141 * Removes a task from both the specified event list and the list of blocked
fep 0:62cd296ba2a7 2142 * tasks, and places it on a ready queue.
fep 0:62cd296ba2a7 2143 *
fep 0:62cd296ba2a7 2144 * xTaskRemoveFromEventList()/xTaskRemoveFromUnorderedEventList() will be called
fep 0:62cd296ba2a7 2145 * if either an event occurs to unblock a task, or the block timeout period
fep 0:62cd296ba2a7 2146 * expires.
fep 0:62cd296ba2a7 2147 *
fep 0:62cd296ba2a7 2148 * xTaskRemoveFromEventList() is used when the event list is in task priority
fep 0:62cd296ba2a7 2149 * order. It removes the list item from the head of the event list as that will
fep 0:62cd296ba2a7 2150 * have the highest priority owning task of all the tasks on the event list.
fep 0:62cd296ba2a7 2151 * xTaskRemoveFromUnorderedEventList() is used when the event list is not
fep 0:62cd296ba2a7 2152 * ordered and the event list items hold something other than the owning tasks
fep 0:62cd296ba2a7 2153 * priority. In this case the event list item value is updated to the value
fep 0:62cd296ba2a7 2154 * passed in the xItemValue parameter.
fep 0:62cd296ba2a7 2155 *
fep 0:62cd296ba2a7 2156 * @return pdTRUE if the task being removed has a higher priority than the task
fep 0:62cd296ba2a7 2157 * making the call, otherwise pdFALSE.
fep 0:62cd296ba2a7 2158 */
fep 0:62cd296ba2a7 2159 BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2160 BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2161
fep 0:62cd296ba2a7 2162 /*
fep 0:62cd296ba2a7 2163 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
fep 0:62cd296ba2a7 2164 * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
fep 0:62cd296ba2a7 2165 * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
fep 0:62cd296ba2a7 2166 *
fep 0:62cd296ba2a7 2167 * Sets the pointer to the current TCB to the TCB of the highest priority task
fep 0:62cd296ba2a7 2168 * that is ready to run.
fep 0:62cd296ba2a7 2169 */
fep 0:62cd296ba2a7 2170 void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2171
fep 0:62cd296ba2a7 2172 /*
fep 0:62cd296ba2a7 2173 * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY
fep 0:62cd296ba2a7 2174 * THE EVENT BITS MODULE.
fep 0:62cd296ba2a7 2175 */
fep 0:62cd296ba2a7 2176 TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2177
fep 0:62cd296ba2a7 2178 /*
fep 0:62cd296ba2a7 2179 * Return the handle of the calling task.
fep 0:62cd296ba2a7 2180 */
fep 0:62cd296ba2a7 2181 TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2182
fep 0:62cd296ba2a7 2183 /*
fep 0:62cd296ba2a7 2184 * Capture the current time status for future reference.
fep 0:62cd296ba2a7 2185 */
fep 0:62cd296ba2a7 2186 void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2187
fep 0:62cd296ba2a7 2188 /*
fep 0:62cd296ba2a7 2189 * Compare the time status now with that previously captured to see if the
fep 0:62cd296ba2a7 2190 * timeout has expired.
fep 0:62cd296ba2a7 2191 */
fep 0:62cd296ba2a7 2192 BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2193
fep 0:62cd296ba2a7 2194 /*
fep 0:62cd296ba2a7 2195 * Shortcut used by the queue implementation to prevent unnecessary call to
fep 0:62cd296ba2a7 2196 * taskYIELD();
fep 0:62cd296ba2a7 2197 */
fep 0:62cd296ba2a7 2198 void vTaskMissedYield( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2199
fep 0:62cd296ba2a7 2200 /*
fep 0:62cd296ba2a7 2201 * Returns the scheduler state as taskSCHEDULER_RUNNING,
fep 0:62cd296ba2a7 2202 * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.
fep 0:62cd296ba2a7 2203 */
fep 0:62cd296ba2a7 2204 BaseType_t xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2205
fep 0:62cd296ba2a7 2206 /*
fep 0:62cd296ba2a7 2207 * Raises the priority of the mutex holder to that of the calling task should
fep 0:62cd296ba2a7 2208 * the mutex holder have a priority less than the calling task.
fep 0:62cd296ba2a7 2209 */
fep 0:62cd296ba2a7 2210 void vTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2211
fep 0:62cd296ba2a7 2212 /*
fep 0:62cd296ba2a7 2213 * Set the priority of a task back to its proper priority in the case that it
fep 0:62cd296ba2a7 2214 * inherited a higher priority while it was holding a semaphore.
fep 0:62cd296ba2a7 2215 */
fep 0:62cd296ba2a7 2216 BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2217
fep 0:62cd296ba2a7 2218 /*
fep 0:62cd296ba2a7 2219 * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.
fep 0:62cd296ba2a7 2220 */
fep 0:62cd296ba2a7 2221 UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2222
fep 0:62cd296ba2a7 2223 /*
fep 0:62cd296ba2a7 2224 * Set the uxTaskNumber of the task referenced by the xTask parameter to
fep 0:62cd296ba2a7 2225 * uxHandle.
fep 0:62cd296ba2a7 2226 */
fep 0:62cd296ba2a7 2227 void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2228
fep 0:62cd296ba2a7 2229 /*
fep 0:62cd296ba2a7 2230 * Only available when configUSE_TICKLESS_IDLE is set to 1.
fep 0:62cd296ba2a7 2231 * If tickless mode is being used, or a low power mode is implemented, then
fep 0:62cd296ba2a7 2232 * the tick interrupt will not execute during idle periods. When this is the
fep 0:62cd296ba2a7 2233 * case, the tick count value maintained by the scheduler needs to be kept up
fep 0:62cd296ba2a7 2234 * to date with the actual execution time by being skipped forward by a time
fep 0:62cd296ba2a7 2235 * equal to the idle period.
fep 0:62cd296ba2a7 2236 */
fep 0:62cd296ba2a7 2237 void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2238
fep 0:62cd296ba2a7 2239 /*
fep 0:62cd296ba2a7 2240 * Only avilable when configUSE_TICKLESS_IDLE is set to 1.
fep 0:62cd296ba2a7 2241 * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port
fep 0:62cd296ba2a7 2242 * specific sleep function to determine if it is ok to proceed with the sleep,
fep 0:62cd296ba2a7 2243 * and if it is ok to proceed, if it is ok to sleep indefinitely.
fep 0:62cd296ba2a7 2244 *
fep 0:62cd296ba2a7 2245 * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only
fep 0:62cd296ba2a7 2246 * called with the scheduler suspended, not from within a critical section. It
fep 0:62cd296ba2a7 2247 * is therefore possible for an interrupt to request a context switch between
fep 0:62cd296ba2a7 2248 * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being
fep 0:62cd296ba2a7 2249 * entered. eTaskConfirmSleepModeStatus() should be called from a short
fep 0:62cd296ba2a7 2250 * critical section between the timer being stopped and the sleep mode being
fep 0:62cd296ba2a7 2251 * entered to ensure it is ok to proceed into the sleep mode.
fep 0:62cd296ba2a7 2252 */
fep 0:62cd296ba2a7 2253 eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2254
fep 0:62cd296ba2a7 2255 /*
fep 0:62cd296ba2a7 2256 * For internal use only. Increment the mutex held count when a mutex is
fep 0:62cd296ba2a7 2257 * taken and return the handle of the task that has taken the mutex.
fep 0:62cd296ba2a7 2258 */
fep 0:62cd296ba2a7 2259 void *pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
fep 0:62cd296ba2a7 2260
fep 0:62cd296ba2a7 2261 #ifdef __cplusplus
fep 0:62cd296ba2a7 2262 }
fep 0:62cd296ba2a7 2263 #endif
fep 0:62cd296ba2a7 2264 #endif /* INC_TASK_H */
fep 0:62cd296ba2a7 2265
fep 0:62cd296ba2a7 2266
fep 0:62cd296ba2a7 2267
fep 0:62cd296ba2a7 2268