Update revision to use TI's mqtt and Freertos.

Dependencies:   mbed client server

Fork of cc3100_Test_mqtt_CM3 by David Fletcher

Committer:
dflet
Date:
Thu Sep 03 14:02:37 2015 +0000
Revision:
3:a8c249046181
SPI Mode change 1 to 0

Who changed what in which revision?

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