]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
Add FreeRTOS 8.2.2
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 26 Aug 2015 15:43:26 +0000 (17:43 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 26 Aug 2015 20:17:40 +0000 (22:17 +0200)
34 files changed:
os/8.2.2/include/os/.gitattributes [new file with mode: 0644]
os/8.2.2/include/os/FreeRTOS.h [new file with mode: 0644]
os/8.2.2/include/os/FreeRTOSConfig.h [new file with mode: 0644]
os/8.2.2/include/os/StackMacros.h [new file with mode: 0644]
os/8.2.2/include/os/croutine.h [new file with mode: 0644]
os/8.2.2/include/os/deprecated_definitions.h [new file with mode: 0644]
os/8.2.2/include/os/event_groups.h [new file with mode: 0644]
os/8.2.2/include/os/list.h [new file with mode: 0644]
os/8.2.2/include/os/mpu_wrappers.h [new file with mode: 0644]
os/8.2.2/include/os/os.h [new file with mode: 0644]
os/8.2.2/include/os/portable.h [new file with mode: 0644]
os/8.2.2/include/os/portmacro.h [new file with mode: 0644]
os/8.2.2/include/os/projdefs.h [new file with mode: 0644]
os/8.2.2/include/os/queue.h [new file with mode: 0644]
os/8.2.2/include/os/semphr.h [new file with mode: 0644]
os/8.2.2/include/os/stdint.readme [new file with mode: 0644]
os/8.2.2/include/os/task.h [new file with mode: 0644]
os/8.2.2/include/os/timers.h [new file with mode: 0644]
os/8.2.2/src/os/.gitattributes [new file with mode: 0644]
os/8.2.2/src/os/croutine.c [new file with mode: 0644]
os/8.2.2/src/os/event_groups.c [new file with mode: 0644]
os/8.2.2/src/os/heap.c [new file with mode: 0644]
os/8.2.2/src/os/heap_1.c [new file with mode: 0644]
os/8.2.2/src/os/heap_2.c [new file with mode: 0644]
os/8.2.2/src/os/heap_3.c [new file with mode: 0644]
os/8.2.2/src/os/heap_4.c [new file with mode: 0644]
os/8.2.2/src/os/heap_5.c [new file with mode: 0644]
os/8.2.2/src/os/list.c [new file with mode: 0644]
os/8.2.2/src/os/port.c [new file with mode: 0644]
os/8.2.2/src/os/portASM.asm [new file with mode: 0644]
os/8.2.2/src/os/queue.c [new file with mode: 0644]
os/8.2.2/src/os/readme.txt [new file with mode: 0644]
os/8.2.2/src/os/tasks.c [new file with mode: 0644]
os/8.2.2/src/os/timers.c [new file with mode: 0644]

diff --git a/os/8.2.2/include/os/.gitattributes b/os/8.2.2/include/os/.gitattributes
new file mode 100644 (file)
index 0000000..edc39a0
--- /dev/null
@@ -0,0 +1,17 @@
+/FreeRTOS.h    eaton
+/FreeRTOSConfig.h      eaton
+/StackMacros.h eaton
+/croutine.h    eaton
+/deprecated_definitions.h      eaton
+/event_groups.h        eaton
+/list.h        eaton
+/mpu_wrappers.h        eaton
+/os.h          eaton
+/portable.h    eaton
+/portmacro.h   eaton
+/projdefs.h    eaton
+/queue.h       eaton
+/semphr.h      eaton
+/stdint.readme eaton
+/task.h        eaton
+/timers.h      eaton
diff --git a/os/8.2.2/include/os/FreeRTOS.h b/os/8.2.2/include/os/FreeRTOS.h
new file mode 100644 (file)
index 0000000..bee1dab
--- /dev/null
@@ -0,0 +1,831 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+#ifndef INC_FREERTOS_H\r
+#define INC_FREERTOS_H\r
+\r
+/*\r
+ * Include the generic headers required for the FreeRTOS port being used.\r
+ */\r
+#include <stddef.h>\r
+\r
+/*\r
+ * If stdint.h cannot be located then:\r
+ *   + If using GCC ensure the -nostdint options is *not* being used.\r
+ *   + Ensure the project's include path includes the directory in which your\r
+ *     compiler stores stdint.h.\r
+ *   + Set any compiler options necessary for it to support C99, as technically\r
+ *     stdint.h is only mandatory with C99 (FreeRTOS does not require C99 in any\r
+ *     other way).\r
+ *   + The FreeRTOS download includes a simple stdint.h definition that can be\r
+ *     used in cases where none is provided by the compiler.  The files only\r
+ *     contains the typedefs required to build FreeRTOS.  Read the instructions\r
+ *     in FreeRTOS/source/stdint.readme for more information.\r
+ */\r
+#include <stdint.h> /* READ COMMENT ABOVE. */\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/* Application specific configuration options. */\r
+#include "os/FreeRTOSConfig.h"\r
+\r
+/* Basic FreeRTOS definitions. */\r
+#include "projdefs.h"\r
+\r
+/* Definitions specific to the port being used. */\r
+#include "portable.h"\r
+\r
+/*\r
+ * Check all the required application specific macros have been defined.\r
+ * These macros are application specific and (as downloaded) are defined\r
+ * within FreeRTOSConfig.h.\r
+ */\r
+\r
+#ifndef configMINIMAL_STACK_SIZE\r
+       #error Missing definition:  configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h.  configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task.  Refer to the demo project provided for your port for a suitable value.\r
+#endif\r
+\r
+#ifndef configMAX_PRIORITIES\r
+       #error Missing definition:  configMAX_PRIORITIES must be defined in FreeRTOSConfig.h.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#endif\r
+\r
+#ifndef configUSE_PREEMPTION\r
+       #error Missing definition:  configUSE_PREEMPTION must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#endif\r
+\r
+#ifndef configUSE_IDLE_HOOK\r
+       #error Missing definition:  configUSE_IDLE_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#endif\r
+\r
+#ifndef configUSE_TICK_HOOK\r
+       #error Missing definition:  configUSE_TICK_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#endif\r
+\r
+#ifndef INCLUDE_vTaskPrioritySet\r
+       #error Missing definition:  INCLUDE_vTaskPrioritySet must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#endif\r
+\r
+#ifndef INCLUDE_uxTaskPriorityGet\r
+       #error Missing definition:  INCLUDE_uxTaskPriorityGet must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#endif\r
+\r
+#ifndef INCLUDE_vTaskDelete\r
+       #error Missing definition:  INCLUDE_vTaskDelete must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#endif\r
+\r
+#ifndef INCLUDE_vTaskSuspend\r
+       #error Missing definition:  INCLUDE_vTaskSuspend must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#endif\r
+\r
+#ifndef INCLUDE_vTaskDelayUntil\r
+       #error Missing definition:  INCLUDE_vTaskDelayUntil must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#endif\r
+\r
+#ifndef INCLUDE_vTaskDelay\r
+       #error Missing definition:  INCLUDE_vTaskDelay must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#endif\r
+\r
+#ifndef configUSE_16_BIT_TICKS\r
+       #error Missing definition:  configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#endif\r
+\r
+#ifndef configMAX_PRIORITIES\r
+       #error configMAX_PRIORITIES must be defined to be greater than or equal to 1.\r
+#endif\r
+\r
+#ifndef configUSE_CO_ROUTINES\r
+       #define configUSE_CO_ROUTINES 0\r
+#endif\r
+\r
+#if configUSE_CO_ROUTINES != 0\r
+       #ifndef configMAX_CO_ROUTINE_PRIORITIES\r
+               #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1.\r
+       #endif\r
+#endif\r
+\r
+#ifndef INCLUDE_xTaskGetIdleTaskHandle\r
+       #define INCLUDE_xTaskGetIdleTaskHandle 0\r
+#endif\r
+\r
+#ifndef INCLUDE_xTimerGetTimerDaemonTaskHandle\r
+       #define INCLUDE_xTimerGetTimerDaemonTaskHandle 0\r
+#endif\r
+\r
+#ifndef INCLUDE_xQueueGetMutexHolder\r
+       #define INCLUDE_xQueueGetMutexHolder 0\r
+#endif\r
+\r
+#ifndef INCLUDE_xSemaphoreGetMutexHolder\r
+       #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder\r
+#endif\r
+\r
+#ifndef INCLUDE_pcTaskGetTaskName\r
+       #define INCLUDE_pcTaskGetTaskName 0\r
+#endif\r
+\r
+#ifndef configUSE_APPLICATION_TASK_TAG\r
+       #define configUSE_APPLICATION_TASK_TAG 0\r
+#endif\r
+\r
+#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS\r
+       #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0\r
+#endif\r
+\r
+#ifndef INCLUDE_uxTaskGetStackHighWaterMark\r
+       #define INCLUDE_uxTaskGetStackHighWaterMark 0\r
+#endif\r
+\r
+#ifndef INCLUDE_eTaskGetState\r
+       #define INCLUDE_eTaskGetState 0\r
+#endif\r
+\r
+#ifndef configUSE_RECURSIVE_MUTEXES\r
+       #define configUSE_RECURSIVE_MUTEXES 0\r
+#endif\r
+\r
+#ifndef configUSE_MUTEXES\r
+       #define configUSE_MUTEXES 0\r
+#endif\r
+\r
+#ifndef configUSE_TIMERS\r
+       #define configUSE_TIMERS 0\r
+#endif\r
+\r
+#ifndef configUSE_COUNTING_SEMAPHORES\r
+       #define configUSE_COUNTING_SEMAPHORES 0\r
+#endif\r
+\r
+#ifndef configUSE_ALTERNATIVE_API\r
+       #define configUSE_ALTERNATIVE_API 0\r
+#endif\r
+\r
+#ifndef portCRITICAL_NESTING_IN_TCB\r
+       #define portCRITICAL_NESTING_IN_TCB 0\r
+#endif\r
+\r
+#ifndef configMAX_TASK_NAME_LEN\r
+       #define configMAX_TASK_NAME_LEN 16\r
+#endif\r
+\r
+#ifndef configIDLE_SHOULD_YIELD\r
+       #define configIDLE_SHOULD_YIELD         1\r
+#endif\r
+\r
+#if configMAX_TASK_NAME_LEN < 1\r
+       #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h\r
+#endif\r
+\r
+#ifndef INCLUDE_xTaskResumeFromISR\r
+       #define INCLUDE_xTaskResumeFromISR 1\r
+#endif\r
+\r
+#ifndef INCLUDE_xEventGroupSetBitFromISR\r
+       #define INCLUDE_xEventGroupSetBitFromISR 0\r
+#endif\r
+\r
+#ifndef INCLUDE_xTimerPendFunctionCall\r
+       #define INCLUDE_xTimerPendFunctionCall 0\r
+#endif\r
+\r
+#ifndef configASSERT\r
+       #define configASSERT( x )\r
+       #define configASSERT_DEFINED 0\r
+#else\r
+       #define configASSERT_DEFINED 1\r
+#endif\r
+\r
+/* The timers module relies on xTaskGetSchedulerState(). */\r
+#if configUSE_TIMERS == 1\r
+\r
+       #ifndef configTIMER_TASK_PRIORITY\r
+               #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined.\r
+       #endif /* configTIMER_TASK_PRIORITY */\r
+\r
+       #ifndef configTIMER_QUEUE_LENGTH\r
+               #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined.\r
+       #endif /* configTIMER_QUEUE_LENGTH */\r
+\r
+       #ifndef configTIMER_TASK_STACK_DEPTH\r
+               #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined.\r
+       #endif /* configTIMER_TASK_STACK_DEPTH */\r
+\r
+#endif /* configUSE_TIMERS */\r
+\r
+#ifndef INCLUDE_xTaskGetSchedulerState\r
+       #define INCLUDE_xTaskGetSchedulerState 0\r
+#endif\r
+\r
+#ifndef INCLUDE_xTaskGetCurrentTaskHandle\r
+       #define INCLUDE_xTaskGetCurrentTaskHandle 0\r
+#endif\r
+\r
+\r
+#ifndef portSET_INTERRUPT_MASK_FROM_ISR\r
+       #define portSET_INTERRUPT_MASK_FROM_ISR() 0\r
+#endif\r
+\r
+#ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR\r
+       #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue\r
+#endif\r
+\r
+#ifndef portCLEAN_UP_TCB\r
+       #define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB\r
+#endif\r
+\r
+#ifndef portPRE_TASK_DELETE_HOOK\r
+       #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxYieldPending )\r
+#endif\r
+\r
+#ifndef portSETUP_TCB\r
+       #define portSETUP_TCB( pxTCB ) ( void ) pxTCB\r
+#endif\r
+\r
+#ifndef configQUEUE_REGISTRY_SIZE\r
+       #define configQUEUE_REGISTRY_SIZE 0U\r
+#endif\r
+\r
+#if ( configQUEUE_REGISTRY_SIZE < 1 )\r
+       #define vQueueAddToRegistry( xQueue, pcName )\r
+       #define vQueueUnregisterQueue( xQueue )\r
+#endif\r
+\r
+#ifndef portPOINTER_SIZE_TYPE\r
+       #define portPOINTER_SIZE_TYPE uint32_t\r
+#endif\r
+\r
+/* Remove any unused trace macros. */\r
+#ifndef traceSTART\r
+       /* Used to perform any necessary initialisation - for example, open a file\r
+       into which trace is to be written. */\r
+       #define traceSTART()\r
+#endif\r
+\r
+#ifndef traceEND\r
+       /* Use to close a trace, for example close a file into which trace has been\r
+       written. */\r
+       #define traceEND()\r
+#endif\r
+\r
+#ifndef traceTASK_SWITCHED_IN\r
+       /* Called after a task has been selected to run.  pxCurrentTCB holds a pointer\r
+       to the task control block of the selected task. */\r
+       #define traceTASK_SWITCHED_IN()\r
+#endif\r
+\r
+#ifndef traceINCREASE_TICK_COUNT\r
+       /* Called before stepping the tick count after waking from tickless idle\r
+       sleep. */\r
+       #define traceINCREASE_TICK_COUNT( x )\r
+#endif\r
+\r
+#ifndef traceLOW_POWER_IDLE_BEGIN\r
+       /* Called immediately before entering tickless idle. */\r
+       #define traceLOW_POWER_IDLE_BEGIN()\r
+#endif\r
+\r
+#ifndef        traceLOW_POWER_IDLE_END\r
+       /* Called when returning to the Idle task after a tickless idle. */\r
+       #define traceLOW_POWER_IDLE_END()\r
+#endif\r
+\r
+#ifndef traceTASK_SWITCHED_OUT\r
+       /* Called before a task has been selected to run.  pxCurrentTCB holds a pointer\r
+       to the task control block of the task being switched out. */\r
+       #define traceTASK_SWITCHED_OUT()\r
+#endif\r
+\r
+#ifndef traceTASK_PRIORITY_INHERIT\r
+       /* Called when a task attempts to take a mutex that is already held by a\r
+       lower priority task.  pxTCBOfMutexHolder is a pointer to the TCB of the task\r
+       that holds the mutex.  uxInheritedPriority is the priority the mutex holder\r
+       will inherit (the priority of the task that is attempting to obtain the\r
+       muted. */\r
+       #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority )\r
+#endif\r
+\r
+#ifndef traceTASK_PRIORITY_DISINHERIT\r
+       /* Called when a task releases a mutex, the holding of which had resulted in\r
+       the task inheriting the priority of a higher priority task.\r
+       pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the\r
+       mutex.  uxOriginalPriority is the task's configured (base) priority. */\r
+       #define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority )\r
+#endif\r
+\r
+#ifndef traceBLOCKING_ON_QUEUE_RECEIVE\r
+       /* Task is about to block because it cannot read from a\r
+       queue/mutex/semaphore.  pxQueue is a pointer to the queue/mutex/semaphore\r
+       upon which the read was attempted.  pxCurrentTCB points to the TCB of the\r
+       task that attempted the read. */\r
+       #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue )\r
+#endif\r
+\r
+#ifndef traceBLOCKING_ON_QUEUE_SEND\r
+       /* Task is about to block because it cannot write to a\r
+       queue/mutex/semaphore.  pxQueue is a pointer to the queue/mutex/semaphore\r
+       upon which the write was attempted.  pxCurrentTCB points to the TCB of the\r
+       task that attempted the write. */\r
+       #define traceBLOCKING_ON_QUEUE_SEND( pxQueue )\r
+#endif\r
+\r
+#ifndef configCHECK_FOR_STACK_OVERFLOW\r
+       #define configCHECK_FOR_STACK_OVERFLOW 0\r
+#endif\r
+\r
+/* The following event macros are embedded in the kernel API calls. */\r
+\r
+#ifndef traceMOVED_TASK_TO_READY_STATE\r
+       #define traceMOVED_TASK_TO_READY_STATE( pxTCB )\r
+#endif\r
+\r
+#ifndef traceQUEUE_CREATE\r
+       #define traceQUEUE_CREATE( pxNewQueue )\r
+#endif\r
+\r
+#ifndef traceQUEUE_CREATE_FAILED\r
+       #define traceQUEUE_CREATE_FAILED( ucQueueType )\r
+#endif\r
+\r
+#ifndef traceCREATE_MUTEX\r
+       #define traceCREATE_MUTEX( pxNewQueue )\r
+#endif\r
+\r
+#ifndef traceCREATE_MUTEX_FAILED\r
+       #define traceCREATE_MUTEX_FAILED()\r
+#endif\r
+\r
+#ifndef traceGIVE_MUTEX_RECURSIVE\r
+       #define traceGIVE_MUTEX_RECURSIVE( pxMutex )\r
+#endif\r
+\r
+#ifndef traceGIVE_MUTEX_RECURSIVE_FAILED\r
+       #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex )\r
+#endif\r
+\r
+#ifndef traceTAKE_MUTEX_RECURSIVE\r
+       #define traceTAKE_MUTEX_RECURSIVE( pxMutex )\r
+#endif\r
+\r
+#ifndef traceTAKE_MUTEX_RECURSIVE_FAILED\r
+       #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex )\r
+#endif\r
+\r
+#ifndef traceCREATE_COUNTING_SEMAPHORE\r
+       #define traceCREATE_COUNTING_SEMAPHORE()\r
+#endif\r
+\r
+#ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED\r
+       #define traceCREATE_COUNTING_SEMAPHORE_FAILED()\r
+#endif\r
+\r
+#ifndef traceQUEUE_SEND\r
+       #define traceQUEUE_SEND( pxQueue )\r
+#endif\r
+\r
+#ifndef traceQUEUE_SEND_FAILED\r
+       #define traceQUEUE_SEND_FAILED( pxQueue )\r
+#endif\r
+\r
+#ifndef traceQUEUE_RECEIVE\r
+       #define traceQUEUE_RECEIVE( pxQueue )\r
+#endif\r
+\r
+#ifndef traceQUEUE_PEEK\r
+       #define traceQUEUE_PEEK( pxQueue )\r
+#endif\r
+\r
+#ifndef traceQUEUE_PEEK_FROM_ISR\r
+       #define traceQUEUE_PEEK_FROM_ISR( pxQueue )\r
+#endif\r
+\r
+#ifndef traceQUEUE_RECEIVE_FAILED\r
+       #define traceQUEUE_RECEIVE_FAILED( pxQueue )\r
+#endif\r
+\r
+#ifndef traceQUEUE_SEND_FROM_ISR\r
+       #define traceQUEUE_SEND_FROM_ISR( pxQueue )\r
+#endif\r
+\r
+#ifndef traceQUEUE_SEND_FROM_ISR_FAILED\r
+       #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue )\r
+#endif\r
+\r
+#ifndef traceQUEUE_RECEIVE_FROM_ISR\r
+       #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue )\r
+#endif\r
+\r
+#ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED\r
+       #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue )\r
+#endif\r
+\r
+#ifndef traceQUEUE_PEEK_FROM_ISR_FAILED\r
+       #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue )\r
+#endif\r
+\r
+#ifndef traceQUEUE_DELETE\r
+       #define traceQUEUE_DELETE( pxQueue )\r
+#endif\r
+\r
+#ifndef traceTASK_CREATE\r
+       #define traceTASK_CREATE( pxNewTCB )\r
+#endif\r
+\r
+#ifndef traceTASK_CREATE_FAILED\r
+       #define traceTASK_CREATE_FAILED()\r
+#endif\r
+\r
+#ifndef traceTASK_DELETE\r
+       #define traceTASK_DELETE( pxTaskToDelete )\r
+#endif\r
+\r
+#ifndef traceTASK_DELAY_UNTIL\r
+       #define traceTASK_DELAY_UNTIL()\r
+#endif\r
+\r
+#ifndef traceTASK_DELAY\r
+       #define traceTASK_DELAY()\r
+#endif\r
+\r
+#ifndef traceTASK_PRIORITY_SET\r
+       #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority )\r
+#endif\r
+\r
+#ifndef traceTASK_SUSPEND\r
+       #define traceTASK_SUSPEND( pxTaskToSuspend )\r
+#endif\r
+\r
+#ifndef traceTASK_RESUME\r
+       #define traceTASK_RESUME( pxTaskToResume )\r
+#endif\r
+\r
+#ifndef traceTASK_RESUME_FROM_ISR\r
+       #define traceTASK_RESUME_FROM_ISR( pxTaskToResume )\r
+#endif\r
+\r
+#ifndef traceTASK_INCREMENT_TICK\r
+       #define traceTASK_INCREMENT_TICK( xTickCount )\r
+#endif\r
+\r
+#ifndef traceTIMER_CREATE\r
+       #define traceTIMER_CREATE( pxNewTimer )\r
+#endif\r
+\r
+#ifndef traceTIMER_CREATE_FAILED\r
+       #define traceTIMER_CREATE_FAILED()\r
+#endif\r
+\r
+#ifndef traceTIMER_COMMAND_SEND\r
+       #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn )\r
+#endif\r
+\r
+#ifndef traceTIMER_EXPIRED\r
+       #define traceTIMER_EXPIRED( pxTimer )\r
+#endif\r
+\r
+#ifndef traceTIMER_COMMAND_RECEIVED\r
+       #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue )\r
+#endif\r
+\r
+#ifndef traceMALLOC\r
+    #define traceMALLOC( pvAddress, uiSize )\r
+#endif\r
+\r
+#ifndef traceFREE\r
+    #define traceFREE( pvAddress, uiSize )\r
+#endif\r
+\r
+#ifndef traceEVENT_GROUP_CREATE\r
+       #define traceEVENT_GROUP_CREATE( xEventGroup )\r
+#endif\r
+\r
+#ifndef traceEVENT_GROUP_CREATE_FAILED\r
+       #define traceEVENT_GROUP_CREATE_FAILED()\r
+#endif\r
+\r
+#ifndef traceEVENT_GROUP_SYNC_BLOCK\r
+       #define traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor )\r
+#endif\r
+\r
+#ifndef traceEVENT_GROUP_SYNC_END\r
+       #define traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred\r
+#endif\r
+\r
+#ifndef traceEVENT_GROUP_WAIT_BITS_BLOCK\r
+       #define traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor )\r
+#endif\r
+\r
+#ifndef traceEVENT_GROUP_WAIT_BITS_END\r
+       #define traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred\r
+#endif\r
+\r
+#ifndef traceEVENT_GROUP_CLEAR_BITS\r
+       #define traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear )\r
+#endif\r
+\r
+#ifndef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR\r
+       #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear )\r
+#endif\r
+\r
+#ifndef traceEVENT_GROUP_SET_BITS\r
+       #define traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet )\r
+#endif\r
+\r
+#ifndef traceEVENT_GROUP_SET_BITS_FROM_ISR\r
+       #define traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet )\r
+#endif\r
+\r
+#ifndef traceEVENT_GROUP_DELETE\r
+       #define traceEVENT_GROUP_DELETE( xEventGroup )\r
+#endif\r
+\r
+#ifndef tracePEND_FUNC_CALL\r
+       #define tracePEND_FUNC_CALL(xFunctionToPend, pvParameter1, ulParameter2, ret)\r
+#endif\r
+\r
+#ifndef tracePEND_FUNC_CALL_FROM_ISR\r
+       #define tracePEND_FUNC_CALL_FROM_ISR(xFunctionToPend, pvParameter1, ulParameter2, ret)\r
+#endif\r
+\r
+#ifndef traceQUEUE_REGISTRY_ADD\r
+       #define traceQUEUE_REGISTRY_ADD(xQueue, pcQueueName)\r
+#endif\r
+\r
+#ifndef traceTASK_NOTIFY_TAKE_BLOCK\r
+       #define traceTASK_NOTIFY_TAKE_BLOCK()\r
+#endif\r
+\r
+#ifndef traceTASK_NOTIFY_TAKE\r
+       #define traceTASK_NOTIFY_TAKE()\r
+#endif\r
+\r
+#ifndef traceTASK_NOTIFY_WAIT_BLOCK\r
+       #define traceTASK_NOTIFY_WAIT_BLOCK()\r
+#endif\r
+\r
+#ifndef traceTASK_NOTIFY_WAIT\r
+       #define traceTASK_NOTIFY_WAIT()\r
+#endif\r
+\r
+#ifndef traceTASK_NOTIFY\r
+       #define traceTASK_NOTIFY()\r
+#endif\r
+\r
+#ifndef traceTASK_NOTIFY_FROM_ISR\r
+       #define traceTASK_NOTIFY_FROM_ISR()\r
+#endif\r
+\r
+#ifndef traceTASK_NOTIFY_GIVE_FROM_ISR\r
+       #define traceTASK_NOTIFY_GIVE_FROM_ISR()\r
+#endif\r
+\r
+#ifndef traceTASK_DELAY_SUSPEND\r
+       #define traceTASK_DELAY_SUSPEND( pxCurrentTCB )\r
+#endif\r
+\r
+#ifndef configGENERATE_RUN_TIME_STATS\r
+       #define configGENERATE_RUN_TIME_STATS 0\r
+#endif\r
+\r
+#if ( configGENERATE_RUN_TIME_STATS == 1 )\r
+\r
+       #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS\r
+               #error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined.  portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base.\r
+       #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */\r
+\r
+       #ifndef portGET_RUN_TIME_COUNTER_VALUE\r
+               #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE\r
+                       #error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined.  See the examples provided and the FreeRTOS web site for more information.\r
+               #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */\r
+       #endif /* portGET_RUN_TIME_COUNTER_VALUE */\r
+\r
+#endif /* configGENERATE_RUN_TIME_STATS */\r
+\r
+#ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS\r
+       #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()\r
+#endif\r
+\r
+#ifndef configUSE_MALLOC_FAILED_HOOK\r
+       #define configUSE_MALLOC_FAILED_HOOK 0\r
+#endif\r
+\r
+#ifndef portPRIVILEGE_BIT\r
+       #define portPRIVILEGE_BIT ( ( UBaseType_t ) 0x00 )\r
+#endif\r
+\r
+#ifndef portYIELD_WITHIN_API\r
+       #define portYIELD_WITHIN_API portYIELD\r
+#endif\r
+\r
+#ifndef pvPortMallocAligned\r
+       #define pvPortMallocAligned( x, puxStackBuffer ) ( ( ( puxStackBuffer ) == NULL ) ? ( pvPortMalloc( ( x ) ) ) : ( puxStackBuffer ) )\r
+#endif\r
+\r
+#ifndef vPortFreeAligned\r
+       #define vPortFreeAligned( pvBlockToFree ) vPortFree( pvBlockToFree )\r
+#endif\r
+\r
+#ifndef portSUPPRESS_TICKS_AND_SLEEP\r
+       #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime )\r
+#endif\r
+\r
+#ifndef configEXPECTED_IDLE_TIME_BEFORE_SLEEP\r
+       #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2\r
+#endif\r
+\r
+#if configEXPECTED_IDLE_TIME_BEFORE_SLEEP < 2\r
+       #error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2\r
+#endif\r
+\r
+#ifndef configUSE_TICKLESS_IDLE\r
+       #define configUSE_TICKLESS_IDLE 0\r
+#endif\r
+\r
+#ifndef configPRE_SLEEP_PROCESSING\r
+       #define configPRE_SLEEP_PROCESSING( x )\r
+#endif\r
+\r
+#ifndef configPOST_SLEEP_PROCESSING\r
+       #define configPOST_SLEEP_PROCESSING( x )\r
+#endif\r
+\r
+#ifndef configUSE_QUEUE_SETS\r
+       #define configUSE_QUEUE_SETS 0\r
+#endif\r
+\r
+#ifndef portTASK_USES_FLOATING_POINT\r
+       #define portTASK_USES_FLOATING_POINT()\r
+#endif\r
+\r
+#ifndef configUSE_TIME_SLICING\r
+       #define configUSE_TIME_SLICING 1\r
+#endif\r
+\r
+#ifndef configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS\r
+       #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0\r
+#endif\r
+\r
+#ifndef configUSE_NEWLIB_REENTRANT\r
+       #define configUSE_NEWLIB_REENTRANT 0\r
+#endif\r
+\r
+#ifndef configUSE_STATS_FORMATTING_FUNCTIONS\r
+       #define configUSE_STATS_FORMATTING_FUNCTIONS 0\r
+#endif\r
+\r
+#ifndef portASSERT_IF_INTERRUPT_PRIORITY_INVALID\r
+       #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID()\r
+#endif\r
+\r
+#ifndef configUSE_TRACE_FACILITY\r
+       #define configUSE_TRACE_FACILITY 0\r
+#endif\r
+\r
+#ifndef mtCOVERAGE_TEST_MARKER\r
+       #define mtCOVERAGE_TEST_MARKER()\r
+#endif\r
+\r
+#ifndef mtCOVERAGE_TEST_DELAY\r
+       #define mtCOVERAGE_TEST_DELAY()\r
+#endif\r
+\r
+#ifndef portASSERT_IF_IN_ISR\r
+       #define portASSERT_IF_IN_ISR()\r
+#endif\r
+\r
+#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION\r
+       #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0\r
+#endif\r
+\r
+#ifndef configAPPLICATION_ALLOCATED_HEAP\r
+       #define configAPPLICATION_ALLOCATED_HEAP 0\r
+#endif\r
+\r
+#ifndef configUSE_TASK_NOTIFICATIONS\r
+       #define configUSE_TASK_NOTIFICATIONS 1\r
+#endif\r
+\r
+#ifndef portTICK_TYPE_IS_ATOMIC\r
+       #define portTICK_TYPE_IS_ATOMIC 0\r
+#endif\r
+\r
+#if( portTICK_TYPE_IS_ATOMIC == 0 )\r
+       /* Either variables of tick type cannot be read atomically, or\r
+       portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when\r
+       the tick count is returned to the standard critical section macros. */\r
+       #define portTICK_TYPE_ENTER_CRITICAL() portENTER_CRITICAL()\r
+       #define portTICK_TYPE_EXIT_CRITICAL() portEXIT_CRITICAL()\r
+       #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()\r
+       #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) )\r
+#else\r
+       /* The tick type can be read atomically, so critical sections used when the\r
+       tick count is returned can be defined away. */\r
+       #define portTICK_TYPE_ENTER_CRITICAL()\r
+       #define portTICK_TYPE_EXIT_CRITICAL()\r
+       #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() 0\r
+       #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) ( void ) x\r
+#endif\r
+\r
+/* Definitions to allow backward compatibility with FreeRTOS versions prior to\r
+V8 if desired. */\r
+#ifndef configENABLE_BACKWARD_COMPATIBILITY\r
+       #define configENABLE_BACKWARD_COMPATIBILITY 1\r
+#endif\r
+\r
+#if configENABLE_BACKWARD_COMPATIBILITY == 1\r
+       #define eTaskStateGet eTaskGetState\r
+       #define portTickType TickType_t\r
+       #define xTaskHandle TaskHandle_t\r
+       #define xQueueHandle QueueHandle_t\r
+       #define xSemaphoreHandle SemaphoreHandle_t\r
+       #define xQueueSetHandle QueueSetHandle_t\r
+       #define xQueueSetMemberHandle QueueSetMemberHandle_t\r
+       #define xTimeOutType TimeOut_t\r
+       #define xMemoryRegion MemoryRegion_t\r
+       #define xTaskParameters TaskParameters_t\r
+       #define xTaskStatusType TaskStatus_t\r
+       #define xTimerHandle TimerHandle_t\r
+       #define xCoRoutineHandle CoRoutineHandle_t\r
+       #define pdTASK_HOOK_CODE TaskHookFunction_t\r
+       #define portTICK_RATE_MS portTICK_PERIOD_MS\r
+\r
+       /* Backward compatibility within the scheduler code only - these definitions\r
+       are not really required but are included for completeness. */\r
+       #define tmrTIMER_CALLBACK TimerCallbackFunction_t\r
+       #define pdTASK_CODE TaskFunction_t\r
+       #define xListItem ListItem_t\r
+       #define xList List_t\r
+#endif /* configENABLE_BACKWARD_COMPATIBILITY */\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* INC_FREERTOS_H */\r
+\r
diff --git a/os/8.2.2/include/os/FreeRTOSConfig.h b/os/8.2.2/include/os/FreeRTOSConfig.h
new file mode 100644 (file)
index 0000000..5eca637
--- /dev/null
@@ -0,0 +1,76 @@
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+ * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+ *
+ * See http://www.freertos.org/a00110.html.
+ *----------------------------------------------------------*/
+
+
+/*-----------------------------------------------------------
+ * RPP Notes:
+ *
+ * Please change configCHECK_FOR_STACK_OVERFLOW to 0 when going to production
+ * Check http://www.freertos.org/Stacks-and-stack-overflow-checking.html
+ *----------------------------------------------------------*/
+#include "sys/port.h"
+
+
+#define configUSE_PREEMPTION                    1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION        1
+#define configUSE_IDLE_HOOK                     0
+#define configUSE_TICK_HOOK                     0
+
+#define configUSE_TRACE_FACILITY                0
+#define configUSE_16_BIT_TICKS                  0
+#define configCPU_CLOCK_HZ                      ( ( unsigned portLONG ) RPP_RCLK_FREQ ) /* Timer clock. */
+#define configTICK_RATE_HZ                      ( ( portTickType ) 1000 )
+#define configMAX_PRIORITIES                    ( 8 )
+#define configMINIMAL_STACK_SIZE                ( ( unsigned portSHORT ) 128 )
+#define configTOTAL_HEAP_SIZE                   ( ( size_t ) 65535 )
+#define configMAX_TASK_NAME_LEN                 ( 16 )
+#define configIDLE_SHOULD_YIELD                 1
+#define configGENERATE_RUN_TIME_STATS           0
+#define configUSE_MALLOC_FAILED_HOOK            1
+#define configCHECK_FOR_STACK_OVERFLOW          2
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES                   0
+#define configMAX_CO_ROUTINE_PRIORITIES         ( 2 )
+
+/* Mutexes */
+#define configUSE_MUTEXES                       1
+#define configUSE_RECURSIVE_MUTEXES             0
+
+/* Semaphores */
+#define configUSE_COUNTING_SEMAPHORES           1
+
+/* Timers */
+#define configUSE_TIMERS                        0
+#define configTIMER_TASK_PRIORITY               ( 0 )
+#define configTIMER_QUEUE_LENGTH                0
+#define configTIMER_TASK_STACK_DEPTH            ( 0 )
+
+/* Set the following definitions to 1 to include the API function, or zero to exclude the API function. */
+#define INCLUDE_vTaskPrioritySet                1
+#define INCLUDE_uxTaskPriorityGet               1
+#define INCLUDE_vTaskDelete                     1
+#define INCLUDE_vTaskCleanUpResources           0
+#define INCLUDE_vTaskSuspend                    1
+#define INCLUDE_xTaskResumeFromISR              1
+#define INCLUDE_vTaskDelayUntil                 1
+#define INCLUDE_vTaskDelay                      1
+#define INCLUDE_xTaskGetSchedulerState          1
+#define INCLUDE_uxTaskGetStackHighWaterMark     1
+#define INCLUDE_pcTaskGetTaskName              1
+
+#define configASSERT( x ) if( ( x ) == pdFALSE ) { taskDISABLE_INTERRUPTS(); for( ;; ); }
+
+#endif /* FREERTOS_CONFIG_H */
diff --git a/os/8.2.2/include/os/StackMacros.h b/os/8.2.2/include/os/StackMacros.h
new file mode 100644 (file)
index 0000000..8a71156
--- /dev/null
@@ -0,0 +1,184 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+#ifndef STACK_MACROS_H\r
+#define STACK_MACROS_H\r
+\r
+/*\r
+ * Call the stack overflow hook function if the stack of the task being swapped\r
+ * out is currently overflowed, or looks like it might have overflowed in the\r
+ * past.\r
+ *\r
+ * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check\r
+ * the current stack state only - comparing the current top of stack value to\r
+ * the stack limit.  Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1\r
+ * will also cause the last few stack bytes to be checked to ensure the value\r
+ * to which the bytes were set when the task was created have not been\r
+ * overwritten.  Note this second test does not guarantee that an overflowed\r
+ * stack will always be recognised.\r
+ */\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( configCHECK_FOR_STACK_OVERFLOW == 0 )\r
+\r
+       /* FreeRTOSConfig.h is not set to check for stack overflows. */\r
+       #define taskFIRST_CHECK_FOR_STACK_OVERFLOW()\r
+       #define taskSECOND_CHECK_FOR_STACK_OVERFLOW()\r
+\r
+#endif /* configCHECK_FOR_STACK_OVERFLOW == 0 */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( configCHECK_FOR_STACK_OVERFLOW == 1 )\r
+\r
+       /* FreeRTOSConfig.h is only set to use the first method of\r
+       overflow checking. */\r
+       #define taskSECOND_CHECK_FOR_STACK_OVERFLOW()\r
+\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH < 0 ) )\r
+\r
+       /* Only the current stack state is to be checked. */\r
+       #define taskFIRST_CHECK_FOR_STACK_OVERFLOW()                                                                                                            \\r
+       {                                                                                                                                                                                                       \\r
+               /* Is the currently saved stack pointer within the stack limit? */                                                              \\r
+               if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack )                                                                               \\r
+               {                                                                                                                                                                                               \\r
+                       vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName );       \\r
+               }                                                                                                                                                                                               \\r
+       }\r
+\r
+#endif /* configCHECK_FOR_STACK_OVERFLOW > 0 */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH > 0 ) )\r
+\r
+       /* Only the current stack state is to be checked. */\r
+       #define taskFIRST_CHECK_FOR_STACK_OVERFLOW()                                                                                                            \\r
+       {                                                                                                                                                                                                       \\r
+                                                                                                                                                                                                               \\r
+               /* Is the currently saved stack pointer within the stack limit? */                                                              \\r
+               if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack )                                                                  \\r
+               {                                                                                                                                                                                               \\r
+                       vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName );       \\r
+               }                                                                                                                                                                                               \\r
+       }\r
+\r
+#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) )\r
+\r
+       #define taskSECOND_CHECK_FOR_STACK_OVERFLOW()                                                                                                                                                                           \\r
+       {                                                                                                                                                                                                                                                                       \\r
+       static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE,         \\r
+                                                                                                       tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE,         \\r
+                                                                                                       tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE,         \\r
+                                                                                                       tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE,         \\r
+                                                                                                       tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE };       \\r
+                                                                                                                                                                                                                                                                               \\r
+                                                                                                                                                                                                                                                                               \\r
+               /* Has the extremity of the task stack ever been written over? */                                                                                                                               \\r
+               if( memcmp( ( void * ) pxCurrentTCB->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 )                  \\r
+               {                                                                                                                                                                                                                                                               \\r
+                       vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName );                                                                       \\r
+               }                                                                                                                                                                                                                                                               \\r
+       }\r
+\r
+#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) )\r
+\r
+       #define taskSECOND_CHECK_FOR_STACK_OVERFLOW()                                                                                                                                                                           \\r
+       {                                                                                                                                                                                                                                                                       \\r
+       int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack;                                                                                                                                         \\r
+       static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE,         \\r
+                                                                                                       tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE,         \\r
+                                                                                                       tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE,         \\r
+                                                                                                       tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE,         \\r
+                                                                                                       tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE };       \\r
+                                                                                                                                                                                                                                                                               \\r
+                                                                                                                                                                                                                                                                               \\r
+               pcEndOfStack -= sizeof( ucExpectedStackBytes );                                                                                                                                                                 \\r
+                                                                                                                                                                                                                                                                               \\r
+               /* Has the extremity of the task stack ever been written over? */                                                                                                                               \\r
+               if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 )                                   \\r
+               {                                                                                                                                                                                                                                                               \\r
+                       vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName );                                                                       \\r
+               }                                                                                                                                                                                                                                                               \\r
+       }\r
+\r
+#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */\r
+/*-----------------------------------------------------------*/\r
+\r
+#endif /* STACK_MACROS_H */\r
+\r
diff --git a/os/8.2.2/include/os/croutine.h b/os/8.2.2/include/os/croutine.h
new file mode 100644 (file)
index 0000000..5579ec4
--- /dev/null
@@ -0,0 +1,762 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+#ifndef CO_ROUTINE_H\r
+#define CO_ROUTINE_H\r
+\r
+#ifndef INC_FREERTOS_H\r
+       #error "include FreeRTOS.h must appear in source files before include croutine.h"\r
+#endif\r
+\r
+#include "list.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/* Used to hide the implementation of the co-routine control block.  The\r
+control block structure however has to be included in the header due to\r
+the macro implementation of the co-routine functionality. */\r
+typedef void * CoRoutineHandle_t;\r
+\r
+/* Defines the prototype to which co-routine functions must conform. */\r
+typedef void (*crCOROUTINE_CODE)( CoRoutineHandle_t, UBaseType_t );\r
+\r
+typedef struct corCoRoutineControlBlock\r
+{\r
+       crCOROUTINE_CODE        pxCoRoutineFunction;\r
+       ListItem_t                      xGenericListItem;       /*< List item used to place the CRCB in ready and blocked queues. */\r
+       ListItem_t                      xEventListItem;         /*< List item used to place the CRCB in event lists. */\r
+       UBaseType_t             uxPriority;                     /*< The priority of the co-routine in relation to other co-routines. */\r
+       UBaseType_t             uxIndex;                        /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */\r
+       uint16_t                        uxState;                        /*< Used internally by the co-routine implementation. */\r
+} CRCB_t; /* Co-routine control block.  Note must be identical in size down to uxPriority with TCB_t. */\r
+\r
+/**\r
+ * croutine. h\r
+ *<pre>\r
+ BaseType_t xCoRoutineCreate(\r
+                                 crCOROUTINE_CODE pxCoRoutineCode,\r
+                                 UBaseType_t uxPriority,\r
+                                 UBaseType_t uxIndex\r
+                               );</pre>\r
+ *\r
+ * Create a new co-routine and add it to the list of co-routines that are\r
+ * ready to run.\r
+ *\r
+ * @param pxCoRoutineCode Pointer to the co-routine function.  Co-routine\r
+ * functions require special syntax - see the co-routine section of the WEB\r
+ * documentation for more information.\r
+ *\r
+ * @param uxPriority The priority with respect to other co-routines at which\r
+ *  the co-routine will run.\r
+ *\r
+ * @param uxIndex Used to distinguish between different co-routines that\r
+ * execute the same function.  See the example below and the co-routine section\r
+ * of the WEB documentation for further information.\r
+ *\r
+ * @return pdPASS if the co-routine was successfully created and added to a ready\r
+ * list, otherwise an error code defined with ProjDefs.h.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ // Co-routine to be created.\r
+ void vFlashCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
+ {\r
+ // Variables in co-routines must be declared static if they must maintain value across a blocking call.\r
+ // This may not be necessary for const variables.\r
+ static const char cLedToFlash[ 2 ] = { 5, 6 };\r
+ static const TickType_t uxFlashRates[ 2 ] = { 200, 400 };\r
+\r
+     // Must start every co-routine with a call to crSTART();\r
+     crSTART( xHandle );\r
+\r
+     for( ;; )\r
+     {\r
+         // This co-routine just delays for a fixed period, then toggles\r
+         // an LED.  Two co-routines are created using this function, so\r
+         // the uxIndex parameter is used to tell the co-routine which\r
+         // LED to flash and how int32_t to delay.  This assumes xQueue has\r
+         // already been created.\r
+         vParTestToggleLED( cLedToFlash[ uxIndex ] );\r
+         crDELAY( xHandle, uxFlashRates[ uxIndex ] );\r
+     }\r
+\r
+     // Must end every co-routine with a call to crEND();\r
+     crEND();\r
+ }\r
+\r
+ // Function that creates two co-routines.\r
+ void vOtherFunction( void )\r
+ {\r
+ uint8_t ucParameterToPass;\r
+ TaskHandle_t xHandle;\r
+\r
+     // Create two co-routines at priority 0.  The first is given index 0\r
+     // so (from the code above) toggles LED 5 every 200 ticks.  The second\r
+     // is given index 1 so toggles LED 6 every 400 ticks.\r
+     for( uxIndex = 0; uxIndex < 2; uxIndex++ )\r
+     {\r
+         xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex );\r
+     }\r
+ }\r
+   </pre>\r
+ * \defgroup xCoRoutineCreate xCoRoutineCreate\r
+ * \ingroup Tasks\r
+ */\r
+BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex );\r
+\r
+\r
+/**\r
+ * croutine. h\r
+ *<pre>\r
+ void vCoRoutineSchedule( void );</pre>\r
+ *\r
+ * Run a co-routine.\r
+ *\r
+ * vCoRoutineSchedule() executes the highest priority co-routine that is able\r
+ * to run.  The co-routine will execute until it either blocks, yields or is\r
+ * preempted by a task.  Co-routines execute cooperatively so one\r
+ * co-routine cannot be preempted by another, but can be preempted by a task.\r
+ *\r
+ * If an application comprises of both tasks and co-routines then\r
+ * vCoRoutineSchedule should be called from the idle task (in an idle task\r
+ * hook).\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ // This idle task hook will schedule a co-routine each time it is called.\r
+ // The rest of the idle task will execute between co-routine calls.\r
+ void vApplicationIdleHook( void )\r
+ {\r
+       vCoRoutineSchedule();\r
+ }\r
+\r
+ // Alternatively, if you do not require any other part of the idle task to\r
+ // execute, the idle task hook can call vCoRoutineScheduler() within an\r
+ // infinite loop.\r
+ void vApplicationIdleHook( void )\r
+ {\r
+    for( ;; )\r
+    {\r
+        vCoRoutineSchedule();\r
+    }\r
+ }\r
+ </pre>\r
+ * \defgroup vCoRoutineSchedule vCoRoutineSchedule\r
+ * \ingroup Tasks\r
+ */\r
+void vCoRoutineSchedule( void );\r
+\r
+/**\r
+ * croutine. h\r
+ * <pre>\r
+ crSTART( CoRoutineHandle_t xHandle );</pre>\r
+ *\r
+ * This macro MUST always be called at the start of a co-routine function.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ // Co-routine to be created.\r
+ void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
+ {\r
+ // Variables in co-routines must be declared static if they must maintain value across a blocking call.\r
+ static int32_t ulAVariable;\r
+\r
+     // Must start every co-routine with a call to crSTART();\r
+     crSTART( xHandle );\r
+\r
+     for( ;; )\r
+     {\r
+          // Co-routine functionality goes here.\r
+     }\r
+\r
+     // Must end every co-routine with a call to crEND();\r
+     crEND();\r
+ }</pre>\r
+ * \defgroup crSTART crSTART\r
+ * \ingroup Tasks\r
+ */\r
+#define crSTART( pxCRCB ) switch( ( ( CRCB_t * )( pxCRCB ) )->uxState ) { case 0:\r
+\r
+/**\r
+ * croutine. h\r
+ * <pre>\r
+ crEND();</pre>\r
+ *\r
+ * This macro MUST always be called at the end of a co-routine function.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ // Co-routine to be created.\r
+ void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
+ {\r
+ // Variables in co-routines must be declared static if they must maintain value across a blocking call.\r
+ static int32_t ulAVariable;\r
+\r
+     // Must start every co-routine with a call to crSTART();\r
+     crSTART( xHandle );\r
+\r
+     for( ;; )\r
+     {\r
+          // Co-routine functionality goes here.\r
+     }\r
+\r
+     // Must end every co-routine with a call to crEND();\r
+     crEND();\r
+ }</pre>\r
+ * \defgroup crSTART crSTART\r
+ * \ingroup Tasks\r
+ */\r
+#define crEND() }\r
+\r
+/*\r
+ * These macros are intended for internal use by the co-routine implementation\r
+ * only.  The macros should not be used directly by application writers.\r
+ */\r
+#define crSET_STATE0( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2):\r
+#define crSET_STATE1( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1):\r
+\r
+/**\r
+ * croutine. h\r
+ *<pre>\r
+ crDELAY( CoRoutineHandle_t xHandle, TickType_t xTicksToDelay );</pre>\r
+ *\r
+ * Delay a co-routine for a fixed period of time.\r
+ *\r
+ * crDELAY can only be called from the co-routine function itself - not\r
+ * from within a function called by the co-routine function.  This is because\r
+ * co-routines do not maintain their own stack.\r
+ *\r
+ * @param xHandle The handle of the co-routine to delay.  This is the xHandle\r
+ * parameter of the co-routine function.\r
+ *\r
+ * @param xTickToDelay The number of ticks that the co-routine should delay\r
+ * for.  The actual amount of time this equates to is defined by\r
+ * configTICK_RATE_HZ (set in FreeRTOSConfig.h).  The constant portTICK_PERIOD_MS\r
+ * can be used to convert ticks to milliseconds.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ // Co-routine to be created.\r
+ void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
+ {\r
+ // Variables in co-routines must be declared static if they must maintain value across a blocking call.\r
+ // This may not be necessary for const variables.\r
+ // We are to delay for 200ms.\r
+ static const xTickType xDelayTime = 200 / portTICK_PERIOD_MS;\r
+\r
+     // Must start every co-routine with a call to crSTART();\r
+     crSTART( xHandle );\r
+\r
+     for( ;; )\r
+     {\r
+        // Delay for 200ms.\r
+        crDELAY( xHandle, xDelayTime );\r
+\r
+        // Do something here.\r
+     }\r
+\r
+     // Must end every co-routine with a call to crEND();\r
+     crEND();\r
+ }</pre>\r
+ * \defgroup crDELAY crDELAY\r
+ * \ingroup Tasks\r
+ */\r
+#define crDELAY( xHandle, xTicksToDelay )                                                                                              \\r
+       if( ( xTicksToDelay ) > 0 )                                                                                                                     \\r
+       {                                                                                                                                                                       \\r
+               vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL );                                                  \\r
+       }                                                                                                                                                                       \\r
+       crSET_STATE0( ( xHandle ) );\r
+\r
+/**\r
+ * <pre>\r
+ crQUEUE_SEND(\r
+                  CoRoutineHandle_t xHandle,\r
+                  QueueHandle_t pxQueue,\r
+                  void *pvItemToQueue,\r
+                  TickType_t xTicksToWait,\r
+                  BaseType_t *pxResult\r
+             )</pre>\r
+ *\r
+ * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine\r
+ * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks.\r
+ *\r
+ * crQUEUE_SEND and crQUEUE_RECEIVE can only be used from a co-routine whereas\r
+ * xQueueSend() and xQueueReceive() can only be used from tasks.\r
+ *\r
+ * crQUEUE_SEND can only be called from the co-routine function itself - not\r
+ * from within a function called by the co-routine function.  This is because\r
+ * co-routines do not maintain their own stack.\r
+ *\r
+ * See the co-routine section of the WEB documentation for information on\r
+ * passing data between tasks and co-routines and between ISR's and\r
+ * co-routines.\r
+ *\r
+ * @param xHandle The handle of the calling co-routine.  This is the xHandle\r
+ * parameter of the co-routine function.\r
+ *\r
+ * @param pxQueue The handle of the queue on which the data will be posted.\r
+ * The handle is obtained as the return value when the queue is created using\r
+ * the xQueueCreate() API function.\r
+ *\r
+ * @param pvItemToQueue A pointer to the data being posted onto the queue.\r
+ * The number of bytes of each queued item is specified when the queue is\r
+ * created.  This number of bytes is copied from pvItemToQueue into the queue\r
+ * itself.\r
+ *\r
+ * @param xTickToDelay The number of ticks that the co-routine should block\r
+ * to wait for space to become available on the queue, should space not be\r
+ * available immediately. The actual amount of time this equates to is defined\r
+ * by configTICK_RATE_HZ (set in FreeRTOSConfig.h).  The constant\r
+ * portTICK_PERIOD_MS can be used to convert ticks to milliseconds (see example\r
+ * below).\r
+ *\r
+ * @param pxResult The variable pointed to by pxResult will be set to pdPASS if\r
+ * data was successfully posted onto the queue, otherwise it will be set to an\r
+ * error defined within ProjDefs.h.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ // Co-routine function that blocks for a fixed period then posts a number onto\r
+ // a queue.\r
+ static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
+ {\r
+ // Variables in co-routines must be declared static if they must maintain value across a blocking call.\r
+ static BaseType_t xNumberToPost = 0;\r
+ static BaseType_t xResult;\r
+\r
+    // Co-routines must begin with a call to crSTART().\r
+    crSTART( xHandle );\r
+\r
+    for( ;; )\r
+    {\r
+        // This assumes the queue has already been created.\r
+        crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult );\r
+\r
+        if( xResult != pdPASS )\r
+        {\r
+            // The message was not posted!\r
+        }\r
+\r
+        // Increment the number to be posted onto the queue.\r
+        xNumberToPost++;\r
+\r
+        // Delay for 100 ticks.\r
+        crDELAY( xHandle, 100 );\r
+    }\r
+\r
+    // Co-routines must end with a call to crEND().\r
+    crEND();\r
+ }</pre>\r
+ * \defgroup crQUEUE_SEND crQUEUE_SEND\r
+ * \ingroup Tasks\r
+ */\r
+#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult )                        \\r
+{                                                                                                                                                                              \\r
+       *( pxResult ) = xQueueCRSend( ( pxQueue) , ( pvItemToQueue) , ( xTicksToWait ) );       \\r
+       if( *( pxResult ) == errQUEUE_BLOCKED )                                                                                         \\r
+       {                                                                                                                                                                       \\r
+               crSET_STATE0( ( xHandle ) );                                                                                                    \\r
+               *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 );                                  \\r
+       }                                                                                                                                                                       \\r
+       if( *pxResult == errQUEUE_YIELD )                                                                                                       \\r
+       {                                                                                                                                                                       \\r
+               crSET_STATE1( ( xHandle ) );                                                                                                    \\r
+               *pxResult = pdPASS;                                                                                                                             \\r
+       }                                                                                                                                                                       \\r
+}\r
+\r
+/**\r
+ * croutine. h\r
+ * <pre>\r
+  crQUEUE_RECEIVE(\r
+                     CoRoutineHandle_t xHandle,\r
+                     QueueHandle_t pxQueue,\r
+                     void *pvBuffer,\r
+                     TickType_t xTicksToWait,\r
+                     BaseType_t *pxResult\r
+                 )</pre>\r
+ *\r
+ * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine\r
+ * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks.\r
+ *\r
+ * crQUEUE_SEND and crQUEUE_RECEIVE can only be used from a co-routine whereas\r
+ * xQueueSend() and xQueueReceive() can only be used from tasks.\r
+ *\r
+ * crQUEUE_RECEIVE can only be called from the co-routine function itself - not\r
+ * from within a function called by the co-routine function.  This is because\r
+ * co-routines do not maintain their own stack.\r
+ *\r
+ * See the co-routine section of the WEB documentation for information on\r
+ * passing data between tasks and co-routines and between ISR's and\r
+ * co-routines.\r
+ *\r
+ * @param xHandle The handle of the calling co-routine.  This is the xHandle\r
+ * parameter of the co-routine function.\r
+ *\r
+ * @param pxQueue The handle of the queue from which the data will be received.\r
+ * The handle is obtained as the return value when the queue is created using\r
+ * the xQueueCreate() API function.\r
+ *\r
+ * @param pvBuffer The buffer into which the received item is to be copied.\r
+ * The number of bytes of each queued item is specified when the queue is\r
+ * created.  This number of bytes is copied into pvBuffer.\r
+ *\r
+ * @param xTickToDelay The number of ticks that the co-routine should block\r
+ * to wait for data to become available from the queue, should data not be\r
+ * available immediately. The actual amount of time this equates to is defined\r
+ * by configTICK_RATE_HZ (set in FreeRTOSConfig.h).  The constant\r
+ * portTICK_PERIOD_MS can be used to convert ticks to milliseconds (see the\r
+ * crQUEUE_SEND example).\r
+ *\r
+ * @param pxResult The variable pointed to by pxResult will be set to pdPASS if\r
+ * data was successfully retrieved from the queue, otherwise it will be set to\r
+ * an error code as defined within ProjDefs.h.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ // A co-routine receives the number of an LED to flash from a queue.  It\r
+ // blocks on the queue until the number is received.\r
+ static void prvCoRoutineFlashWorkTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
+ {\r
+ // Variables in co-routines must be declared static if they must maintain value across a blocking call.\r
+ static BaseType_t xResult;\r
+ static UBaseType_t uxLEDToFlash;\r
+\r
+    // All co-routines must start with a call to crSTART().\r
+    crSTART( xHandle );\r
+\r
+    for( ;; )\r
+    {\r
+        // Wait for data to become available on the queue.\r
+        crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );\r
+\r
+        if( xResult == pdPASS )\r
+        {\r
+            // We received the LED to flash - flash it!\r
+            vParTestToggleLED( uxLEDToFlash );\r
+        }\r
+    }\r
+\r
+    crEND();\r
+ }</pre>\r
+ * \defgroup crQUEUE_RECEIVE crQUEUE_RECEIVE\r
+ * \ingroup Tasks\r
+ */\r
+#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult )                  \\r
+{                                                                                                                                                                              \\r
+       *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), ( xTicksToWait ) );         \\r
+       if( *( pxResult ) == errQUEUE_BLOCKED )                                                                                         \\r
+       {                                                                                                                                                                       \\r
+               crSET_STATE0( ( xHandle ) );                                                                                                    \\r
+               *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), 0 );                                \\r
+       }                                                                                                                                                                       \\r
+       if( *( pxResult ) == errQUEUE_YIELD )                                                                                           \\r
+       {                                                                                                                                                                       \\r
+               crSET_STATE1( ( xHandle ) );                                                                                                    \\r
+               *( pxResult ) = pdPASS;                                                                                                                 \\r
+       }                                                                                                                                                                       \\r
+}\r
+\r
+/**\r
+ * croutine. h\r
+ * <pre>\r
+  crQUEUE_SEND_FROM_ISR(\r
+                            QueueHandle_t pxQueue,\r
+                            void *pvItemToQueue,\r
+                            BaseType_t xCoRoutinePreviouslyWoken\r
+                       )</pre>\r
+ *\r
+ * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the\r
+ * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR()\r
+ * functions used by tasks.\r
+ *\r
+ * crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() can only be used to\r
+ * pass data between a co-routine and and ISR, whereas xQueueSendFromISR() and\r
+ * xQueueReceiveFromISR() can only be used to pass data between a task and and\r
+ * ISR.\r
+ *\r
+ * crQUEUE_SEND_FROM_ISR can only be called from an ISR to send data to a queue\r
+ * that is being used from within a co-routine.\r
+ *\r
+ * See the co-routine section of the WEB documentation for information on\r
+ * passing data between tasks and co-routines and between ISR's and\r
+ * co-routines.\r
+ *\r
+ * @param xQueue The handle to the queue on which the item is to be posted.\r
+ *\r
+ * @param pvItemToQueue A pointer to the item that is to be placed on the\r
+ * queue.  The size of the items the queue will hold was defined when the\r
+ * queue was created, so this many bytes will be copied from pvItemToQueue\r
+ * into the queue storage area.\r
+ *\r
+ * @param xCoRoutinePreviouslyWoken This is included so an ISR can post onto\r
+ * the same queue multiple times from a single interrupt.  The first call\r
+ * should always pass in pdFALSE.  Subsequent calls should pass in\r
+ * the value returned from the previous call.\r
+ *\r
+ * @return pdTRUE if a co-routine was woken by posting onto the queue.  This is\r
+ * used by the ISR to determine if a context switch may be required following\r
+ * the ISR.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ // A co-routine that blocks on a queue waiting for characters to be received.\r
+ static void vReceivingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
+ {\r
+ char cRxedChar;\r
+ BaseType_t xResult;\r
+\r
+     // All co-routines must start with a call to crSTART().\r
+     crSTART( xHandle );\r
+\r
+     for( ;; )\r
+     {\r
+         // Wait for data to become available on the queue.  This assumes the\r
+         // queue xCommsRxQueue has already been created!\r
+         crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );\r
+\r
+         // Was a character received?\r
+         if( xResult == pdPASS )\r
+         {\r
+             // Process the character here.\r
+         }\r
+     }\r
+\r
+     // All co-routines must end with a call to crEND().\r
+     crEND();\r
+ }\r
+\r
+ // An ISR that uses a queue to send characters received on a serial port to\r
+ // a co-routine.\r
+ void vUART_ISR( void )\r
+ {\r
+ char cRxedChar;\r
+ BaseType_t xCRWokenByPost = pdFALSE;\r
+\r
+     // We loop around reading characters until there are none left in the UART.\r
+     while( UART_RX_REG_NOT_EMPTY() )\r
+     {\r
+         // Obtain the character from the UART.\r
+         cRxedChar = UART_RX_REG;\r
+\r
+         // Post the character onto a queue.  xCRWokenByPost will be pdFALSE\r
+         // the first time around the loop.  If the post causes a co-routine\r
+         // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE.\r
+         // In this manner we can ensure that if more than one co-routine is\r
+         // blocked on the queue only one is woken by this ISR no matter how\r
+         // many characters are posted to the queue.\r
+         xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost );\r
+     }\r
+ }</pre>\r
+ * \defgroup crQUEUE_SEND_FROM_ISR crQUEUE_SEND_FROM_ISR\r
+ * \ingroup Tasks\r
+ */\r
+#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) )\r
+\r
+\r
+/**\r
+ * croutine. h\r
+ * <pre>\r
+  crQUEUE_SEND_FROM_ISR(\r
+                            QueueHandle_t pxQueue,\r
+                            void *pvBuffer,\r
+                            BaseType_t * pxCoRoutineWoken\r
+                       )</pre>\r
+ *\r
+ * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the\r
+ * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR()\r
+ * functions used by tasks.\r
+ *\r
+ * crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() can only be used to\r
+ * pass data between a co-routine and and ISR, whereas xQueueSendFromISR() and\r
+ * xQueueReceiveFromISR() can only be used to pass data between a task and and\r
+ * ISR.\r
+ *\r
+ * crQUEUE_RECEIVE_FROM_ISR can only be called from an ISR to receive data\r
+ * from a queue that is being used from within a co-routine (a co-routine\r
+ * posted to the queue).\r
+ *\r
+ * See the co-routine section of the WEB documentation for information on\r
+ * passing data between tasks and co-routines and between ISR's and\r
+ * co-routines.\r
+ *\r
+ * @param xQueue The handle to the queue on which the item is to be posted.\r
+ *\r
+ * @param pvBuffer A pointer to a buffer into which the received item will be\r
+ * placed.  The size of the items the queue will hold was defined when the\r
+ * queue was created, so this many bytes will be copied from the queue into\r
+ * pvBuffer.\r
+ *\r
+ * @param pxCoRoutineWoken A co-routine may be blocked waiting for space to become\r
+ * available on the queue.  If crQUEUE_RECEIVE_FROM_ISR causes such a\r
+ * co-routine to unblock *pxCoRoutineWoken will get set to pdTRUE, otherwise\r
+ * *pxCoRoutineWoken will remain unchanged.\r
+ *\r
+ * @return pdTRUE an item was successfully received from the queue, otherwise\r
+ * pdFALSE.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ // A co-routine that posts a character to a queue then blocks for a fixed\r
+ // period.  The character is incremented each time.\r
+ static void vSendingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
+ {\r
+ // cChar holds its value while this co-routine is blocked and must therefore\r
+ // be declared static.\r
+ static char cCharToTx = 'a';\r
+ BaseType_t xResult;\r
+\r
+     // All co-routines must start with a call to crSTART().\r
+     crSTART( xHandle );\r
+\r
+     for( ;; )\r
+     {\r
+         // Send the next character to the queue.\r
+         crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult );\r
+\r
+         if( xResult == pdPASS )\r
+         {\r
+             // The character was successfully posted to the queue.\r
+         }\r
+                else\r
+                {\r
+                       // Could not post the character to the queue.\r
+                }\r
+\r
+         // Enable the UART Tx interrupt to cause an interrupt in this\r
+                // hypothetical UART.  The interrupt will obtain the character\r
+                // from the queue and send it.\r
+                ENABLE_RX_INTERRUPT();\r
+\r
+                // Increment to the next character then block for a fixed period.\r
+                // cCharToTx will maintain its value across the delay as it is\r
+                // declared static.\r
+                cCharToTx++;\r
+                if( cCharToTx > 'x' )\r
+                {\r
+                       cCharToTx = 'a';\r
+                }\r
+                crDELAY( 100 );\r
+     }\r
+\r
+     // All co-routines must end with a call to crEND().\r
+     crEND();\r
+ }\r
+\r
+ // An ISR that uses a queue to receive characters to send on a UART.\r
+ void vUART_ISR( void )\r
+ {\r
+ char cCharToTx;\r
+ BaseType_t xCRWokenByPost = pdFALSE;\r
+\r
+     while( UART_TX_REG_EMPTY() )\r
+     {\r
+         // Are there any characters in the queue waiting to be sent?\r
+                // xCRWokenByPost will automatically be set to pdTRUE if a co-routine\r
+                // is woken by the post - ensuring that only a single co-routine is\r
+                // woken no matter how many times we go around this loop.\r
+         if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) )\r
+                {\r
+                        SEND_CHARACTER( cCharToTx );\r
+                }\r
+     }\r
+ }</pre>\r
+ * \defgroup crQUEUE_RECEIVE_FROM_ISR crQUEUE_RECEIVE_FROM_ISR\r
+ * \ingroup Tasks\r
+ */\r
+#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) )\r
+\r
+/*\r
+ * This function is intended for internal use by the co-routine macros only.\r
+ * The macro nature of the co-routine implementation requires that the\r
+ * prototype appears here.  The function should not be used by application\r
+ * writers.\r
+ *\r
+ * Removes the current co-routine from its ready list and places it in the\r
+ * appropriate delayed list.\r
+ */\r
+void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList );\r
+\r
+/*\r
+ * This function is intended for internal use by the queue implementation only.\r
+ * The function should not be used by application writers.\r
+ *\r
+ * Removes the highest priority co-routine from the event list and places it in\r
+ * the pending ready list.\r
+ */\r
+BaseType_t xCoRoutineRemoveFromEventList( const List_t *pxEventList );\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* CO_ROUTINE_H */\r
diff --git a/os/8.2.2/include/os/deprecated_definitions.h b/os/8.2.2/include/os/deprecated_definitions.h
new file mode 100644 (file)
index 0000000..d904a2e
--- /dev/null
@@ -0,0 +1,321 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+#ifndef DEPRECATED_DEFINITIONS_H\r
+#define DEPRECATED_DEFINITIONS_H\r
+\r
+\r
+/* Each FreeRTOS port has a unique portmacro.h header file.  Originally a\r
+pre-processor definition was used to ensure the pre-processor found the correct\r
+portmacro.h file for the port being used.  That scheme was deprecated in favour\r
+of setting the compiler's include path such that it found the correct\r
+portmacro.h file - removing the need for the constant and allowing the\r
+portmacro.h file to be located anywhere in relation to the port being used.  The\r
+definitions below remain in the code for backward compatibility only.  New\r
+projects should not use them. */\r
+\r
+#ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT\r
+       #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h"\r
+       typedef void ( __interrupt __far *pxISR )();\r
+#endif\r
+\r
+#ifdef OPEN_WATCOM_FLASH_LITE_186_PORT\r
+       #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h"\r
+       typedef void ( __interrupt __far *pxISR )();\r
+#endif\r
+\r
+#ifdef GCC_MEGA_AVR\r
+       #include "../portable/GCC/ATMega323/portmacro.h"\r
+#endif\r
+\r
+#ifdef IAR_MEGA_AVR\r
+       #include "../portable/IAR/ATMega323/portmacro.h"\r
+#endif\r
+\r
+#ifdef MPLAB_PIC24_PORT\r
+       #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h"\r
+#endif\r
+\r
+#ifdef MPLAB_DSPIC_PORT\r
+       #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h"\r
+#endif\r
+\r
+#ifdef MPLAB_PIC18F_PORT\r
+       #include "../../Source/portable/MPLAB/PIC18F/portmacro.h"\r
+#endif\r
+\r
+#ifdef MPLAB_PIC32MX_PORT\r
+       #include "../../Source/portable/MPLAB/PIC32MX/portmacro.h"\r
+#endif\r
+\r
+#ifdef _FEDPICC\r
+       #include "libFreeRTOS/Include/portmacro.h"\r
+#endif\r
+\r
+#ifdef SDCC_CYGNAL\r
+       #include "../../Source/portable/SDCC/Cygnal/portmacro.h"\r
+#endif\r
+\r
+#ifdef GCC_ARM7\r
+       #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h"\r
+#endif\r
+\r
+#ifdef GCC_ARM7_ECLIPSE\r
+       #include "portmacro.h"\r
+#endif\r
+\r
+#ifdef ROWLEY_LPC23xx\r
+       #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h"\r
+#endif\r
+\r
+#ifdef IAR_MSP430\r
+       #include "..\..\Source\portable\IAR\MSP430\portmacro.h"\r
+#endif\r
+\r
+#ifdef GCC_MSP430\r
+       #include "../../Source/portable/GCC/MSP430F449/portmacro.h"\r
+#endif\r
+\r
+#ifdef ROWLEY_MSP430\r
+       #include "../../Source/portable/Rowley/MSP430F449/portmacro.h"\r
+#endif\r
+\r
+#ifdef ARM7_LPC21xx_KEIL_RVDS\r
+       #include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h"\r
+#endif\r
+\r
+#ifdef SAM7_GCC\r
+       #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h"\r
+#endif\r
+\r
+#ifdef SAM7_IAR\r
+       #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h"\r
+#endif\r
+\r
+#ifdef SAM9XE_IAR\r
+       #include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h"\r
+#endif\r
+\r
+#ifdef LPC2000_IAR\r
+       #include "..\..\Source\portable\IAR\LPC2000\portmacro.h"\r
+#endif\r
+\r
+#ifdef STR71X_IAR\r
+       #include "..\..\Source\portable\IAR\STR71x\portmacro.h"\r
+#endif\r
+\r
+#ifdef STR75X_IAR\r
+       #include "..\..\Source\portable\IAR\STR75x\portmacro.h"\r
+#endif\r
+\r
+#ifdef STR75X_GCC\r
+       #include "..\..\Source\portable\GCC\STR75x\portmacro.h"\r
+#endif\r
+\r
+#ifdef STR91X_IAR\r
+       #include "..\..\Source\portable\IAR\STR91x\portmacro.h"\r
+#endif\r
+\r
+#ifdef GCC_H8S\r
+       #include "../../Source/portable/GCC/H8S2329/portmacro.h"\r
+#endif\r
+\r
+#ifdef GCC_AT91FR40008\r
+       #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h"\r
+#endif\r
+\r
+#ifdef RVDS_ARMCM3_LM3S102\r
+       #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h"\r
+#endif\r
+\r
+#ifdef GCC_ARMCM3_LM3S102\r
+       #include "../../Source/portable/GCC/ARM_CM3/portmacro.h"\r
+#endif\r
+\r
+#ifdef GCC_ARMCM3\r
+       #include "../../Source/portable/GCC/ARM_CM3/portmacro.h"\r
+#endif\r
+\r
+#ifdef IAR_ARM_CM3\r
+       #include "../../Source/portable/IAR/ARM_CM3/portmacro.h"\r
+#endif\r
+\r
+#ifdef IAR_ARMCM3_LM\r
+       #include "../../Source/portable/IAR/ARM_CM3/portmacro.h"\r
+#endif\r
+\r
+#ifdef HCS12_CODE_WARRIOR\r
+       #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h"\r
+#endif\r
+\r
+#ifdef MICROBLAZE_GCC\r
+       #include "../../Source/portable/GCC/MicroBlaze/portmacro.h"\r
+#endif\r
+\r
+#ifdef TERN_EE\r
+       #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h"\r
+#endif\r
+\r
+#ifdef GCC_HCS12\r
+       #include "../../Source/portable/GCC/HCS12/portmacro.h"\r
+#endif\r
+\r
+#ifdef GCC_MCF5235\r
+    #include "../../Source/portable/GCC/MCF5235/portmacro.h"\r
+#endif\r
+\r
+#ifdef COLDFIRE_V2_GCC\r
+       #include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h"\r
+#endif\r
+\r
+#ifdef COLDFIRE_V2_CODEWARRIOR\r
+       #include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h"\r
+#endif\r
+\r
+#ifdef GCC_PPC405\r
+       #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h"\r
+#endif\r
+\r
+#ifdef GCC_PPC440\r
+       #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h"\r
+#endif\r
+\r
+#ifdef _16FX_SOFTUNE\r
+       #include "..\..\Source\portable\Softune\MB96340\portmacro.h"\r
+#endif\r
+\r
+#ifdef BCC_INDUSTRIAL_PC_PORT\r
+       /* A short file name has to be used in place of the normal\r
+       FreeRTOSConfig.h when using the Borland compiler. */\r
+       #include "frconfig.h"\r
+       #include "..\portable\BCC\16BitDOS\PC\prtmacro.h"\r
+    typedef void ( __interrupt __far *pxISR )();\r
+#endif\r
+\r
+#ifdef BCC_FLASH_LITE_186_PORT\r
+       /* A short file name has to be used in place of the normal\r
+       FreeRTOSConfig.h when using the Borland compiler. */\r
+       #include "frconfig.h"\r
+       #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h"\r
+    typedef void ( __interrupt __far *pxISR )();\r
+#endif\r
+\r
+#ifdef __GNUC__\r
+   #ifdef __AVR32_AVR32A__\r
+          #include "portmacro.h"\r
+   #endif\r
+#endif\r
+\r
+#ifdef __ICCAVR32__\r
+   #ifdef __CORE__\r
+      #if __CORE__ == __AVR32A__\r
+             #include "portmacro.h"\r
+      #endif\r
+   #endif\r
+#endif\r
+\r
+#ifdef __91467D\r
+       #include "portmacro.h"\r
+#endif\r
+\r
+#ifdef __96340\r
+       #include "portmacro.h"\r
+#endif\r
+\r
+\r
+#ifdef __IAR_V850ES_Fx3__\r
+       #include "../../Source/portable/IAR/V850ES/portmacro.h"\r
+#endif\r
+\r
+#ifdef __IAR_V850ES_Jx3__\r
+       #include "../../Source/portable/IAR/V850ES/portmacro.h"\r
+#endif\r
+\r
+#ifdef __IAR_V850ES_Jx3_L__\r
+       #include "../../Source/portable/IAR/V850ES/portmacro.h"\r
+#endif\r
+\r
+#ifdef __IAR_V850ES_Jx2__\r
+       #include "../../Source/portable/IAR/V850ES/portmacro.h"\r
+#endif\r
+\r
+#ifdef __IAR_V850ES_Hx2__\r
+       #include "../../Source/portable/IAR/V850ES/portmacro.h"\r
+#endif\r
+\r
+#ifdef __IAR_78K0R_Kx3__\r
+       #include "../../Source/portable/IAR/78K0R/portmacro.h"\r
+#endif\r
+\r
+#ifdef __IAR_78K0R_Kx3L__\r
+       #include "../../Source/portable/IAR/78K0R/portmacro.h"\r
+#endif\r
+\r
+#endif /* DEPRECATED_DEFINITIONS_H */\r
+\r
diff --git a/os/8.2.2/include/os/event_groups.h b/os/8.2.2/include/os/event_groups.h
new file mode 100644 (file)
index 0000000..106ed60
--- /dev/null
@@ -0,0 +1,730 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+#ifndef EVENT_GROUPS_H\r
+#define EVENT_GROUPS_H\r
+\r
+#ifndef INC_FREERTOS_H\r
+       #error "include FreeRTOS.h" must appear in source files before "include event_groups.h"\r
+#endif\r
+\r
+#include "timers.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/**\r
+ * An event group is a collection of bits to which an application can assign a\r
+ * meaning.  For example, an application may create an event group to convey\r
+ * the status of various CAN bus related events in which bit 0 might mean "A CAN\r
+ * message has been received and is ready for processing", bit 1 might mean "The\r
+ * application has queued a message that is ready for sending onto the CAN\r
+ * network", and bit 2 might mean "It is time to send a SYNC message onto the\r
+ * CAN network" etc.  A task can then test the bit values to see which events\r
+ * are active, and optionally enter the Blocked state to wait for a specified\r
+ * bit or a group of specified bits to be active.  To continue the CAN bus\r
+ * example, a CAN controlling task can enter the Blocked state (and therefore\r
+ * not consume any processing time) until either bit 0, bit 1 or bit 2 are\r
+ * active, at which time the bit that was actually active would inform the task\r
+ * which action it had to take (process a received message, send a message, or\r
+ * send a SYNC).\r
+ *\r
+ * The event groups implementation contains intelligence to avoid race\r
+ * conditions that would otherwise occur were an application to use a simple\r
+ * variable for the same purpose.  This is particularly important with respect\r
+ * to when a bit within an event group is to be cleared, and when bits have to\r
+ * be set and then tested atomically - as is the case where event groups are\r
+ * used to create a synchronisation point between multiple tasks (a\r
+ * 'rendezvous').\r
+ *\r
+ * \defgroup EventGroup\r
+ */\r
+\r
+\r
+\r
+/**\r
+ * event_groups.h\r
+ *\r
+ * Type by which event groups are referenced.  For example, a call to\r
+ * xEventGroupCreate() returns an EventGroupHandle_t variable that can then\r
+ * be used as a parameter to other event group functions.\r
+ *\r
+ * \defgroup EventGroupHandle_t EventGroupHandle_t\r
+ * \ingroup EventGroup\r
+ */\r
+typedef void * EventGroupHandle_t;\r
+\r
+/* \r
+ * The type that holds event bits always matches TickType_t - therefore the\r
+ * number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1,\r
+ * 32 bits if set to 0. \r
+ *\r
+ * \defgroup EventBits_t EventBits_t\r
+ * \ingroup EventGroup\r
+ */\r
+typedef TickType_t EventBits_t;\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+ EventGroupHandle_t xEventGroupCreate( void );\r
+ </pre>\r
+ *\r
+ * Create a new event group.  This function cannot be called from an interrupt.\r
+ *\r
+ * Although event groups are not related to ticks, for internal implementation\r
+ * reasons the number of bits available for use in an event group is dependent\r
+ * on the configUSE_16_BIT_TICKS setting in FreeRTOSConfig.h.  If\r
+ * configUSE_16_BIT_TICKS is 1 then each event group contains 8 usable bits (bit\r
+ * 0 to bit 7).  If configUSE_16_BIT_TICKS is set to 0 then each event group has\r
+ * 24 usable bits (bit 0 to bit 23).  The EventBits_t type is used to store\r
+ * event bits within an event group.\r
+ *\r
+ * @return If the event group was created then a handle to the event group is\r
+ * returned.  If there was insufficient FreeRTOS heap available to create the\r
+ * event group then NULL is returned.  See http://www.freertos.org/a00111.html\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+       // Declare a variable to hold the created event group.\r
+       EventGroupHandle_t xCreatedEventGroup;\r
+\r
+       // Attempt to create the event group.\r
+       xCreatedEventGroup = xEventGroupCreate();\r
+\r
+       // Was the event group created successfully?\r
+       if( xCreatedEventGroup == NULL )\r
+       {\r
+               // The event group was not created because there was insufficient\r
+               // FreeRTOS heap available.\r
+       }\r
+       else\r
+       {\r
+               // The event group was created.\r
+       }\r
+   </pre>\r
+ * \defgroup xEventGroupCreate xEventGroupCreate\r
+ * \ingroup EventGroup\r
+ */\r
+EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       EventBits_t xEventGroupWaitBits(        EventGroupHandle_t xEventGroup,\r
+                                                                               const EventBits_t uxBitsToWaitFor,\r
+                                                                               const BaseType_t xClearOnExit,\r
+                                                                               const BaseType_t xWaitForAllBits,\r
+                                                                               const TickType_t xTicksToWait );\r
+ </pre>\r
+ *\r
+ * [Potentially] block to wait for one or more bits to be set within a\r
+ * previously created event group.\r
+ *\r
+ * This function cannot be called from an interrupt.\r
+ *\r
+ * @param xEventGroup The event group in which the bits are being tested.  The\r
+ * event group must have previously been created using a call to\r
+ * xEventGroupCreate().\r
+ *\r
+ * @param uxBitsToWaitFor A bitwise value that indicates the bit or bits to test\r
+ * inside the event group.  For example, to wait for bit 0 and/or bit 2 set\r
+ * uxBitsToWaitFor to 0x05.  To wait for bits 0 and/or bit 1 and/or bit 2 set\r
+ * uxBitsToWaitFor to 0x07.  Etc.\r
+ *\r
+ * @param xClearOnExit If xClearOnExit is set to pdTRUE then any bits within\r
+ * uxBitsToWaitFor that are set within the event group will be cleared before\r
+ * xEventGroupWaitBits() returns if the wait condition was met (if the function\r
+ * returns for a reason other than a timeout).  If xClearOnExit is set to\r
+ * pdFALSE then the bits set in the event group are not altered when the call to\r
+ * xEventGroupWaitBits() returns.\r
+ *\r
+ * @param xWaitForAllBits If xWaitForAllBits is set to pdTRUE then\r
+ * xEventGroupWaitBits() will return when either all the bits in uxBitsToWaitFor\r
+ * are set or the specified block time expires.  If xWaitForAllBits is set to\r
+ * pdFALSE then xEventGroupWaitBits() will return when any one of the bits set\r
+ * in uxBitsToWaitFor is set or the specified block time expires.  The block\r
+ * time is specified by the xTicksToWait parameter.\r
+ *\r
+ * @param xTicksToWait The maximum amount of time (specified in 'ticks') to wait\r
+ * for one/all (depending on the xWaitForAllBits value) of the bits specified by\r
+ * uxBitsToWaitFor to become set.\r
+ *\r
+ * @return The value of the event group at the time either the bits being waited\r
+ * for became set, or the block time expired.  Test the return value to know\r
+ * which bits were set.  If xEventGroupWaitBits() returned because its timeout\r
+ * expired then not all the bits being waited for will be set.  If\r
+ * xEventGroupWaitBits() returned because the bits it was waiting for were set\r
+ * then the returned value is the event group value before any bits were\r
+ * automatically cleared in the case that xClearOnExit parameter was set to\r
+ * pdTRUE.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+   #define BIT_0       ( 1 << 0 )\r
+   #define BIT_4       ( 1 << 4 )\r
+\r
+   void aFunction( EventGroupHandle_t xEventGroup )\r
+   {\r
+   EventBits_t uxBits;\r
+   const TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;\r
+\r
+               // Wait a maximum of 100ms for either bit 0 or bit 4 to be set within\r
+               // the event group.  Clear the bits before exiting.\r
+               uxBits = xEventGroupWaitBits(\r
+                                       xEventGroup,    // The event group being tested.\r
+                                       BIT_0 | BIT_4,  // The bits within the event group to wait for.\r
+                                       pdTRUE,                 // BIT_0 and BIT_4 should be cleared before returning.\r
+                                       pdFALSE,                // Don't wait for both bits, either bit will do.\r
+                                       xTicksToWait ); // Wait a maximum of 100ms for either bit to be set.\r
+\r
+               if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )\r
+               {\r
+                       // xEventGroupWaitBits() returned because both bits were set.\r
+               }\r
+               else if( ( uxBits & BIT_0 ) != 0 )\r
+               {\r
+                       // xEventGroupWaitBits() returned because just BIT_0 was set.\r
+               }\r
+               else if( ( uxBits & BIT_4 ) != 0 )\r
+               {\r
+                       // xEventGroupWaitBits() returned because just BIT_4 was set.\r
+               }\r
+               else\r
+               {\r
+                       // xEventGroupWaitBits() returned because xTicksToWait ticks passed\r
+                       // without either BIT_0 or BIT_4 becoming set.\r
+               }\r
+   }\r
+   </pre>\r
+ * \defgroup xEventGroupWaitBits xEventGroupWaitBits\r
+ * \ingroup EventGroup\r
+ */\r
+EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear );\r
+ </pre>\r
+ *\r
+ * Clear bits within an event group.  This function cannot be called from an\r
+ * interrupt.\r
+ *\r
+ * @param xEventGroup The event group in which the bits are to be cleared.\r
+ *\r
+ * @param uxBitsToClear A bitwise value that indicates the bit or bits to clear\r
+ * in the event group.  For example, to clear bit 3 only, set uxBitsToClear to\r
+ * 0x08.  To clear bit 3 and bit 0 set uxBitsToClear to 0x09.\r
+ *\r
+ * @return The value of the event group before the specified bits were cleared.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+   #define BIT_0       ( 1 << 0 )\r
+   #define BIT_4       ( 1 << 4 )\r
+\r
+   void aFunction( EventGroupHandle_t xEventGroup )\r
+   {\r
+   EventBits_t uxBits;\r
+\r
+               // Clear bit 0 and bit 4 in xEventGroup.\r
+               uxBits = xEventGroupClearBits(\r
+                                                               xEventGroup,    // The event group being updated.\r
+                                                               BIT_0 | BIT_4 );// The bits being cleared.\r
+\r
+               if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )\r
+               {\r
+                       // Both bit 0 and bit 4 were set before xEventGroupClearBits() was\r
+                       // called.  Both will now be clear (not set).\r
+               }\r
+               else if( ( uxBits & BIT_0 ) != 0 )\r
+               {\r
+                       // Bit 0 was set before xEventGroupClearBits() was called.  It will\r
+                       // now be clear.\r
+               }\r
+               else if( ( uxBits & BIT_4 ) != 0 )\r
+               {\r
+                       // Bit 4 was set before xEventGroupClearBits() was called.  It will\r
+                       // now be clear.\r
+               }\r
+               else\r
+               {\r
+                       // Neither bit 0 nor bit 4 were set in the first place.\r
+               }\r
+   }\r
+   </pre>\r
+ * \defgroup xEventGroupClearBits xEventGroupClearBits\r
+ * \ingroup EventGroup\r
+ */\r
+EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );\r
+ </pre>\r
+ *\r
+ * A version of xEventGroupClearBits() that can be called from an interrupt.\r
+ *\r
+ * Setting bits in an event group is not a deterministic operation because there\r
+ * are an unknown number of tasks that may be waiting for the bit or bits being\r
+ * set.  FreeRTOS does not allow nondeterministic operations to be performed\r
+ * while interrupts are disabled, so protects event groups that are accessed\r
+ * from tasks by suspending the scheduler rather than disabling interrupts.  As\r
+ * a result event groups cannot be accessed directly from an interrupt service\r
+ * routine.  Therefore xEventGroupClearBitsFromISR() sends a message to the \r
+ * timer task to have the clear operation performed in the context of the timer \r
+ * task.\r
+ *\r
+ * @param xEventGroup The event group in which the bits are to be cleared.\r
+ *\r
+ * @param uxBitsToClear A bitwise value that indicates the bit or bits to clear.\r
+ * For example, to clear bit 3 only, set uxBitsToClear to 0x08.  To clear bit 3\r
+ * and bit 0 set uxBitsToClear to 0x09.\r
+ *\r
+ * @return If the request to execute the function was posted successfully then \r
+ * pdPASS is returned, otherwise pdFALSE is returned.  pdFALSE will be returned \r
+ * if the timer service queue was full.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+   #define BIT_0       ( 1 << 0 )\r
+   #define BIT_4       ( 1 << 4 )\r
+\r
+   // An event group which it is assumed has already been created by a call to\r
+   // xEventGroupCreate().\r
+   EventGroupHandle_t xEventGroup;\r
+\r
+   void anInterruptHandler( void )\r
+   {\r
+               // Clear bit 0 and bit 4 in xEventGroup.\r
+               xResult = xEventGroupClearBitsFromISR(\r
+                                                       xEventGroup,     // The event group being updated.\r
+                                                       BIT_0 | BIT_4 ); // The bits being set.\r
+\r
+               if( xResult == pdPASS )\r
+               {\r
+                       // The message was posted successfully.\r
+               }\r
+  }\r
+   </pre>\r
+ * \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR\r
+ * \ingroup EventGroup\r
+ */\r
+#if( configUSE_TRACE_FACILITY == 1 )\r
+       BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION;\r
+#else\r
+       #define xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ) xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL )\r
+#endif\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );\r
+ </pre>\r
+ *\r
+ * Set bits within an event group.\r
+ * This function cannot be called from an interrupt.  xEventGroupSetBitsFromISR()\r
+ * is a version that can be called from an interrupt.\r
+ *\r
+ * Setting bits in an event group will automatically unblock tasks that are\r
+ * blocked waiting for the bits.\r
+ *\r
+ * @param xEventGroup The event group in which the bits are to be set.\r
+ *\r
+ * @param uxBitsToSet A bitwise value that indicates the bit or bits to set.\r
+ * For example, to set bit 3 only, set uxBitsToSet to 0x08.  To set bit 3\r
+ * and bit 0 set uxBitsToSet to 0x09.\r
+ *\r
+ * @return The value of the event group at the time the call to\r
+ * xEventGroupSetBits() returns.  There are two reasons why the returned value\r
+ * might have the bits specified by the uxBitsToSet parameter cleared.  First,\r
+ * if setting a bit results in a task that was waiting for the bit leaving the\r
+ * blocked state then it is possible the bit will be cleared automatically\r
+ * (see the xClearBitOnExit parameter of xEventGroupWaitBits()).  Second, any\r
+ * unblocked (or otherwise Ready state) task that has a priority above that of\r
+ * the task that called xEventGroupSetBits() will execute and may change the\r
+ * event group value before the call to xEventGroupSetBits() returns.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+   #define BIT_0       ( 1 << 0 )\r
+   #define BIT_4       ( 1 << 4 )\r
+\r
+   void aFunction( EventGroupHandle_t xEventGroup )\r
+   {\r
+   EventBits_t uxBits;\r
+\r
+               // Set bit 0 and bit 4 in xEventGroup.\r
+               uxBits = xEventGroupSetBits(\r
+                                                       xEventGroup,    // The event group being updated.\r
+                                                       BIT_0 | BIT_4 );// The bits being set.\r
+\r
+               if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )\r
+               {\r
+                       // Both bit 0 and bit 4 remained set when the function returned.\r
+               }\r
+               else if( ( uxBits & BIT_0 ) != 0 )\r
+               {\r
+                       // Bit 0 remained set when the function returned, but bit 4 was\r
+                       // cleared.  It might be that bit 4 was cleared automatically as a\r
+                       // task that was waiting for bit 4 was removed from the Blocked\r
+                       // state.\r
+               }\r
+               else if( ( uxBits & BIT_4 ) != 0 )\r
+               {\r
+                       // Bit 4 remained set when the function returned, but bit 0 was\r
+                       // cleared.  It might be that bit 0 was cleared automatically as a\r
+                       // task that was waiting for bit 0 was removed from the Blocked\r
+                       // state.\r
+               }\r
+               else\r
+               {\r
+                       // Neither bit 0 nor bit 4 remained set.  It might be that a task\r
+                       // was waiting for both of the bits to be set, and the bits were\r
+                       // cleared as the task left the Blocked state.\r
+               }\r
+   }\r
+   </pre>\r
+ * \defgroup xEventGroupSetBits xEventGroupSetBits\r
+ * \ingroup EventGroup\r
+ */\r
+EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken );\r
+ </pre>\r
+ *\r
+ * A version of xEventGroupSetBits() that can be called from an interrupt.\r
+ *\r
+ * Setting bits in an event group is not a deterministic operation because there\r
+ * are an unknown number of tasks that may be waiting for the bit or bits being\r
+ * set.  FreeRTOS does not allow nondeterministic operations to be performed in\r
+ * interrupts or from critical sections.  Therefore xEventGroupSetBitFromISR()\r
+ * sends a message to the timer task to have the set operation performed in the\r
+ * context of the timer task - where a scheduler lock is used in place of a\r
+ * critical section.\r
+ *\r
+ * @param xEventGroup The event group in which the bits are to be set.\r
+ *\r
+ * @param uxBitsToSet A bitwise value that indicates the bit or bits to set.\r
+ * For example, to set bit 3 only, set uxBitsToSet to 0x08.  To set bit 3\r
+ * and bit 0 set uxBitsToSet to 0x09.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken As mentioned above, calling this function\r
+ * will result in a message being sent to the timer daemon task.  If the\r
+ * priority of the timer daemon task is higher than the priority of the\r
+ * currently running task (the task the interrupt interrupted) then\r
+ * *pxHigherPriorityTaskWoken will be set to pdTRUE by\r
+ * xEventGroupSetBitsFromISR(), indicating that a context switch should be\r
+ * requested before the interrupt exits.  For that reason\r
+ * *pxHigherPriorityTaskWoken must be initialised to pdFALSE.  See the\r
+ * example code below.\r
+ *\r
+ * @return If the request to execute the function was posted successfully then \r
+ * pdPASS is returned, otherwise pdFALSE is returned.  pdFALSE will be returned \r
+ * if the timer service queue was full.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+   #define BIT_0       ( 1 << 0 )\r
+   #define BIT_4       ( 1 << 4 )\r
+\r
+   // An event group which it is assumed has already been created by a call to\r
+   // xEventGroupCreate().\r
+   EventGroupHandle_t xEventGroup;\r
+\r
+   void anInterruptHandler( void )\r
+   {\r
+   BaseType_t xHigherPriorityTaskWoken, xResult;\r
+\r
+               // xHigherPriorityTaskWoken must be initialised to pdFALSE.\r
+               xHigherPriorityTaskWoken = pdFALSE;\r
+\r
+               // Set bit 0 and bit 4 in xEventGroup.\r
+               xResult = xEventGroupSetBitsFromISR(\r
+                                                       xEventGroup,    // The event group being updated.\r
+                                                       BIT_0 | BIT_4   // The bits being set.\r
+                                                       &xHigherPriorityTaskWoken );\r
+\r
+               // Was the message posted successfully?\r
+               if( xResult == pdPASS )\r
+               {\r
+                       // If xHigherPriorityTaskWoken is now set to pdTRUE then a context\r
+                       // switch should be requested.  The macro used is port specific and \r
+                       // will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - \r
+                       // refer to the documentation page for the port being used.\r
+                       portYIELD_FROM_ISR( xHigherPriorityTaskWoken );\r
+               }\r
+  }\r
+   </pre>\r
+ * \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR\r
+ * \ingroup EventGroup\r
+ */\r
+#if( configUSE_TRACE_FACILITY == 1 )\r
+       BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
+#else\r
+       #define xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ) xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken )\r
+#endif\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       EventBits_t xEventGroupSync(    EventGroupHandle_t xEventGroup,\r
+                                                                       const EventBits_t uxBitsToSet,\r
+                                                                       const EventBits_t uxBitsToWaitFor,\r
+                                                                       TickType_t xTicksToWait );\r
+ </pre>\r
+ *\r
+ * Atomically set bits within an event group, then wait for a combination of\r
+ * bits to be set within the same event group.  This functionality is typically\r
+ * used to synchronise multiple tasks, where each task has to wait for the other\r
+ * tasks to reach a synchronisation point before proceeding.\r
+ *\r
+ * This function cannot be used from an interrupt.\r
+ *\r
+ * The function will return before its block time expires if the bits specified\r
+ * by the uxBitsToWait parameter are set, or become set within that time.  In\r
+ * this case all the bits specified by uxBitsToWait will be automatically\r
+ * cleared before the function returns.\r
+ *\r
+ * @param xEventGroup The event group in which the bits are being tested.  The\r
+ * event group must have previously been created using a call to\r
+ * xEventGroupCreate().\r
+ *\r
+ * @param uxBitsToSet The bits to set in the event group before determining\r
+ * if, and possibly waiting for, all the bits specified by the uxBitsToWait\r
+ * parameter are set.\r
+ *\r
+ * @param uxBitsToWaitFor A bitwise value that indicates the bit or bits to test\r
+ * inside the event group.  For example, to wait for bit 0 and bit 2 set\r
+ * uxBitsToWaitFor to 0x05.  To wait for bits 0 and bit 1 and bit 2 set\r
+ * uxBitsToWaitFor to 0x07.  Etc.\r
+ *\r
+ * @param xTicksToWait The maximum amount of time (specified in 'ticks') to wait\r
+ * for all of the bits specified by uxBitsToWaitFor to become set.\r
+ *\r
+ * @return The value of the event group at the time either the bits being waited\r
+ * for became set, or the block time expired.  Test the return value to know\r
+ * which bits were set.  If xEventGroupSync() returned because its timeout\r
+ * expired then not all the bits being waited for will be set.  If\r
+ * xEventGroupSync() returned because all the bits it was waiting for were\r
+ * set then the returned value is the event group value before any bits were\r
+ * automatically cleared.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ // Bits used by the three tasks.\r
+ #define TASK_0_BIT            ( 1 << 0 )\r
+ #define TASK_1_BIT            ( 1 << 1 )\r
+ #define TASK_2_BIT            ( 1 << 2 )\r
+\r
+ #define ALL_SYNC_BITS ( TASK_0_BIT | TASK_1_BIT | TASK_2_BIT )\r
+\r
+ // Use an event group to synchronise three tasks.  It is assumed this event\r
+ // group has already been created elsewhere.\r
+ EventGroupHandle_t xEventBits;\r
+\r
+ void vTask0( void *pvParameters )\r
+ {\r
+ EventBits_t uxReturn;\r
+ TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;\r
+\r
+        for( ;; )\r
+        {\r
+               // Perform task functionality here.\r
+\r
+               // Set bit 0 in the event flag to note this task has reached the\r
+               // sync point.  The other two tasks will set the other two bits defined\r
+               // by ALL_SYNC_BITS.  All three tasks have reached the synchronisation\r
+               // point when all the ALL_SYNC_BITS are set.  Wait a maximum of 100ms\r
+               // for this to happen.\r
+               uxReturn = xEventGroupSync( xEventBits, TASK_0_BIT, ALL_SYNC_BITS, xTicksToWait );\r
+\r
+               if( ( uxReturn & ALL_SYNC_BITS ) == ALL_SYNC_BITS )\r
+               {\r
+                       // All three tasks reached the synchronisation point before the call\r
+                       // to xEventGroupSync() timed out.\r
+               }\r
+       }\r
+ }\r
+\r
+ void vTask1( void *pvParameters )\r
+ {\r
+        for( ;; )\r
+        {\r
+               // Perform task functionality here.\r
+\r
+               // Set bit 1 in the event flag to note this task has reached the\r
+               // synchronisation point.  The other two tasks will set the other two\r
+               // bits defined by ALL_SYNC_BITS.  All three tasks have reached the\r
+               // synchronisation point when all the ALL_SYNC_BITS are set.  Wait\r
+               // indefinitely for this to happen.\r
+               xEventGroupSync( xEventBits, TASK_1_BIT, ALL_SYNC_BITS, portMAX_DELAY );\r
+\r
+               // xEventGroupSync() was called with an indefinite block time, so\r
+               // this task will only reach here if the syncrhonisation was made by all\r
+               // three tasks, so there is no need to test the return value.\r
+        }\r
+ }\r
+\r
+ void vTask2( void *pvParameters )\r
+ {\r
+        for( ;; )\r
+        {\r
+               // Perform task functionality here.\r
+\r
+               // Set bit 2 in the event flag to note this task has reached the\r
+               // synchronisation point.  The other two tasks will set the other two\r
+               // bits defined by ALL_SYNC_BITS.  All three tasks have reached the\r
+               // synchronisation point when all the ALL_SYNC_BITS are set.  Wait\r
+               // indefinitely for this to happen.\r
+               xEventGroupSync( xEventBits, TASK_2_BIT, ALL_SYNC_BITS, portMAX_DELAY );\r
+\r
+               // xEventGroupSync() was called with an indefinite block time, so\r
+               // this task will only reach here if the syncrhonisation was made by all\r
+               // three tasks, so there is no need to test the return value.\r
+       }\r
+ }\r
+\r
+ </pre>\r
+ * \defgroup xEventGroupSync xEventGroupSync\r
+ * \ingroup EventGroup\r
+ */\r
+EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
+\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       EventBits_t xEventGroupGetBits( EventGroupHandle_t xEventGroup );\r
+ </pre>\r
+ *\r
+ * Returns the current value of the bits in an event group.  This function\r
+ * cannot be used from an interrupt.\r
+ *\r
+ * @param xEventGroup The event group being queried.\r
+ *\r
+ * @return The event group bits at the time xEventGroupGetBits() was called.\r
+ *\r
+ * \defgroup xEventGroupGetBits xEventGroupGetBits\r
+ * \ingroup EventGroup\r
+ */\r
+#define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( xEventGroup, 0 )\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup );\r
+ </pre>\r
+ *\r
+ * A version of xEventGroupGetBits() that can be called from an ISR.\r
+ *\r
+ * @param xEventGroup The event group being queried.\r
+ *\r
+ * @return The event group bits at the time xEventGroupGetBitsFromISR() was called.\r
+ *\r
+ * \defgroup xEventGroupGetBitsFromISR xEventGroupGetBitsFromISR\r
+ * \ingroup EventGroup\r
+ */\r
+EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       void xEventGroupDelete( EventGroupHandle_t xEventGroup );\r
+ </pre>\r
+ *\r
+ * Delete an event group that was previously created by a call to\r
+ * xEventGroupCreate().  Tasks that are blocked on the event group will be\r
+ * unblocked and obtain 0 as the event group's value.\r
+ *\r
+ * @param xEventGroup The event group being deleted.\r
+ */\r
+void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;\r
+\r
+/* For internal use only. */\r
+void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION;\r
+void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;\r
+\r
+#if (configUSE_TRACE_FACILITY == 1)\r
+       UBaseType_t uxEventGroupGetNumber( void* xEventGroup ) PRIVILEGED_FUNCTION;\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* EVENT_GROUPS_H */\r
+\r
+\r
diff --git a/os/8.2.2/include/os/list.h b/os/8.2.2/include/os/list.h
new file mode 100644 (file)
index 0000000..140e56c
--- /dev/null
@@ -0,0 +1,453 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+/*\r
+ * This is the list implementation used by the scheduler.  While it is tailored\r
+ * heavily for the schedulers needs, it is also available for use by\r
+ * application code.\r
+ *\r
+ * list_ts can only store pointers to list_item_ts.  Each ListItem_t contains a\r
+ * numeric value (xItemValue).  Most of the time the lists are sorted in\r
+ * descending item value order.\r
+ *\r
+ * Lists are created already containing one list item.  The value of this\r
+ * item is the maximum possible that can be stored, it is therefore always at\r
+ * the end of the list and acts as a marker.  The list member pxHead always\r
+ * points to this marker - even though it is at the tail of the list.  This\r
+ * is because the tail contains a wrap back pointer to the true head of\r
+ * the list.\r
+ *\r
+ * In addition to it's value, each list item contains a pointer to the next\r
+ * item in the list (pxNext), a pointer to the list it is in (pxContainer)\r
+ * and a pointer to back to the object that contains it.  These later two\r
+ * pointers are included for efficiency of list manipulation.  There is\r
+ * effectively a two way link between the object containing the list item and\r
+ * the list item itself.\r
+ *\r
+ *\r
+ * \page ListIntroduction List Implementation\r
+ * \ingroup FreeRTOSIntro\r
+ */\r
+\r
+#ifndef INC_FREERTOS_H\r
+       #error FreeRTOS.h must be included before list.h\r
+#endif\r
+\r
+#ifndef LIST_H\r
+#define LIST_H\r
+\r
+/*\r
+ * The list structure members are modified from within interrupts, and therefore\r
+ * by rights should be declared volatile.  However, they are only modified in a\r
+ * functionally atomic way (within critical sections of with the scheduler\r
+ * suspended) and are either passed by reference into a function or indexed via\r
+ * a volatile variable.  Therefore, in all use cases tested so far, the volatile\r
+ * qualifier can be omitted in order to provide a moderate performance\r
+ * improvement without adversely affecting functional behaviour.  The assembly\r
+ * instructions generated by the IAR, ARM and GCC compilers when the respective\r
+ * compiler's options were set for maximum optimisation has been inspected and\r
+ * deemed to be as intended.  That said, as compiler technology advances, and\r
+ * especially if aggressive cross module optimisation is used (a use case that\r
+ * has not been exercised to any great extend) then it is feasible that the\r
+ * volatile qualifier will be needed for correct optimisation.  It is expected\r
+ * that a compiler removing essential code because, without the volatile\r
+ * qualifier on the list structure members and with aggressive cross module\r
+ * optimisation, the compiler deemed the code unnecessary will result in\r
+ * complete and obvious failure of the scheduler.  If this is ever experienced\r
+ * then the volatile qualifier can be inserted in the relevant places within the\r
+ * list structures by simply defining configLIST_VOLATILE to volatile in\r
+ * FreeRTOSConfig.h (as per the example at the bottom of this comment block).\r
+ * If configLIST_VOLATILE is not defined then the preprocessor directives below\r
+ * will simply #define configLIST_VOLATILE away completely.\r
+ *\r
+ * To use volatile list structure members then add the following line to\r
+ * FreeRTOSConfig.h (without the quotes):\r
+ * "#define configLIST_VOLATILE volatile"\r
+ */\r
+#ifndef configLIST_VOLATILE\r
+       #define configLIST_VOLATILE\r
+#endif /* configSUPPORT_CROSS_MODULE_OPTIMISATION */\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/* Macros that can be used to place known values within the list structures,\r
+then check that the known values do not get corrupted during the execution of\r
+the application.   These may catch the list data structures being overwritten in\r
+memory.  They will not catch data errors caused by incorrect configuration or\r
+use of FreeRTOS.*/\r
+#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 )\r
+       /* Define the macros to do nothing. */\r
+       #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE\r
+       #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE\r
+       #define listFIRST_LIST_INTEGRITY_CHECK_VALUE\r
+       #define listSECOND_LIST_INTEGRITY_CHECK_VALUE\r
+       #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem )\r
+       #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem )\r
+       #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList )\r
+       #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList )\r
+       #define listTEST_LIST_ITEM_INTEGRITY( pxItem )\r
+       #define listTEST_LIST_INTEGRITY( pxList )\r
+#else\r
+       /* Define macros that add new members into the list structures. */\r
+       #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE                               TickType_t xListItemIntegrityValue1;\r
+       #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE                              TickType_t xListItemIntegrityValue2;\r
+       #define listFIRST_LIST_INTEGRITY_CHECK_VALUE                                    TickType_t xListIntegrityValue1;\r
+       #define listSECOND_LIST_INTEGRITY_CHECK_VALUE                                   TickType_t xListIntegrityValue2;\r
+\r
+       /* Define macros that set the new structure members to known values. */\r
+       #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem )         ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE\r
+       #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem )        ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE\r
+       #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList )          ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE\r
+       #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList )          ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE\r
+\r
+       /* Define macros that will assert if one of the structure members does not\r
+       contain its expected value. */\r
+       #define listTEST_LIST_ITEM_INTEGRITY( pxItem )          configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) )\r
+       #define listTEST_LIST_INTEGRITY( pxList )                       configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) )\r
+#endif /* configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES */\r
+\r
+\r
+/*\r
+ * Definition of the only type of object that a list can contain.\r
+ */\r
+struct xLIST_ITEM\r
+{\r
+       listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE                       /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */\r
+       configLIST_VOLATILE TickType_t xItemValue;                      /*< The value being listed.  In most cases this is used to sort the list in descending order. */\r
+       struct xLIST_ITEM * configLIST_VOLATILE pxNext;         /*< Pointer to the next ListItem_t in the list. */\r
+       struct xLIST_ITEM * configLIST_VOLATILE pxPrevious;     /*< Pointer to the previous ListItem_t in the list. */\r
+       void * pvOwner;                                                                         /*< Pointer to the object (normally a TCB) that contains the list item.  There is therefore a two way link between the object containing the list item and the list item itself. */\r
+       void * configLIST_VOLATILE pvContainer;                         /*< Pointer to the list in which this list item is placed (if any). */\r
+       listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE                      /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */\r
+};\r
+typedef struct xLIST_ITEM ListItem_t;                                  /* For some reason lint wants this as two separate definitions. */\r
+\r
+struct xMINI_LIST_ITEM\r
+{\r
+       listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE                       /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */\r
+       configLIST_VOLATILE TickType_t xItemValue;\r
+       struct xLIST_ITEM * configLIST_VOLATILE pxNext;\r
+       struct xLIST_ITEM * configLIST_VOLATILE pxPrevious;\r
+};\r
+typedef struct xMINI_LIST_ITEM MiniListItem_t;\r
+\r
+/*\r
+ * Definition of the type of queue used by the scheduler.\r
+ */\r
+typedef struct xLIST\r
+{\r
+       listFIRST_LIST_INTEGRITY_CHECK_VALUE                            /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */\r
+       configLIST_VOLATILE UBaseType_t uxNumberOfItems;\r
+       ListItem_t * configLIST_VOLATILE pxIndex;                       /*< Used to walk through the list.  Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */\r
+       MiniListItem_t xListEnd;                                                        /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */\r
+       listSECOND_LIST_INTEGRITY_CHECK_VALUE                           /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */\r
+} List_t;\r
+\r
+/*\r
+ * Access macro to set the owner of a list item.  The owner of a list item\r
+ * is the object (usually a TCB) that contains the list item.\r
+ *\r
+ * \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER\r
+ * \ingroup LinkedList\r
+ */\r
+#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner )         ( ( pxListItem )->pvOwner = ( void * ) ( pxOwner ) )\r
+\r
+/*\r
+ * Access macro to get the owner of a list item.  The owner of a list item\r
+ * is the object (usually a TCB) that contains the list item.\r
+ *\r
+ * \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER\r
+ * \ingroup LinkedList\r
+ */\r
+#define listGET_LIST_ITEM_OWNER( pxListItem )  ( ( pxListItem )->pvOwner )\r
+\r
+/*\r
+ * Access macro to set the value of the list item.  In most cases the value is\r
+ * used to sort the list in descending order.\r
+ *\r
+ * \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE\r
+ * \ingroup LinkedList\r
+ */\r
+#define listSET_LIST_ITEM_VALUE( pxListItem, xValue )  ( ( pxListItem )->xItemValue = ( xValue ) )\r
+\r
+/*\r
+ * Access macro to retrieve the value of the list item.  The value can\r
+ * represent anything - for example the priority of a task, or the time at\r
+ * which a task should be unblocked.\r
+ *\r
+ * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE\r
+ * \ingroup LinkedList\r
+ */\r
+#define listGET_LIST_ITEM_VALUE( pxListItem )  ( ( pxListItem )->xItemValue )\r
+\r
+/*\r
+ * Access macro to retrieve the value of the list item at the head of a given\r
+ * list.\r
+ *\r
+ * \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE\r
+ * \ingroup LinkedList\r
+ */\r
+#define listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxList )     ( ( ( pxList )->xListEnd ).pxNext->xItemValue )\r
+\r
+/*\r
+ * Return the list item at the head of the list.\r
+ *\r
+ * \page listGET_HEAD_ENTRY listGET_HEAD_ENTRY\r
+ * \ingroup LinkedList\r
+ */\r
+#define listGET_HEAD_ENTRY( pxList )   ( ( ( pxList )->xListEnd ).pxNext )\r
+\r
+/*\r
+ * Return the list item at the head of the list.\r
+ *\r
+ * \page listGET_NEXT listGET_NEXT\r
+ * \ingroup LinkedList\r
+ */\r
+#define listGET_NEXT( pxListItem )     ( ( pxListItem )->pxNext )\r
+\r
+/*\r
+ * Return the list item that marks the end of the list\r
+ *\r
+ * \page listGET_END_MARKER listGET_END_MARKER\r
+ * \ingroup LinkedList\r
+ */\r
+#define listGET_END_MARKER( pxList )   ( ( ListItem_t const * ) ( &( ( pxList )->xListEnd ) ) )\r
+\r
+/*\r
+ * Access macro to determine if a list contains any items.  The macro will\r
+ * only have the value true if the list is empty.\r
+ *\r
+ * \page listLIST_IS_EMPTY listLIST_IS_EMPTY\r
+ * \ingroup LinkedList\r
+ */\r
+#define listLIST_IS_EMPTY( pxList )    ( ( BaseType_t ) ( ( pxList )->uxNumberOfItems == ( UBaseType_t ) 0 ) )\r
+\r
+/*\r
+ * Access macro to return the number of items in the list.\r
+ */\r
+#define listCURRENT_LIST_LENGTH( pxList )      ( ( pxList )->uxNumberOfItems )\r
+\r
+/*\r
+ * Access function to obtain the owner of the next entry in a list.\r
+ *\r
+ * The list member pxIndex is used to walk through a list.  Calling\r
+ * listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list\r
+ * and returns that entry's pxOwner parameter.  Using multiple calls to this\r
+ * function it is therefore possible to move through every item contained in\r
+ * a list.\r
+ *\r
+ * The pxOwner parameter of a list item is a pointer to the object that owns\r
+ * the list item.  In the scheduler this is normally a task control block.\r
+ * The pxOwner parameter effectively creates a two way link between the list\r
+ * item and its owner.\r
+ *\r
+ * @param pxTCB pxTCB is set to the address of the owner of the next list item.\r
+ * @param pxList The list from which the next item owner is to be returned.\r
+ *\r
+ * \page listGET_OWNER_OF_NEXT_ENTRY listGET_OWNER_OF_NEXT_ENTRY\r
+ * \ingroup LinkedList\r
+ */\r
+#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList )                                                                           \\r
+{                                                                                                                                                                                      \\r
+List_t * const pxConstList = ( pxList );                                                                                                       \\r
+       /* Increment the index to the next item and return the item, ensuring */                                \\r
+       /* we don't return the marker used at the end of the list.  */                                                  \\r
+       ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext;                                                    \\r
+       if( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) )  \\r
+       {                                                                                                                                                                               \\r
+               ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext;                                            \\r
+       }                                                                                                                                                                               \\r
+       ( pxTCB ) = ( pxConstList )->pxIndex->pvOwner;                                                                                  \\r
+}\r
+\r
+\r
+/*\r
+ * Access function to obtain the owner of the first entry in a list.  Lists\r
+ * are normally sorted in ascending item value order.\r
+ *\r
+ * This function returns the pxOwner member of the first item in the list.\r
+ * The pxOwner parameter of a list item is a pointer to the object that owns\r
+ * the list item.  In the scheduler this is normally a task control block.\r
+ * The pxOwner parameter effectively creates a two way link between the list\r
+ * item and its owner.\r
+ *\r
+ * @param pxList The list from which the owner of the head item is to be\r
+ * returned.\r
+ *\r
+ * \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY\r
+ * \ingroup LinkedList\r
+ */\r
+#define listGET_OWNER_OF_HEAD_ENTRY( pxList )  ( (&( ( pxList )->xListEnd ))->pxNext->pvOwner )\r
+\r
+/*\r
+ * Check to see if a list item is within a list.  The list item maintains a\r
+ * "container" pointer that points to the list it is in.  All this macro does\r
+ * is check to see if the container and the list match.\r
+ *\r
+ * @param pxList The list we want to know if the list item is within.\r
+ * @param pxListItem The list item we want to know if is in the list.\r
+ * @return pdTRUE if the list item is in the list, otherwise pdFALSE.\r
+ */\r
+#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( BaseType_t ) ( ( pxListItem )->pvContainer == ( void * ) ( pxList ) ) )\r
+\r
+/*\r
+ * Return the list a list item is contained within (referenced from).\r
+ *\r
+ * @param pxListItem The list item being queried.\r
+ * @return A pointer to the List_t object that references the pxListItem\r
+ */\r
+#define listLIST_ITEM_CONTAINER( pxListItem ) ( ( pxListItem )->pvContainer )\r
+\r
+/*\r
+ * This provides a crude means of knowing if a list has been initialised, as\r
+ * pxList->xListEnd.xItemValue is set to portMAX_DELAY by the vListInitialise()\r
+ * function.\r
+ */\r
+#define listLIST_IS_INITIALISED( pxList ) ( ( pxList )->xListEnd.xItemValue == portMAX_DELAY )\r
+\r
+/*\r
+ * Must be called before a list is used!  This initialises all the members\r
+ * of the list structure and inserts the xListEnd item into the list as a\r
+ * marker to the back of the list.\r
+ *\r
+ * @param pxList Pointer to the list being initialised.\r
+ *\r
+ * \page vListInitialise vListInitialise\r
+ * \ingroup LinkedList\r
+ */\r
+void vListInitialise( List_t * const pxList ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Must be called before a list item is used.  This sets the list container to\r
+ * null so the item does not think that it is already contained in a list.\r
+ *\r
+ * @param pxItem Pointer to the list item being initialised.\r
+ *\r
+ * \page vListInitialiseItem vListInitialiseItem\r
+ * \ingroup LinkedList\r
+ */\r
+void vListInitialiseItem( ListItem_t * const pxItem ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Insert a list item into a list.  The item will be inserted into the list in\r
+ * a position determined by its item value (descending item value order).\r
+ *\r
+ * @param pxList The list into which the item is to be inserted.\r
+ *\r
+ * @param pxNewListItem The item that is to be placed in the list.\r
+ *\r
+ * \page vListInsert vListInsert\r
+ * \ingroup LinkedList\r
+ */\r
+void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Insert a list item into a list.  The item will be inserted in a position\r
+ * such that it will be the last item within the list returned by multiple\r
+ * calls to listGET_OWNER_OF_NEXT_ENTRY.\r
+ *\r
+ * The list member pvIndex is used to walk through a list.  Calling\r
+ * listGET_OWNER_OF_NEXT_ENTRY increments pvIndex to the next item in the list.\r
+ * Placing an item in a list using vListInsertEnd effectively places the item\r
+ * in the list position pointed to by pvIndex.  This means that every other\r
+ * item within the list will be returned by listGET_OWNER_OF_NEXT_ENTRY before\r
+ * the pvIndex parameter again points to the item being inserted.\r
+ *\r
+ * @param pxList The list into which the item is to be inserted.\r
+ *\r
+ * @param pxNewListItem The list item to be inserted into the list.\r
+ *\r
+ * \page vListInsertEnd vListInsertEnd\r
+ * \ingroup LinkedList\r
+ */\r
+void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Remove an item from a list.  The list item has a pointer to the list that\r
+ * it is in, so only the list item need be passed into the function.\r
+ *\r
+ * @param uxListRemove The item to be removed.  The item will remove itself from\r
+ * the list pointed to by it's pxContainer parameter.\r
+ *\r
+ * @return The number of items that remain in the list after the list item has\r
+ * been removed.\r
+ *\r
+ * \page uxListRemove uxListRemove\r
+ * \ingroup LinkedList\r
+ */\r
+UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) PRIVILEGED_FUNCTION;\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif\r
+\r
diff --git a/os/8.2.2/include/os/mpu_wrappers.h b/os/8.2.2/include/os/mpu_wrappers.h
new file mode 100644 (file)
index 0000000..8706003
--- /dev/null
@@ -0,0 +1,177 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+#ifndef MPU_WRAPPERS_H\r
+#define MPU_WRAPPERS_H\r
+\r
+/* This file redefines API functions to be called through a wrapper macro, but\r
+only for ports that are using the MPU. */\r
+#ifdef portUSING_MPU_WRAPPERS\r
+\r
+       /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is\r
+       included from queue.c or task.c to prevent it from having an effect within\r
+       those files. */\r
+       #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+               #define xTaskGenericCreate                              MPU_xTaskGenericCreate\r
+               #define vTaskAllocateMPURegions                 MPU_vTaskAllocateMPURegions\r
+               #define vTaskDelete                                             MPU_vTaskDelete\r
+               #define vTaskDelayUntil                                 MPU_vTaskDelayUntil\r
+               #define vTaskDelay                                              MPU_vTaskDelay\r
+               #define uxTaskPriorityGet                               MPU_uxTaskPriorityGet\r
+               #define vTaskPrioritySet                                MPU_vTaskPrioritySet\r
+               #define eTaskGetState                                   MPU_eTaskGetState\r
+               #define vTaskSuspend                                    MPU_vTaskSuspend\r
+               #define vTaskResume                                             MPU_vTaskResume\r
+               #define vTaskSuspendAll                                 MPU_vTaskSuspendAll\r
+               #define xTaskResumeAll                                  MPU_xTaskResumeAll\r
+               #define xTaskGetTickCount                               MPU_xTaskGetTickCount\r
+               #define uxTaskGetNumberOfTasks                  MPU_uxTaskGetNumberOfTasks\r
+               #define vTaskList                                               MPU_vTaskList\r
+               #define vTaskGetRunTimeStats                    MPU_vTaskGetRunTimeStats\r
+               #define vTaskSetApplicationTaskTag              MPU_vTaskSetApplicationTaskTag\r
+               #define xTaskGetApplicationTaskTag              MPU_xTaskGetApplicationTaskTag\r
+               #define xTaskCallApplicationTaskHook    MPU_xTaskCallApplicationTaskHook\r
+               #define uxTaskGetStackHighWaterMark             MPU_uxTaskGetStackHighWaterMark\r
+               #define xTaskGetCurrentTaskHandle               MPU_xTaskGetCurrentTaskHandle\r
+               #define xTaskGetSchedulerState                  MPU_xTaskGetSchedulerState\r
+               #define xTaskGetIdleTaskHandle                  MPU_xTaskGetIdleTaskHandle\r
+               #define uxTaskGetSystemState                    MPU_uxTaskGetSystemState\r
+               #define xTaskGenericNotify                              MPU_xTaskGenericNotify\r
+               #define xTaskNotifyWait                                 MPU_xTaskNotifyWait\r
+               #define ulTaskNotifyTake                                MPU_ulTaskNotifyTake\r
+\r
+               #define xQueueGenericCreate                             MPU_xQueueGenericCreate\r
+               #define xQueueCreateMutex                               MPU_xQueueCreateMutex\r
+               #define xQueueGiveMutexRecursive                MPU_xQueueGiveMutexRecursive\r
+               #define xQueueTakeMutexRecursive                MPU_xQueueTakeMutexRecursive\r
+               #define xQueueCreateCountingSemaphore   MPU_xQueueCreateCountingSemaphore\r
+               #define xQueueGenericSend                               MPU_xQueueGenericSend\r
+               #define xQueueAltGenericSend                    MPU_xQueueAltGenericSend\r
+               #define xQueueAltGenericReceive                 MPU_xQueueAltGenericReceive\r
+               #define xQueueGenericReceive                    MPU_xQueueGenericReceive\r
+               #define uxQueueMessagesWaiting                  MPU_uxQueueMessagesWaiting\r
+               #define vQueueDelete                                    MPU_vQueueDelete\r
+               #define xQueueGenericReset                              MPU_xQueueGenericReset\r
+               #define xQueueCreateSet                                 MPU_xQueueCreateSet\r
+               #define xQueueSelectFromSet                             MPU_xQueueSelectFromSet\r
+               #define xQueueAddToSet                                  MPU_xQueueAddToSet\r
+               #define xQueueRemoveFromSet                             MPU_xQueueRemoveFromSet\r
+               #define xQueueGetMutexHolder                    MPU_xQueueGetMutexHolder\r
+               #define xQueueGetMutexHolder                    MPU_xQueueGetMutexHolder\r
+\r
+               #define pvPortMalloc                                    MPU_pvPortMalloc\r
+               #define vPortFree                                               MPU_vPortFree\r
+               #define xPortGetFreeHeapSize                    MPU_xPortGetFreeHeapSize\r
+               #define vPortInitialiseBlocks                   MPU_vPortInitialiseBlocks\r
+               #define xPortGetMinimumEverFreeHeapSize MPU_xPortGetMinimumEverFreeHeapSize\r
+\r
+               #if configQUEUE_REGISTRY_SIZE > 0\r
+                       #define vQueueAddToRegistry                             MPU_vQueueAddToRegistry\r
+                       #define vQueueUnregisterQueue                   MPU_vQueueUnregisterQueue\r
+               #endif\r
+\r
+               #define xTimerCreate                                    MPU_xTimerCreate\r
+               #define pvTimerGetTimerID                               MPU_pvTimerGetTimerID\r
+               #define vTimerSetTimerID                                MPU_vTimerSetTimerID\r
+               #define xTimerIsTimerActive                             MPU_xTimerIsTimerActive\r
+               #define xTimerGetTimerDaemonTaskHandle  MPU_xTimerGetTimerDaemonTaskHandle\r
+               #define xTimerPendFunctionCall                  MPU_xTimerPendFunctionCall\r
+               #define pcTimerGetTimerName                             MPU_pcTimerGetTimerName\r
+               #define xTimerGenericCommand                    MPU_xTimerGenericCommand\r
+\r
+               #define xEventGroupCreate                               MPU_xEventGroupCreate\r
+               #define xEventGroupWaitBits                             MPU_xEventGroupWaitBits\r
+               #define xEventGroupClearBits                    MPU_xEventGroupClearBits\r
+               #define xEventGroupSetBits                              MPU_xEventGroupSetBits\r
+               #define xEventGroupSync                                 MPU_xEventGroupSync\r
+               #define vEventGroupDelete                               MPU_vEventGroupDelete\r
+\r
+               /* Remove the privileged function macro. */\r
+               #define PRIVILEGED_FUNCTION\r
+\r
+       #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */\r
+\r
+               /* Ensure API functions go in the privileged execution section. */\r
+               #define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions")))\r
+               #define PRIVILEGED_DATA __attribute__((section("privileged_data")))\r
+\r
+       #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */\r
+\r
+#else /* portUSING_MPU_WRAPPERS */\r
+\r
+       #define PRIVILEGED_FUNCTION\r
+       #define PRIVILEGED_DATA\r
+       #define portUSING_MPU_WRAPPERS 0\r
+\r
+#endif /* portUSING_MPU_WRAPPERS */\r
+\r
+\r
+#endif /* MPU_WRAPPERS_H */\r
+\r
diff --git a/os/8.2.2/include/os/os.h b/os/8.2.2/include/os/os.h
new file mode 100644 (file)
index 0000000..ab0bb25
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * FreeRTOS library interface file.
+ *
+ * @file os.h
+ *
+ * @copyright Copyright (C) 2013, 2015 Czech Technical University in Prague
+ *
+ * @author Carlos Jenkins <carlos@jenkins.co.cr>
+ */
+
+#ifndef __OS_H
+#define __OS_H
+
+#define FREERTOS_VERSION_NUMBER_MAYOR 8
+#define FREERTOS_VERSION_NUMBER_MINOR 2
+#define FREERTOS_VERSION_NUMBER_REV   2
+
+/**
+ * Data type casting macro for the xTaskCreate function.
+ *
+ * The xTaskCreate function has a name parameter, which data type is different for
+ * FreeRTOS versions 7.x.x and 8.x.x.
+ *
+ * Use this macro for the task name specification to avoid compiler warnings when
+ * changing the Operating system.
+ */
+#define FREERTOS_TASK_NAME(name) ((const char *)(name))
+
+#include "os/FreeRTOS.h"
+#include "os/task.h"
+#include "os/semphr.h"
+#include "os/queue.h"
+
+
+#endif /* __OS_H */
diff --git a/os/8.2.2/include/os/portable.h b/os/8.2.2/include/os/portable.h
new file mode 100644 (file)
index 0000000..fd9be79
--- /dev/null
@@ -0,0 +1,207 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+/*-----------------------------------------------------------\r
+ * Portable layer API.  Each function must be defined for each port.\r
+ *----------------------------------------------------------*/\r
+\r
+#ifndef PORTABLE_H\r
+#define PORTABLE_H\r
+\r
+/* Each FreeRTOS port has a unique portmacro.h header file.  Originally a\r
+pre-processor definition was used to ensure the pre-processor found the correct\r
+portmacro.h file for the port being used.  That scheme was deprecated in favour\r
+of setting the compiler's include path such that it found the correct\r
+portmacro.h file - removing the need for the constant and allowing the\r
+portmacro.h file to be located anywhere in relation to the port being used.\r
+Purely for reasons of backward compatibility the old method is still valid, but\r
+to make it clear that new projects should not use it, support for the port\r
+specific constants has been moved into the deprecated_definitions.h header\r
+file. */\r
+#include "deprecated_definitions.h"\r
+\r
+/* If portENTER_CRITICAL is not defined then including deprecated_definitions.h\r
+did not result in a portmacro.h header file being included - and it should be\r
+included here.  In this case the path to the correct portmacro.h header file\r
+must be set in the compiler's include path. */\r
+#ifndef portENTER_CRITICAL\r
+       #include "portmacro.h"\r
+#endif\r
+\r
+#if portBYTE_ALIGNMENT == 32\r
+       #define portBYTE_ALIGNMENT_MASK ( 0x001f )\r
+#endif\r
+\r
+#if portBYTE_ALIGNMENT == 16\r
+       #define portBYTE_ALIGNMENT_MASK ( 0x000f )\r
+#endif\r
+\r
+#if portBYTE_ALIGNMENT == 8\r
+       #define portBYTE_ALIGNMENT_MASK ( 0x0007 )\r
+#endif\r
+\r
+#if portBYTE_ALIGNMENT == 4\r
+       #define portBYTE_ALIGNMENT_MASK ( 0x0003 )\r
+#endif\r
+\r
+#if portBYTE_ALIGNMENT == 2\r
+       #define portBYTE_ALIGNMENT_MASK ( 0x0001 )\r
+#endif\r
+\r
+#if portBYTE_ALIGNMENT == 1\r
+       #define portBYTE_ALIGNMENT_MASK ( 0x0000 )\r
+#endif\r
+\r
+#ifndef portBYTE_ALIGNMENT_MASK\r
+       #error "Invalid portBYTE_ALIGNMENT definition"\r
+#endif\r
+\r
+#ifndef portNUM_CONFIGURABLE_REGIONS\r
+       #define portNUM_CONFIGURABLE_REGIONS 1\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+#include "mpu_wrappers.h"\r
+\r
+/*\r
+ * Setup the stack of a new task so it is ready to be placed under the\r
+ * scheduler control.  The registers have to be placed on the stack in\r
+ * the order that the port expects to find them.\r
+ *\r
+ */\r
+#if( portUSING_MPU_WRAPPERS == 1 )\r
+       StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION;\r
+#else\r
+       StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION;\r
+#endif\r
+\r
+/* Used by heap_5.c. */\r
+typedef struct HeapRegion\r
+{\r
+       uint8_t *pucStartAddress;\r
+       size_t xSizeInBytes;\r
+} HeapRegion_t;\r
+\r
+/*\r
+ * Used to define multiple heap regions for use by heap_5.c.  This function\r
+ * must be called before any calls to pvPortMalloc() - not creating a task,\r
+ * queue, semaphore, mutex, software timer, event group, etc. will result in\r
+ * pvPortMalloc being called.\r
+ *\r
+ * pxHeapRegions passes in an array of HeapRegion_t structures - each of which\r
+ * defines a region of memory that can be used as the heap.  The array is\r
+ * terminated by a HeapRegions_t structure that has a size of 0.  The region\r
+ * with the lowest start address must appear first in the array.\r
+ */\r
+void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION;\r
+\r
+\r
+/*\r
+ * Map to the memory management routines required for the port.\r
+ */\r
+void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;\r
+void vPortFree( void *pv ) PRIVILEGED_FUNCTION;\r
+void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;\r
+size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;\r
+size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Setup the hardware ready for the scheduler to take control.  This generally\r
+ * sets up a tick interrupt and sets timers for the correct tick frequency.\r
+ */\r
+BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so\r
+ * the hardware is left in its original condition after the scheduler stops\r
+ * executing.\r
+ */\r
+void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * The structures and methods of manipulating the MPU are contained within the\r
+ * port layer.\r
+ *\r
+ * Fills the xMPUSettings structure with the memory region information\r
+ * contained in xRegions.\r
+ */\r
+#if( portUSING_MPU_WRAPPERS == 1 )\r
+       struct xMEMORY_REGION;\r
+       void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint16_t usStackDepth ) PRIVILEGED_FUNCTION;\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* PORTABLE_H */\r
+\r
diff --git a/os/8.2.2/include/os/portmacro.h b/os/8.2.2/include/os/portmacro.h
new file mode 100644 (file)
index 0000000..a5b3c80
--- /dev/null
@@ -0,0 +1,159 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+#ifndef __PORTMACRO_H__\r
+#define __PORTMACRO_H__\r
+\r
+/*-----------------------------------------------------------\r
+ * Port specific definitions.\r
+ *\r
+ * The settings in this file configure FreeRTOS correctly for the\r
+ * given hardware and compiler.\r
+ *\r
+ * These settings should not be altered.\r
+ *-----------------------------------------------------------\r
+ */\r
+\r
+/* Type definitions. */\r
+#define portCHAR        char\r
+#define portFLOAT       float\r
+#define portDOUBLE      double\r
+#define portLONG        long\r
+#define portSHORT       short\r
+#define portSTACK_TYPE  uint32_t\r
+#define portBASE_TYPE   long\r
+\r
+typedef portSTACK_TYPE StackType_t;\r
+typedef long BaseType_t;\r
+typedef unsigned long UBaseType_t;\r
+\r
+#if (configUSE_16_BIT_TICKS == 1)\r
+    typedef uint16_t TickType_t;\r
+    #define portMAX_DELAY (TickType_t) 0xFFFF\r
+#else\r
+    typedef uint32_t TickType_t;\r
+    #define portMAX_DELAY (TickType_t) 0xFFFFFFFFF\r
+\r
+       /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do\r
+       not need to be guarded with a critical section. */\r
+       #define portTICK_TYPE_IS_ATOMIC 1\r
+#endif\r
+\r
+\r
+/* Architecture specifics. */\r
+#define portSTACK_GROWTH    (-1)\r
+#define portTICK_PERIOD_MS    ((TickType_t) 1000 / configTICK_RATE_HZ)\r
+#define portBYTE_ALIGNMENT  8\r
+\r
+/* Critical section handling. */\r
+extern void vPortEnterCritical(void);\r
+extern void vPortExitCritical(void);\r
+#define portENTER_CRITICAL()           vPortEnterCritical()\r
+#define portEXIT_CRITICAL()                    vPortExitCritical()\r
+#define portDISABLE_INTERRUPTS()       asm( " CPSID I" )\r
+#define portENABLE_INTERRUPTS()                asm( " CPSIE I" )\r
+\r
+/* Scheduler utilities. */\r
+#pragma SWI_ALIAS( vPortYield, 0 )\r
+extern void vPortYield( void );\r
+#define portYIELD()                    vPortYield()\r
+#define portSYS_SSIR1_REG                      ( * ( ( volatile uint32_t * ) 0xFFFFFFB0 ) )\r
+#define portSYS_SSIR1_SSKEY                    ( 0x7500UL )\r
+#define portYIELD_WITHIN_API()         { portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY;  asm( " DSB " ); asm( " ISB " ); }\r
+#define portYIELD_FROM_ISR( x )                if( x != pdFALSE ){ portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY;  ( void ) portSYS_SSIR1_REG; }\r
+\r
+#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION\r
+       #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1\r
+#endif\r
+\r
+/* Architecture specific optimisations. */\r
+#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1\r
+\r
+       /* Check the configuration. */\r
+       #if( configMAX_PRIORITIES > 32 )\r
+               #error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32.  It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.\r
+       #endif\r
+\r
+       /* Store/clear the ready priorities in a bit map. */\r
+       #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )\r
+       #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )\r
+\r
+       /*-----------------------------------------------------------*/\r
+\r
+       #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - __clz( ( uxReadyPriorities ) ) )\r
+\r
+#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
+\r
+\r
+/* Task function macros as described on the FreeRTOS.org WEB site. */\r
+#define portTASK_FUNCTION(vFunction, pvParameters)       void vFunction(void *pvParameters)\r
+#define portTASK_FUNCTION_PROTO(vFunction, pvParameters) void vFunction(void *pvParameters)\r
+\r
+#endif /* __PORTMACRO_H__ */\r
+\r
diff --git a/os/8.2.2/include/os/projdefs.h b/os/8.2.2/include/os/projdefs.h
new file mode 100644 (file)
index 0000000..fe51999
--- /dev/null
@@ -0,0 +1,156 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+#ifndef PROJDEFS_H\r
+#define PROJDEFS_H\r
+\r
+/*\r
+ * Defines the prototype to which task functions must conform.  Defined in this\r
+ * file to ensure the type is known before portable.h is included.\r
+ */\r
+typedef void (*TaskFunction_t)( void * );\r
+\r
+/* Converts a time in milliseconds to a time in ticks. */\r
+#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) )\r
+\r
+#define pdFALSE                        ( ( BaseType_t ) 0 )\r
+#define pdTRUE                 ( ( BaseType_t ) 1 )\r
+\r
+#define pdPASS                 ( pdTRUE )\r
+#define pdFAIL                 ( pdFALSE )\r
+#define errQUEUE_EMPTY ( ( BaseType_t ) 0 )\r
+#define errQUEUE_FULL  ( ( BaseType_t ) 0 )\r
+\r
+/* FreeRTOS error definitions. */\r
+#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY  ( -1 )\r
+#define errQUEUE_BLOCKED                                               ( -4 )\r
+#define errQUEUE_YIELD                                                 ( -5 )\r
+\r
+/* Macros used for basic data corruption checks. */\r
+#ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES\r
+       #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0\r
+#endif\r
+\r
+#if( configUSE_16_BIT_TICKS == 1 )\r
+       #define pdINTEGRITY_CHECK_VALUE 0x5a5a\r
+#else\r
+       #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL\r
+#endif\r
+\r
+/* The following errno values are used by FreeRTOS+ components, not FreeRTOS\r
+itself. */\r
+#define pdFREERTOS_ERRNO_NONE                  0       /* No errors */\r
+#define        pdFREERTOS_ERRNO_ENOENT                 2       /* No such file or directory */\r
+#define        pdFREERTOS_ERRNO_EIO                    5       /* I/O error */\r
+#define        pdFREERTOS_ERRNO_ENXIO                  6       /* No such device or address */\r
+#define        pdFREERTOS_ERRNO_EBADF                  9       /* Bad file number */\r
+#define        pdFREERTOS_ERRNO_EAGAIN                 11      /* No more processes */\r
+#define        pdFREERTOS_ERRNO_EWOULDBLOCK    11      /* Operation would block */\r
+#define        pdFREERTOS_ERRNO_ENOMEM                 12      /* Not enough memory */\r
+#define        pdFREERTOS_ERRNO_EACCES                 13      /* Permission denied */\r
+#define        pdFREERTOS_ERRNO_EFAULT                 14      /* Bad address */\r
+#define        pdFREERTOS_ERRNO_EBUSY                  16      /* Mount device busy */\r
+#define        pdFREERTOS_ERRNO_EEXIST                 17      /* File exists */\r
+#define        pdFREERTOS_ERRNO_EXDEV                  18      /* Cross-device link */\r
+#define        pdFREERTOS_ERRNO_ENODEV                 19      /* No such device */\r
+#define        pdFREERTOS_ERRNO_ENOTDIR                20      /* Not a directory */\r
+#define        pdFREERTOS_ERRNO_EISDIR                 21      /* Is a directory */\r
+#define        pdFREERTOS_ERRNO_EINVAL                 22      /* Invalid argument */\r
+#define        pdFREERTOS_ERRNO_ENOSPC                 28      /* No space left on device */\r
+#define        pdFREERTOS_ERRNO_ESPIPE                 29      /* Illegal seek */\r
+#define        pdFREERTOS_ERRNO_EROFS                  30      /* Read only file system */\r
+#define        pdFREERTOS_ERRNO_EUNATCH                42      /* Protocol driver not attached */\r
+#define        pdFREERTOS_ERRNO_EBADE                  50      /* Invalid exchange */\r
+#define        pdFREERTOS_ERRNO_EFTYPE                 79      /* Inappropriate file type or format */\r
+#define        pdFREERTOS_ERRNO_ENMFILE                89      /* No more files */\r
+#define        pdFREERTOS_ERRNO_ENOTEMPTY              90      /* Directory not empty */\r
+#define        pdFREERTOS_ERRNO_ENAMETOOLONG   91      /* File or path name too long */\r
+#define        pdFREERTOS_ERRNO_EOPNOTSUPP             95      /* Operation not supported on transport endpoint */\r
+#define        pdFREERTOS_ERRNO_ENOBUFS                105     /* No buffer space available */\r
+#define        pdFREERTOS_ERRNO_ENOPROTOOPT    109     /* Protocol not available */\r
+#define        pdFREERTOS_ERRNO_EADDRINUSE             112     /* Address already in use */\r
+#define        pdFREERTOS_ERRNO_ETIMEDOUT              116     /* Connection timed out */\r
+#define        pdFREERTOS_ERRNO_EINPROGRESS    119     /* Connection already in progress */\r
+#define        pdFREERTOS_ERRNO_EALREADY               120     /* Socket already connected */\r
+#define        pdFREERTOS_ERRNO_EADDRNOTAVAIL  125     /* Address not available */\r
+#define        pdFREERTOS_ERRNO_EISCONN                127     /* Socket is already connected */\r
+#define        pdFREERTOS_ERRNO_ENOTCONN               128     /* Socket is not connected */\r
+#define        pdFREERTOS_ERRNO_ENOMEDIUM              135     /* No medium inserted */\r
+#define        pdFREERTOS_ERRNO_EILSEQ                 138     /* An invalid UTF-16 sequence was encountered. */\r
+#define        pdFREERTOS_ERRNO_ECANCELED              140     /* Operation canceled. */\r
+\r
+/* The following endian values are used by FreeRTOS+ components, not FreeRTOS\r
+itself. */\r
+#define pdFREERTOS_LITTLE_ENDIAN       0\r
+#define pdFREERTOS_BIG_ENDIAN          1\r
+\r
+#endif /* PROJDEFS_H */\r
+\r
+\r
+\r
diff --git a/os/8.2.2/include/os/queue.h b/os/8.2.2/include/os/queue.h
new file mode 100644 (file)
index 0000000..4ab7fd9
--- /dev/null
@@ -0,0 +1,1691 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+\r
+#ifndef QUEUE_H\r
+#define QUEUE_H\r
+\r
+#ifndef INC_FREERTOS_H\r
+       #error "include FreeRTOS.h" must appear in source files before "include queue.h"\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+\r
+/**\r
+ * Type by which queues are referenced.  For example, a call to xQueueCreate()\r
+ * returns an QueueHandle_t variable that can then be used as a parameter to\r
+ * xQueueSend(), xQueueReceive(), etc.\r
+ */\r
+typedef void * QueueHandle_t;\r
+\r
+/**\r
+ * Type by which queue sets are referenced.  For example, a call to\r
+ * xQueueCreateSet() returns an xQueueSet variable that can then be used as a\r
+ * parameter to xQueueSelectFromSet(), xQueueAddToSet(), etc.\r
+ */\r
+typedef void * QueueSetHandle_t;\r
+\r
+/**\r
+ * Queue sets can contain both queues and semaphores, so the\r
+ * QueueSetMemberHandle_t is defined as a type to be used where a parameter or\r
+ * return value can be either an QueueHandle_t or an SemaphoreHandle_t.\r
+ */\r
+typedef void * QueueSetMemberHandle_t;\r
+\r
+/* For internal use only. */\r
+#define        queueSEND_TO_BACK               ( ( BaseType_t ) 0 )\r
+#define        queueSEND_TO_FRONT              ( ( BaseType_t ) 1 )\r
+#define queueOVERWRITE                 ( ( BaseType_t ) 2 )\r
+\r
+/* For internal use only.  These definitions *must* match those in queue.c. */\r
+#define queueQUEUE_TYPE_BASE                           ( ( uint8_t ) 0U )\r
+#define queueQUEUE_TYPE_SET                                    ( ( uint8_t ) 0U )\r
+#define queueQUEUE_TYPE_MUTEX                          ( ( uint8_t ) 1U )\r
+#define queueQUEUE_TYPE_COUNTING_SEMAPHORE     ( ( uint8_t ) 2U )\r
+#define queueQUEUE_TYPE_BINARY_SEMAPHORE       ( ( uint8_t ) 3U )\r
+#define queueQUEUE_TYPE_RECURSIVE_MUTEX                ( ( uint8_t ) 4U )\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ QueueHandle_t xQueueCreate(\r
+                                                         UBaseType_t uxQueueLength,\r
+                                                         UBaseType_t uxItemSize\r
+                                                 );\r
+ * </pre>\r
+ *\r
+ * Creates a new queue instance.  This allocates the storage required by the\r
+ * new queue and returns a handle for the queue.\r
+ *\r
+ * @param uxQueueLength The maximum number of items that the queue can contain.\r
+ *\r
+ * @param uxItemSize The number of bytes each item in the queue will require.\r
+ * Items are queued by copy, not by reference, so this is the number of bytes\r
+ * that will be copied for each posted item.  Each item on the queue must be\r
+ * the same size.\r
+ *\r
+ * @return If the queue is successfully create then a handle to the newly\r
+ * created queue is returned.  If the queue cannot be created then 0 is\r
+ * returned.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ struct AMessage\r
+ {\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
+ };\r
+\r
+ void vATask( void *pvParameters )\r
+ {\r
+ QueueHandle_t xQueue1, xQueue2;\r
+\r
+       // Create a queue capable of containing 10 uint32_t values.\r
+       xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );\r
+       if( xQueue1 == 0 )\r
+       {\r
+               // Queue was not created and must not be used.\r
+       }\r
+\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+       if( xQueue2 == 0 )\r
+       {\r
+               // Queue was not created and must not be used.\r
+       }\r
+\r
+       // ... Rest of task code.\r
+ }\r
+ </pre>\r
+ * \defgroup xQueueCreate xQueueCreate\r
+ * \ingroup QueueManagement\r
+ */\r
+#define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( uxQueueLength, uxItemSize, queueQUEUE_TYPE_BASE )\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueueSendToToFront(\r
+                                                                  QueueHandle_t        xQueue,\r
+                                                                  const void           *pvItemToQueue,\r
+                                                                  TickType_t           xTicksToWait\r
+                                                          );\r
+ * </pre>\r
+ *\r
+ * This is a macro that calls xQueueGenericSend().\r
+ *\r
+ * Post an item to the front of a queue.  The item is queued by copy, not by\r
+ * reference.  This function must not be called from an interrupt service\r
+ * routine.  See xQueueSendFromISR () for an alternative which may be used\r
+ * in an ISR.\r
+ *\r
+ * @param xQueue The handle to the queue on which the item is to be posted.\r
+ *\r
+ * @param pvItemToQueue A pointer to the item that is to be placed on the\r
+ * queue.  The size of the items the queue will hold was defined when the\r
+ * queue was created, so this many bytes will be copied from pvItemToQueue\r
+ * into the queue storage area.\r
+ *\r
+ * @param xTicksToWait The maximum amount of time the task should block\r
+ * waiting for space to become available on the queue, should it already\r
+ * be full.  The call will return immediately if this is set to 0 and the\r
+ * queue is full.  The time is defined in tick periods so the constant\r
+ * portTICK_PERIOD_MS should be used to convert to real time if this is required.\r
+ *\r
+ * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ struct AMessage\r
+ {\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
+ } xMessage;\r
+\r
+ uint32_t ulVar = 10UL;\r
+\r
+ void vATask( void *pvParameters )\r
+ {\r
+ QueueHandle_t xQueue1, xQueue2;\r
+ struct AMessage *pxMessage;\r
+\r
+       // Create a queue capable of containing 10 uint32_t values.\r
+       xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );\r
+\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+\r
+       // ...\r
+\r
+       if( xQueue1 != 0 )\r
+       {\r
+               // Send an uint32_t.  Wait for 10 ticks for space to become\r
+               // available if necessary.\r
+               if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )\r
+               {\r
+                       // Failed to post the message, even after 10 ticks.\r
+               }\r
+       }\r
+\r
+       if( xQueue2 != 0 )\r
+       {\r
+               // Send a pointer to a struct AMessage object.  Don't block if the\r
+               // queue is already full.\r
+               pxMessage = & xMessage;\r
+               xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );\r
+       }\r
+\r
+       // ... Rest of task code.\r
+ }\r
+ </pre>\r
+ * \defgroup xQueueSend xQueueSend\r
+ * \ingroup QueueManagement\r
+ */\r
+#define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT )\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueueSendToBack(\r
+                                                                  QueueHandle_t        xQueue,\r
+                                                                  const void           *pvItemToQueue,\r
+                                                                  TickType_t           xTicksToWait\r
+                                                          );\r
+ * </pre>\r
+ *\r
+ * This is a macro that calls xQueueGenericSend().\r
+ *\r
+ * Post an item to the back of a queue.  The item is queued by copy, not by\r
+ * reference.  This function must not be called from an interrupt service\r
+ * routine.  See xQueueSendFromISR () for an alternative which may be used\r
+ * in an ISR.\r
+ *\r
+ * @param xQueue The handle to the queue on which the item is to be posted.\r
+ *\r
+ * @param pvItemToQueue A pointer to the item that is to be placed on the\r
+ * queue.  The size of the items the queue will hold was defined when the\r
+ * queue was created, so this many bytes will be copied from pvItemToQueue\r
+ * into the queue storage area.\r
+ *\r
+ * @param xTicksToWait The maximum amount of time the task should block\r
+ * waiting for space to become available on the queue, should it already\r
+ * be full.  The call will return immediately if this is set to 0 and the queue\r
+ * is full.  The  time is defined in tick periods so the constant\r
+ * portTICK_PERIOD_MS should be used to convert to real time if this is required.\r
+ *\r
+ * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ struct AMessage\r
+ {\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
+ } xMessage;\r
+\r
+ uint32_t ulVar = 10UL;\r
+\r
+ void vATask( void *pvParameters )\r
+ {\r
+ QueueHandle_t xQueue1, xQueue2;\r
+ struct AMessage *pxMessage;\r
+\r
+       // Create a queue capable of containing 10 uint32_t values.\r
+       xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );\r
+\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+\r
+       // ...\r
+\r
+       if( xQueue1 != 0 )\r
+       {\r
+               // Send an uint32_t.  Wait for 10 ticks for space to become\r
+               // available if necessary.\r
+               if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )\r
+               {\r
+                       // Failed to post the message, even after 10 ticks.\r
+               }\r
+       }\r
+\r
+       if( xQueue2 != 0 )\r
+       {\r
+               // Send a pointer to a struct AMessage object.  Don't block if the\r
+               // queue is already full.\r
+               pxMessage = & xMessage;\r
+               xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );\r
+       }\r
+\r
+       // ... Rest of task code.\r
+ }\r
+ </pre>\r
+ * \defgroup xQueueSend xQueueSend\r
+ * \ingroup QueueManagement\r
+ */\r
+#define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueueSend(\r
+                                                         QueueHandle_t xQueue,\r
+                                                         const void * pvItemToQueue,\r
+                                                         TickType_t xTicksToWait\r
+                                                );\r
+ * </pre>\r
+ *\r
+ * This is a macro that calls xQueueGenericSend().  It is included for\r
+ * backward compatibility with versions of FreeRTOS.org that did not\r
+ * include the xQueueSendToFront() and xQueueSendToBack() macros.  It is\r
+ * equivalent to xQueueSendToBack().\r
+ *\r
+ * Post an item on a queue.  The item is queued by copy, not by reference.\r
+ * This function must not be called from an interrupt service routine.\r
+ * See xQueueSendFromISR () for an alternative which may be used in an ISR.\r
+ *\r
+ * @param xQueue The handle to the queue on which the item is to be posted.\r
+ *\r
+ * @param pvItemToQueue A pointer to the item that is to be placed on the\r
+ * queue.  The size of the items the queue will hold was defined when the\r
+ * queue was created, so this many bytes will be copied from pvItemToQueue\r
+ * into the queue storage area.\r
+ *\r
+ * @param xTicksToWait The maximum amount of time the task should block\r
+ * waiting for space to become available on the queue, should it already\r
+ * be full.  The call will return immediately if this is set to 0 and the\r
+ * queue is full.  The time is defined in tick periods so the constant\r
+ * portTICK_PERIOD_MS should be used to convert to real time if this is required.\r
+ *\r
+ * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ struct AMessage\r
+ {\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
+ } xMessage;\r
+\r
+ uint32_t ulVar = 10UL;\r
+\r
+ void vATask( void *pvParameters )\r
+ {\r
+ QueueHandle_t xQueue1, xQueue2;\r
+ struct AMessage *pxMessage;\r
+\r
+       // Create a queue capable of containing 10 uint32_t values.\r
+       xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );\r
+\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+\r
+       // ...\r
+\r
+       if( xQueue1 != 0 )\r
+       {\r
+               // Send an uint32_t.  Wait for 10 ticks for space to become\r
+               // available if necessary.\r
+               if( xQueueSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )\r
+               {\r
+                       // Failed to post the message, even after 10 ticks.\r
+               }\r
+       }\r
+\r
+       if( xQueue2 != 0 )\r
+       {\r
+               // Send a pointer to a struct AMessage object.  Don't block if the\r
+               // queue is already full.\r
+               pxMessage = & xMessage;\r
+               xQueueSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );\r
+       }\r
+\r
+       // ... Rest of task code.\r
+ }\r
+ </pre>\r
+ * \defgroup xQueueSend xQueueSend\r
+ * \ingroup QueueManagement\r
+ */\r
+#define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueueOverwrite(\r
+                                                         QueueHandle_t xQueue,\r
+                                                         const void * pvItemToQueue\r
+                                                );\r
+ * </pre>\r
+ *\r
+ * Only for use with queues that have a length of one - so the queue is either\r
+ * empty or full.\r
+ *\r
+ * Post an item on a queue.  If the queue is already full then overwrite the\r
+ * value held in the queue.  The item is queued by copy, not by reference.\r
+ *\r
+ * This function must not be called from an interrupt service routine.\r
+ * See xQueueOverwriteFromISR () for an alternative which may be used in an ISR.\r
+ *\r
+ * @param xQueue The handle of the queue to which the data is being sent.\r
+ *\r
+ * @param pvItemToQueue A pointer to the item that is to be placed on the\r
+ * queue.  The size of the items the queue will hold was defined when the\r
+ * queue was created, so this many bytes will be copied from pvItemToQueue\r
+ * into the queue storage area.\r
+ *\r
+ * @return xQueueOverwrite() is a macro that calls xQueueGenericSend(), and\r
+ * therefore has the same return values as xQueueSendToFront().  However, pdPASS\r
+ * is the only value that can be returned because xQueueOverwrite() will write\r
+ * to the queue even when the queue is already full.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+\r
+ void vFunction( void *pvParameters )\r
+ {\r
+ QueueHandle_t xQueue;\r
+ uint32_t ulVarToSend, ulValReceived;\r
+\r
+       // Create a queue to hold one uint32_t value.  It is strongly\r
+       // recommended *not* to use xQueueOverwrite() on queues that can\r
+       // contain more than one value, and doing so will trigger an assertion\r
+       // if configASSERT() is defined.\r
+       xQueue = xQueueCreate( 1, sizeof( uint32_t ) );\r
+\r
+       // Write the value 10 to the queue using xQueueOverwrite().\r
+       ulVarToSend = 10;\r
+       xQueueOverwrite( xQueue, &ulVarToSend );\r
+\r
+       // Peeking the queue should now return 10, but leave the value 10 in\r
+       // the queue.  A block time of zero is used as it is known that the\r
+       // queue holds a value.\r
+       ulValReceived = 0;\r
+       xQueuePeek( xQueue, &ulValReceived, 0 );\r
+\r
+       if( ulValReceived != 10 )\r
+       {\r
+               // Error unless the item was removed by a different task.\r
+       }\r
+\r
+       // The queue is still full.  Use xQueueOverwrite() to overwrite the\r
+       // value held in the queue with 100.\r
+       ulVarToSend = 100;\r
+       xQueueOverwrite( xQueue, &ulVarToSend );\r
+\r
+       // This time read from the queue, leaving the queue empty once more.\r
+       // A block time of 0 is used again.\r
+       xQueueReceive( xQueue, &ulValReceived, 0 );\r
+\r
+       // The value read should be the last value written, even though the\r
+       // queue was already full when the value was written.\r
+       if( ulValReceived != 100 )\r
+       {\r
+               // Error!\r
+       }\r
+\r
+       // ...\r
+}\r
+ </pre>\r
+ * \defgroup xQueueOverwrite xQueueOverwrite\r
+ * \ingroup QueueManagement\r
+ */\r
+#define xQueueOverwrite( xQueue, pvItemToQueue ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE )\r
+\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueueGenericSend(\r
+                                                                       QueueHandle_t xQueue,\r
+                                                                       const void * pvItemToQueue,\r
+                                                                       TickType_t xTicksToWait\r
+                                                                       BaseType_t xCopyPosition\r
+                                                               );\r
+ * </pre>\r
+ *\r
+ * It is preferred that the macros xQueueSend(), xQueueSendToFront() and\r
+ * xQueueSendToBack() are used in place of calling this function directly.\r
+ *\r
+ * Post an item on a queue.  The item is queued by copy, not by reference.\r
+ * This function must not be called from an interrupt service routine.\r
+ * See xQueueSendFromISR () for an alternative which may be used in an ISR.\r
+ *\r
+ * @param xQueue The handle to the queue on which the item is to be posted.\r
+ *\r
+ * @param pvItemToQueue A pointer to the item that is to be placed on the\r
+ * queue.  The size of the items the queue will hold was defined when the\r
+ * queue was created, so this many bytes will be copied from pvItemToQueue\r
+ * into the queue storage area.\r
+ *\r
+ * @param xTicksToWait The maximum amount of time the task should block\r
+ * waiting for space to become available on the queue, should it already\r
+ * be full.  The call will return immediately if this is set to 0 and the\r
+ * queue is full.  The time is defined in tick periods so the constant\r
+ * portTICK_PERIOD_MS should be used to convert to real time if this is required.\r
+ *\r
+ * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the\r
+ * item at the back of the queue, or queueSEND_TO_FRONT to place the item\r
+ * at the front of the queue (for high priority messages).\r
+ *\r
+ * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ struct AMessage\r
+ {\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
+ } xMessage;\r
+\r
+ uint32_t ulVar = 10UL;\r
+\r
+ void vATask( void *pvParameters )\r
+ {\r
+ QueueHandle_t xQueue1, xQueue2;\r
+ struct AMessage *pxMessage;\r
+\r
+       // Create a queue capable of containing 10 uint32_t values.\r
+       xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );\r
+\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+\r
+       // ...\r
+\r
+       if( xQueue1 != 0 )\r
+       {\r
+               // Send an uint32_t.  Wait for 10 ticks for space to become\r
+               // available if necessary.\r
+               if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10, queueSEND_TO_BACK ) != pdPASS )\r
+               {\r
+                       // Failed to post the message, even after 10 ticks.\r
+               }\r
+       }\r
+\r
+       if( xQueue2 != 0 )\r
+       {\r
+               // Send a pointer to a struct AMessage object.  Don't block if the\r
+               // queue is already full.\r
+               pxMessage = & xMessage;\r
+               xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0, queueSEND_TO_BACK );\r
+       }\r
+\r
+       // ... Rest of task code.\r
+ }\r
+ </pre>\r
+ * \defgroup xQueueSend xQueueSend\r
+ * \ingroup QueueManagement\r
+ */\r
+BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueuePeek(\r
+                                                        QueueHandle_t xQueue,\r
+                                                        void *pvBuffer,\r
+                                                        TickType_t xTicksToWait\r
+                                                );</pre>\r
+ *\r
+ * This is a macro that calls the xQueueGenericReceive() function.\r
+ *\r
+ * Receive an item from a queue without removing the item from the queue.\r
+ * The item is received by copy so a buffer of adequate size must be\r
+ * provided.  The number of bytes copied into the buffer was defined when\r
+ * the queue was created.\r
+ *\r
+ * Successfully received items remain on the queue so will be returned again\r
+ * by the next call, or a call to xQueueReceive().\r
+ *\r
+ * This macro must not be used in an interrupt service routine.  See\r
+ * xQueuePeekFromISR() for an alternative that can be called from an interrupt\r
+ * service routine.\r
+ *\r
+ * @param xQueue The handle to the queue from which the item is to be\r
+ * received.\r
+ *\r
+ * @param pvBuffer Pointer to the buffer into which the received item will\r
+ * be copied.\r
+ *\r
+ * @param xTicksToWait The maximum amount of time the task should block\r
+ * waiting for an item to receive should the queue be empty at the time\r
+ * of the call.         The time is defined in tick periods so the constant\r
+ * portTICK_PERIOD_MS should be used to convert to real time if this is required.\r
+ * xQueuePeek() will return immediately if xTicksToWait is 0 and the queue\r
+ * is empty.\r
+ *\r
+ * @return pdTRUE if an item was successfully received from the queue,\r
+ * otherwise pdFALSE.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ struct AMessage\r
+ {\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
+ } xMessage;\r
+\r
+ QueueHandle_t xQueue;\r
+\r
+ // Task to create a queue and post a value.\r
+ void vATask( void *pvParameters )\r
+ {\r
+ struct AMessage *pxMessage;\r
+\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+       if( xQueue == 0 )\r
+       {\r
+               // Failed to create the queue.\r
+       }\r
+\r
+       // ...\r
+\r
+       // Send a pointer to a struct AMessage object.  Don't block if the\r
+       // queue is already full.\r
+       pxMessage = & xMessage;\r
+       xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );\r
+\r
+       // ... Rest of task code.\r
+ }\r
+\r
+ // Task to peek the data from the queue.\r
+ void vADifferentTask( void *pvParameters )\r
+ {\r
+ struct AMessage *pxRxedMessage;\r
+\r
+       if( xQueue != 0 )\r
+       {\r
+               // Peek a message on the created queue.  Block for 10 ticks if a\r
+               // message is not immediately available.\r
+               if( xQueuePeek( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )\r
+               {\r
+                       // pcRxedMessage now points to the struct AMessage variable posted\r
+                       // by vATask, but the item still remains on the queue.\r
+               }\r
+       }\r
+\r
+       // ... Rest of task code.\r
+ }\r
+ </pre>\r
+ * \defgroup xQueueReceive xQueueReceive\r
+ * \ingroup QueueManagement\r
+ */\r
+#define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueuePeekFromISR(\r
+                                                                       QueueHandle_t xQueue,\r
+                                                                       void *pvBuffer,\r
+                                                               );</pre>\r
+ *\r
+ * A version of xQueuePeek() that can be called from an interrupt service\r
+ * routine (ISR).\r
+ *\r
+ * Receive an item from a queue without removing the item from the queue.\r
+ * The item is received by copy so a buffer of adequate size must be\r
+ * provided.  The number of bytes copied into the buffer was defined when\r
+ * the queue was created.\r
+ *\r
+ * Successfully received items remain on the queue so will be returned again\r
+ * by the next call, or a call to xQueueReceive().\r
+ *\r
+ * @param xQueue The handle to the queue from which the item is to be\r
+ * received.\r
+ *\r
+ * @param pvBuffer Pointer to the buffer into which the received item will\r
+ * be copied.\r
+ *\r
+ * @return pdTRUE if an item was successfully received from the queue,\r
+ * otherwise pdFALSE.\r
+ *\r
+ * \defgroup xQueuePeekFromISR xQueuePeekFromISR\r
+ * \ingroup QueueManagement\r
+ */\r
+BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueueReceive(\r
+                                                                QueueHandle_t xQueue,\r
+                                                                void *pvBuffer,\r
+                                                                TickType_t xTicksToWait\r
+                                                       );</pre>\r
+ *\r
+ * This is a macro that calls the xQueueGenericReceive() function.\r
+ *\r
+ * Receive an item from a queue.  The item is received by copy so a buffer of\r
+ * adequate size must be provided.  The number of bytes copied into the buffer\r
+ * was defined when the queue was created.\r
+ *\r
+ * Successfully received items are removed from the queue.\r
+ *\r
+ * This function must not be used in an interrupt service routine.  See\r
+ * xQueueReceiveFromISR for an alternative that can.\r
+ *\r
+ * @param xQueue The handle to the queue from which the item is to be\r
+ * received.\r
+ *\r
+ * @param pvBuffer Pointer to the buffer into which the received item will\r
+ * be copied.\r
+ *\r
+ * @param xTicksToWait The maximum amount of time the task should block\r
+ * waiting for an item to receive should the queue be empty at the time\r
+ * of the call.         xQueueReceive() will return immediately if xTicksToWait\r
+ * is zero and the queue is empty.  The time is defined in tick periods so the\r
+ * constant portTICK_PERIOD_MS should be used to convert to real time if this is\r
+ * required.\r
+ *\r
+ * @return pdTRUE if an item was successfully received from the queue,\r
+ * otherwise pdFALSE.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ struct AMessage\r
+ {\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
+ } xMessage;\r
+\r
+ QueueHandle_t xQueue;\r
+\r
+ // Task to create a queue and post a value.\r
+ void vATask( void *pvParameters )\r
+ {\r
+ struct AMessage *pxMessage;\r
+\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+       if( xQueue == 0 )\r
+       {\r
+               // Failed to create the queue.\r
+       }\r
+\r
+       // ...\r
+\r
+       // Send a pointer to a struct AMessage object.  Don't block if the\r
+       // queue is already full.\r
+       pxMessage = & xMessage;\r
+       xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );\r
+\r
+       // ... Rest of task code.\r
+ }\r
+\r
+ // Task to receive from the queue.\r
+ void vADifferentTask( void *pvParameters )\r
+ {\r
+ struct AMessage *pxRxedMessage;\r
+\r
+       if( xQueue != 0 )\r
+       {\r
+               // Receive a message on the created queue.  Block for 10 ticks if a\r
+               // message is not immediately available.\r
+               if( xQueueReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )\r
+               {\r
+                       // pcRxedMessage now points to the struct AMessage variable posted\r
+                       // by vATask.\r
+               }\r
+       }\r
+\r
+       // ... Rest of task code.\r
+ }\r
+ </pre>\r
+ * \defgroup xQueueReceive xQueueReceive\r
+ * \ingroup QueueManagement\r
+ */\r
+#define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )\r
+\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueueGenericReceive(\r
+                                                                          QueueHandle_t        xQueue,\r
+                                                                          void *pvBuffer,\r
+                                                                          TickType_t   xTicksToWait\r
+                                                                          BaseType_t   xJustPeek\r
+                                                                       );</pre>\r
+ *\r
+ * It is preferred that the macro xQueueReceive() be used rather than calling\r
+ * this function directly.\r
+ *\r
+ * Receive an item from a queue.  The item is received by copy so a buffer of\r
+ * adequate size must be provided.  The number of bytes copied into the buffer\r
+ * was defined when the queue was created.\r
+ *\r
+ * This function must not be used in an interrupt service routine.  See\r
+ * xQueueReceiveFromISR for an alternative that can.\r
+ *\r
+ * @param xQueue The handle to the queue from which the item is to be\r
+ * received.\r
+ *\r
+ * @param pvBuffer Pointer to the buffer into which the received item will\r
+ * be copied.\r
+ *\r
+ * @param xTicksToWait The maximum amount of time the task should block\r
+ * waiting for an item to receive should the queue be empty at the time\r
+ * of the call.         The time is defined in tick periods so the constant\r
+ * portTICK_PERIOD_MS should be used to convert to real time if this is required.\r
+ * xQueueGenericReceive() will return immediately if the queue is empty and\r
+ * xTicksToWait is 0.\r
+ *\r
+ * @param xJustPeek When set to true, the item received from the queue is not\r
+ * actually removed from the queue - meaning a subsequent call to\r
+ * xQueueReceive() will return the same item.  When set to false, the item\r
+ * being received from the queue is also removed from the queue.\r
+ *\r
+ * @return pdTRUE if an item was successfully received from the queue,\r
+ * otherwise pdFALSE.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ struct AMessage\r
+ {\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
+ } xMessage;\r
+\r
+ QueueHandle_t xQueue;\r
+\r
+ // Task to create a queue and post a value.\r
+ void vATask( void *pvParameters )\r
+ {\r
+ struct AMessage *pxMessage;\r
+\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+       if( xQueue == 0 )\r
+       {\r
+               // Failed to create the queue.\r
+       }\r
+\r
+       // ...\r
+\r
+       // Send a pointer to a struct AMessage object.  Don't block if the\r
+       // queue is already full.\r
+       pxMessage = & xMessage;\r
+       xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );\r
+\r
+       // ... Rest of task code.\r
+ }\r
+\r
+ // Task to receive from the queue.\r
+ void vADifferentTask( void *pvParameters )\r
+ {\r
+ struct AMessage *pxRxedMessage;\r
+\r
+       if( xQueue != 0 )\r
+       {\r
+               // Receive a message on the created queue.  Block for 10 ticks if a\r
+               // message is not immediately available.\r
+               if( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )\r
+               {\r
+                       // pcRxedMessage now points to the struct AMessage variable posted\r
+                       // by vATask.\r
+               }\r
+       }\r
+\r
+       // ... Rest of task code.\r
+ }\r
+ </pre>\r
+ * \defgroup xQueueReceive xQueueReceive\r
+ * \ingroup QueueManagement\r
+ */\r
+BaseType_t xQueueGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, const BaseType_t xJustPeek ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue );</pre>\r
+ *\r
+ * Return the number of messages stored in a queue.\r
+ *\r
+ * @param xQueue A handle to the queue being queried.\r
+ *\r
+ * @return The number of messages available in the queue.\r
+ *\r
+ * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting\r
+ * \ingroup QueueManagement\r
+ */\r
+UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue );</pre>\r
+ *\r
+ * Return the number of free spaces available in a queue.  This is equal to the\r
+ * number of items that can be sent to the queue before the queue becomes full\r
+ * if no items are removed.\r
+ *\r
+ * @param xQueue A handle to the queue being queried.\r
+ *\r
+ * @return The number of spaces available in the queue.\r
+ *\r
+ * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting\r
+ * \ingroup QueueManagement\r
+ */\r
+UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>void vQueueDelete( QueueHandle_t xQueue );</pre>\r
+ *\r
+ * Delete a queue - freeing all the memory allocated for storing of items\r
+ * placed on the queue.\r
+ *\r
+ * @param xQueue A handle to the queue to be deleted.\r
+ *\r
+ * \defgroup vQueueDelete vQueueDelete\r
+ * \ingroup QueueManagement\r
+ */\r
+void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueueSendToFrontFromISR(\r
+                                                                                QueueHandle_t xQueue,\r
+                                                                                const void *pvItemToQueue,\r
+                                                                                BaseType_t *pxHigherPriorityTaskWoken\r
+                                                                         );\r
+ </pre>\r
+ *\r
+ * This is a macro that calls xQueueGenericSendFromISR().\r
+ *\r
+ * Post an item to the front of a queue.  It is safe to use this macro from\r
+ * within an interrupt service routine.\r
+ *\r
+ * Items are queued by copy not reference so it is preferable to only\r
+ * queue small items, especially when called from an ISR.  In most cases\r
+ * it would be preferable to store a pointer to the item being queued.\r
+ *\r
+ * @param xQueue The handle to the queue on which the item is to be posted.\r
+ *\r
+ * @param pvItemToQueue A pointer to the item that is to be placed on the\r
+ * queue.  The size of the items the queue will hold was defined when the\r
+ * queue was created, so this many bytes will be copied from pvItemToQueue\r
+ * into the queue storage area.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set\r
+ * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
+ * to unblock, and the unblocked task has a priority higher than the currently\r
+ * running task.  If xQueueSendToFromFromISR() sets this value to pdTRUE then\r
+ * a context switch should be requested before the interrupt is exited.\r
+ *\r
+ * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
+ * errQUEUE_FULL.\r
+ *\r
+ * Example usage for buffered IO (where the ISR can obtain more than one value\r
+ * per call):\r
+   <pre>\r
+ void vBufferISR( void )\r
+ {\r
+ char cIn;\r
+ BaseType_t xHigherPrioritTaskWoken;\r
+\r
+       // We have not woken a task at the start of the ISR.\r
+       xHigherPriorityTaskWoken = pdFALSE;\r
+\r
+       // Loop until the buffer is empty.\r
+       do\r
+       {\r
+               // Obtain a byte from the buffer.\r
+               cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
+\r
+               // Post the byte.\r
+               xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
+\r
+       } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
+\r
+       // Now the buffer is empty we can switch context if necessary.\r
+       if( xHigherPriorityTaskWoken )\r
+       {\r
+               taskYIELD ();\r
+       }\r
+ }\r
+ </pre>\r
+ *\r
+ * \defgroup xQueueSendFromISR xQueueSendFromISR\r
+ * \ingroup QueueManagement\r
+ */\r
+#define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT )\r
+\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueueSendToBackFromISR(\r
+                                                                                QueueHandle_t xQueue,\r
+                                                                                const void *pvItemToQueue,\r
+                                                                                BaseType_t *pxHigherPriorityTaskWoken\r
+                                                                         );\r
+ </pre>\r
+ *\r
+ * This is a macro that calls xQueueGenericSendFromISR().\r
+ *\r
+ * Post an item to the back of a queue.  It is safe to use this macro from\r
+ * within an interrupt service routine.\r
+ *\r
+ * Items are queued by copy not reference so it is preferable to only\r
+ * queue small items, especially when called from an ISR.  In most cases\r
+ * it would be preferable to store a pointer to the item being queued.\r
+ *\r
+ * @param xQueue The handle to the queue on which the item is to be posted.\r
+ *\r
+ * @param pvItemToQueue A pointer to the item that is to be placed on the\r
+ * queue.  The size of the items the queue will hold was defined when the\r
+ * queue was created, so this many bytes will be copied from pvItemToQueue\r
+ * into the queue storage area.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set\r
+ * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
+ * to unblock, and the unblocked task has a priority higher than the currently\r
+ * running task.  If xQueueSendToBackFromISR() sets this value to pdTRUE then\r
+ * a context switch should be requested before the interrupt is exited.\r
+ *\r
+ * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
+ * errQUEUE_FULL.\r
+ *\r
+ * Example usage for buffered IO (where the ISR can obtain more than one value\r
+ * per call):\r
+   <pre>\r
+ void vBufferISR( void )\r
+ {\r
+ char cIn;\r
+ BaseType_t xHigherPriorityTaskWoken;\r
+\r
+       // We have not woken a task at the start of the ISR.\r
+       xHigherPriorityTaskWoken = pdFALSE;\r
+\r
+       // Loop until the buffer is empty.\r
+       do\r
+       {\r
+               // Obtain a byte from the buffer.\r
+               cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
+\r
+               // Post the byte.\r
+               xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
+\r
+       } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
+\r
+       // Now the buffer is empty we can switch context if necessary.\r
+       if( xHigherPriorityTaskWoken )\r
+       {\r
+               taskYIELD ();\r
+       }\r
+ }\r
+ </pre>\r
+ *\r
+ * \defgroup xQueueSendFromISR xQueueSendFromISR\r
+ * \ingroup QueueManagement\r
+ */\r
+#define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueueOverwriteFromISR(\r
+                                                         QueueHandle_t xQueue,\r
+                                                         const void * pvItemToQueue,\r
+                                                         BaseType_t *pxHigherPriorityTaskWoken\r
+                                                );\r
+ * </pre>\r
+ *\r
+ * A version of xQueueOverwrite() that can be used in an interrupt service\r
+ * routine (ISR).\r
+ *\r
+ * Only for use with queues that can hold a single item - so the queue is either\r
+ * empty or full.\r
+ *\r
+ * Post an item on a queue.  If the queue is already full then overwrite the\r
+ * value held in the queue.  The item is queued by copy, not by reference.\r
+ *\r
+ * @param xQueue The handle to the queue on which the item is to be posted.\r
+ *\r
+ * @param pvItemToQueue A pointer to the item that is to be placed on the\r
+ * queue.  The size of the items the queue will hold was defined when the\r
+ * queue was created, so this many bytes will be copied from pvItemToQueue\r
+ * into the queue storage area.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken xQueueOverwriteFromISR() will set\r
+ * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
+ * to unblock, and the unblocked task has a priority higher than the currently\r
+ * running task.  If xQueueOverwriteFromISR() sets this value to pdTRUE then\r
+ * a context switch should be requested before the interrupt is exited.\r
+ *\r
+ * @return xQueueOverwriteFromISR() is a macro that calls\r
+ * xQueueGenericSendFromISR(), and therefore has the same return values as\r
+ * xQueueSendToFrontFromISR().  However, pdPASS is the only value that can be\r
+ * returned because xQueueOverwriteFromISR() will write to the queue even when\r
+ * the queue is already full.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+\r
+ QueueHandle_t xQueue;\r
+\r
+ void vFunction( void *pvParameters )\r
+ {\r
+       // Create a queue to hold one uint32_t value.  It is strongly\r
+       // recommended *not* to use xQueueOverwriteFromISR() on queues that can\r
+       // contain more than one value, and doing so will trigger an assertion\r
+       // if configASSERT() is defined.\r
+       xQueue = xQueueCreate( 1, sizeof( uint32_t ) );\r
+}\r
+\r
+void vAnInterruptHandler( void )\r
+{\r
+// xHigherPriorityTaskWoken must be set to pdFALSE before it is used.\r
+BaseType_t xHigherPriorityTaskWoken = pdFALSE;\r
+uint32_t ulVarToSend, ulValReceived;\r
+\r
+       // Write the value 10 to the queue using xQueueOverwriteFromISR().\r
+       ulVarToSend = 10;\r
+       xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );\r
+\r
+       // The queue is full, but calling xQueueOverwriteFromISR() again will still\r
+       // pass because the value held in the queue will be overwritten with the\r
+       // new value.\r
+       ulVarToSend = 100;\r
+       xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );\r
+\r
+       // Reading from the queue will now return 100.\r
+\r
+       // ...\r
+\r
+       if( xHigherPrioritytaskWoken == pdTRUE )\r
+       {\r
+               // Writing to the queue caused a task to unblock and the unblocked task\r
+               // has a priority higher than or equal to the priority of the currently\r
+               // executing task (the task this interrupt interrupted).  Perform a context\r
+               // switch so this interrupt returns directly to the unblocked task.\r
+               portYIELD_FROM_ISR(); // or portEND_SWITCHING_ISR() depending on the port.\r
+       }\r
+}\r
+ </pre>\r
+ * \defgroup xQueueOverwriteFromISR xQueueOverwriteFromISR\r
+ * \ingroup QueueManagement\r
+ */\r
+#define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE )\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueueSendFromISR(\r
+                                                                        QueueHandle_t xQueue,\r
+                                                                        const void *pvItemToQueue,\r
+                                                                        BaseType_t *pxHigherPriorityTaskWoken\r
+                                                               );\r
+ </pre>\r
+ *\r
+ * This is a macro that calls xQueueGenericSendFromISR().  It is included\r
+ * for backward compatibility with versions of FreeRTOS.org that did not\r
+ * include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR()\r
+ * macros.\r
+ *\r
+ * Post an item to the back of a queue.  It is safe to use this function from\r
+ * within an interrupt service routine.\r
+ *\r
+ * Items are queued by copy not reference so it is preferable to only\r
+ * queue small items, especially when called from an ISR.  In most cases\r
+ * it would be preferable to store a pointer to the item being queued.\r
+ *\r
+ * @param xQueue The handle to the queue on which the item is to be posted.\r
+ *\r
+ * @param pvItemToQueue A pointer to the item that is to be placed on the\r
+ * queue.  The size of the items the queue will hold was defined when the\r
+ * queue was created, so this many bytes will be copied from pvItemToQueue\r
+ * into the queue storage area.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken xQueueSendFromISR() will set\r
+ * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
+ * to unblock, and the unblocked task has a priority higher than the currently\r
+ * running task.  If xQueueSendFromISR() sets this value to pdTRUE then\r
+ * a context switch should be requested before the interrupt is exited.\r
+ *\r
+ * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
+ * errQUEUE_FULL.\r
+ *\r
+ * Example usage for buffered IO (where the ISR can obtain more than one value\r
+ * per call):\r
+   <pre>\r
+ void vBufferISR( void )\r
+ {\r
+ char cIn;\r
+ BaseType_t xHigherPriorityTaskWoken;\r
+\r
+       // We have not woken a task at the start of the ISR.\r
+       xHigherPriorityTaskWoken = pdFALSE;\r
+\r
+       // Loop until the buffer is empty.\r
+       do\r
+       {\r
+               // Obtain a byte from the buffer.\r
+               cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
+\r
+               // Post the byte.\r
+               xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
+\r
+       } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
+\r
+       // Now the buffer is empty we can switch context if necessary.\r
+       if( xHigherPriorityTaskWoken )\r
+       {\r
+               // Actual macro used here is port specific.\r
+               portYIELD_FROM_ISR ();\r
+       }\r
+ }\r
+ </pre>\r
+ *\r
+ * \defgroup xQueueSendFromISR xQueueSendFromISR\r
+ * \ingroup QueueManagement\r
+ */\r
+#define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueueGenericSendFromISR(\r
+                                                                                  QueueHandle_t                xQueue,\r
+                                                                                  const        void    *pvItemToQueue,\r
+                                                                                  BaseType_t   *pxHigherPriorityTaskWoken,\r
+                                                                                  BaseType_t   xCopyPosition\r
+                                                                          );\r
+ </pre>\r
+ *\r
+ * It is preferred that the macros xQueueSendFromISR(),\r
+ * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place\r
+ * of calling this function directly.  xQueueGiveFromISR() is an\r
+ * equivalent for use by semaphores that don't actually copy any data.\r
+ *\r
+ * Post an item on a queue.  It is safe to use this function from within an\r
+ * interrupt service routine.\r
+ *\r
+ * Items are queued by copy not reference so it is preferable to only\r
+ * queue small items, especially when called from an ISR.  In most cases\r
+ * it would be preferable to store a pointer to the item being queued.\r
+ *\r
+ * @param xQueue The handle to the queue on which the item is to be posted.\r
+ *\r
+ * @param pvItemToQueue A pointer to the item that is to be placed on the\r
+ * queue.  The size of the items the queue will hold was defined when the\r
+ * queue was created, so this many bytes will be copied from pvItemToQueue\r
+ * into the queue storage area.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set\r
+ * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
+ * to unblock, and the unblocked task has a priority higher than the currently\r
+ * running task.  If xQueueGenericSendFromISR() sets this value to pdTRUE then\r
+ * a context switch should be requested before the interrupt is exited.\r
+ *\r
+ * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the\r
+ * item at the back of the queue, or queueSEND_TO_FRONT to place the item\r
+ * at the front of the queue (for high priority messages).\r
+ *\r
+ * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
+ * errQUEUE_FULL.\r
+ *\r
+ * Example usage for buffered IO (where the ISR can obtain more than one value\r
+ * per call):\r
+   <pre>\r
+ void vBufferISR( void )\r
+ {\r
+ char cIn;\r
+ BaseType_t xHigherPriorityTaskWokenByPost;\r
+\r
+       // We have not woken a task at the start of the ISR.\r
+       xHigherPriorityTaskWokenByPost = pdFALSE;\r
+\r
+       // Loop until the buffer is empty.\r
+       do\r
+       {\r
+               // Obtain a byte from the buffer.\r
+               cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
+\r
+               // Post each byte.\r
+               xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK );\r
+\r
+       } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
+\r
+       // Now the buffer is empty we can switch context if necessary.  Note that the\r
+       // name of the yield function required is port specific.\r
+       if( xHigherPriorityTaskWokenByPost )\r
+       {\r
+               taskYIELD_YIELD_FROM_ISR();\r
+       }\r
+ }\r
+ </pre>\r
+ *\r
+ * \defgroup xQueueSendFromISR xQueueSendFromISR\r
+ * \ingroup QueueManagement\r
+ */\r
+BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;\r
+BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ BaseType_t xQueueReceiveFromISR(\r
+                                                                          QueueHandle_t        xQueue,\r
+                                                                          void *pvBuffer,\r
+                                                                          BaseType_t *pxTaskWoken\r
+                                                                  );\r
+ * </pre>\r
+ *\r
+ * Receive an item from a queue.  It is safe to use this function from within an\r
+ * interrupt service routine.\r
+ *\r
+ * @param xQueue The handle to the queue from which the item is to be\r
+ * received.\r
+ *\r
+ * @param pvBuffer Pointer to the buffer into which the received item will\r
+ * be copied.\r
+ *\r
+ * @param pxTaskWoken A task may be blocked waiting for space to become\r
+ * available on the queue.  If xQueueReceiveFromISR causes such a task to\r
+ * unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will\r
+ * remain unchanged.\r
+ *\r
+ * @return pdTRUE if an item was successfully received from the queue,\r
+ * otherwise pdFALSE.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+\r
+ QueueHandle_t xQueue;\r
+\r
+ // Function to create a queue and post some values.\r
+ void vAFunction( void *pvParameters )\r
+ {\r
+ char cValueToPost;\r
+ const TickType_t xTicksToWait = ( TickType_t )0xff;\r
+\r
+       // Create a queue capable of containing 10 characters.\r
+       xQueue = xQueueCreate( 10, sizeof( char ) );\r
+       if( xQueue == 0 )\r
+       {\r
+               // Failed to create the queue.\r
+       }\r
+\r
+       // ...\r
+\r
+       // Post some characters that will be used within an ISR.  If the queue\r
+       // is full then this task will block for xTicksToWait ticks.\r
+       cValueToPost = 'a';\r
+       xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );\r
+       cValueToPost = 'b';\r
+       xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );\r
+\r
+       // ... keep posting characters ... this task may block when the queue\r
+       // becomes full.\r
+\r
+       cValueToPost = 'c';\r
+       xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );\r
+ }\r
+\r
+ // ISR that outputs all the characters received on the queue.\r
+ void vISR_Routine( void )\r
+ {\r
+ BaseType_t xTaskWokenByReceive = pdFALSE;\r
+ char cRxedChar;\r
+\r
+       while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )\r
+       {\r
+               // A character was received.  Output the character now.\r
+               vOutputCharacter( cRxedChar );\r
+\r
+               // If removing the character from the queue woke the task that was\r
+               // posting onto the queue cTaskWokenByReceive will have been set to\r
+               // pdTRUE.  No matter how many times this loop iterates only one\r
+               // task will be woken.\r
+       }\r
+\r
+       if( cTaskWokenByPost != ( char ) pdFALSE;\r
+       {\r
+               taskYIELD ();\r
+       }\r
+ }\r
+ </pre>\r
+ * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR\r
+ * \ingroup QueueManagement\r
+ */\r
+BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void * const pvBuffer, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Utilities to query queues that are safe to use from an ISR.  These utilities\r
+ * should be used only from witin an ISR, or within a critical section.\r
+ */\r
+BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
+BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
+UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
+\r
+\r
+/*\r
+ * xQueueAltGenericSend() is an alternative version of xQueueGenericSend().\r
+ * Likewise xQueueAltGenericReceive() is an alternative version of\r
+ * xQueueGenericReceive().\r
+ *\r
+ * The source code that implements the alternative (Alt) API is much\r
+ * simpler     because it executes everything from within a critical section.\r
+ * This is     the approach taken by many other RTOSes, but FreeRTOS.org has the\r
+ * preferred fully featured API too.  The fully featured API has more\r
+ * complex     code that takes longer to execute, but makes much less use of\r
+ * critical sections.  Therefore the alternative API sacrifices interrupt\r
+ * responsiveness to gain execution speed, whereas the fully featured API\r
+ * sacrifices execution speed to ensure better interrupt responsiveness.\r
+ */\r
+BaseType_t xQueueAltGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;\r
+BaseType_t xQueueAltGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, BaseType_t xJustPeeking ) PRIVILEGED_FUNCTION;\r
+#define xQueueAltSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT )\r
+#define xQueueAltSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )\r
+#define xQueueAltReceive( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )\r
+#define xQueueAltPeek( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )\r
+\r
+/*\r
+ * The functions defined above are for passing data to and from tasks.  The\r
+ * functions below are the equivalents for passing data to and from\r
+ * co-routines.\r
+ *\r
+ * These functions are called from the co-routine macro implementation and\r
+ * should not be called directly from application code.  Instead use the macro\r
+ * wrappers defined within croutine.h.\r
+ */\r
+BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken );\r
+BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxTaskWoken );\r
+BaseType_t xQueueCRSend( QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait );\r
+BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait );\r
+\r
+/*\r
+ * For internal use only.  Use xSemaphoreCreateMutex(),\r
+ * xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling\r
+ * these functions directly.\r
+ */\r
+QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;\r
+QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION;\r
+void* xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * For internal use only.  Use xSemaphoreTakeMutexRecursive() or\r
+ * xSemaphoreGiveMutexRecursive() instead of calling these functions directly.\r
+ */\r
+BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
+BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Reset a queue back to its original empty state.  The return value is now\r
+ * obsolete and is always set to pdPASS.\r
+ */\r
+#define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE )\r
+\r
+/*\r
+ * The registry is provided as a means for kernel aware debuggers to\r
+ * locate queues, semaphores and mutexes.  Call vQueueAddToRegistry() add\r
+ * a queue, semaphore or mutex handle to the registry if you want the handle\r
+ * to be available to a kernel aware debugger.  If you are not using a kernel\r
+ * aware debugger then this function can be ignored.\r
+ *\r
+ * configQUEUE_REGISTRY_SIZE defines the maximum number of handles the\r
+ * registry can hold.  configQUEUE_REGISTRY_SIZE must be greater than 0\r
+ * within FreeRTOSConfig.h for the registry to be available.  Its value\r
+ * does not effect the number of queues, semaphores and mutexes that can be\r
+ * created - just the number that the registry can hold.\r
+ *\r
+ * @param xQueue The handle of the queue being added to the registry.  This\r
+ * is the handle returned by a call to xQueueCreate().  Semaphore and mutex\r
+ * handles can also be passed in here.\r
+ *\r
+ * @param pcName The name to be associated with the handle.  This is the\r
+ * name that the kernel aware debugger will display.  The queue registry only\r
+ * stores a pointer to the string - so the string must be persistent (global or\r
+ * preferably in ROM/Flash), not on the stack.\r
+ */\r
+#if configQUEUE_REGISTRY_SIZE > 0\r
+       void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+#endif\r
+\r
+/*\r
+ * The registry is provided as a means for kernel aware debuggers to\r
+ * locate queues, semaphores and mutexes.  Call vQueueAddToRegistry() add\r
+ * a queue, semaphore or mutex handle to the registry if you want the handle\r
+ * to be available to a kernel aware debugger, and vQueueUnregisterQueue() to\r
+ * remove the queue, semaphore or mutex from the register.  If you are not using\r
+ * a kernel aware debugger then this function can be ignored.\r
+ *\r
+ * @param xQueue The handle of the queue being removed from the registry.\r
+ */\r
+#if configQUEUE_REGISTRY_SIZE > 0\r
+       void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
+#endif\r
+\r
+/*\r
+ * Generic version of the queue creation function, which is in turn called by\r
+ * any queue, semaphore or mutex creation function or macro.\r
+ */\r
+QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Queue sets provide a mechanism to allow a task to block (pend) on a read\r
+ * operation from multiple queues or semaphores simultaneously.\r
+ *\r
+ * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
+ * function.\r
+ *\r
+ * A queue set must be explicitly created using a call to xQueueCreateSet()\r
+ * before it can be used.  Once created, standard FreeRTOS queues and semaphores\r
+ * can be added to the set using calls to xQueueAddToSet().\r
+ * xQueueSelectFromSet() is then used to determine which, if any, of the queues\r
+ * or semaphores contained in the set is in a state where a queue read or\r
+ * semaphore take operation would be successful.\r
+ *\r
+ * Note 1:  See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html\r
+ * for reasons why queue sets are very rarely needed in practice as there are\r
+ * simpler methods of blocking on multiple objects.\r
+ *\r
+ * Note 2:  Blocking on a queue set that contains a mutex will not cause the\r
+ * mutex holder to inherit the priority of the blocked task.\r
+ *\r
+ * Note 3:  An additional 4 bytes of RAM is required for each space in a every\r
+ * queue added to a queue set.  Therefore counting semaphores that have a high\r
+ * maximum count value should not be added to a queue set.\r
+ *\r
+ * Note 4:  A receive (in the case of a queue) or take (in the case of a\r
+ * semaphore) operation must not be performed on a member of a queue set unless\r
+ * a call to xQueueSelectFromSet() has first returned a handle to that set member.\r
+ *\r
+ * @param uxEventQueueLength Queue sets store events that occur on\r
+ * the queues and semaphores contained in the set.  uxEventQueueLength specifies\r
+ * the maximum number of events that can be queued at once.  To be absolutely\r
+ * certain that events are not lost uxEventQueueLength should be set to the\r
+ * total sum of the length of the queues added to the set, where binary\r
+ * semaphores and mutexes have a length of 1, and counting semaphores have a\r
+ * length set by their maximum count value.  Examples:\r
+ *  + If a queue set is to hold a queue of length 5, another queue of length 12,\r
+ *    and a binary semaphore, then uxEventQueueLength should be set to\r
+ *    (5 + 12 + 1), or 18.\r
+ *  + If a queue set is to hold three binary semaphores then uxEventQueueLength\r
+ *    should be set to (1 + 1 + 1 ), or 3.\r
+ *  + If a queue set is to hold a counting semaphore that has a maximum count of\r
+ *    5, and a counting semaphore that has a maximum count of 3, then\r
+ *    uxEventQueueLength should be set to (5 + 3), or 8.\r
+ *\r
+ * @return If the queue set is created successfully then a handle to the created\r
+ * queue set is returned.  Otherwise NULL is returned.\r
+ */\r
+QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Adds a queue or semaphore to a queue set that was previously created by a\r
+ * call to xQueueCreateSet().\r
+ *\r
+ * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
+ * function.\r
+ *\r
+ * Note 1:  A receive (in the case of a queue) or take (in the case of a\r
+ * semaphore) operation must not be performed on a member of a queue set unless\r
+ * a call to xQueueSelectFromSet() has first returned a handle to that set member.\r
+ *\r
+ * @param xQueueOrSemaphore The handle of the queue or semaphore being added to\r
+ * the queue set (cast to an QueueSetMemberHandle_t type).\r
+ *\r
+ * @param xQueueSet The handle of the queue set to which the queue or semaphore\r
+ * is being added.\r
+ *\r
+ * @return If the queue or semaphore was successfully added to the queue set\r
+ * then pdPASS is returned.  If the queue could not be successfully added to the\r
+ * queue set because it is already a member of a different queue set then pdFAIL\r
+ * is returned.\r
+ */\r
+BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Removes a queue or semaphore from a queue set.  A queue or semaphore can only\r
+ * be removed from a set if the queue or semaphore is empty.\r
+ *\r
+ * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
+ * function.\r
+ *\r
+ * @param xQueueOrSemaphore The handle of the queue or semaphore being removed\r
+ * from the queue set (cast to an QueueSetMemberHandle_t type).\r
+ *\r
+ * @param xQueueSet The handle of the queue set in which the queue or semaphore\r
+ * is included.\r
+ *\r
+ * @return If the queue or semaphore was successfully removed from the queue set\r
+ * then pdPASS is returned.  If the queue was not in the queue set, or the\r
+ * queue (or semaphore) was not empty, then pdFAIL is returned.\r
+ */\r
+BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * xQueueSelectFromSet() selects from the members of a queue set a queue or\r
+ * semaphore that either contains data (in the case of a queue) or is available\r
+ * to take (in the case of a semaphore).  xQueueSelectFromSet() effectively\r
+ * allows a task to block (pend) on a read operation on all the queues and\r
+ * semaphores in a queue set simultaneously.\r
+ *\r
+ * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
+ * function.\r
+ *\r
+ * Note 1:  See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html\r
+ * for reasons why queue sets are very rarely needed in practice as there are\r
+ * simpler methods of blocking on multiple objects.\r
+ *\r
+ * Note 2:  Blocking on a queue set that contains a mutex will not cause the\r
+ * mutex holder to inherit the priority of the blocked task.\r
+ *\r
+ * Note 3:  A receive (in the case of a queue) or take (in the case of a\r
+ * semaphore) operation must not be performed on a member of a queue set unless\r
+ * a call to xQueueSelectFromSet() has first returned a handle to that set member.\r
+ *\r
+ * @param xQueueSet The queue set on which the task will (potentially) block.\r
+ *\r
+ * @param xTicksToWait The maximum time, in ticks, that the calling task will\r
+ * remain in the Blocked state (with other tasks executing) to wait for a member\r
+ * of the queue set to be ready for a successful queue read or semaphore take\r
+ * operation.\r
+ *\r
+ * @return xQueueSelectFromSet() will return the handle of a queue (cast to\r
+ * a QueueSetMemberHandle_t type) contained in the queue set that contains data,\r
+ * or the handle of a semaphore (cast to a QueueSetMemberHandle_t type) contained\r
+ * in the queue set that is available, or NULL if no such queue or semaphore\r
+ * exists before before the specified block time expires.\r
+ */\r
+QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * A version of xQueueSelectFromSet() that can be used from an ISR.\r
+ */\r
+QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;\r
+\r
+/* Not public API functions. */\r
+void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;\r
+BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) PRIVILEGED_FUNCTION;\r
+void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ) PRIVILEGED_FUNCTION;\r
+UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
+uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
+\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* QUEUE_H */\r
+\r
diff --git a/os/8.2.2/include/os/semphr.h b/os/8.2.2/include/os/semphr.h
new file mode 100644 (file)
index 0000000..2266bb9
--- /dev/null
@@ -0,0 +1,844 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+#ifndef SEMAPHORE_H\r
+#define SEMAPHORE_H\r
+\r
+#ifndef INC_FREERTOS_H\r
+       #error "include FreeRTOS.h" must appear in source files before "include semphr.h"\r
+#endif\r
+\r
+#include "queue.h"\r
+\r
+typedef QueueHandle_t SemaphoreHandle_t;\r
+\r
+#define semBINARY_SEMAPHORE_QUEUE_LENGTH       ( ( uint8_t ) 1U )\r
+#define semSEMAPHORE_QUEUE_ITEM_LENGTH         ( ( uint8_t ) 0U )\r
+#define semGIVE_BLOCK_TIME                                     ( ( TickType_t ) 0U )\r
+\r
+\r
+/**\r
+ * semphr. h\r
+ * <pre>vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore )</pre>\r
+ *\r
+ * This old vSemaphoreCreateBinary() macro is now deprecated in favour of the\r
+ * xSemaphoreCreateBinary() function.  Note that binary semaphores created using\r
+ * the vSemaphoreCreateBinary() macro are created in a state such that the\r
+ * first call to 'take' the semaphore would pass, whereas binary semaphores\r
+ * created using xSemaphoreCreateBinary() are created in a state such that the\r
+ * the semaphore must first be 'given' before it can be 'taken'.\r
+ *\r
+ * <i>Macro</i> that implements a semaphore by using the existing queue mechanism.\r
+ * The queue length is 1 as this is a binary semaphore.  The data size is 0\r
+ * as we don't want to actually store any data - we just want to know if the\r
+ * queue is empty or full.\r
+ *\r
+ * This type of semaphore can be used for pure synchronisation between tasks or\r
+ * between an interrupt and a task.  The semaphore need not be given back once\r
+ * obtained, so one task/interrupt can continuously 'give' the semaphore while\r
+ * another continuously 'takes' the semaphore.  For this reason this type of\r
+ * semaphore does not use a priority inheritance mechanism.  For an alternative\r
+ * that does use priority inheritance see xSemaphoreCreateMutex().\r
+ *\r
+ * @param xSemaphore Handle to the created semaphore.  Should be of type SemaphoreHandle_t.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ SemaphoreHandle_t xSemaphore = NULL;\r
+\r
+ void vATask( void * pvParameters )\r
+ {\r
+    // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().\r
+    // This is a macro so pass the variable in directly.\r
+    vSemaphoreCreateBinary( xSemaphore );\r
+\r
+    if( xSemaphore != NULL )\r
+    {\r
+        // The semaphore was created successfully.\r
+        // The semaphore can now be used.\r
+    }\r
+ }\r
+ </pre>\r
+ * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary\r
+ * \ingroup Semaphores\r
+ */\r
+#define vSemaphoreCreateBinary( xSemaphore )                                                                                                                                                                                   \\r
+       {                                                                                                                                                                                                                                                                       \\r
+               ( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE );    \\r
+               if( ( xSemaphore ) != NULL )                                                                                                                                                                                                    \\r
+               {                                                                                                                                                                                                                                                               \\r
+                       ( void ) xSemaphoreGive( ( xSemaphore ) );                                                                                                                                                                      \\r
+               }                                                                                                                                                                                                                                                               \\r
+       }\r
+\r
+/**\r
+ * semphr. h\r
+ * <pre>SemaphoreHandle_t xSemaphoreCreateBinary( void )</pre>\r
+ *\r
+ * The old vSemaphoreCreateBinary() macro is now deprecated in favour of this\r
+ * xSemaphoreCreateBinary() function.  Note that binary semaphores created using\r
+ * the vSemaphoreCreateBinary() macro are created in a state such that the\r
+ * first call to 'take' the semaphore would pass, whereas binary semaphores\r
+ * created using xSemaphoreCreateBinary() are created in a state such that the\r
+ * the semaphore must first be 'given' before it can be 'taken'.\r
+ *\r
+ * Function that creates a semaphore by using the existing queue mechanism.\r
+ * The queue length is 1 as this is a binary semaphore.  The data size is 0\r
+ * as nothing is actually stored - all that is important is whether the queue is\r
+ * empty or full (the binary semaphore is available or not).\r
+ *\r
+ * This type of semaphore can be used for pure synchronisation between tasks or\r
+ * between an interrupt and a task.  The semaphore need not be given back once\r
+ * obtained, so one task/interrupt can continuously 'give' the semaphore while\r
+ * another continuously 'takes' the semaphore.  For this reason this type of\r
+ * semaphore does not use a priority inheritance mechanism.  For an alternative\r
+ * that does use priority inheritance see xSemaphoreCreateMutex().\r
+ *\r
+ * @return Handle to the created semaphore.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ SemaphoreHandle_t xSemaphore = NULL;\r
+\r
+ void vATask( void * pvParameters )\r
+ {\r
+    // Semaphore cannot be used before a call to vSemaphoreCreateBinary ().\r
+    // This is a macro so pass the variable in directly.\r
+    xSemaphore = xSemaphoreCreateBinary();\r
+\r
+    if( xSemaphore != NULL )\r
+    {\r
+        // The semaphore was created successfully.\r
+        // The semaphore can now be used.\r
+    }\r
+ }\r
+ </pre>\r
+ * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary\r
+ * \ingroup Semaphores\r
+ */\r
+#define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE )\r
+\r
+/**\r
+ * semphr. h\r
+ * <pre>xSemaphoreTake(\r
+ *                   SemaphoreHandle_t xSemaphore,\r
+ *                   TickType_t xBlockTime\r
+ *               )</pre>\r
+ *\r
+ * <i>Macro</i> to obtain a semaphore.  The semaphore must have previously been\r
+ * created with a call to vSemaphoreCreateBinary(), xSemaphoreCreateMutex() or\r
+ * xSemaphoreCreateCounting().\r
+ *\r
+ * @param xSemaphore A handle to the semaphore being taken - obtained when\r
+ * the semaphore was created.\r
+ *\r
+ * @param xBlockTime The time in ticks to wait for the semaphore to become\r
+ * available.  The macro portTICK_PERIOD_MS can be used to convert this to a\r
+ * real time.  A block time of zero can be used to poll the semaphore.  A block\r
+ * time of portMAX_DELAY can be used to block indefinitely (provided\r
+ * INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h).\r
+ *\r
+ * @return pdTRUE if the semaphore was obtained.  pdFALSE\r
+ * if xBlockTime expired without the semaphore becoming available.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ SemaphoreHandle_t xSemaphore = NULL;\r
+\r
+ // A task that creates a semaphore.\r
+ void vATask( void * pvParameters )\r
+ {\r
+    // Create the semaphore to guard a shared resource.\r
+    vSemaphoreCreateBinary( xSemaphore );\r
+ }\r
+\r
+ // A task that uses the semaphore.\r
+ void vAnotherTask( void * pvParameters )\r
+ {\r
+    // ... Do other things.\r
+\r
+    if( xSemaphore != NULL )\r
+    {\r
+        // See if we can obtain the semaphore.  If the semaphore is not available\r
+        // wait 10 ticks to see if it becomes free.\r
+        if( xSemaphoreTake( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )\r
+        {\r
+            // We were able to obtain the semaphore and can now access the\r
+            // shared resource.\r
+\r
+            // ...\r
+\r
+            // We have finished accessing the shared resource.  Release the\r
+            // semaphore.\r
+            xSemaphoreGive( xSemaphore );\r
+        }\r
+        else\r
+        {\r
+            // We could not obtain the semaphore and can therefore not access\r
+            // the shared resource safely.\r
+        }\r
+    }\r
+ }\r
+ </pre>\r
+ * \defgroup xSemaphoreTake xSemaphoreTake\r
+ * \ingroup Semaphores\r
+ */\r
+#define xSemaphoreTake( xSemaphore, xBlockTime )               xQueueGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE )\r
+\r
+/**\r
+ * semphr. h\r
+ * xSemaphoreTakeRecursive(\r
+ *                          SemaphoreHandle_t xMutex,\r
+ *                          TickType_t xBlockTime\r
+ *                        )\r
+ *\r
+ * <i>Macro</i> to recursively obtain, or 'take', a mutex type semaphore.\r
+ * The mutex must have previously been created using a call to\r
+ * xSemaphoreCreateRecursiveMutex();\r
+ *\r
+ * configUSE_RECURSIVE_MUTEXES must be set to 1 in FreeRTOSConfig.h for this\r
+ * macro to be available.\r
+ *\r
+ * This macro must not be used on mutexes created using xSemaphoreCreateMutex().\r
+ *\r
+ * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex\r
+ * doesn't become available again until the owner has called\r
+ * xSemaphoreGiveRecursive() for each successful 'take' request.  For example,\r
+ * if a task successfully 'takes' the same mutex 5 times then the mutex will\r
+ * not be available to any other task until it has also  'given' the mutex back\r
+ * exactly five times.\r
+ *\r
+ * @param xMutex A handle to the mutex being obtained.  This is the\r
+ * handle returned by xSemaphoreCreateRecursiveMutex();\r
+ *\r
+ * @param xBlockTime The time in ticks to wait for the semaphore to become\r
+ * available.  The macro portTICK_PERIOD_MS can be used to convert this to a\r
+ * real time.  A block time of zero can be used to poll the semaphore.  If\r
+ * the task already owns the semaphore then xSemaphoreTakeRecursive() will\r
+ * return immediately no matter what the value of xBlockTime.\r
+ *\r
+ * @return pdTRUE if the semaphore was obtained.  pdFALSE if xBlockTime\r
+ * expired without the semaphore becoming available.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ SemaphoreHandle_t xMutex = NULL;\r
+\r
+ // A task that creates a mutex.\r
+ void vATask( void * pvParameters )\r
+ {\r
+    // Create the mutex to guard a shared resource.\r
+    xMutex = xSemaphoreCreateRecursiveMutex();\r
+ }\r
+\r
+ // A task that uses the mutex.\r
+ void vAnotherTask( void * pvParameters )\r
+ {\r
+    // ... Do other things.\r
+\r
+    if( xMutex != NULL )\r
+    {\r
+        // See if we can obtain the mutex.  If the mutex is not available\r
+        // wait 10 ticks to see if it becomes free.\r
+        if( xSemaphoreTakeRecursive( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )\r
+        {\r
+            // We were able to obtain the mutex and can now access the\r
+            // shared resource.\r
+\r
+            // ...\r
+            // For some reason due to the nature of the code further calls to\r
+                       // xSemaphoreTakeRecursive() are made on the same mutex.  In real\r
+                       // code these would not be just sequential calls as this would make\r
+                       // no sense.  Instead the calls are likely to be buried inside\r
+                       // a more complex call structure.\r
+            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );\r
+            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );\r
+\r
+            // The mutex has now been 'taken' three times, so will not be\r
+                       // available to another task until it has also been given back\r
+                       // three times.  Again it is unlikely that real code would have\r
+                       // these calls sequentially, but instead buried in a more complex\r
+                       // call structure.  This is just for illustrative purposes.\r
+            xSemaphoreGiveRecursive( xMutex );\r
+                       xSemaphoreGiveRecursive( xMutex );\r
+                       xSemaphoreGiveRecursive( xMutex );\r
+\r
+                       // Now the mutex can be taken by other tasks.\r
+        }\r
+        else\r
+        {\r
+            // We could not obtain the mutex and can therefore not access\r
+            // the shared resource safely.\r
+        }\r
+    }\r
+ }\r
+ </pre>\r
+ * \defgroup xSemaphoreTakeRecursive xSemaphoreTakeRecursive\r
+ * \ingroup Semaphores\r
+ */\r
+#define xSemaphoreTakeRecursive( xMutex, xBlockTime )  xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) )\r
+\r
+\r
+/*\r
+ * xSemaphoreAltTake() is an alternative version of xSemaphoreTake().\r
+ *\r
+ * The source code that implements the alternative (Alt) API is much\r
+ * simpler     because it executes everything from within a critical section.\r
+ * This is     the approach taken by many other RTOSes, but FreeRTOS.org has the\r
+ * preferred fully featured API too.  The fully featured API has more\r
+ * complex     code that takes longer to execute, but makes much less use of\r
+ * critical sections.  Therefore the alternative API sacrifices interrupt\r
+ * responsiveness to gain execution speed, whereas the fully featured API\r
+ * sacrifices execution speed to ensure better interrupt responsiveness.\r
+ */\r
+#define xSemaphoreAltTake( xSemaphore, xBlockTime )            xQueueAltGenericReceive( ( QueueHandle_t ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE )\r
+\r
+/**\r
+ * semphr. h\r
+ * <pre>xSemaphoreGive( SemaphoreHandle_t xSemaphore )</pre>\r
+ *\r
+ * <i>Macro</i> to release a semaphore.  The semaphore must have previously been\r
+ * created with a call to vSemaphoreCreateBinary(), xSemaphoreCreateMutex() or\r
+ * xSemaphoreCreateCounting(). and obtained using sSemaphoreTake().\r
+ *\r
+ * This macro must not be used from an ISR.  See xSemaphoreGiveFromISR () for\r
+ * an alternative which can be used from an ISR.\r
+ *\r
+ * This macro must also not be used on semaphores created using\r
+ * xSemaphoreCreateRecursiveMutex().\r
+ *\r
+ * @param xSemaphore A handle to the semaphore being released.  This is the\r
+ * handle returned when the semaphore was created.\r
+ *\r
+ * @return pdTRUE if the semaphore was released.  pdFALSE if an error occurred.\r
+ * Semaphores are implemented using queues.  An error can occur if there is\r
+ * no space on the queue to post a message - indicating that the\r
+ * semaphore was not first obtained correctly.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ SemaphoreHandle_t xSemaphore = NULL;\r
+\r
+ void vATask( void * pvParameters )\r
+ {\r
+    // Create the semaphore to guard a shared resource.\r
+    vSemaphoreCreateBinary( xSemaphore );\r
+\r
+    if( xSemaphore != NULL )\r
+    {\r
+        if( xSemaphoreGive( xSemaphore ) != pdTRUE )\r
+        {\r
+            // We would expect this call to fail because we cannot give\r
+            // a semaphore without first "taking" it!\r
+        }\r
+\r
+        // Obtain the semaphore - don't block if the semaphore is not\r
+        // immediately available.\r
+        if( xSemaphoreTake( xSemaphore, ( TickType_t ) 0 ) )\r
+        {\r
+            // We now have the semaphore and can access the shared resource.\r
+\r
+            // ...\r
+\r
+            // We have finished accessing the shared resource so can free the\r
+            // semaphore.\r
+            if( xSemaphoreGive( xSemaphore ) != pdTRUE )\r
+            {\r
+                // We would not expect this call to fail because we must have\r
+                // obtained the semaphore to get here.\r
+            }\r
+        }\r
+    }\r
+ }\r
+ </pre>\r
+ * \defgroup xSemaphoreGive xSemaphoreGive\r
+ * \ingroup Semaphores\r
+ */\r
+#define xSemaphoreGive( xSemaphore )           xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )\r
+\r
+/**\r
+ * semphr. h\r
+ * <pre>xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex )</pre>\r
+ *\r
+ * <i>Macro</i> to recursively release, or 'give', a mutex type semaphore.\r
+ * The mutex must have previously been created using a call to\r
+ * xSemaphoreCreateRecursiveMutex();\r
+ *\r
+ * configUSE_RECURSIVE_MUTEXES must be set to 1 in FreeRTOSConfig.h for this\r
+ * macro to be available.\r
+ *\r
+ * This macro must not be used on mutexes created using xSemaphoreCreateMutex().\r
+ *\r
+ * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex\r
+ * doesn't become available again until the owner has called\r
+ * xSemaphoreGiveRecursive() for each successful 'take' request.  For example,\r
+ * if a task successfully 'takes' the same mutex 5 times then the mutex will\r
+ * not be available to any other task until it has also  'given' the mutex back\r
+ * exactly five times.\r
+ *\r
+ * @param xMutex A handle to the mutex being released, or 'given'.  This is the\r
+ * handle returned by xSemaphoreCreateMutex();\r
+ *\r
+ * @return pdTRUE if the semaphore was given.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ SemaphoreHandle_t xMutex = NULL;\r
+\r
+ // A task that creates a mutex.\r
+ void vATask( void * pvParameters )\r
+ {\r
+    // Create the mutex to guard a shared resource.\r
+    xMutex = xSemaphoreCreateRecursiveMutex();\r
+ }\r
+\r
+ // A task that uses the mutex.\r
+ void vAnotherTask( void * pvParameters )\r
+ {\r
+    // ... Do other things.\r
+\r
+    if( xMutex != NULL )\r
+    {\r
+        // See if we can obtain the mutex.  If the mutex is not available\r
+        // wait 10 ticks to see if it becomes free.\r
+        if( xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 ) == pdTRUE )\r
+        {\r
+            // We were able to obtain the mutex and can now access the\r
+            // shared resource.\r
+\r
+            // ...\r
+            // For some reason due to the nature of the code further calls to\r
+                       // xSemaphoreTakeRecursive() are made on the same mutex.  In real\r
+                       // code these would not be just sequential calls as this would make\r
+                       // no sense.  Instead the calls are likely to be buried inside\r
+                       // a more complex call structure.\r
+            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );\r
+            xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );\r
+\r
+            // The mutex has now been 'taken' three times, so will not be\r
+                       // available to another task until it has also been given back\r
+                       // three times.  Again it is unlikely that real code would have\r
+                       // these calls sequentially, it would be more likely that the calls\r
+                       // to xSemaphoreGiveRecursive() would be called as a call stack\r
+                       // unwound.  This is just for demonstrative purposes.\r
+            xSemaphoreGiveRecursive( xMutex );\r
+                       xSemaphoreGiveRecursive( xMutex );\r
+                       xSemaphoreGiveRecursive( xMutex );\r
+\r
+                       // Now the mutex can be taken by other tasks.\r
+        }\r
+        else\r
+        {\r
+            // We could not obtain the mutex and can therefore not access\r
+            // the shared resource safely.\r
+        }\r
+    }\r
+ }\r
+ </pre>\r
+ * \defgroup xSemaphoreGiveRecursive xSemaphoreGiveRecursive\r
+ * \ingroup Semaphores\r
+ */\r
+#define xSemaphoreGiveRecursive( xMutex )      xQueueGiveMutexRecursive( ( xMutex ) )\r
+\r
+/*\r
+ * xSemaphoreAltGive() is an alternative version of xSemaphoreGive().\r
+ *\r
+ * The source code that implements the alternative (Alt) API is much\r
+ * simpler     because it executes everything from within a critical section.\r
+ * This is     the approach taken by many other RTOSes, but FreeRTOS.org has the\r
+ * preferred fully featured API too.  The fully featured API has more\r
+ * complex     code that takes longer to execute, but makes much less use of\r
+ * critical sections.  Therefore the alternative API sacrifices interrupt\r
+ * responsiveness to gain execution speed, whereas the fully featured API\r
+ * sacrifices execution speed to ensure better interrupt responsiveness.\r
+ */\r
+#define xSemaphoreAltGive( xSemaphore )                xQueueAltGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )\r
+\r
+/**\r
+ * semphr. h\r
+ * <pre>\r
+ xSemaphoreGiveFromISR(\r
+                          SemaphoreHandle_t xSemaphore,\r
+                          BaseType_t *pxHigherPriorityTaskWoken\r
+                      )</pre>\r
+ *\r
+ * <i>Macro</i> to  release a semaphore.  The semaphore must have previously been\r
+ * created with a call to vSemaphoreCreateBinary() or xSemaphoreCreateCounting().\r
+ *\r
+ * Mutex type semaphores (those created using a call to xSemaphoreCreateMutex())\r
+ * must not be used with this macro.\r
+ *\r
+ * This macro can be used from an ISR.\r
+ *\r
+ * @param xSemaphore A handle to the semaphore being released.  This is the\r
+ * handle returned when the semaphore was created.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken xSemaphoreGiveFromISR() will set\r
+ * *pxHigherPriorityTaskWoken to pdTRUE if giving the semaphore caused a task\r
+ * to unblock, and the unblocked task has a priority higher than the currently\r
+ * running task.  If xSemaphoreGiveFromISR() sets this value to pdTRUE then\r
+ * a context switch should be requested before the interrupt is exited.\r
+ *\r
+ * @return pdTRUE if the semaphore was successfully given, otherwise errQUEUE_FULL.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ \#define LONG_TIME 0xffff\r
+ \#define TICKS_TO_WAIT        10\r
+ SemaphoreHandle_t xSemaphore = NULL;\r
+\r
+ // Repetitive task.\r
+ void vATask( void * pvParameters )\r
+ {\r
+    for( ;; )\r
+    {\r
+        // We want this task to run every 10 ticks of a timer.  The semaphore\r
+        // was created before this task was started.\r
+\r
+        // Block waiting for the semaphore to become available.\r
+        if( xSemaphoreTake( xSemaphore, LONG_TIME ) == pdTRUE )\r
+        {\r
+            // It is time to execute.\r
+\r
+            // ...\r
+\r
+            // We have finished our task.  Return to the top of the loop where\r
+            // we will block on the semaphore until it is time to execute\r
+            // again.  Note when using the semaphore for synchronisation with an\r
+                       // ISR in this manner there is no need to 'give' the semaphore back.\r
+        }\r
+    }\r
+ }\r
+\r
+ // Timer ISR\r
+ void vTimerISR( void * pvParameters )\r
+ {\r
+ static uint8_t ucLocalTickCount = 0;\r
+ static BaseType_t xHigherPriorityTaskWoken;\r
+\r
+    // A timer tick has occurred.\r
+\r
+    // ... Do other time functions.\r
+\r
+    // Is it time for vATask () to run?\r
+       xHigherPriorityTaskWoken = pdFALSE;\r
+    ucLocalTickCount++;\r
+    if( ucLocalTickCount >= TICKS_TO_WAIT )\r
+    {\r
+        // Unblock the task by releasing the semaphore.\r
+        xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );\r
+\r
+        // Reset the count so we release the semaphore again in 10 ticks time.\r
+        ucLocalTickCount = 0;\r
+    }\r
+\r
+    if( xHigherPriorityTaskWoken != pdFALSE )\r
+    {\r
+        // We can force a context switch here.  Context switching from an\r
+        // ISR uses port specific syntax.  Check the demo task for your port\r
+        // to find the syntax required.\r
+    }\r
+ }\r
+ </pre>\r
+ * \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR\r
+ * \ingroup Semaphores\r
+ */\r
+#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) )\r
+\r
+/**\r
+ * semphr. h\r
+ * <pre>\r
+ xSemaphoreTakeFromISR(\r
+                          SemaphoreHandle_t xSemaphore,\r
+                          BaseType_t *pxHigherPriorityTaskWoken\r
+                      )</pre>\r
+ *\r
+ * <i>Macro</i> to  take a semaphore from an ISR.  The semaphore must have\r
+ * previously been created with a call to vSemaphoreCreateBinary() or\r
+ * xSemaphoreCreateCounting().\r
+ *\r
+ * Mutex type semaphores (those created using a call to xSemaphoreCreateMutex())\r
+ * must not be used with this macro.\r
+ *\r
+ * This macro can be used from an ISR, however taking a semaphore from an ISR\r
+ * is not a common operation.  It is likely to only be useful when taking a\r
+ * counting semaphore when an interrupt is obtaining an object from a resource\r
+ * pool (when the semaphore count indicates the number of resources available).\r
+ *\r
+ * @param xSemaphore A handle to the semaphore being taken.  This is the\r
+ * handle returned when the semaphore was created.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken xSemaphoreTakeFromISR() will set\r
+ * *pxHigherPriorityTaskWoken to pdTRUE if taking the semaphore caused a task\r
+ * to unblock, and the unblocked task has a priority higher than the currently\r
+ * running task.  If xSemaphoreTakeFromISR() sets this value to pdTRUE then\r
+ * a context switch should be requested before the interrupt is exited.\r
+ *\r
+ * @return pdTRUE if the semaphore was successfully taken, otherwise\r
+ * pdFALSE\r
+ */\r
+#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) )\r
+\r
+/**\r
+ * semphr. h\r
+ * <pre>SemaphoreHandle_t xSemaphoreCreateMutex( void )</pre>\r
+ *\r
+ * <i>Macro</i> that implements a mutex semaphore by using the existing queue\r
+ * mechanism.\r
+ *\r
+ * Mutexes created using this macro can be accessed using the xSemaphoreTake()\r
+ * and xSemaphoreGive() macros.  The xSemaphoreTakeRecursive() and\r
+ * xSemaphoreGiveRecursive() macros should not be used.\r
+ *\r
+ * This type of semaphore uses a priority inheritance mechanism so a task\r
+ * 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the\r
+ * semaphore it is no longer required.\r
+ *\r
+ * Mutex type semaphores cannot be used from within interrupt service routines.\r
+ *\r
+ * See vSemaphoreCreateBinary() for an alternative implementation that can be\r
+ * used for pure synchronisation (where one task or interrupt always 'gives' the\r
+ * semaphore and another always 'takes' the semaphore) and from within interrupt\r
+ * service routines.\r
+ *\r
+ * @return xSemaphore Handle to the created mutex semaphore.  Should be of type\r
+ *             SemaphoreHandle_t.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ SemaphoreHandle_t xSemaphore;\r
+\r
+ void vATask( void * pvParameters )\r
+ {\r
+    // Semaphore cannot be used before a call to xSemaphoreCreateMutex().\r
+    // This is a macro so pass the variable in directly.\r
+    xSemaphore = xSemaphoreCreateMutex();\r
+\r
+    if( xSemaphore != NULL )\r
+    {\r
+        // The semaphore was created successfully.\r
+        // The semaphore can now be used.\r
+    }\r
+ }\r
+ </pre>\r
+ * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex\r
+ * \ingroup Semaphores\r
+ */\r
+#define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX )\r
+\r
+\r
+/**\r
+ * semphr. h\r
+ * <pre>SemaphoreHandle_t xSemaphoreCreateRecursiveMutex( void )</pre>\r
+ *\r
+ * <i>Macro</i> that implements a recursive mutex by using the existing queue\r
+ * mechanism.\r
+ *\r
+ * Mutexes created using this macro can be accessed using the\r
+ * xSemaphoreTakeRecursive() and xSemaphoreGiveRecursive() macros.  The\r
+ * xSemaphoreTake() and xSemaphoreGive() macros should not be used.\r
+ *\r
+ * A mutex used recursively can be 'taken' repeatedly by the owner. The mutex\r
+ * doesn't become available again until the owner has called\r
+ * xSemaphoreGiveRecursive() for each successful 'take' request.  For example,\r
+ * if a task successfully 'takes' the same mutex 5 times then the mutex will\r
+ * not be available to any other task until it has also  'given' the mutex back\r
+ * exactly five times.\r
+ *\r
+ * This type of semaphore uses a priority inheritance mechanism so a task\r
+ * 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the\r
+ * semaphore it is no longer required.\r
+ *\r
+ * Mutex type semaphores cannot be used from within interrupt service routines.\r
+ *\r
+ * See vSemaphoreCreateBinary() for an alternative implementation that can be\r
+ * used for pure synchronisation (where one task or interrupt always 'gives' the\r
+ * semaphore and another always 'takes' the semaphore) and from within interrupt\r
+ * service routines.\r
+ *\r
+ * @return xSemaphore Handle to the created mutex semaphore.  Should be of type\r
+ *             SemaphoreHandle_t.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ SemaphoreHandle_t xSemaphore;\r
+\r
+ void vATask( void * pvParameters )\r
+ {\r
+    // Semaphore cannot be used before a call to xSemaphoreCreateMutex().\r
+    // This is a macro so pass the variable in directly.\r
+    xSemaphore = xSemaphoreCreateRecursiveMutex();\r
+\r
+    if( xSemaphore != NULL )\r
+    {\r
+        // The semaphore was created successfully.\r
+        // The semaphore can now be used.\r
+    }\r
+ }\r
+ </pre>\r
+ * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex\r
+ * \ingroup Semaphores\r
+ */\r
+#define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX )\r
+\r
+/**\r
+ * semphr. h\r
+ * <pre>SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount )</pre>\r
+ *\r
+ * <i>Macro</i> that creates a counting semaphore by using the existing\r
+ * queue mechanism.\r
+ *\r
+ * Counting semaphores are typically used for two things:\r
+ *\r
+ * 1) Counting events.\r
+ *\r
+ *    In this usage scenario an event handler will 'give' a semaphore each time\r
+ *    an event occurs (incrementing the semaphore count value), and a handler\r
+ *    task will 'take' a semaphore each time it processes an event\r
+ *    (decrementing the semaphore count value).  The count value is therefore\r
+ *    the difference between the number of events that have occurred and the\r
+ *    number that have been processed.  In this case it is desirable for the\r
+ *    initial count value to be zero.\r
+ *\r
+ * 2) Resource management.\r
+ *\r
+ *    In this usage scenario the count value indicates the number of resources\r
+ *    available.  To obtain control of a resource a task must first obtain a\r
+ *    semaphore - decrementing the semaphore count value.  When the count value\r
+ *    reaches zero there are no free resources.  When a task finishes with the\r
+ *    resource it 'gives' the semaphore back - incrementing the semaphore count\r
+ *    value.  In this case it is desirable for the initial count value to be\r
+ *    equal to the maximum count value, indicating that all resources are free.\r
+ *\r
+ * @param uxMaxCount The maximum count value that can be reached.  When the\r
+ *        semaphore reaches this value it can no longer be 'given'.\r
+ *\r
+ * @param uxInitialCount The count value assigned to the semaphore when it is\r
+ *        created.\r
+ *\r
+ * @return Handle to the created semaphore.  Null if the semaphore could not be\r
+ *         created.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ SemaphoreHandle_t xSemaphore;\r
+\r
+ void vATask( void * pvParameters )\r
+ {\r
+ SemaphoreHandle_t xSemaphore = NULL;\r
+\r
+    // Semaphore cannot be used before a call to xSemaphoreCreateCounting().\r
+    // The max value to which the semaphore can count should be 10, and the\r
+    // initial value assigned to the count should be 0.\r
+    xSemaphore = xSemaphoreCreateCounting( 10, 0 );\r
+\r
+    if( xSemaphore != NULL )\r
+    {\r
+        // The semaphore was created successfully.\r
+        // The semaphore can now be used.\r
+    }\r
+ }\r
+ </pre>\r
+ * \defgroup xSemaphoreCreateCounting xSemaphoreCreateCounting\r
+ * \ingroup Semaphores\r
+ */\r
+#define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) )\r
+\r
+/**\r
+ * semphr. h\r
+ * <pre>void vSemaphoreDelete( SemaphoreHandle_t xSemaphore );</pre>\r
+ *\r
+ * Delete a semaphore.  This function must be used with care.  For example,\r
+ * do not delete a mutex type semaphore if the mutex is held by a task.\r
+ *\r
+ * @param xSemaphore A handle to the semaphore to be deleted.\r
+ *\r
+ * \defgroup vSemaphoreDelete vSemaphoreDelete\r
+ * \ingroup Semaphores\r
+ */\r
+#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) )\r
+\r
+/**\r
+ * semphr.h\r
+ * <pre>TaskHandle_t xSemaphoreGetMutexHolder( SemaphoreHandle_t xMutex );</pre>\r
+ *\r
+ * If xMutex is indeed a mutex type semaphore, return the current mutex holder.\r
+ * If xMutex is not a mutex type semaphore, or the mutex is available (not held\r
+ * by a task), return NULL.\r
+ *\r
+ * Note: This is a good way of determining if the calling task is the mutex\r
+ * holder, but not a good way of determining the identity of the mutex holder as\r
+ * the holder may change between the function exiting and the returned value\r
+ * being tested.\r
+ */\r
+#define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) )\r
+\r
+#endif /* SEMAPHORE_H */\r
+\r
+\r
diff --git a/os/8.2.2/include/os/stdint.readme b/os/8.2.2/include/os/stdint.readme
new file mode 100644 (file)
index 0000000..6d86149
--- /dev/null
@@ -0,0 +1,27 @@
+\r
+#ifndef FREERTOS_STDINT\r
+#define FREERTOS_STDINT\r
+\r
+/*******************************************************************************\r
+ * THIS IS NOT A FULL stdint.h IMPLEMENTATION - It only contains the definitions\r
+ * necessary to build the FreeRTOS code.  It is provided to allow FreeRTOS to be\r
+ * built using compilers that do not provide their own stdint.h definition.\r
+ *\r
+ * To use this file:\r
+ *\r
+ *    1) Copy this file into the directory that contains your FreeRTOSConfig.h\r
+ *       header file, as that directory will already be in the compilers include\r
+ *       path.\r
+ *\r
+ *    2) Rename the copied file stdint.h.\r
+ *\r
+ */\r
+\r
+typedef signed char int8_t;\r
+typedef unsigned char uint8_t;\r
+typedef short int16_t;\r
+typedef unsigned short uint16_t;\r
+typedef long int32_t;\r
+typedef unsigned long uint32_t;\r
+\r
+#endif /* FREERTOS_STDINT */\r
diff --git a/os/8.2.2/include/os/task.h b/os/8.2.2/include/os/task.h
new file mode 100644 (file)
index 0000000..deda894
--- /dev/null
@@ -0,0 +1,2021 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+\r
+#ifndef INC_TASK_H\r
+#define INC_TASK_H\r
+\r
+#ifndef INC_FREERTOS_H\r
+       #error "include FreeRTOS.h must appear in source files before include task.h"\r
+#endif\r
+\r
+#include "list.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/*-----------------------------------------------------------\r
+ * MACROS AND DEFINITIONS\r
+ *----------------------------------------------------------*/\r
+\r
+#define tskKERNEL_VERSION_NUMBER "V8.2.2"\r
+#define tskKERNEL_VERSION_MAJOR 8\r
+#define tskKERNEL_VERSION_MINOR 2\r
+#define tskKERNEL_VERSION_BUILD 2\r
+\r
+/**\r
+ * task. h\r
+ *\r
+ * Type by which tasks are referenced.  For example, a call to xTaskCreate\r
+ * returns (via a pointer parameter) an TaskHandle_t variable that can then\r
+ * be used as a parameter to vTaskDelete to delete the task.\r
+ *\r
+ * \defgroup TaskHandle_t TaskHandle_t\r
+ * \ingroup Tasks\r
+ */\r
+typedef void * TaskHandle_t;\r
+\r
+/*\r
+ * Defines the prototype to which the application task hook function must\r
+ * conform.\r
+ */\r
+typedef BaseType_t (*TaskHookFunction_t)( void * );\r
+\r
+/* Task states returned by eTaskGetState. */\r
+typedef enum\r
+{\r
+       eRunning = 0,   /* A task is querying the state of itself, so must be running. */\r
+       eReady,                 /* The task being queried is in a read or pending ready list. */\r
+       eBlocked,               /* The task being queried is in the Blocked state. */\r
+       eSuspended,             /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */\r
+       eDeleted                /* The task being queried has been deleted, but its TCB has not yet been freed. */\r
+} eTaskState;\r
+\r
+/* Actions that can be performed when vTaskNotify() is called. */\r
+typedef enum\r
+{\r
+       eNoAction = 0,                          /* Notify the task without updating its notify value. */\r
+       eSetBits,                                       /* Set bits in the task's notification value. */\r
+       eIncrement,                                     /* Increment the task's notification value. */\r
+       eSetValueWithOverwrite,         /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */\r
+       eSetValueWithoutOverwrite       /* Set the task's notification value if the previous value has been read by the task. */\r
+} eNotifyAction;\r
+\r
+/*\r
+ * Used internally only.\r
+ */\r
+typedef struct xTIME_OUT\r
+{\r
+       BaseType_t xOverflowCount;\r
+       TickType_t xTimeOnEntering;\r
+} TimeOut_t;\r
+\r
+/*\r
+ * Defines the memory ranges allocated to the task when an MPU is used.\r
+ */\r
+typedef struct xMEMORY_REGION\r
+{\r
+       void *pvBaseAddress;\r
+       uint32_t ulLengthInBytes;\r
+       uint32_t ulParameters;\r
+} MemoryRegion_t;\r
+\r
+/*\r
+ * Parameters required to create an MPU protected task.\r
+ */\r
+typedef struct xTASK_PARAMETERS\r
+{\r
+       TaskFunction_t pvTaskCode;\r
+       const char * const pcName;      /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+       uint16_t usStackDepth;\r
+       void *pvParameters;\r
+       UBaseType_t uxPriority;\r
+       StackType_t *puxStackBuffer;\r
+       MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ];\r
+} TaskParameters_t;\r
+\r
+/* Used with the uxTaskGetSystemState() function to return the state of each task\r
+in the system. */\r
+typedef struct xTASK_STATUS\r
+{\r
+       TaskHandle_t xHandle;                   /* The handle of the task to which the rest of the information in the structure relates. */\r
+       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. */\r
+       UBaseType_t xTaskNumber;                /* A number unique to the task. */\r
+       eTaskState eCurrentState;               /* The state in which the task existed when the structure was populated. */\r
+       UBaseType_t uxCurrentPriority;  /* The priority at which the task was running (may be inherited) when the structure was populated. */\r
+       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. */\r
+       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. */\r
+       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. */\r
+} TaskStatus_t;\r
+\r
+/* Possible return values for eTaskConfirmSleepModeStatus(). */\r
+typedef enum\r
+{\r
+       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. */\r
+       eStandardSleep,                 /* Enter a sleep mode that will not last any longer than the expected idle time. */\r
+       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. */\r
+} eSleepModeStatus;\r
+\r
+\r
+/**\r
+ * Defines the priority used by the idle task.  This must not be modified.\r
+ *\r
+ * \ingroup TaskUtils\r
+ */\r
+#define tskIDLE_PRIORITY                       ( ( UBaseType_t ) 0U )\r
+\r
+/**\r
+ * task. h\r
+ *\r
+ * Macro for forcing a context switch.\r
+ *\r
+ * \defgroup taskYIELD taskYIELD\r
+ * \ingroup SchedulerControl\r
+ */\r
+#define taskYIELD()                                    portYIELD()\r
+\r
+/**\r
+ * task. h\r
+ *\r
+ * Macro to mark the start of a critical code region.  Preemptive context\r
+ * switches cannot occur when in a critical region.\r
+ *\r
+ * NOTE: This may alter the stack (depending on the portable implementation)\r
+ * so must be used with care!\r
+ *\r
+ * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL\r
+ * \ingroup SchedulerControl\r
+ */\r
+#define taskENTER_CRITICAL()           portENTER_CRITICAL()\r
+#define taskENTER_CRITICAL_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()\r
+\r
+/**\r
+ * task. h\r
+ *\r
+ * Macro to mark the end of a critical code region.  Preemptive context\r
+ * switches cannot occur when in a critical region.\r
+ *\r
+ * NOTE: This may alter the stack (depending on the portable implementation)\r
+ * so must be used with care!\r
+ *\r
+ * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL\r
+ * \ingroup SchedulerControl\r
+ */\r
+#define taskEXIT_CRITICAL()                    portEXIT_CRITICAL()\r
+#define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x )\r
+/**\r
+ * task. h\r
+ *\r
+ * Macro to disable all maskable interrupts.\r
+ *\r
+ * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS\r
+ * \ingroup SchedulerControl\r
+ */\r
+#define taskDISABLE_INTERRUPTS()       portDISABLE_INTERRUPTS()\r
+\r
+/**\r
+ * task. h\r
+ *\r
+ * Macro to enable microcontroller interrupts.\r
+ *\r
+ * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS\r
+ * \ingroup SchedulerControl\r
+ */\r
+#define taskENABLE_INTERRUPTS()                portENABLE_INTERRUPTS()\r
+\r
+/* Definitions returned by xTaskGetSchedulerState().  taskSCHEDULER_SUSPENDED is\r
+0 to generate more optimal code when configASSERT() is defined as the constant\r
+is used in assert() statements. */\r
+#define taskSCHEDULER_SUSPENDED                ( ( BaseType_t ) 0 )\r
+#define taskSCHEDULER_NOT_STARTED      ( ( BaseType_t ) 1 )\r
+#define taskSCHEDULER_RUNNING          ( ( BaseType_t ) 2 )\r
+\r
+\r
+/*-----------------------------------------------------------\r
+ * TASK CREATION API\r
+ *----------------------------------------------------------*/\r
+\r
+/**\r
+ * task. h\r
+ *<pre>\r
+ BaseType_t xTaskCreate(\r
+                                                         TaskFunction_t pvTaskCode,\r
+                                                         const char * const pcName,\r
+                                                         uint16_t usStackDepth,\r
+                                                         void *pvParameters,\r
+                                                         UBaseType_t uxPriority,\r
+                                                         TaskHandle_t *pvCreatedTask\r
+                                                 );</pre>\r
+ *\r
+ * Create a new task and add it to the list of tasks that are ready to run.\r
+ *\r
+ * xTaskCreate() can only be used to create a task that has unrestricted\r
+ * access to the entire microcontroller memory map.  Systems that include MPU\r
+ * support can alternatively create an MPU constrained task using\r
+ * xTaskCreateRestricted().\r
+ *\r
+ * @param pvTaskCode Pointer to the task entry function.  Tasks\r
+ * must be implemented to never return (i.e. continuous loop).\r
+ *\r
+ * @param pcName A descriptive name for the task.  This is mainly used to\r
+ * facilitate debugging.  Max length defined by configMAX_TASK_NAME_LEN - default\r
+ * is 16.\r
+ *\r
+ * @param usStackDepth The size of the task stack specified as the number of\r
+ * variables the stack can hold - not the number of bytes.  For example, if\r
+ * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes\r
+ * will be allocated for stack storage.\r
+ *\r
+ * @param pvParameters Pointer that will be used as the parameter for the task\r
+ * being created.\r
+ *\r
+ * @param uxPriority The priority at which the task should run.  Systems that\r
+ * include MPU support can optionally create tasks in a privileged (system)\r
+ * mode by setting bit portPRIVILEGE_BIT of the priority parameter.  For\r
+ * example, to create a privileged task at priority 2 the uxPriority parameter\r
+ * should be set to ( 2 | portPRIVILEGE_BIT ).\r
+ *\r
+ * @param pvCreatedTask Used to pass back a handle by which the created task\r
+ * can be referenced.\r
+ *\r
+ * @return pdPASS if the task was successfully created and added to a ready\r
+ * list, otherwise an error code defined in the file projdefs.h\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ // Task to be created.\r
+ void vTaskCode( void * pvParameters )\r
+ {\r
+        for( ;; )\r
+        {\r
+                // Task code goes here.\r
+        }\r
+ }\r
+\r
+ // Function that creates a task.\r
+ void vOtherFunction( void )\r
+ {\r
+ static uint8_t ucParameterToPass;\r
+ TaskHandle_t xHandle = NULL;\r
+\r
+        // Create the task, storing the handle.  Note that the passed parameter ucParameterToPass\r
+        // must exist for the lifetime of the task, so in this case is declared static.  If it was just an\r
+        // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time\r
+        // the new task attempts to access it.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );\r
+     configASSERT( xHandle );\r
+\r
+        // Use the handle to delete the task.\r
+     if( xHandle != NULL )\r
+     {\r
+            vTaskDelete( xHandle );\r
+     }\r
+ }\r
+   </pre>\r
+ * \defgroup xTaskCreate xTaskCreate\r
+ * \ingroup Tasks\r
+ */\r
+#define xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask ) xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( NULL ), ( NULL ) )\r
+\r
+/**\r
+ * task. h\r
+ *<pre>\r
+ BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );</pre>\r
+ *\r
+ * xTaskCreateRestricted() should only be used in systems that include an MPU\r
+ * implementation.\r
+ *\r
+ * Create a new task and add it to the list of tasks that are ready to run.\r
+ * The function parameters define the memory regions and associated access\r
+ * permissions allocated to the task.\r
+ *\r
+ * @param pxTaskDefinition Pointer to a structure that contains a member\r
+ * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API\r
+ * documentation) plus an optional stack buffer and the memory region\r
+ * definitions.\r
+ *\r
+ * @param pxCreatedTask Used to pass back a handle by which the created task\r
+ * can be referenced.\r
+ *\r
+ * @return pdPASS if the task was successfully created and added to a ready\r
+ * list, otherwise an error code defined in the file projdefs.h\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+// Create an TaskParameters_t structure that defines the task to be created.\r
+static const TaskParameters_t xCheckTaskParameters =\r
+{\r
+       vATask,         // pvTaskCode - the function that implements the task.\r
+       "ATask",        // pcName - just a text name for the task to assist debugging.\r
+       100,            // usStackDepth - the stack size DEFINED IN WORDS.\r
+       NULL,           // pvParameters - passed into the task function as the function parameters.\r
+       ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.\r
+       cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.\r
+\r
+       // xRegions - Allocate up to three separate memory regions for access by\r
+       // the task, with appropriate access permissions.  Different processors have\r
+       // different memory alignment requirements - refer to the FreeRTOS documentation\r
+       // for full information.\r
+       {\r
+               // Base address                                 Length  Parameters\r
+        { cReadWriteArray,                             32,             portMPU_REGION_READ_WRITE },\r
+        { cReadOnlyArray,                              32,             portMPU_REGION_READ_ONLY },\r
+        { cPrivilegedOnlyAccessArray,  128,    portMPU_REGION_PRIVILEGED_READ_WRITE }\r
+       }\r
+};\r
+\r
+int main( void )\r
+{\r
+TaskHandle_t xHandle;\r
+\r
+       // Create a task from the const structure defined above.  The task handle\r
+       // is requested (the second parameter is not NULL) but in this case just for\r
+       // demonstration purposes as its not actually used.\r
+       xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );\r
+\r
+       // Start the scheduler.\r
+       vTaskStartScheduler();\r
+\r
+       // Will only get here if there was insufficient memory to create the idle\r
+       // and/or timer task.\r
+       for( ;; );\r
+}\r
+   </pre>\r
+ * \defgroup xTaskCreateRestricted xTaskCreateRestricted\r
+ * \ingroup Tasks\r
+ */\r
+#define xTaskCreateRestricted( x, pxCreatedTask ) xTaskGenericCreate( ((x)->pvTaskCode), ((x)->pcName), ((x)->usStackDepth), ((x)->pvParameters), ((x)->uxPriority), (pxCreatedTask), ((x)->puxStackBuffer), ((x)->xRegions) )\r
+\r
+/**\r
+ * task. h\r
+ *<pre>\r
+ void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );</pre>\r
+ *\r
+ * Memory regions are assigned to a restricted task when the task is created by\r
+ * a call to xTaskCreateRestricted().  These regions can be redefined using\r
+ * vTaskAllocateMPURegions().\r
+ *\r
+ * @param xTask The handle of the task being updated.\r
+ *\r
+ * @param xRegions A pointer to an MemoryRegion_t structure that contains the\r
+ * new memory region definitions.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+// Define an array of MemoryRegion_t structures that configures an MPU region\r
+// allowing read/write access for 1024 bytes starting at the beginning of the\r
+// ucOneKByte array.  The other two of the maximum 3 definable regions are\r
+// unused so set to zero.\r
+static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =\r
+{\r
+       // Base address         Length          Parameters\r
+       { ucOneKByte,           1024,           portMPU_REGION_READ_WRITE },\r
+       { 0,                            0,                      0 },\r
+       { 0,                            0,                      0 }\r
+};\r
+\r
+void vATask( void *pvParameters )\r
+{\r
+       // This task was created such that it has access to certain regions of\r
+       // memory as defined by the MPU configuration.  At some point it is\r
+       // desired that these MPU regions are replaced with that defined in the\r
+       // xAltRegions const struct above.  Use a call to vTaskAllocateMPURegions()\r
+       // for this purpose.  NULL is used as the task handle to indicate that this\r
+       // function should modify the MPU regions of the calling task.\r
+       vTaskAllocateMPURegions( NULL, xAltRegions );\r
+\r
+       // Now the task can continue its function, but from this point on can only\r
+       // access its stack and the ucOneKByte array (unless any other statically\r
+       // defined or shared regions have been declared elsewhere).\r
+}\r
+   </pre>\r
+ * \defgroup xTaskCreateRestricted xTaskCreateRestricted\r
+ * \ingroup Tasks\r
+ */\r
+void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <pre>void vTaskDelete( TaskHandle_t xTask );</pre>\r
+ *\r
+ * INCLUDE_vTaskDelete must be defined as 1 for this function to be available.\r
+ * See the configuration section for more information.\r
+ *\r
+ * Remove a task from the RTOS real time kernel's management.  The task being\r
+ * deleted will be removed from all ready, blocked, suspended and event lists.\r
+ *\r
+ * NOTE:  The idle task is responsible for freeing the kernel allocated\r
+ * memory from tasks that have been deleted.  It is therefore important that\r
+ * the idle task is not starved of microcontroller processing time if your\r
+ * application makes any calls to vTaskDelete ().  Memory allocated by the\r
+ * task code is not automatically freed, and should be freed before the task\r
+ * is deleted.\r
+ *\r
+ * See the demo application file death.c for sample code that utilises\r
+ * vTaskDelete ().\r
+ *\r
+ * @param xTask The handle of the task to be deleted.  Passing NULL will\r
+ * cause the calling task to be deleted.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ void vOtherFunction( void )\r
+ {\r
+ TaskHandle_t xHandle;\r
+\r
+        // Create the task, storing the handle.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
+\r
+        // Use the handle to delete the task.\r
+        vTaskDelete( xHandle );\r
+ }\r
+   </pre>\r
+ * \defgroup vTaskDelete vTaskDelete\r
+ * \ingroup Tasks\r
+ */\r
+void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;\r
+\r
+/*-----------------------------------------------------------\r
+ * TASK CONTROL API\r
+ *----------------------------------------------------------*/\r
+\r
+/**\r
+ * task. h\r
+ * <pre>void vTaskDelay( const TickType_t xTicksToDelay );</pre>\r
+ *\r
+ * Delay a task for a given number of ticks.  The actual time that the\r
+ * task remains blocked depends on the tick rate.  The constant\r
+ * portTICK_PERIOD_MS can be used to calculate real time from the tick\r
+ * rate - with the resolution of one tick period.\r
+ *\r
+ * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.\r
+ * See the configuration section for more information.\r
+ *\r
+ *\r
+ * vTaskDelay() specifies a time at which the task wishes to unblock relative to\r
+ * the time at which vTaskDelay() is called.  For example, specifying a block\r
+ * period of 100 ticks will cause the task to unblock 100 ticks after\r
+ * vTaskDelay() is called.  vTaskDelay() does not therefore provide a good method\r
+ * of controlling the frequency of a periodic task as the path taken through the\r
+ * code, as well as other task and interrupt activity, will effect the frequency\r
+ * at which vTaskDelay() gets called and therefore the time at which the task\r
+ * next executes.  See vTaskDelayUntil() for an alternative API function designed\r
+ * to facilitate fixed frequency execution.  It does this by specifying an\r
+ * absolute time (rather than a relative time) at which the calling task should\r
+ * unblock.\r
+ *\r
+ * @param xTicksToDelay The amount of time, in tick periods, that\r
+ * the calling task should block.\r
+ *\r
+ * Example usage:\r
+\r
+ void vTaskFunction( void * pvParameters )\r
+ {\r
+ // Block for 500ms.\r
+ const TickType_t xDelay = 500 / portTICK_PERIOD_MS;\r
+\r
+        for( ;; )\r
+        {\r
+                // Simply toggle the LED every 500ms, blocking between each toggle.\r
+                vToggleLED();\r
+                vTaskDelay( xDelay );\r
+        }\r
+ }\r
+\r
+ * \defgroup vTaskDelay vTaskDelay\r
+ * \ingroup TaskCtrl\r
+ */\r
+void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <pre>void vTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );</pre>\r
+ *\r
+ * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available.\r
+ * See the configuration section for more information.\r
+ *\r
+ * Delay a task until a specified time.  This function can be used by periodic\r
+ * tasks to ensure a constant execution frequency.\r
+ *\r
+ * This function differs from vTaskDelay () in one important aspect:  vTaskDelay () will\r
+ * cause a task to block for the specified number of ticks from the time vTaskDelay () is\r
+ * called.  It is therefore difficult to use vTaskDelay () by itself to generate a fixed\r
+ * execution frequency as the time between a task starting to execute and that task\r
+ * calling vTaskDelay () may not be fixed [the task may take a different path though the\r
+ * code between calls, or may get interrupted or preempted a different number of times\r
+ * each time it executes].\r
+ *\r
+ * Whereas vTaskDelay () specifies a wake time relative to the time at which the function\r
+ * is called, vTaskDelayUntil () specifies the absolute (exact) time at which it wishes to\r
+ * unblock.\r
+ *\r
+ * The constant portTICK_PERIOD_MS can be used to calculate real time from the tick\r
+ * rate - with the resolution of one tick period.\r
+ *\r
+ * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the\r
+ * task was last unblocked.  The variable must be initialised with the current time\r
+ * prior to its first use (see the example below).  Following this the variable is\r
+ * automatically updated within vTaskDelayUntil ().\r
+ *\r
+ * @param xTimeIncrement The cycle time period.  The task will be unblocked at\r
+ * time *pxPreviousWakeTime + xTimeIncrement.  Calling vTaskDelayUntil with the\r
+ * same xTimeIncrement parameter value will cause the task to execute with\r
+ * a fixed interface period.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ // Perform an action every 10 ticks.\r
+ void vTaskFunction( void * pvParameters )\r
+ {\r
+ TickType_t xLastWakeTime;\r
+ const TickType_t xFrequency = 10;\r
+\r
+        // Initialise the xLastWakeTime variable with the current time.\r
+        xLastWakeTime = xTaskGetTickCount ();\r
+        for( ;; )\r
+        {\r
+                // Wait for the next cycle.\r
+                vTaskDelayUntil( &xLastWakeTime, xFrequency );\r
+\r
+                // Perform action here.\r
+        }\r
+ }\r
+   </pre>\r
+ * \defgroup vTaskDelayUntil vTaskDelayUntil\r
+ * \ingroup TaskCtrl\r
+ */\r
+void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <pre>UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask );</pre>\r
+ *\r
+ * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.\r
+ * See the configuration section for more information.\r
+ *\r
+ * Obtain the priority of any task.\r
+ *\r
+ * @param xTask Handle of the task to be queried.  Passing a NULL\r
+ * handle results in the priority of the calling task being returned.\r
+ *\r
+ * @return The priority of xTask.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ void vAFunction( void )\r
+ {\r
+ TaskHandle_t xHandle;\r
+\r
+        // Create a task, storing the handle.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
+\r
+        // ...\r
+\r
+        // Use the handle to obtain the priority of the created task.\r
+        // It was created with tskIDLE_PRIORITY, but may have changed\r
+        // it itself.\r
+        if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )\r
+        {\r
+                // The task has changed it's priority.\r
+        }\r
+\r
+        // ...\r
+\r
+        // Is our priority higher than the created task?\r
+        if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )\r
+        {\r
+                // Our priority (obtained using NULL handle) is higher.\r
+        }\r
+ }\r
+   </pre>\r
+ * \defgroup uxTaskPriorityGet uxTaskPriorityGet\r
+ * \ingroup TaskCtrl\r
+ */\r
+UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <pre>UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask );</pre>\r
+ *\r
+ * A version of uxTaskPriorityGet() that can be used from an ISR.\r
+ */\r
+UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <pre>eTaskState eTaskGetState( TaskHandle_t xTask );</pre>\r
+ *\r
+ * INCLUDE_eTaskGetState must be defined as 1 for this function to be available.\r
+ * See the configuration section for more information.\r
+ *\r
+ * Obtain the state of any task.  States are encoded by the eTaskState\r
+ * enumerated type.\r
+ *\r
+ * @param xTask Handle of the task to be queried.\r
+ *\r
+ * @return The state of xTask at the time the function was called.  Note the\r
+ * state of the task might change between the function being called, and the\r
+ * functions return value being tested by the calling task.\r
+ */\r
+eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <pre>void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );</pre>\r
+ *\r
+ * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.\r
+ * See the configuration section for more information.\r
+ *\r
+ * Set the priority of any task.\r
+ *\r
+ * A context switch will occur before the function returns if the priority\r
+ * being set is higher than the currently executing task.\r
+ *\r
+ * @param xTask Handle to the task for which the priority is being set.\r
+ * Passing a NULL handle results in the priority of the calling task being set.\r
+ *\r
+ * @param uxNewPriority The priority to which the task will be set.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ void vAFunction( void )\r
+ {\r
+ TaskHandle_t xHandle;\r
+\r
+        // Create a task, storing the handle.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
+\r
+        // ...\r
+\r
+        // Use the handle to raise the priority of the created task.\r
+        vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );\r
+\r
+        // ...\r
+\r
+        // Use a NULL handle to raise our priority to the same value.\r
+        vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );\r
+ }\r
+   </pre>\r
+ * \defgroup vTaskPrioritySet vTaskPrioritySet\r
+ * \ingroup TaskCtrl\r
+ */\r
+void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <pre>void vTaskSuspend( TaskHandle_t xTaskToSuspend );</pre>\r
+ *\r
+ * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.\r
+ * See the configuration section for more information.\r
+ *\r
+ * Suspend any task.  When suspended a task will never get any microcontroller\r
+ * processing time, no matter what its priority.\r
+ *\r
+ * Calls to vTaskSuspend are not accumulative -\r
+ * i.e. calling vTaskSuspend () twice on the same task still only requires one\r
+ * call to vTaskResume () to ready the suspended task.\r
+ *\r
+ * @param xTaskToSuspend Handle to the task being suspended.  Passing a NULL\r
+ * handle will cause the calling task to be suspended.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ void vAFunction( void )\r
+ {\r
+ TaskHandle_t xHandle;\r
+\r
+        // Create a task, storing the handle.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
+\r
+        // ...\r
+\r
+        // Use the handle to suspend the created task.\r
+        vTaskSuspend( xHandle );\r
+\r
+        // ...\r
+\r
+        // The created task will not run during this period, unless\r
+        // another task calls vTaskResume( xHandle ).\r
+\r
+        //...\r
+\r
+\r
+        // Suspend ourselves.\r
+        vTaskSuspend( NULL );\r
+\r
+        // We cannot get here unless another task calls vTaskResume\r
+        // with our handle as the parameter.\r
+ }\r
+   </pre>\r
+ * \defgroup vTaskSuspend vTaskSuspend\r
+ * \ingroup TaskCtrl\r
+ */\r
+void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <pre>void vTaskResume( TaskHandle_t xTaskToResume );</pre>\r
+ *\r
+ * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.\r
+ * See the configuration section for more information.\r
+ *\r
+ * Resumes a suspended task.\r
+ *\r
+ * A task that has been suspended by one or more calls to vTaskSuspend ()\r
+ * will be made available for running again by a single call to\r
+ * vTaskResume ().\r
+ *\r
+ * @param xTaskToResume Handle to the task being readied.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ void vAFunction( void )\r
+ {\r
+ TaskHandle_t xHandle;\r
+\r
+        // Create a task, storing the handle.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
+\r
+        // ...\r
+\r
+        // Use the handle to suspend the created task.\r
+        vTaskSuspend( xHandle );\r
+\r
+        // ...\r
+\r
+        // The created task will not run during this period, unless\r
+        // another task calls vTaskResume( xHandle ).\r
+\r
+        //...\r
+\r
+\r
+        // Resume the suspended task ourselves.\r
+        vTaskResume( xHandle );\r
+\r
+        // The created task will once again get microcontroller processing\r
+        // time in accordance with its priority within the system.\r
+ }\r
+   </pre>\r
+ * \defgroup vTaskResume vTaskResume\r
+ * \ingroup TaskCtrl\r
+ */\r
+void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <pre>void xTaskResumeFromISR( TaskHandle_t xTaskToResume );</pre>\r
+ *\r
+ * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be\r
+ * available.  See the configuration section for more information.\r
+ *\r
+ * An implementation of vTaskResume() that can be called from within an ISR.\r
+ *\r
+ * A task that has been suspended by one or more calls to vTaskSuspend ()\r
+ * will be made available for running again by a single call to\r
+ * xTaskResumeFromISR ().\r
+ *\r
+ * xTaskResumeFromISR() should not be used to synchronise a task with an\r
+ * interrupt if there is a chance that the interrupt could arrive prior to the\r
+ * task being suspended - as this can lead to interrupts being missed. Use of a\r
+ * semaphore as a synchronisation mechanism would avoid this eventuality.\r
+ *\r
+ * @param xTaskToResume Handle to the task being readied.\r
+ *\r
+ * @return pdTRUE if resuming the task should result in a context switch,\r
+ * otherwise pdFALSE. This is used by the ISR to determine if a context switch\r
+ * may be required following the ISR.\r
+ *\r
+ * \defgroup vTaskResumeFromISR vTaskResumeFromISR\r
+ * \ingroup TaskCtrl\r
+ */\r
+BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;\r
+\r
+/*-----------------------------------------------------------\r
+ * SCHEDULER CONTROL\r
+ *----------------------------------------------------------*/\r
+\r
+/**\r
+ * task. h\r
+ * <pre>void vTaskStartScheduler( void );</pre>\r
+ *\r
+ * Starts the real time kernel tick processing.  After calling the kernel\r
+ * has control over which tasks are executed and when.\r
+ *\r
+ * See the demo application file main.c for an example of creating\r
+ * tasks and starting the kernel.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ void vAFunction( void )\r
+ {\r
+        // Create at least one task before starting the kernel.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
+\r
+        // Start the real time kernel with preemption.\r
+        vTaskStartScheduler ();\r
+\r
+        // Will not get here unless a task calls vTaskEndScheduler ()\r
+ }\r
+   </pre>\r
+ *\r
+ * \defgroup vTaskStartScheduler vTaskStartScheduler\r
+ * \ingroup SchedulerControl\r
+ */\r
+void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <pre>void vTaskEndScheduler( void );</pre>\r
+ *\r
+ * NOTE:  At the time of writing only the x86 real mode port, which runs on a PC\r
+ * in place of DOS, implements this function.\r
+ *\r
+ * Stops the real time kernel tick.  All created tasks will be automatically\r
+ * deleted and multitasking (either preemptive or cooperative) will\r
+ * stop.  Execution then resumes from the point where vTaskStartScheduler ()\r
+ * was called, as if vTaskStartScheduler () had just returned.\r
+ *\r
+ * See the demo application file main. c in the demo/PC directory for an\r
+ * example that uses vTaskEndScheduler ().\r
+ *\r
+ * vTaskEndScheduler () requires an exit function to be defined within the\r
+ * portable layer (see vPortEndScheduler () in port. c for the PC port).  This\r
+ * performs hardware specific operations such as stopping the kernel tick.\r
+ *\r
+ * vTaskEndScheduler () will cause all of the resources allocated by the\r
+ * kernel to be freed - but will not free resources allocated by application\r
+ * tasks.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ void vTaskCode( void * pvParameters )\r
+ {\r
+        for( ;; )\r
+        {\r
+                // Task code goes here.\r
+\r
+                // At some point we want to end the real time kernel processing\r
+                // so call ...\r
+                vTaskEndScheduler ();\r
+        }\r
+ }\r
+\r
+ void vAFunction( void )\r
+ {\r
+        // Create at least one task before starting the kernel.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
+\r
+        // Start the real time kernel with preemption.\r
+        vTaskStartScheduler ();\r
+\r
+        // Will only get here when the vTaskCode () task has called\r
+        // vTaskEndScheduler ().  When we get here we are back to single task\r
+        // execution.\r
+ }\r
+   </pre>\r
+ *\r
+ * \defgroup vTaskEndScheduler vTaskEndScheduler\r
+ * \ingroup SchedulerControl\r
+ */\r
+void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <pre>void vTaskSuspendAll( void );</pre>\r
+ *\r
+ * Suspends the scheduler without disabling interrupts.  Context switches will\r
+ * not occur while the scheduler is suspended.\r
+ *\r
+ * After calling vTaskSuspendAll () the calling task will continue to execute\r
+ * without risk of being swapped out until a call to xTaskResumeAll () has been\r
+ * made.\r
+ *\r
+ * API functions that have the potential to cause a context switch (for example,\r
+ * vTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler\r
+ * is suspended.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ void vTask1( void * pvParameters )\r
+ {\r
+        for( ;; )\r
+        {\r
+                // Task code goes here.\r
+\r
+                // ...\r
+\r
+                // At some point the task wants to perform a long operation during\r
+                // which it does not want to get swapped out.  It cannot use\r
+                // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the\r
+                // operation may cause interrupts to be missed - including the\r
+                // ticks.\r
+\r
+                // Prevent the real time kernel swapping out the task.\r
+                vTaskSuspendAll ();\r
+\r
+                // Perform the operation here.  There is no need to use critical\r
+                // sections as we have all the microcontroller processing time.\r
+                // During this time interrupts will still operate and the kernel\r
+                // tick count will be maintained.\r
+\r
+                // ...\r
+\r
+                // The operation is complete.  Restart the kernel.\r
+                xTaskResumeAll ();\r
+        }\r
+ }\r
+   </pre>\r
+ * \defgroup vTaskSuspendAll vTaskSuspendAll\r
+ * \ingroup SchedulerControl\r
+ */\r
+void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <pre>BaseType_t xTaskResumeAll( void );</pre>\r
+ *\r
+ * Resumes scheduler activity after it was suspended by a call to\r
+ * vTaskSuspendAll().\r
+ *\r
+ * xTaskResumeAll() only resumes the scheduler.  It does not unsuspend tasks\r
+ * that were previously suspended by a call to vTaskSuspend().\r
+ *\r
+ * @return If resuming the scheduler caused a context switch then pdTRUE is\r
+ *               returned, otherwise pdFALSE is returned.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+ void vTask1( void * pvParameters )\r
+ {\r
+        for( ;; )\r
+        {\r
+                // Task code goes here.\r
+\r
+                // ...\r
+\r
+                // At some point the task wants to perform a long operation during\r
+                // which it does not want to get swapped out.  It cannot use\r
+                // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the\r
+                // operation may cause interrupts to be missed - including the\r
+                // ticks.\r
+\r
+                // Prevent the real time kernel swapping out the task.\r
+                vTaskSuspendAll ();\r
+\r
+                // Perform the operation here.  There is no need to use critical\r
+                // sections as we have all the microcontroller processing time.\r
+                // During this time interrupts will still operate and the real\r
+                // time kernel tick count will be maintained.\r
+\r
+                // ...\r
+\r
+                // The operation is complete.  Restart the kernel.  We want to force\r
+                // a context switch - but there is no point if resuming the scheduler\r
+                // caused a context switch already.\r
+                if( !xTaskResumeAll () )\r
+                {\r
+                         taskYIELD ();\r
+                }\r
+        }\r
+ }\r
+   </pre>\r
+ * \defgroup xTaskResumeAll xTaskResumeAll\r
+ * \ingroup SchedulerControl\r
+ */\r
+BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*-----------------------------------------------------------\r
+ * TASK UTILITIES\r
+ *----------------------------------------------------------*/\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>TickType_t xTaskGetTickCount( void );</PRE>\r
+ *\r
+ * @return The count of ticks since vTaskStartScheduler was called.\r
+ *\r
+ * \defgroup xTaskGetTickCount xTaskGetTickCount\r
+ * \ingroup TaskUtils\r
+ */\r
+TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>TickType_t xTaskGetTickCountFromISR( void );</PRE>\r
+ *\r
+ * @return The count of ticks since vTaskStartScheduler was called.\r
+ *\r
+ * This is a version of xTaskGetTickCount() that is safe to be called from an\r
+ * ISR - provided that TickType_t is the natural word size of the\r
+ * microcontroller being used or interrupt nesting is either not supported or\r
+ * not being used.\r
+ *\r
+ * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR\r
+ * \ingroup TaskUtils\r
+ */\r
+TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>uint16_t uxTaskGetNumberOfTasks( void );</PRE>\r
+ *\r
+ * @return The number of tasks that the real time kernel is currently managing.\r
+ * This includes all ready, blocked and suspended tasks.  A task that\r
+ * has been deleted but not yet freed by the idle task will also be\r
+ * included in the count.\r
+ *\r
+ * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks\r
+ * \ingroup TaskUtils\r
+ */\r
+UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery );</PRE>\r
+ *\r
+ * @return The text (human readable) name of the task referenced by the handle\r
+ * xTaskToQuery.  A task can query its own name by either passing in its own\r
+ * handle, or by setting xTaskToQuery to NULL.  INCLUDE_pcTaskGetTaskName must be\r
+ * set to 1 in FreeRTOSConfig.h for pcTaskGetTaskName() to be available.\r
+ *\r
+ * \defgroup pcTaskGetTaskName pcTaskGetTaskName\r
+ * \ingroup TaskUtils\r
+ */\r
+char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+\r
+/**\r
+ * task.h\r
+ * <PRE>UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );</PRE>\r
+ *\r
+ * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for\r
+ * this function to be available.\r
+ *\r
+ * Returns the high water mark of the stack associated with xTask.  That is,\r
+ * the minimum free stack space there has been (in words, so on a 32 bit machine\r
+ * a value of 1 means 4 bytes) since the task started.  The smaller the returned\r
+ * number the closer the task has come to overflowing its stack.\r
+ *\r
+ * @param xTask Handle of the task associated with the stack to be checked.\r
+ * Set xTask to NULL to check the stack of the calling task.\r
+ *\r
+ * @return The smallest amount of free stack space there has been (in words, so\r
+ * actual spaces on the stack rather than bytes) since the task referenced by\r
+ * xTask was created.\r
+ */\r
+UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+\r
+/* When using trace macros it is sometimes necessary to include task.h before\r
+FreeRTOS.h.  When this is done TaskHookFunction_t will not yet have been defined,\r
+so the following two prototypes will cause a compilation error.  This can be\r
+fixed by simply guarding against the inclusion of these two prototypes unless\r
+they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration\r
+constant. */\r
+#ifdef configUSE_APPLICATION_TASK_TAG\r
+       #if configUSE_APPLICATION_TASK_TAG == 1\r
+               /**\r
+                * task.h\r
+                * <pre>void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );</pre>\r
+                *\r
+                * Sets pxHookFunction to be the task hook function used by the task xTask.\r
+                * Passing xTask as NULL has the effect of setting the calling tasks hook\r
+                * function.\r
+                */\r
+               void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION;\r
+\r
+               /**\r
+                * task.h\r
+                * <pre>void xTaskGetApplicationTaskTag( TaskHandle_t xTask );</pre>\r
+                *\r
+                * Returns the pxHookFunction value assigned to the task xTask.\r
+                */\r
+               TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+       #endif /* configUSE_APPLICATION_TASK_TAG ==1 */\r
+#endif /* ifdef configUSE_APPLICATION_TASK_TAG */\r
+\r
+#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )\r
+\r
+       /* Each task contains an array of pointers that is dimensioned by the\r
+       configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h.  The\r
+       kernel does not use the pointers itself, so the application writer can use\r
+       the pointers for any purpose they wish.  The following two functions are\r
+       used to set and query a pointer respectively. */\r
+       void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) PRIVILEGED_FUNCTION;\r
+       void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) PRIVILEGED_FUNCTION;\r
+\r
+#endif\r
+\r
+/**\r
+ * task.h\r
+ * <pre>BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );</pre>\r
+ *\r
+ * Calls the hook function associated with xTask.  Passing xTask as NULL has\r
+ * the effect of calling the Running tasks (the calling task) hook function.\r
+ *\r
+ * pvParameter is passed to the hook function for the task to interpret as it\r
+ * wants.  The return value is the value returned by the task hook function\r
+ * registered by the user.\r
+ */\r
+BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * xTaskGetIdleTaskHandle() is only available if\r
+ * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.\r
+ *\r
+ * Simply returns the handle of the idle task.  It is not valid to call\r
+ * xTaskGetIdleTaskHandle() before the scheduler has been started.\r
+ */\r
+TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for\r
+ * uxTaskGetSystemState() to be available.\r
+ *\r
+ * uxTaskGetSystemState() populates an TaskStatus_t structure for each task in\r
+ * the system.  TaskStatus_t structures contain, among other things, members\r
+ * for the task handle, task name, task priority, task state, and total amount\r
+ * of run time consumed by the task.  See the TaskStatus_t structure\r
+ * definition in this file for the full member list.\r
+ *\r
+ * NOTE:  This function is intended for debugging use only as its use results in\r
+ * the scheduler remaining suspended for an extended period.\r
+ *\r
+ * @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures.\r
+ * The array must contain at least one TaskStatus_t structure for each task\r
+ * that is under the control of the RTOS.  The number of tasks under the control\r
+ * of the RTOS can be determined using the uxTaskGetNumberOfTasks() API function.\r
+ *\r
+ * @param uxArraySize The size of the array pointed to by the pxTaskStatusArray\r
+ * parameter.  The size is specified as the number of indexes in the array, or\r
+ * the number of TaskStatus_t structures contained in the array, not by the\r
+ * number of bytes in the array.\r
+ *\r
+ * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in\r
+ * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the\r
+ * total run time (as defined by the run time stats clock, see\r
+ * http://www.freertos.org/rtos-run-time-stats.html) since the target booted.\r
+ * pulTotalRunTime can be set to NULL to omit the total run time information.\r
+ *\r
+ * @return The number of TaskStatus_t structures that were populated by\r
+ * uxTaskGetSystemState().  This should equal the number returned by the\r
+ * uxTaskGetNumberOfTasks() API function, but will be zero if the value passed\r
+ * in the uxArraySize parameter was too small.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+    // This example demonstrates how a human readable table of run time stats\r
+       // information is generated from raw data provided by uxTaskGetSystemState().\r
+       // The human readable table is written to pcWriteBuffer\r
+       void vTaskGetRunTimeStats( char *pcWriteBuffer )\r
+       {\r
+       TaskStatus_t *pxTaskStatusArray;\r
+       volatile UBaseType_t uxArraySize, x;\r
+       uint32_t ulTotalRunTime, ulStatsAsPercentage;\r
+\r
+               // Make sure the write buffer does not contain a string.\r
+               *pcWriteBuffer = 0x00;\r
+\r
+               // Take a snapshot of the number of tasks in case it changes while this\r
+               // function is executing.\r
+               uxArraySize = uxTaskGetNumberOfTasks();\r
+\r
+               // Allocate a TaskStatus_t structure for each task.  An array could be\r
+               // allocated statically at compile time.\r
+               pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );\r
+\r
+               if( pxTaskStatusArray != NULL )\r
+               {\r
+                       // Generate raw status information about each task.\r
+                       uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );\r
+\r
+                       // For percentage calculations.\r
+                       ulTotalRunTime /= 100UL;\r
+\r
+                       // Avoid divide by zero errors.\r
+                       if( ulTotalRunTime > 0 )\r
+                       {\r
+                               // For each populated position in the pxTaskStatusArray array,\r
+                               // format the raw data as human readable ASCII data\r
+                               for( x = 0; x < uxArraySize; x++ )\r
+                               {\r
+                                       // What percentage of the total run time has the task used?\r
+                                       // This will always be rounded down to the nearest integer.\r
+                                       // ulTotalRunTimeDiv100 has already been divided by 100.\r
+                                       ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;\r
+\r
+                                       if( ulStatsAsPercentage > 0UL )\r
+                                       {\r
+                                               sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               // If the percentage is zero here then the task has\r
+                                               // consumed less than 1% of the total run time.\r
+                                               sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );\r
+                                       }\r
+\r
+                                       pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );\r
+                               }\r
+                       }\r
+\r
+                       // The array is no longer needed, free the memory it consumes.\r
+                       vPortFree( pxTaskStatusArray );\r
+               }\r
+       }\r
+       </pre>\r
+ */\r
+UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>void vTaskList( char *pcWriteBuffer );</PRE>\r
+ *\r
+ * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must\r
+ * both be defined as 1 for this function to be available.  See the\r
+ * configuration section of the FreeRTOS.org website for more information.\r
+ *\r
+ * NOTE 1: This function will disable interrupts for its duration.  It is\r
+ * not intended for normal application runtime use but as a debug aid.\r
+ *\r
+ * Lists all the current tasks, along with their current state and stack\r
+ * usage high water mark.\r
+ *\r
+ * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or\r
+ * suspended ('S').\r
+ *\r
+ * PLEASE NOTE:\r
+ *\r
+ * This function is provided for convenience only, and is used by many of the\r
+ * demo applications.  Do not consider it to be part of the scheduler.\r
+ *\r
+ * vTaskList() calls uxTaskGetSystemState(), then formats part of the\r
+ * uxTaskGetSystemState() output into a human readable table that displays task\r
+ * names, states and stack usage.\r
+ *\r
+ * vTaskList() has a dependency on the sprintf() C library function that might\r
+ * bloat the code size, use a lot of stack, and provide different results on\r
+ * different platforms.  An alternative, tiny, third party, and limited\r
+ * functionality implementation of sprintf() is provided in many of the\r
+ * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note\r
+ * printf-stdarg.c does not provide a full snprintf() implementation!).\r
+ *\r
+ * It is recommended that production systems call uxTaskGetSystemState()\r
+ * directly to get access to raw stats data, rather than indirectly through a\r
+ * call to vTaskList().\r
+ *\r
+ * @param pcWriteBuffer A buffer into which the above mentioned details\r
+ * will be written, in ASCII form.  This buffer is assumed to be large\r
+ * enough to contain the generated report.  Approximately 40 bytes per\r
+ * task should be sufficient.\r
+ *\r
+ * \defgroup vTaskList vTaskList\r
+ * \ingroup TaskUtils\r
+ */\r
+void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>void vTaskGetRunTimeStats( char *pcWriteBuffer );</PRE>\r
+ *\r
+ * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS\r
+ * must both be defined as 1 for this function to be available.  The application\r
+ * must also then provide definitions for\r
+ * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()\r
+ * to configure a peripheral timer/counter and return the timers current count\r
+ * value respectively.  The counter should be at least 10 times the frequency of\r
+ * the tick count.\r
+ *\r
+ * NOTE 1: This function will disable interrupts for its duration.  It is\r
+ * not intended for normal application runtime use but as a debug aid.\r
+ *\r
+ * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total\r
+ * accumulated execution time being stored for each task.  The resolution\r
+ * of the accumulated time value depends on the frequency of the timer\r
+ * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.\r
+ * Calling vTaskGetRunTimeStats() writes the total execution time of each\r
+ * task into a buffer, both as an absolute count value and as a percentage\r
+ * of the total system execution time.\r
+ *\r
+ * NOTE 2:\r
+ *\r
+ * This function is provided for convenience only, and is used by many of the\r
+ * demo applications.  Do not consider it to be part of the scheduler.\r
+ *\r
+ * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the\r
+ * uxTaskGetSystemState() output into a human readable table that displays the\r
+ * amount of time each task has spent in the Running state in both absolute and\r
+ * percentage terms.\r
+ *\r
+ * vTaskGetRunTimeStats() has a dependency on the sprintf() C library function\r
+ * that might bloat the code size, use a lot of stack, and provide different\r
+ * results on different platforms.  An alternative, tiny, third party, and\r
+ * limited functionality implementation of sprintf() is provided in many of the\r
+ * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note\r
+ * printf-stdarg.c does not provide a full snprintf() implementation!).\r
+ *\r
+ * It is recommended that production systems call uxTaskGetSystemState() directly\r
+ * to get access to raw stats data, rather than indirectly through a call to\r
+ * vTaskGetRunTimeStats().\r
+ *\r
+ * @param pcWriteBuffer A buffer into which the execution times will be\r
+ * written, in ASCII form.  This buffer is assumed to be large enough to\r
+ * contain the generated report.  Approximately 40 bytes per task should\r
+ * be sufficient.\r
+ *\r
+ * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats\r
+ * \ingroup TaskUtils\r
+ */\r
+void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );</PRE>\r
+ *\r
+ * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this\r
+ * function to be available.\r
+ *\r
+ * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private\r
+ * "notification value", which is a 32-bit unsigned integer (uint32_t).\r
+ *\r
+ * Events can be sent to a task using an intermediary object.  Examples of such\r
+ * objects are queues, semaphores, mutexes and event groups.  Task notifications\r
+ * are a method of sending an event directly to a task without the need for such\r
+ * an intermediary object.\r
+ *\r
+ * A notification sent to a task can optionally perform an action, such as\r
+ * update, overwrite or increment the task's notification value.  In that way\r
+ * task notifications can be used to send data to a task, or be used as light\r
+ * weight and fast binary or counting semaphores.\r
+ *\r
+ * A notification sent to a task will remain pending until it is cleared by the\r
+ * task calling xTaskNotifyWait() or ulTaskNotifyTake().  If the task was\r
+ * already in the Blocked state to wait for a notification when the notification\r
+ * arrives then the task will automatically be removed from the Blocked state\r
+ * (unblocked) and the notification cleared.\r
+ *\r
+ * A task can use xTaskNotifyWait() to [optionally] block to wait for a\r
+ * notification to be pending, or ulTaskNotifyTake() to [optionally] block\r
+ * to wait for its notification value to have a non-zero value.  The task does\r
+ * not consume any CPU time while it is in the Blocked state.\r
+ *\r
+ * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.\r
+ *\r
+ * @param xTaskToNotify The handle of the task being notified.  The handle to a\r
+ * task can be returned from the xTaskCreate() API function used to create the\r
+ * task, and the handle of the currently running task can be obtained by calling\r
+ * xTaskGetCurrentTaskHandle().\r
+ *\r
+ * @param ulValue Data that can be sent with the notification.  How the data is\r
+ * used depends on the value of the eAction parameter.\r
+ *\r
+ * @param eAction Specifies how the notification updates the task's notification\r
+ * value, if at all.  Valid values for eAction are as follows:\r
+ *\r
+ * eSetBits -\r
+ * The task's notification value is bitwise ORed with ulValue.  xTaskNofify()\r
+ * always returns pdPASS in this case.\r
+ *\r
+ * eIncrement -\r
+ * The task's notification value is incremented.  ulValue is not used and\r
+ * xTaskNotify() always returns pdPASS in this case.\r
+ *\r
+ * eSetValueWithOverwrite -\r
+ * The task's notification value is set to the value of ulValue, even if the\r
+ * task being notified had not yet processed the previous notification (the\r
+ * task already had a notification pending).  xTaskNotify() always returns\r
+ * pdPASS in this case.\r
+ *\r
+ * eSetValueWithoutOverwrite -\r
+ * If the task being notified did not already have a notification pending then\r
+ * the task's notification value is set to ulValue and xTaskNotify() will\r
+ * return pdPASS.  If the task being notified already had a notification\r
+ * pending then no action is performed and pdFAIL is returned.\r
+ *\r
+ * eNoAction -\r
+ * The task receives a notification without its notification value being\r
+ * updated.  ulValue is not used and xTaskNotify() always returns pdPASS in\r
+ * this case.\r
+ *\r
+ *  pulPreviousNotificationValue -\r
+ *  Can be used to pass out the subject task's notification value before any\r
+ *  bits are modified by the notify function.\r
+ *\r
+ * @return Dependent on the value of eAction.  See the description of the\r
+ * eAction parameter.\r
+ *\r
+ * \defgroup xTaskNotify xTaskNotify\r
+ * \ingroup TaskNotifications\r
+ */\r
+BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) PRIVILEGED_FUNCTION;\r
+#define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL )\r
+#define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );</PRE>\r
+ *\r
+ * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this\r
+ * function to be available.\r
+ *\r
+ * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private\r
+ * "notification value", which is a 32-bit unsigned integer (uint32_t).\r
+ *\r
+ * A version of xTaskNotify() that can be used from an interrupt service routine\r
+ * (ISR).\r
+ *\r
+ * Events can be sent to a task using an intermediary object.  Examples of such\r
+ * objects are queues, semaphores, mutexes and event groups.  Task notifications\r
+ * are a method of sending an event directly to a task without the need for such\r
+ * an intermediary object.\r
+ *\r
+ * A notification sent to a task can optionally perform an action, such as\r
+ * update, overwrite or increment the task's notification value.  In that way\r
+ * task notifications can be used to send data to a task, or be used as light\r
+ * weight and fast binary or counting semaphores.\r
+ *\r
+ * A notification sent to a task will remain pending until it is cleared by the\r
+ * task calling xTaskNotifyWait() or ulTaskNotifyTake().  If the task was\r
+ * already in the Blocked state to wait for a notification when the notification\r
+ * arrives then the task will automatically be removed from the Blocked state\r
+ * (unblocked) and the notification cleared.\r
+ *\r
+ * A task can use xTaskNotifyWait() to [optionally] block to wait for a\r
+ * notification to be pending, or ulTaskNotifyTake() to [optionally] block\r
+ * to wait for its notification value to have a non-zero value.  The task does\r
+ * not consume any CPU time while it is in the Blocked state.\r
+ *\r
+ * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.\r
+ *\r
+ * @param xTaskToNotify The handle of the task being notified.  The handle to a\r
+ * task can be returned from the xTaskCreate() API function used to create the\r
+ * task, and the handle of the currently running task can be obtained by calling\r
+ * xTaskGetCurrentTaskHandle().\r
+ *\r
+ * @param ulValue Data that can be sent with the notification.  How the data is\r
+ * used depends on the value of the eAction parameter.\r
+ *\r
+ * @param eAction Specifies how the notification updates the task's notification\r
+ * value, if at all.  Valid values for eAction are as follows:\r
+ *\r
+ * eSetBits -\r
+ * The task's notification value is bitwise ORed with ulValue.  xTaskNofify()\r
+ * always returns pdPASS in this case.\r
+ *\r
+ * eIncrement -\r
+ * The task's notification value is incremented.  ulValue is not used and\r
+ * xTaskNotify() always returns pdPASS in this case.\r
+ *\r
+ * eSetValueWithOverwrite -\r
+ * The task's notification value is set to the value of ulValue, even if the\r
+ * task being notified had not yet processed the previous notification (the\r
+ * task already had a notification pending).  xTaskNotify() always returns\r
+ * pdPASS in this case.\r
+ *\r
+ * eSetValueWithoutOverwrite -\r
+ * If the task being notified did not already have a notification pending then\r
+ * the task's notification value is set to ulValue and xTaskNotify() will\r
+ * return pdPASS.  If the task being notified already had a notification\r
+ * pending then no action is performed and pdFAIL is returned.\r
+ *\r
+ * eNoAction -\r
+ * The task receives a notification without its notification value being\r
+ * updated.  ulValue is not used and xTaskNotify() always returns pdPASS in\r
+ * this case.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken  xTaskNotifyFromISR() will set\r
+ * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the\r
+ * task to which the notification was sent to leave the Blocked state, and the\r
+ * unblocked task has a priority higher than the currently running task.  If\r
+ * xTaskNotifyFromISR() sets this value to pdTRUE then a context switch should\r
+ * be requested before the interrupt is exited.  How a context switch is\r
+ * requested from an ISR is dependent on the port - see the documentation page\r
+ * for the port in use.\r
+ *\r
+ * @return Dependent on the value of eAction.  See the description of the\r
+ * eAction parameter.\r
+ *\r
+ * \defgroup xTaskNotify xTaskNotify\r
+ * \ingroup TaskNotifications\r
+ */\r
+BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
+#define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )\r
+#define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );</pre>\r
+ *\r
+ * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this\r
+ * function to be available.\r
+ *\r
+ * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private\r
+ * "notification value", which is a 32-bit unsigned integer (uint32_t).\r
+ *\r
+ * Events can be sent to a task using an intermediary object.  Examples of such\r
+ * objects are queues, semaphores, mutexes and event groups.  Task notifications\r
+ * are a method of sending an event directly to a task without the need for such\r
+ * an intermediary object.\r
+ *\r
+ * A notification sent to a task can optionally perform an action, such as\r
+ * update, overwrite or increment the task's notification value.  In that way\r
+ * task notifications can be used to send data to a task, or be used as light\r
+ * weight and fast binary or counting semaphores.\r
+ *\r
+ * A notification sent to a task will remain pending until it is cleared by the\r
+ * task calling xTaskNotifyWait() or ulTaskNotifyTake().  If the task was\r
+ * already in the Blocked state to wait for a notification when the notification\r
+ * arrives then the task will automatically be removed from the Blocked state\r
+ * (unblocked) and the notification cleared.\r
+ *\r
+ * A task can use xTaskNotifyWait() to [optionally] block to wait for a\r
+ * notification to be pending, or ulTaskNotifyTake() to [optionally] block\r
+ * to wait for its notification value to have a non-zero value.  The task does\r
+ * not consume any CPU time while it is in the Blocked state.\r
+ *\r
+ * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.\r
+ *\r
+ * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value\r
+ * will be cleared in the calling task's notification value before the task\r
+ * checks to see if any notifications are pending, and optionally blocks if no\r
+ * notifications are pending.  Setting ulBitsToClearOnEntry to ULONG_MAX (if\r
+ * limits.h is included) or 0xffffffffUL (if limits.h is not included) will have\r
+ * the effect of resetting the task's notification value to 0.  Setting\r
+ * ulBitsToClearOnEntry to 0 will leave the task's notification value unchanged.\r
+ *\r
+ * @param ulBitsToClearOnExit If a notification is pending or received before\r
+ * the calling task exits the xTaskNotifyWait() function then the task's\r
+ * notification value (see the xTaskNotify() API function) is passed out using\r
+ * the pulNotificationValue parameter.  Then any bits that are set in\r
+ * ulBitsToClearOnExit will be cleared in the task's notification value (note\r
+ * *pulNotificationValue is set before any bits are cleared).  Setting\r
+ * ulBitsToClearOnExit to ULONG_MAX (if limits.h is included) or 0xffffffffUL\r
+ * (if limits.h is not included) will have the effect of resetting the task's\r
+ * notification value to 0 before the function exits.  Setting\r
+ * ulBitsToClearOnExit to 0 will leave the task's notification value unchanged\r
+ * when the function exits (in which case the value passed out in\r
+ * pulNotificationValue will match the task's notification value).\r
+ *\r
+ * @param pulNotificationValue Used to pass the task's notification value out\r
+ * of the function.  Note the value passed out will not be effected by the\r
+ * clearing of any bits caused by ulBitsToClearOnExit being non-zero.\r
+ *\r
+ * @param xTicksToWait The maximum amount of time that the task should wait in\r
+ * the Blocked state for a notification to be received, should a notification\r
+ * not already be pending when xTaskNotifyWait() was called.  The task\r
+ * will not consume any processing time while it is in the Blocked state.  This\r
+ * is specified in kernel ticks, the macro pdMS_TO_TICSK( value_in_ms ) can be\r
+ * used to convert a time specified in milliseconds to a time specified in\r
+ * ticks.\r
+ *\r
+ * @return If a notification was received (including notifications that were\r
+ * already pending when xTaskNotifyWait was called) then pdPASS is\r
+ * returned.  Otherwise pdFAIL is returned.\r
+ *\r
+ * \defgroup xTaskNotifyWait xTaskNotifyWait\r
+ * \ingroup TaskNotifications\r
+ */\r
+BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );</PRE>\r
+ *\r
+ * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro\r
+ * to be available.\r
+ *\r
+ * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private\r
+ * "notification value", which is a 32-bit unsigned integer (uint32_t).\r
+ *\r
+ * Events can be sent to a task using an intermediary object.  Examples of such\r
+ * objects are queues, semaphores, mutexes and event groups.  Task notifications\r
+ * are a method of sending an event directly to a task without the need for such\r
+ * an intermediary object.\r
+ *\r
+ * A notification sent to a task can optionally perform an action, such as\r
+ * update, overwrite or increment the task's notification value.  In that way\r
+ * task notifications can be used to send data to a task, or be used as light\r
+ * weight and fast binary or counting semaphores.\r
+ *\r
+ * xTaskNotifyGive() is a helper macro intended for use when task notifications\r
+ * are used as light weight and faster binary or counting semaphore equivalents.\r
+ * Actual FreeRTOS semaphores are given using the xSemaphoreGive() API function,\r
+ * the equivalent action that instead uses a task notification is\r
+ * xTaskNotifyGive().\r
+ *\r
+ * When task notifications are being used as a binary or counting semaphore\r
+ * equivalent then the task being notified should wait for the notification\r
+ * using the ulTaskNotificationTake() API function rather than the\r
+ * xTaskNotifyWait() API function.\r
+ *\r
+ * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details.\r
+ *\r
+ * @param xTaskToNotify The handle of the task being notified.  The handle to a\r
+ * task can be returned from the xTaskCreate() API function used to create the\r
+ * task, and the handle of the currently running task can be obtained by calling\r
+ * xTaskGetCurrentTaskHandle().\r
+ *\r
+ * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the\r
+ * eAction parameter set to eIncrement - so pdPASS is always returned.\r
+ *\r
+ * \defgroup xTaskNotifyGive xTaskNotifyGive\r
+ * \ingroup TaskNotifications\r
+ */\r
+#define xTaskNotifyGive( xTaskToNotify ) xTaskGenericNotify( ( xTaskToNotify ), ( 0 ), eIncrement, NULL )\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );\r
+ *\r
+ * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro\r
+ * to be available.\r
+ *\r
+ * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private\r
+ * "notification value", which is a 32-bit unsigned integer (uint32_t).\r
+ *\r
+ * A version of xTaskNotifyGive() that can be called from an interrupt service\r
+ * routine (ISR).\r
+ *\r
+ * Events can be sent to a task using an intermediary object.  Examples of such\r
+ * objects are queues, semaphores, mutexes and event groups.  Task notifications\r
+ * are a method of sending an event directly to a task without the need for such\r
+ * an intermediary object.\r
+ *\r
+ * A notification sent to a task can optionally perform an action, such as\r
+ * update, overwrite or increment the task's notification value.  In that way\r
+ * task notifications can be used to send data to a task, or be used as light\r
+ * weight and fast binary or counting semaphores.\r
+ *\r
+ * vTaskNotifyGiveFromISR() is intended for use when task notifications are\r
+ * used as light weight and faster binary or counting semaphore equivalents.\r
+ * Actual FreeRTOS semaphores are given from an ISR using the\r
+ * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses\r
+ * a task notification is vTaskNotifyGiveFromISR().\r
+ *\r
+ * When task notifications are being used as a binary or counting semaphore\r
+ * equivalent then the task being notified should wait for the notification\r
+ * using the ulTaskNotificationTake() API function rather than the\r
+ * xTaskNotifyWait() API function.\r
+ *\r
+ * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details.\r
+ *\r
+ * @param xTaskToNotify The handle of the task being notified.  The handle to a\r
+ * task can be returned from the xTaskCreate() API function used to create the\r
+ * task, and the handle of the currently running task can be obtained by calling\r
+ * xTaskGetCurrentTaskHandle().\r
+ *\r
+ * @param pxHigherPriorityTaskWoken  vTaskNotifyGiveFromISR() will set\r
+ * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the\r
+ * task to which the notification was sent to leave the Blocked state, and the\r
+ * unblocked task has a priority higher than the currently running task.  If\r
+ * vTaskNotifyGiveFromISR() sets this value to pdTRUE then a context switch\r
+ * should be requested before the interrupt is exited.  How a context switch is\r
+ * requested from an ISR is dependent on the port - see the documentation page\r
+ * for the port in use.\r
+ *\r
+ * \defgroup xTaskNotifyWait xTaskNotifyWait\r
+ * \ingroup TaskNotifications\r
+ */\r
+void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );</pre>\r
+ *\r
+ * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this\r
+ * function to be available.\r
+ *\r
+ * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private\r
+ * "notification value", which is a 32-bit unsigned integer (uint32_t).\r
+ *\r
+ * Events can be sent to a task using an intermediary object.  Examples of such\r
+ * objects are queues, semaphores, mutexes and event groups.  Task notifications\r
+ * are a method of sending an event directly to a task without the need for such\r
+ * an intermediary object.\r
+ *\r
+ * A notification sent to a task can optionally perform an action, such as\r
+ * update, overwrite or increment the task's notification value.  In that way\r
+ * task notifications can be used to send data to a task, or be used as light\r
+ * weight and fast binary or counting semaphores.\r
+ *\r
+ * ulTaskNotifyTake() is intended for use when a task notification is used as a\r
+ * faster and lighter weight binary or counting semaphore alternative.  Actual\r
+ * FreeRTOS semaphores are taken using the xSemaphoreTake() API function, the\r
+ * equivalent action that instead uses a task notification is\r
+ * ulTaskNotifyTake().\r
+ *\r
+ * When a task is using its notification value as a binary or counting semaphore\r
+ * other tasks should send notifications to it using the xTaskNotifyGive()\r
+ * macro, or xTaskNotify() function with the eAction parameter set to\r
+ * eIncrement.\r
+ *\r
+ * ulTaskNotifyTake() can either clear the task's notification value to\r
+ * zero on exit, in which case the notification value acts like a binary\r
+ * semaphore, or decrement the task's notification value on exit, in which case\r
+ * the notification value acts like a counting semaphore.\r
+ *\r
+ * A task can use ulTaskNotifyTake() to [optionally] block to wait for a\r
+ * the task's notification value to be non-zero.  The task does not consume any\r
+ * CPU time while it is in the Blocked state.\r
+ *\r
+ * Where as xTaskNotifyWait() will return when a notification is pending,\r
+ * ulTaskNotifyTake() will return when the task's notification value is\r
+ * not zero.\r
+ *\r
+ * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.\r
+ *\r
+ * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's\r
+ * notification value is decremented when the function exits.  In this way the\r
+ * notification value acts like a counting semaphore.  If xClearCountOnExit is\r
+ * not pdFALSE then the task's notification value is cleared to zero when the\r
+ * function exits.  In this way the notification value acts like a binary\r
+ * semaphore.\r
+ *\r
+ * @param xTicksToWait The maximum amount of time that the task should wait in\r
+ * the Blocked state for the task's notification value to be greater than zero,\r
+ * should the count not already be greater than zero when\r
+ * ulTaskNotifyTake() was called.  The task will not consume any processing\r
+ * time while it is in the Blocked state.  This is specified in kernel ticks,\r
+ * the macro pdMS_TO_TICSK( value_in_ms ) can be used to convert a time\r
+ * specified in milliseconds to a time specified in ticks.\r
+ *\r
+ * @return The task's notification count before it is either cleared to zero or\r
+ * decremented (see the xClearCountOnExit parameter).\r
+ *\r
+ * \defgroup ulTaskNotifyTake ulTaskNotifyTake\r
+ * \ingroup TaskNotifications\r
+ */\r
+uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
+\r
+/*-----------------------------------------------------------\r
+ * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES\r
+ *----------------------------------------------------------*/\r
+\r
+/*\r
+ * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS ONLY\r
+ * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS\r
+ * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.\r
+ *\r
+ * Called from the real time kernel tick (either preemptive or cooperative),\r
+ * this increments the tick count and checks if any tasks that are blocked\r
+ * for a finite period required removing from a blocked list and placing on\r
+ * a ready list.  If a non-zero value is returned then a context switch is\r
+ * required because either:\r
+ *   + A task was removed from a blocked list because its timeout had expired,\r
+ *     or\r
+ *   + Time slicing is in use and there is a task of equal priority to the\r
+ *     currently running task.\r
+ */\r
+BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN\r
+ * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.\r
+ *\r
+ * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.\r
+ *\r
+ * Removes the calling task from the ready list and places it both\r
+ * on the list of tasks waiting for a particular event, and the\r
+ * list of delayed tasks.  The task will be removed from both lists\r
+ * and replaced on the ready list should either the event occur (and\r
+ * there be no higher priority tasks waiting on the same event) or\r
+ * the delay period expires.\r
+ *\r
+ * The 'unordered' version replaces the event list item value with the\r
+ * xItemValue value, and inserts the list item at the end of the list.\r
+ *\r
+ * The 'ordered' version uses the existing event list item value (which is the\r
+ * owning tasks priority) to insert the list item into the event list is task\r
+ * priority order.\r
+ *\r
+ * @param pxEventList The list containing tasks that are blocked waiting\r
+ * for the event to occur.\r
+ *\r
+ * @param xItemValue The item value to use for the event list item when the\r
+ * event list is not ordered by task priority.\r
+ *\r
+ * @param xTicksToWait The maximum amount of time that the task should wait\r
+ * for the event to occur.  This is specified in kernel ticks,the constant\r
+ * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time\r
+ * period.\r
+ */\r
+void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
+void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN\r
+ * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.\r
+ *\r
+ * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.\r
+ *\r
+ * This function performs nearly the same function as vTaskPlaceOnEventList().\r
+ * The difference being that this function does not permit tasks to block\r
+ * indefinitely, whereas vTaskPlaceOnEventList() does.\r
+ *\r
+ */\r
+void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN\r
+ * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.\r
+ *\r
+ * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.\r
+ *\r
+ * Removes a task from both the specified event list and the list of blocked\r
+ * tasks, and places it on a ready queue.\r
+ *\r
+ * xTaskRemoveFromEventList()/xTaskRemoveFromUnorderedEventList() will be called\r
+ * if either an event occurs to unblock a task, or the block timeout period\r
+ * expires.\r
+ *\r
+ * xTaskRemoveFromEventList() is used when the event list is in task priority\r
+ * order.  It removes the list item from the head of the event list as that will\r
+ * have the highest priority owning task of all the tasks on the event list.\r
+ * xTaskRemoveFromUnorderedEventList() is used when the event list is not\r
+ * ordered and the event list items hold something other than the owning tasks\r
+ * priority.  In this case the event list item value is updated to the value\r
+ * passed in the xItemValue parameter.\r
+ *\r
+ * @return pdTRUE if the task being removed has a higher priority than the task\r
+ * making the call, otherwise pdFALSE.\r
+ */\r
+BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION;\r
+BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS ONLY\r
+ * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS\r
+ * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.\r
+ *\r
+ * Sets the pointer to the current TCB to the TCB of the highest priority task\r
+ * that is ready to run.\r
+ */\r
+void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE.  THEY ARE USED BY\r
+ * THE EVENT BITS MODULE.\r
+ */\r
+TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Return the handle of the calling task.\r
+ */\r
+TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Capture the current time status for future reference.\r
+ */\r
+void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Compare the time status now with that previously captured to see if the\r
+ * timeout has expired.\r
+ */\r
+BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Shortcut used by the queue implementation to prevent unnecessary call to\r
+ * taskYIELD();\r
+ */\r
+void vTaskMissedYield( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Returns the scheduler state as taskSCHEDULER_RUNNING,\r
+ * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.\r
+ */\r
+BaseType_t xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Raises the priority of the mutex holder to that of the calling task should\r
+ * the mutex holder have a priority less than the calling task.\r
+ */\r
+void vTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Set the priority of a task back to its proper priority in the case that it\r
+ * inherited a higher priority while it was holding a semaphore.\r
+ */\r
+BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Generic version of the task creation function which is in turn called by the\r
+ * xTaskCreate() and xTaskCreateRestricted() macros.\r
+ */\r
+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. */\r
+\r
+/*\r
+ * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.\r
+ */\r
+UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Set the uxTaskNumber of the task referenced by the xTask parameter to\r
+ * uxHandle.\r
+ */\r
+void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Only available when configUSE_TICKLESS_IDLE is set to 1.\r
+ * If tickless mode is being used, or a low power mode is implemented, then\r
+ * the tick interrupt will not execute during idle periods.  When this is the\r
+ * case, the tick count value maintained by the scheduler needs to be kept up\r
+ * to date with the actual execution time by being skipped forward by a time\r
+ * equal to the idle period.\r
+ */\r
+void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Only avilable when configUSE_TICKLESS_IDLE is set to 1.\r
+ * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port\r
+ * specific sleep function to determine if it is ok to proceed with the sleep,\r
+ * and if it is ok to proceed, if it is ok to sleep indefinitely.\r
+ *\r
+ * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only\r
+ * called with the scheduler suspended, not from within a critical section.  It\r
+ * is therefore possible for an interrupt to request a context switch between\r
+ * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being\r
+ * entered.  eTaskConfirmSleepModeStatus() should be called from a short\r
+ * critical section between the timer being stopped and the sleep mode being\r
+ * entered to ensure it is ok to proceed into the sleep mode.\r
+ */\r
+eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * For internal use only.  Increment the mutex held count when a mutex is\r
+ * taken and return the handle of the task that has taken the mutex.\r
+ */\r
+void *pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif /* INC_TASK_H */\r
+\r
+\r
+\r
diff --git a/os/8.2.2/include/os/timers.h b/os/8.2.2/include/os/timers.h
new file mode 100644 (file)
index 0000000..ac2bedc
--- /dev/null
@@ -0,0 +1,1146 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+\r
+#ifndef TIMERS_H\r
+#define TIMERS_H\r
+\r
+#ifndef INC_FREERTOS_H\r
+       #error "include FreeRTOS.h must appear in source files before include timers.h"\r
+#endif\r
+\r
+/*lint -e537 This headers are only multiply included if the application code\r
+happens to also be including task.h. */\r
+#include "task.h"\r
+/*lint +e537 */\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/*-----------------------------------------------------------\r
+ * MACROS AND DEFINITIONS\r
+ *----------------------------------------------------------*/\r
+\r
+/* IDs for commands that can be sent/received on the timer queue.  These are to\r
+be used solely through the macros that make up the public software timer API,\r
+as defined below.  The commands that are sent from interrupts must use the\r
+highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task\r
+or interrupt version of the queue send function should be used. */\r
+#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR   ( ( BaseType_t ) -2 )\r
+#define tmrCOMMAND_EXECUTE_CALLBACK                            ( ( BaseType_t ) -1 )\r
+#define tmrCOMMAND_START_DONT_TRACE                            ( ( BaseType_t ) 0 )\r
+#define tmrCOMMAND_START                                           ( ( BaseType_t ) 1 )\r
+#define tmrCOMMAND_RESET                                               ( ( BaseType_t ) 2 )\r
+#define tmrCOMMAND_STOP                                                        ( ( BaseType_t ) 3 )\r
+#define tmrCOMMAND_CHANGE_PERIOD                               ( ( BaseType_t ) 4 )\r
+#define tmrCOMMAND_DELETE                                              ( ( BaseType_t ) 5 )\r
+\r
+#define tmrFIRST_FROM_ISR_COMMAND                              ( ( BaseType_t ) 6 )\r
+#define tmrCOMMAND_START_FROM_ISR                              ( ( BaseType_t ) 6 )\r
+#define tmrCOMMAND_RESET_FROM_ISR                              ( ( BaseType_t ) 7 )\r
+#define tmrCOMMAND_STOP_FROM_ISR                               ( ( BaseType_t ) 8 )\r
+#define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR              ( ( BaseType_t ) 9 )\r
+\r
+\r
+/**\r
+ * Type by which software timers are referenced.  For example, a call to\r
+ * xTimerCreate() returns an TimerHandle_t variable that can then be used to\r
+ * reference the subject timer in calls to other software timer API functions\r
+ * (for example, xTimerStart(), xTimerReset(), etc.).\r
+ */\r
+typedef void * TimerHandle_t;\r
+\r
+/*\r
+ * Defines the prototype to which timer callback functions must conform.\r
+ */\r
+typedef void (*TimerCallbackFunction_t)( TimerHandle_t xTimer );\r
+\r
+/*\r
+ * Defines the prototype to which functions used with the\r
+ * xTimerPendFunctionCallFromISR() function must conform.\r
+ */\r
+typedef void (*PendedFunction_t)( void *, uint32_t );\r
+\r
+/**\r
+ * TimerHandle_t xTimerCreate(         const char * const pcTimerName,\r
+ *                                                             TickType_t xTimerPeriodInTicks,\r
+ *                                                             UBaseType_t uxAutoReload,\r
+ *                                                             void * pvTimerID,\r
+ *                                                             TimerCallbackFunction_t pxCallbackFunction );\r
+ *\r
+ * Creates a new software timer instance.  This allocates the storage required\r
+ * by the new timer, initialises the new timers internal state, and returns a\r
+ * handle by which the new timer can be referenced.\r
+ *\r
+ * Timers are created in the dormant state.  The xTimerStart(), xTimerReset(),\r
+ * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and\r
+ * xTimerChangePeriodFromISR() API functions can all be used to transition a\r
+ * timer into the active state.\r
+ *\r
+ * @param pcTimerName A text name that is assigned to the timer.  This is done\r
+ * purely to assist debugging.  The kernel itself only ever references a timer\r
+ * by its handle, and never by its name.\r
+ *\r
+ * @param xTimerPeriodInTicks The timer period.  The time is defined in tick\r
+ * periods so the constant portTICK_PERIOD_MS can be used to convert a time that\r
+ * has been specified in milliseconds.  For example, if the timer must expire\r
+ * after 100 ticks, then xTimerPeriodInTicks should be set to 100.\r
+ * Alternatively, if the timer must expire after 500ms, then xPeriod can be set\r
+ * to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or\r
+ * equal to 1000.\r
+ *\r
+ * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will\r
+ * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter.\r
+ * If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and\r
+ * enter the dormant state after it expires.\r
+ *\r
+ * @param pvTimerID An identifier that is assigned to the timer being created.\r
+ * Typically this would be used in the timer callback function to identify which\r
+ * timer expired when the same callback function is assigned to more than one\r
+ * timer.\r
+ *\r
+ * @param pxCallbackFunction The function to call when the timer expires.\r
+ * Callback functions must have the prototype defined by TimerCallbackFunction_t,\r
+ * which is    "void vCallbackFunction( TimerHandle_t xTimer );".\r
+ *\r
+ * @return If the timer is successfully created then a handle to the newly\r
+ * created timer is returned.  If the timer cannot be created (because either\r
+ * there is insufficient FreeRTOS heap remaining to allocate the timer\r
+ * structures, or the timer period was set to 0) then NULL is returned.\r
+ *\r
+ * Example usage:\r
+ * @verbatim\r
+ * #define NUM_TIMERS 5\r
+ *\r
+ * // An array to hold handles to the created timers.\r
+ * TimerHandle_t xTimers[ NUM_TIMERS ];\r
+ *\r
+ * // An array to hold a count of the number of times each timer expires.\r
+ * int32_t lExpireCounters[ NUM_TIMERS ] = { 0 };\r
+ *\r
+ * // Define a callback function that will be used by multiple timer instances.\r
+ * // The callback function does nothing but count the number of times the\r
+ * // associated timer expires, and stop the timer once the timer has expired\r
+ * // 10 times.\r
+ * void vTimerCallback( TimerHandle_t pxTimer )\r
+ * {\r
+ * int32_t lArrayIndex;\r
+ * const int32_t xMaxExpiryCountBeforeStopping = 10;\r
+ *\r
+ *        // Optionally do something if the pxTimer parameter is NULL.\r
+ *        configASSERT( pxTimer );\r
+ *\r
+ *     // Which timer expired?\r
+ *     lArrayIndex = ( int32_t ) pvTimerGetTimerID( pxTimer );\r
+ *\r
+ *     // Increment the number of times that pxTimer has expired.\r
+ *     lExpireCounters[ lArrayIndex ] += 1;\r
+ *\r
+ *     // If the timer has expired 10 times then stop it from running.\r
+ *     if( lExpireCounters[ lArrayIndex ] == xMaxExpiryCountBeforeStopping )\r
+ *     {\r
+ *         // Do not use a block time if calling a timer API function from a\r
+ *         // timer callback function, as doing so could cause a deadlock!\r
+ *         xTimerStop( pxTimer, 0 );\r
+ *     }\r
+ * }\r
+ *\r
+ * void main( void )\r
+ * {\r
+ * int32_t x;\r
+ *\r
+ *     // Create then start some timers.  Starting the timers before the scheduler\r
+ *     // has been started means the timers will start running immediately that\r
+ *     // the scheduler starts.\r
+ *     for( x = 0; x < NUM_TIMERS; x++ )\r
+ *     {\r
+ *         xTimers[ x ] = xTimerCreate(    "Timer",       // Just a text name, not used by the kernel.\r
+ *                                         ( 100 * x ),   // The timer period in ticks.\r
+ *                                         pdTRUE,        // The timers will auto-reload themselves when they expire.\r
+ *                                         ( void * ) x,  // Assign each timer a unique id equal to its array index.\r
+ *                                         vTimerCallback // Each timer calls the same callback when it expires.\r
+ *                                     );\r
+ *\r
+ *         if( xTimers[ x ] == NULL )\r
+ *         {\r
+ *             // The timer was not created.\r
+ *         }\r
+ *         else\r
+ *         {\r
+ *             // Start the timer.  No block time is specified, and even if one was\r
+ *             // it would be ignored because the scheduler has not yet been\r
+ *             // started.\r
+ *             if( xTimerStart( xTimers[ x ], 0 ) != pdPASS )\r
+ *             {\r
+ *                 // The timer could not be set into the Active state.\r
+ *             }\r
+ *         }\r
+ *     }\r
+ *\r
+ *     // ...\r
+ *     // Create tasks here.\r
+ *     // ...\r
+ *\r
+ *     // Starting the scheduler will start the timers running as they have already\r
+ *     // been set into the active state.\r
+ *     xTaskStartScheduler();\r
+ *\r
+ *     // Should not reach here.\r
+ *     for( ;; );\r
+ * }\r
+ * @endverbatim\r
+ */\r
+TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+\r
+/**\r
+ * void *pvTimerGetTimerID( TimerHandle_t xTimer );\r
+ *\r
+ * Returns the ID assigned to the timer.\r
+ *\r
+ * IDs are assigned to timers using the pvTimerID parameter of the call to\r
+ * xTimerCreated() that was used to create the timer, and by calling the\r
+ * vTimerSetTimerID() API function.\r
+ *\r
+ * If the same callback function is assigned to multiple timers then the timer\r
+ * ID can be used as time specific (timer local) storage.\r
+ *\r
+ * @param xTimer The timer being queried.\r
+ *\r
+ * @return The ID assigned to the timer being queried.\r
+ *\r
+ * Example usage:\r
+ *\r
+ * See the xTimerCreate() API function example usage scenario.\r
+ */\r
+void *pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID );\r
+ *\r
+ * Sets the ID assigned to the timer.\r
+ *\r
+ * IDs are assigned to timers using the pvTimerID parameter of the call to\r
+ * xTimerCreated() that was used to create the timer.\r
+ *\r
+ * If the same callback function is assigned to multiple timers then the timer\r
+ * ID can be used as time specific (timer local) storage.\r
+ *\r
+ * @param xTimer The timer being updated.\r
+ *\r
+ * @param pvNewID The ID to assign to the timer.\r
+ *\r
+ * Example usage:\r
+ *\r
+ * See the xTimerCreate() API function example usage scenario.\r
+ */\r
+void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer );\r
+ *\r
+ * Queries a timer to see if it is active or dormant.\r
+ *\r
+ * A timer will be dormant if:\r
+ *     1) It has been created but not started, or\r
+ *     2) It is an expired one-shot timer that has not been restarted.\r
+ *\r
+ * Timers are created in the dormant state.  The xTimerStart(), xTimerReset(),\r
+ * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and\r
+ * xTimerChangePeriodFromISR() API functions can all be used to transition a timer into the\r
+ * active state.\r
+ *\r
+ * @param xTimer The timer being queried.\r
+ *\r
+ * @return pdFALSE will be returned if the timer is dormant.  A value other than\r
+ * pdFALSE will be returned if the timer is active.\r
+ *\r
+ * Example usage:\r
+ * @verbatim\r
+ * // This function assumes xTimer has already been created.\r
+ * void vAFunction( TimerHandle_t xTimer )\r
+ * {\r
+ *     if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )"\r
+ *     {\r
+ *         // xTimer is active, do something.\r
+ *     }\r
+ *     else\r
+ *     {\r
+ *         // xTimer is not active, do something else.\r
+ *     }\r
+ * }\r
+ * @endverbatim\r
+ */\r
+BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );\r
+ *\r
+ * xTimerGetTimerDaemonTaskHandle() is only available if\r
+ * INCLUDE_xTimerGetTimerDaemonTaskHandle is set to 1 in FreeRTOSConfig.h.\r
+ *\r
+ * Simply returns the handle of the timer service/daemon task.  It it not valid\r
+ * to call xTimerGetTimerDaemonTaskHandle() before the scheduler has been started.\r
+ */\r
+TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * BaseType_t xTimerStart( TimerHandle_t xTimer, TickType_t xTicksToWait );\r
+ *\r
+ * Timer functionality is provided by a timer service/daemon task.  Many of the\r
+ * public FreeRTOS timer API functions send commands to the timer service task\r
+ * through a queue called the timer command queue.  The timer command queue is\r
+ * private to the kernel itself and is not directly accessible to application\r
+ * code.  The length of the timer command queue is set by the\r
+ * configTIMER_QUEUE_LENGTH configuration constant.\r
+ *\r
+ * xTimerStart() starts a timer that was previously created using the\r
+ * xTimerCreate() API function.  If the timer had already been started and was\r
+ * already in the active state, then xTimerStart() has equivalent functionality\r
+ * to the xTimerReset() API function.\r
+ *\r
+ * Starting a timer ensures the timer is in the active state.  If the timer\r
+ * is not stopped, deleted, or reset in the mean time, the callback function\r
+ * associated with the timer will get called 'n' ticks after xTimerStart() was\r
+ * called, where 'n' is the timers defined period.\r
+ *\r
+ * It is valid to call xTimerStart() before the scheduler has been started, but\r
+ * when this is done the timer will not actually start until the scheduler is\r
+ * started, and the timers expiry time will be relative to when the scheduler is\r
+ * started, not relative to when xTimerStart() was called.\r
+ *\r
+ * The configUSE_TIMERS configuration constant must be set to 1 for xTimerStart()\r
+ * to be available.\r
+ *\r
+ * @param xTimer The handle of the timer being started/restarted.\r
+ *\r
+ * @param xTicksToWait Specifies the time, in ticks, that the calling task should\r
+ * be held in the Blocked state to wait for the start command to be successfully\r
+ * sent to the timer command queue, should the queue already be full when\r
+ * xTimerStart() was called.  xTicksToWait is ignored if xTimerStart() is called\r
+ * before the scheduler is started.\r
+ *\r
+ * @return pdFAIL will be returned if the start command could not be sent to\r
+ * the timer command queue even after xTicksToWait ticks had passed.  pdPASS will\r
+ * be returned if the command was successfully sent to the timer command queue.\r
+ * When the command is actually processed will depend on the priority of the\r
+ * timer service/daemon task relative to other tasks in the system, although the\r
+ * timers expiry time is relative to when xTimerStart() is actually called.  The\r
+ * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY\r
+ * configuration constant.\r
+ *\r
+ * Example usage:\r
+ *\r
+ * See the xTimerCreate() API function example usage scenario.\r
+ *\r
+ */\r
+#define xTimerStart( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) )\r
+\r
+/**\r
+ * BaseType_t xTimerStop( TimerHandle_t xTimer, TickType_t xTicksToWait );\r
+ *\r
+ * Timer functionality is provided by a timer service/daemon task.  Many of the\r
+ * public FreeRTOS timer API functions send commands to the timer service task\r
+ * through a queue called the timer command queue.  The timer command queue is\r
+ * private to the kernel itself and is not directly accessible to application\r
+ * code.  The length of the timer command queue is set by the\r
+ * configTIMER_QUEUE_LENGTH configuration constant.\r
+ *\r
+ * xTimerStop() stops a timer that was previously started using either of the\r
+ * The xTimerStart(), xTimerReset(), xTimerStartFromISR(), xTimerResetFromISR(),\r
+ * xTimerChangePeriod() or xTimerChangePeriodFromISR() API functions.\r
+ *\r
+ * Stopping a timer ensures the timer is not in the active state.\r
+ *\r
+ * The configUSE_TIMERS configuration constant must be set to 1 for xTimerStop()\r
+ * to be available.\r
+ *\r
+ * @param xTimer The handle of the timer being stopped.\r
+ *\r
+ * @param xTicksToWait Specifies the time, in ticks, that the calling task should\r
+ * be held in the Blocked state to wait for the stop command to be successfully\r
+ * sent to the timer command queue, should the queue already be full when\r
+ * xTimerStop() was called.  xTicksToWait is ignored if xTimerStop() is called\r
+ * before the scheduler is started.\r
+ *\r
+ * @return pdFAIL will be returned if the stop command could not be sent to\r
+ * the timer command queue even after xTicksToWait ticks had passed.  pdPASS will\r
+ * be returned if the command was successfully sent to the timer command queue.\r
+ * When the command is actually processed will depend on the priority of the\r
+ * timer service/daemon task relative to other tasks in the system.  The timer\r
+ * service/daemon task priority is set by the configTIMER_TASK_PRIORITY\r
+ * configuration constant.\r
+ *\r
+ * Example usage:\r
+ *\r
+ * See the xTimerCreate() API function example usage scenario.\r
+ *\r
+ */\r
+#define xTimerStop( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xTicksToWait ) )\r
+\r
+/**\r
+ * BaseType_t xTimerChangePeriod(      TimerHandle_t xTimer,\r
+ *                                                                             TickType_t xNewPeriod,\r
+ *                                                                             TickType_t xTicksToWait );\r
+ *\r
+ * Timer functionality is provided by a timer service/daemon task.  Many of the\r
+ * public FreeRTOS timer API functions send commands to the timer service task\r
+ * through a queue called the timer command queue.  The timer command queue is\r
+ * private to the kernel itself and is not directly accessible to application\r
+ * code.  The length of the timer command queue is set by the\r
+ * configTIMER_QUEUE_LENGTH configuration constant.\r
+ *\r
+ * xTimerChangePeriod() changes the period of a timer that was previously\r
+ * created using the xTimerCreate() API function.\r
+ *\r
+ * xTimerChangePeriod() can be called to change the period of an active or\r
+ * dormant state timer.\r
+ *\r
+ * The configUSE_TIMERS configuration constant must be set to 1 for\r
+ * xTimerChangePeriod() to be available.\r
+ *\r
+ * @param xTimer The handle of the timer that is having its period changed.\r
+ *\r
+ * @param xNewPeriod The new period for xTimer. Timer periods are specified in\r
+ * tick periods, so the constant portTICK_PERIOD_MS can be used to convert a time\r
+ * that has been specified in milliseconds.  For example, if the timer must\r
+ * expire after 100 ticks, then xNewPeriod should be set to 100.  Alternatively,\r
+ * if the timer must expire after 500ms, then xNewPeriod can be set to\r
+ * ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than\r
+ * or equal to 1000.\r
+ *\r
+ * @param xTicksToWait Specifies the time, in ticks, that the calling task should\r
+ * be held in the Blocked state to wait for the change period command to be\r
+ * successfully sent to the timer command queue, should the queue already be\r
+ * full when xTimerChangePeriod() was called.  xTicksToWait is ignored if\r
+ * xTimerChangePeriod() is called before the scheduler is started.\r
+ *\r
+ * @return pdFAIL will be returned if the change period command could not be\r
+ * sent to the timer command queue even after xTicksToWait ticks had passed.\r
+ * pdPASS will be returned if the command was successfully sent to the timer\r
+ * command queue.  When the command is actually processed will depend on the\r
+ * priority of the timer service/daemon task relative to other tasks in the\r
+ * system.  The timer service/daemon task priority is set by the\r
+ * configTIMER_TASK_PRIORITY configuration constant.\r
+ *\r
+ * Example usage:\r
+ * @verbatim\r
+ * // This function assumes xTimer has already been created.  If the timer\r
+ * // referenced by xTimer is already active when it is called, then the timer\r
+ * // is deleted.  If the timer referenced by xTimer is not active when it is\r
+ * // called, then the period of the timer is set to 500ms and the timer is\r
+ * // started.\r
+ * void vAFunction( TimerHandle_t xTimer )\r
+ * {\r
+ *     if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )"\r
+ *     {\r
+ *         // xTimer is already active - delete it.\r
+ *         xTimerDelete( xTimer );\r
+ *     }\r
+ *     else\r
+ *     {\r
+ *         // xTimer is not active, change its period to 500ms.  This will also\r
+ *         // cause the timer to start.  Block for a maximum of 100 ticks if the\r
+ *         // change period command cannot immediately be sent to the timer\r
+ *         // command queue.\r
+ *         if( xTimerChangePeriod( xTimer, 500 / portTICK_PERIOD_MS, 100 ) == pdPASS )\r
+ *         {\r
+ *             // The command was successfully sent.\r
+ *         }\r
+ *         else\r
+ *         {\r
+ *             // The command could not be sent, even after waiting for 100 ticks\r
+ *             // to pass.  Take appropriate action here.\r
+ *         }\r
+ *     }\r
+ * }\r
+ * @endverbatim\r
+ */\r
+ #define xTimerChangePeriod( xTimer, xNewPeriod, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xTicksToWait ) )\r
+\r
+/**\r
+ * BaseType_t xTimerDelete( TimerHandle_t xTimer, TickType_t xTicksToWait );\r
+ *\r
+ * Timer functionality is provided by a timer service/daemon task.  Many of the\r
+ * public FreeRTOS timer API functions send commands to the timer service task\r
+ * through a queue called the timer command queue.  The timer command queue is\r
+ * private to the kernel itself and is not directly accessible to application\r
+ * code.  The length of the timer command queue is set by the\r
+ * configTIMER_QUEUE_LENGTH configuration constant.\r
+ *\r
+ * xTimerDelete() deletes a timer that was previously created using the\r
+ * xTimerCreate() API function.\r
+ *\r
+ * The configUSE_TIMERS configuration constant must be set to 1 for\r
+ * xTimerDelete() to be available.\r
+ *\r
+ * @param xTimer The handle of the timer being deleted.\r
+ *\r
+ * @param xTicksToWait Specifies the time, in ticks, that the calling task should\r
+ * be held in the Blocked state to wait for the delete command to be\r
+ * successfully sent to the timer command queue, should the queue already be\r
+ * full when xTimerDelete() was called.  xTicksToWait is ignored if xTimerDelete()\r
+ * is called before the scheduler is started.\r
+ *\r
+ * @return pdFAIL will be returned if the delete command could not be sent to\r
+ * the timer command queue even after xTicksToWait ticks had passed.  pdPASS will\r
+ * be returned if the command was successfully sent to the timer command queue.\r
+ * When the command is actually processed will depend on the priority of the\r
+ * timer service/daemon task relative to other tasks in the system.  The timer\r
+ * service/daemon task priority is set by the configTIMER_TASK_PRIORITY\r
+ * configuration constant.\r
+ *\r
+ * Example usage:\r
+ *\r
+ * See the xTimerChangePeriod() API function example usage scenario.\r
+ */\r
+#define xTimerDelete( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xTicksToWait ) )\r
+\r
+/**\r
+ * BaseType_t xTimerReset( TimerHandle_t xTimer, TickType_t xTicksToWait );\r
+ *\r
+ * Timer functionality is provided by a timer service/daemon task.  Many of the\r
+ * public FreeRTOS timer API functions send commands to the timer service task\r
+ * through a queue called the timer command queue.  The timer command queue is\r
+ * private to the kernel itself and is not directly accessible to application\r
+ * code.  The length of the timer command queue is set by the\r
+ * configTIMER_QUEUE_LENGTH configuration constant.\r
+ *\r
+ * xTimerReset() re-starts a timer that was previously created using the\r
+ * xTimerCreate() API function.  If the timer had already been started and was\r
+ * already in the active state, then xTimerReset() will cause the timer to\r
+ * re-evaluate its expiry time so that it is relative to when xTimerReset() was\r
+ * called.  If the timer was in the dormant state then xTimerReset() has\r
+ * equivalent functionality to the xTimerStart() API function.\r
+ *\r
+ * Resetting a timer ensures the timer is in the active state.  If the timer\r
+ * is not stopped, deleted, or reset in the mean time, the callback function\r
+ * associated with the timer will get called 'n' ticks after xTimerReset() was\r
+ * called, where 'n' is the timers defined period.\r
+ *\r
+ * It is valid to call xTimerReset() before the scheduler has been started, but\r
+ * when this is done the timer will not actually start until the scheduler is\r
+ * started, and the timers expiry time will be relative to when the scheduler is\r
+ * started, not relative to when xTimerReset() was called.\r
+ *\r
+ * The configUSE_TIMERS configuration constant must be set to 1 for xTimerReset()\r
+ * to be available.\r
+ *\r
+ * @param xTimer The handle of the timer being reset/started/restarted.\r
+ *\r
+ * @param xTicksToWait Specifies the time, in ticks, that the calling task should\r
+ * be held in the Blocked state to wait for the reset command to be successfully\r
+ * sent to the timer command queue, should the queue already be full when\r
+ * xTimerReset() was called.  xTicksToWait is ignored if xTimerReset() is called\r
+ * before the scheduler is started.\r
+ *\r
+ * @return pdFAIL will be returned if the reset command could not be sent to\r
+ * the timer command queue even after xTicksToWait ticks had passed.  pdPASS will\r
+ * be returned if the command was successfully sent to the timer command queue.\r
+ * When the command is actually processed will depend on the priority of the\r
+ * timer service/daemon task relative to other tasks in the system, although the\r
+ * timers expiry time is relative to when xTimerStart() is actually called.  The\r
+ * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY\r
+ * configuration constant.\r
+ *\r
+ * Example usage:\r
+ * @verbatim\r
+ * // When a key is pressed, an LCD back-light is switched on.  If 5 seconds pass\r
+ * // without a key being pressed, then the LCD back-light is switched off.  In\r
+ * // this case, the timer is a one-shot timer.\r
+ *\r
+ * TimerHandle_t xBacklightTimer = NULL;\r
+ *\r
+ * // The callback function assigned to the one-shot timer.  In this case the\r
+ * // parameter is not used.\r
+ * void vBacklightTimerCallback( TimerHandle_t pxTimer )\r
+ * {\r
+ *     // The timer expired, therefore 5 seconds must have passed since a key\r
+ *     // was pressed.  Switch off the LCD back-light.\r
+ *     vSetBacklightState( BACKLIGHT_OFF );\r
+ * }\r
+ *\r
+ * // The key press event handler.\r
+ * void vKeyPressEventHandler( char cKey )\r
+ * {\r
+ *     // Ensure the LCD back-light is on, then reset the timer that is\r
+ *     // responsible for turning the back-light off after 5 seconds of\r
+ *     // key inactivity.  Wait 10 ticks for the command to be successfully sent\r
+ *     // if it cannot be sent immediately.\r
+ *     vSetBacklightState( BACKLIGHT_ON );\r
+ *     if( xTimerReset( xBacklightTimer, 100 ) != pdPASS )\r
+ *     {\r
+ *         // The reset command was not executed successfully.  Take appropriate\r
+ *         // action here.\r
+ *     }\r
+ *\r
+ *     // Perform the rest of the key processing here.\r
+ * }\r
+ *\r
+ * void main( void )\r
+ * {\r
+ * int32_t x;\r
+ *\r
+ *     // Create then start the one-shot timer that is responsible for turning\r
+ *     // the back-light off if no keys are pressed within a 5 second period.\r
+ *     xBacklightTimer = xTimerCreate( "BacklightTimer",           // Just a text name, not used by the kernel.\r
+ *                                     ( 5000 / portTICK_PERIOD_MS), // The timer period in ticks.\r
+ *                                     pdFALSE,                    // The timer is a one-shot timer.\r
+ *                                     0,                          // The id is not used by the callback so can take any value.\r
+ *                                     vBacklightTimerCallback     // The callback function that switches the LCD back-light off.\r
+ *                                   );\r
+ *\r
+ *     if( xBacklightTimer == NULL )\r
+ *     {\r
+ *         // The timer was not created.\r
+ *     }\r
+ *     else\r
+ *     {\r
+ *         // Start the timer.  No block time is specified, and even if one was\r
+ *         // it would be ignored because the scheduler has not yet been\r
+ *         // started.\r
+ *         if( xTimerStart( xBacklightTimer, 0 ) != pdPASS )\r
+ *         {\r
+ *             // The timer could not be set into the Active state.\r
+ *         }\r
+ *     }\r
+ *\r
+ *     // ...\r
+ *     // Create tasks here.\r
+ *     // ...\r
+ *\r
+ *     // Starting the scheduler will start the timer running as it has already\r
+ *     // been set into the active state.\r
+ *     xTaskStartScheduler();\r
+ *\r
+ *     // Should not reach here.\r
+ *     for( ;; );\r
+ * }\r
+ * @endverbatim\r
+ */\r
+#define xTimerReset( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) )\r
+\r
+/**\r
+ * BaseType_t xTimerStartFromISR(      TimerHandle_t xTimer,\r
+ *                                                                     BaseType_t *pxHigherPriorityTaskWoken );\r
+ *\r
+ * A version of xTimerStart() that can be called from an interrupt service\r
+ * routine.\r
+ *\r
+ * @param xTimer The handle of the timer being started/restarted.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most\r
+ * of its time in the Blocked state, waiting for messages to arrive on the timer\r
+ * command queue.  Calling xTimerStartFromISR() writes a message to the timer\r
+ * command queue, so has the potential to transition the timer service/daemon\r
+ * task out of the Blocked state.  If calling xTimerStartFromISR() causes the\r
+ * timer service/daemon task to leave the Blocked state, and the timer service/\r
+ * daemon task has a priority equal to or greater than the currently executing\r
+ * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will\r
+ * get set to pdTRUE internally within the xTimerStartFromISR() function.  If\r
+ * xTimerStartFromISR() sets this value to pdTRUE then a context switch should\r
+ * be performed before the interrupt exits.\r
+ *\r
+ * @return pdFAIL will be returned if the start command could not be sent to\r
+ * the timer command queue.  pdPASS will be returned if the command was\r
+ * successfully sent to the timer command queue.  When the command is actually\r
+ * processed will depend on the priority of the timer service/daemon task\r
+ * relative to other tasks in the system, although the timers expiry time is\r
+ * relative to when xTimerStartFromISR() is actually called.  The timer\r
+ * service/daemon task priority is set by the configTIMER_TASK_PRIORITY\r
+ * configuration constant.\r
+ *\r
+ * Example usage:\r
+ * @verbatim\r
+ * // This scenario assumes xBacklightTimer has already been created.  When a\r
+ * // key is pressed, an LCD back-light is switched on.  If 5 seconds pass\r
+ * // without a key being pressed, then the LCD back-light is switched off.  In\r
+ * // this case, the timer is a one-shot timer, and unlike the example given for\r
+ * // the xTimerReset() function, the key press event handler is an interrupt\r
+ * // service routine.\r
+ *\r
+ * // The callback function assigned to the one-shot timer.  In this case the\r
+ * // parameter is not used.\r
+ * void vBacklightTimerCallback( TimerHandle_t pxTimer )\r
+ * {\r
+ *     // The timer expired, therefore 5 seconds must have passed since a key\r
+ *     // was pressed.  Switch off the LCD back-light.\r
+ *     vSetBacklightState( BACKLIGHT_OFF );\r
+ * }\r
+ *\r
+ * // The key press interrupt service routine.\r
+ * void vKeyPressEventInterruptHandler( void )\r
+ * {\r
+ * BaseType_t xHigherPriorityTaskWoken = pdFALSE;\r
+ *\r
+ *     // Ensure the LCD back-light is on, then restart the timer that is\r
+ *     // responsible for turning the back-light off after 5 seconds of\r
+ *     // key inactivity.  This is an interrupt service routine so can only\r
+ *     // call FreeRTOS API functions that end in "FromISR".\r
+ *     vSetBacklightState( BACKLIGHT_ON );\r
+ *\r
+ *     // xTimerStartFromISR() or xTimerResetFromISR() could be called here\r
+ *     // as both cause the timer to re-calculate its expiry time.\r
+ *     // xHigherPriorityTaskWoken was initialised to pdFALSE when it was\r
+ *     // declared (in this function).\r
+ *     if( xTimerStartFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS )\r
+ *     {\r
+ *         // The start command was not executed successfully.  Take appropriate\r
+ *         // action here.\r
+ *     }\r
+ *\r
+ *     // Perform the rest of the key processing here.\r
+ *\r
+ *     // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch\r
+ *     // should be performed.  The syntax required to perform a context switch\r
+ *     // from inside an ISR varies from port to port, and from compiler to\r
+ *     // compiler.  Inspect the demos for the port you are using to find the\r
+ *     // actual syntax required.\r
+ *     if( xHigherPriorityTaskWoken != pdFALSE )\r
+ *     {\r
+ *         // Call the interrupt safe yield function here (actual function\r
+ *         // depends on the FreeRTOS port being used).\r
+ *     }\r
+ * }\r
+ * @endverbatim\r
+ */\r
+#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )\r
+\r
+/**\r
+ * BaseType_t xTimerStopFromISR(       TimerHandle_t xTimer,\r
+ *                                                                     BaseType_t *pxHigherPriorityTaskWoken );\r
+ *\r
+ * A version of xTimerStop() that can be called from an interrupt service\r
+ * routine.\r
+ *\r
+ * @param xTimer The handle of the timer being stopped.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most\r
+ * of its time in the Blocked state, waiting for messages to arrive on the timer\r
+ * command queue.  Calling xTimerStopFromISR() writes a message to the timer\r
+ * command queue, so has the potential to transition the timer service/daemon\r
+ * task out of the Blocked state.  If calling xTimerStopFromISR() causes the\r
+ * timer service/daemon task to leave the Blocked state, and the timer service/\r
+ * daemon task has a priority equal to or greater than the currently executing\r
+ * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will\r
+ * get set to pdTRUE internally within the xTimerStopFromISR() function.  If\r
+ * xTimerStopFromISR() sets this value to pdTRUE then a context switch should\r
+ * be performed before the interrupt exits.\r
+ *\r
+ * @return pdFAIL will be returned if the stop command could not be sent to\r
+ * the timer command queue.  pdPASS will be returned if the command was\r
+ * successfully sent to the timer command queue.  When the command is actually\r
+ * processed will depend on the priority of the timer service/daemon task\r
+ * relative to other tasks in the system.  The timer service/daemon task\r
+ * priority is set by the configTIMER_TASK_PRIORITY configuration constant.\r
+ *\r
+ * Example usage:\r
+ * @verbatim\r
+ * // This scenario assumes xTimer has already been created and started.  When\r
+ * // an interrupt occurs, the timer should be simply stopped.\r
+ *\r
+ * // The interrupt service routine that stops the timer.\r
+ * void vAnExampleInterruptServiceRoutine( void )\r
+ * {\r
+ * BaseType_t xHigherPriorityTaskWoken = pdFALSE;\r
+ *\r
+ *     // The interrupt has occurred - simply stop the timer.\r
+ *     // xHigherPriorityTaskWoken was set to pdFALSE where it was defined\r
+ *     // (within this function).  As this is an interrupt service routine, only\r
+ *     // FreeRTOS API functions that end in "FromISR" can be used.\r
+ *     if( xTimerStopFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS )\r
+ *     {\r
+ *         // The stop command was not executed successfully.  Take appropriate\r
+ *         // action here.\r
+ *     }\r
+ *\r
+ *     // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch\r
+ *     // should be performed.  The syntax required to perform a context switch\r
+ *     // from inside an ISR varies from port to port, and from compiler to\r
+ *     // compiler.  Inspect the demos for the port you are using to find the\r
+ *     // actual syntax required.\r
+ *     if( xHigherPriorityTaskWoken != pdFALSE )\r
+ *     {\r
+ *         // Call the interrupt safe yield function here (actual function\r
+ *         // depends on the FreeRTOS port being used).\r
+ *     }\r
+ * }\r
+ * @endverbatim\r
+ */\r
+#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP_FROM_ISR, 0, ( pxHigherPriorityTaskWoken ), 0U )\r
+\r
+/**\r
+ * BaseType_t xTimerChangePeriodFromISR( TimerHandle_t xTimer,\r
+ *                                                                              TickType_t xNewPeriod,\r
+ *                                                                              BaseType_t *pxHigherPriorityTaskWoken );\r
+ *\r
+ * A version of xTimerChangePeriod() that can be called from an interrupt\r
+ * service routine.\r
+ *\r
+ * @param xTimer The handle of the timer that is having its period changed.\r
+ *\r
+ * @param xNewPeriod The new period for xTimer. Timer periods are specified in\r
+ * tick periods, so the constant portTICK_PERIOD_MS can be used to convert a time\r
+ * that has been specified in milliseconds.  For example, if the timer must\r
+ * expire after 100 ticks, then xNewPeriod should be set to 100.  Alternatively,\r
+ * if the timer must expire after 500ms, then xNewPeriod can be set to\r
+ * ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than\r
+ * or equal to 1000.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most\r
+ * of its time in the Blocked state, waiting for messages to arrive on the timer\r
+ * command queue.  Calling xTimerChangePeriodFromISR() writes a message to the\r
+ * timer command queue, so has the potential to transition the timer service/\r
+ * daemon task out of the Blocked state.  If calling xTimerChangePeriodFromISR()\r
+ * causes the timer service/daemon task to leave the Blocked state, and the\r
+ * timer service/daemon task has a priority equal to or greater than the\r
+ * currently executing task (the task that was interrupted), then\r
+ * *pxHigherPriorityTaskWoken will get set to pdTRUE internally within the\r
+ * xTimerChangePeriodFromISR() function.  If xTimerChangePeriodFromISR() sets\r
+ * this value to pdTRUE then a context switch should be performed before the\r
+ * interrupt exits.\r
+ *\r
+ * @return pdFAIL will be returned if the command to change the timers period\r
+ * could not be sent to the timer command queue.  pdPASS will be returned if the\r
+ * command was successfully sent to the timer command queue.  When the command\r
+ * is actually processed will depend on the priority of the timer service/daemon\r
+ * task relative to other tasks in the system.  The timer service/daemon task\r
+ * priority is set by the configTIMER_TASK_PRIORITY configuration constant.\r
+ *\r
+ * Example usage:\r
+ * @verbatim\r
+ * // This scenario assumes xTimer has already been created and started.  When\r
+ * // an interrupt occurs, the period of xTimer should be changed to 500ms.\r
+ *\r
+ * // The interrupt service routine that changes the period of xTimer.\r
+ * void vAnExampleInterruptServiceRoutine( void )\r
+ * {\r
+ * BaseType_t xHigherPriorityTaskWoken = pdFALSE;\r
+ *\r
+ *     // The interrupt has occurred - change the period of xTimer to 500ms.\r
+ *     // xHigherPriorityTaskWoken was set to pdFALSE where it was defined\r
+ *     // (within this function).  As this is an interrupt service routine, only\r
+ *     // FreeRTOS API functions that end in "FromISR" can be used.\r
+ *     if( xTimerChangePeriodFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS )\r
+ *     {\r
+ *         // The command to change the timers period was not executed\r
+ *         // successfully.  Take appropriate action here.\r
+ *     }\r
+ *\r
+ *     // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch\r
+ *     // should be performed.  The syntax required to perform a context switch\r
+ *     // from inside an ISR varies from port to port, and from compiler to\r
+ *     // compiler.  Inspect the demos for the port you are using to find the\r
+ *     // actual syntax required.\r
+ *     if( xHigherPriorityTaskWoken != pdFALSE )\r
+ *     {\r
+ *         // Call the interrupt safe yield function here (actual function\r
+ *         // depends on the FreeRTOS port being used).\r
+ *     }\r
+ * }\r
+ * @endverbatim\r
+ */\r
+#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U )\r
+\r
+/**\r
+ * BaseType_t xTimerResetFromISR(      TimerHandle_t xTimer,\r
+ *                                                                     BaseType_t *pxHigherPriorityTaskWoken );\r
+ *\r
+ * A version of xTimerReset() that can be called from an interrupt service\r
+ * routine.\r
+ *\r
+ * @param xTimer The handle of the timer that is to be started, reset, or\r
+ * restarted.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most\r
+ * of its time in the Blocked state, waiting for messages to arrive on the timer\r
+ * command queue.  Calling xTimerResetFromISR() writes a message to the timer\r
+ * command queue, so has the potential to transition the timer service/daemon\r
+ * task out of the Blocked state.  If calling xTimerResetFromISR() causes the\r
+ * timer service/daemon task to leave the Blocked state, and the timer service/\r
+ * daemon task has a priority equal to or greater than the currently executing\r
+ * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will\r
+ * get set to pdTRUE internally within the xTimerResetFromISR() function.  If\r
+ * xTimerResetFromISR() sets this value to pdTRUE then a context switch should\r
+ * be performed before the interrupt exits.\r
+ *\r
+ * @return pdFAIL will be returned if the reset command could not be sent to\r
+ * the timer command queue.  pdPASS will be returned if the command was\r
+ * successfully sent to the timer command queue.  When the command is actually\r
+ * processed will depend on the priority of the timer service/daemon task\r
+ * relative to other tasks in the system, although the timers expiry time is\r
+ * relative to when xTimerResetFromISR() is actually called.  The timer service/daemon\r
+ * task priority is set by the configTIMER_TASK_PRIORITY configuration constant.\r
+ *\r
+ * Example usage:\r
+ * @verbatim\r
+ * // This scenario assumes xBacklightTimer has already been created.  When a\r
+ * // key is pressed, an LCD back-light is switched on.  If 5 seconds pass\r
+ * // without a key being pressed, then the LCD back-light is switched off.  In\r
+ * // this case, the timer is a one-shot timer, and unlike the example given for\r
+ * // the xTimerReset() function, the key press event handler is an interrupt\r
+ * // service routine.\r
+ *\r
+ * // The callback function assigned to the one-shot timer.  In this case the\r
+ * // parameter is not used.\r
+ * void vBacklightTimerCallback( TimerHandle_t pxTimer )\r
+ * {\r
+ *     // The timer expired, therefore 5 seconds must have passed since a key\r
+ *     // was pressed.  Switch off the LCD back-light.\r
+ *     vSetBacklightState( BACKLIGHT_OFF );\r
+ * }\r
+ *\r
+ * // The key press interrupt service routine.\r
+ * void vKeyPressEventInterruptHandler( void )\r
+ * {\r
+ * BaseType_t xHigherPriorityTaskWoken = pdFALSE;\r
+ *\r
+ *     // Ensure the LCD back-light is on, then reset the timer that is\r
+ *     // responsible for turning the back-light off after 5 seconds of\r
+ *     // key inactivity.  This is an interrupt service routine so can only\r
+ *     // call FreeRTOS API functions that end in "FromISR".\r
+ *     vSetBacklightState( BACKLIGHT_ON );\r
+ *\r
+ *     // xTimerStartFromISR() or xTimerResetFromISR() could be called here\r
+ *     // as both cause the timer to re-calculate its expiry time.\r
+ *     // xHigherPriorityTaskWoken was initialised to pdFALSE when it was\r
+ *     // declared (in this function).\r
+ *     if( xTimerResetFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS )\r
+ *     {\r
+ *         // The reset command was not executed successfully.  Take appropriate\r
+ *         // action here.\r
+ *     }\r
+ *\r
+ *     // Perform the rest of the key processing here.\r
+ *\r
+ *     // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch\r
+ *     // should be performed.  The syntax required to perform a context switch\r
+ *     // from inside an ISR varies from port to port, and from compiler to\r
+ *     // compiler.  Inspect the demos for the port you are using to find the\r
+ *     // actual syntax required.\r
+ *     if( xHigherPriorityTaskWoken != pdFALSE )\r
+ *     {\r
+ *         // Call the interrupt safe yield function here (actual function\r
+ *         // depends on the FreeRTOS port being used).\r
+ *     }\r
+ * }\r
+ * @endverbatim\r
+ */\r
+#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )\r
+\r
+\r
+/**\r
+ * BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend,\r
+ *                                          void *pvParameter1,\r
+ *                                          uint32_t ulParameter2,\r
+ *                                          BaseType_t *pxHigherPriorityTaskWoken );\r
+ *\r
+ *\r
+ * Used from application interrupt service routines to defer the execution of a\r
+ * function to the RTOS daemon task (the timer service task, hence this function\r
+ * is implemented in timers.c and is prefixed with 'Timer').\r
+ *\r
+ * Ideally an interrupt service routine (ISR) is kept as short as possible, but\r
+ * sometimes an ISR either has a lot of processing to do, or needs to perform\r
+ * processing that is not deterministic.  In these cases\r
+ * xTimerPendFunctionCallFromISR() can be used to defer processing of a function\r
+ * to the RTOS daemon task.\r
+ *\r
+ * A mechanism is provided that allows the interrupt to return directly to the\r
+ * task that will subsequently execute the pended callback function.  This\r
+ * allows the callback function to execute contiguously in time with the\r
+ * interrupt - just as if the callback had executed in the interrupt itself.\r
+ *\r
+ * @param xFunctionToPend The function to execute from the timer service/\r
+ * daemon task.  The function must conform to the PendedFunction_t\r
+ * prototype.\r
+ *\r
+ * @param pvParameter1 The value of the callback function's first parameter.\r
+ * The parameter has a void * type to allow it to be used to pass any type.\r
+ * For example, unsigned longs can be cast to a void *, or the void * can be\r
+ * used to point to a structure.\r
+ *\r
+ * @param ulParameter2 The value of the callback function's second parameter.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken As mentioned above, calling this function\r
+ * will result in a message being sent to the timer daemon task.  If the\r
+ * priority of the timer daemon task (which is set using\r
+ * configTIMER_TASK_PRIORITY in FreeRTOSConfig.h) is higher than the priority of\r
+ * the currently running task (the task the interrupt interrupted) then\r
+ * *pxHigherPriorityTaskWoken will be set to pdTRUE within\r
+ * xTimerPendFunctionCallFromISR(), indicating that a context switch should be\r
+ * requested before the interrupt exits.  For that reason\r
+ * *pxHigherPriorityTaskWoken must be initialised to pdFALSE.  See the\r
+ * example code below.\r
+ *\r
+ * @return pdPASS is returned if the message was successfully sent to the\r
+ * timer daemon task, otherwise pdFALSE is returned.\r
+ *\r
+ * Example usage:\r
+ * @verbatim\r
+ *\r
+ *     // The callback function that will execute in the context of the daemon task.\r
+ *  // Note callback functions must all use this same prototype.\r
+ *  void vProcessInterface( void *pvParameter1, uint32_t ulParameter2 )\r
+ *     {\r
+ *             BaseType_t xInterfaceToService;\r
+ *\r
+ *             // The interface that requires servicing is passed in the second\r
+ *      // parameter.  The first parameter is not used in this case.\r
+ *             xInterfaceToService = ( BaseType_t ) ulParameter2;\r
+ *\r
+ *             // ...Perform the processing here...\r
+ *     }\r
+ *\r
+ *     // An ISR that receives data packets from multiple interfaces\r
+ *  void vAnISR( void )\r
+ *     {\r
+ *             BaseType_t xInterfaceToService, xHigherPriorityTaskWoken;\r
+ *\r
+ *             // Query the hardware to determine which interface needs processing.\r
+ *             xInterfaceToService = prvCheckInterfaces();\r
+ *\r
+ *      // The actual processing is to be deferred to a task.  Request the\r
+ *      // vProcessInterface() callback function is executed, passing in the\r
+ *             // number of the interface that needs processing.  The interface to\r
+ *             // service is passed in the second parameter.  The first parameter is\r
+ *             // not used in this case.\r
+ *             xHigherPriorityTaskWoken = pdFALSE;\r
+ *             xTimerPendFunctionCallFromISR( vProcessInterface, NULL, ( uint32_t ) xInterfaceToService, &xHigherPriorityTaskWoken );\r
+ *\r
+ *             // If xHigherPriorityTaskWoken is now set to pdTRUE then a context\r
+ *             // switch should be requested.  The macro used is port specific and will\r
+ *             // be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - refer to\r
+ *             // the documentation page for the port being used.\r
+ *             portYIELD_FROM_ISR( xHigherPriorityTaskWoken );\r
+ *\r
+ *     }\r
+ * @endverbatim\r
+ */\r
+BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
+\r
+ /**\r
+  * BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend,\r
+  *                                    void *pvParameter1,\r
+  *                                    uint32_t ulParameter2,\r
+  *                                    TickType_t xTicksToWait );\r
+  *\r
+  *\r
+  * Used to defer the execution of a function to the RTOS daemon task (the timer\r
+  * service task, hence this function is implemented in timers.c and is prefixed\r
+  * with 'Timer').\r
+  *\r
+  * @param xFunctionToPend The function to execute from the timer service/\r
+  * daemon task.  The function must conform to the PendedFunction_t\r
+  * prototype.\r
+  *\r
+  * @param pvParameter1 The value of the callback function's first parameter.\r
+  * The parameter has a void * type to allow it to be used to pass any type.\r
+  * For example, unsigned longs can be cast to a void *, or the void * can be\r
+  * used to point to a structure.\r
+  *\r
+  * @param ulParameter2 The value of the callback function's second parameter.\r
+  *\r
+  * @param xTicksToWait Calling this function will result in a message being\r
+  * sent to the timer daemon task on a queue.  xTicksToWait is the amount of\r
+  * time the calling task should remain in the Blocked state (so not using any\r
+  * processing time) for space to become available on the timer queue if the\r
+  * queue is found to be full.\r
+  *\r
+  * @return pdPASS is returned if the message was successfully sent to the\r
+  * timer daemon task, otherwise pdFALSE is returned.\r
+  *\r
+  */\r
+BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * const char * const pcTimerGetTimerName( TimerHandle_t xTimer );\r
+ *\r
+ * Returns the name that was assigned to a timer when the timer was created.\r
+ *\r
+ * @param xTimer The handle of the timer being queried.\r
+ *\r
+ * @return The name assigned to the timer specified by the xTimer parameter.\r
+ */\r
+const char * pcTimerGetTimerName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+\r
+/*\r
+ * Functions beyond this part are not part of the public API and are intended\r
+ * for use by the kernel only.\r
+ */\r
+BaseType_t xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION;\r
+BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif /* TIMERS_H */\r
+\r
+\r
+\r
diff --git a/os/8.2.2/src/os/.gitattributes b/os/8.2.2/src/os/.gitattributes
new file mode 100644 (file)
index 0000000..1c965c7
--- /dev/null
@@ -0,0 +1,15 @@
+/croutine.c    eaton
+/event_groups.c        eaton
+/heap_1.c      eaton
+/heap_2.c      eaton
+/heap_3.c      eaton
+/heap_4.c      eaton
+/heap_5.c      eaton
+/heap.c        eaton
+/list.c        eaton
+/portASM.asm   eaton
+/port.c        eaton
+/queue.c       eaton
+/readme.txt    eaton
+/tasks.c       eaton
+/timers.c      eaton
diff --git a/os/8.2.2/src/os/croutine.c b/os/8.2.2/src/os/croutine.c
new file mode 100644 (file)
index 0000000..86ca0ec
--- /dev/null
@@ -0,0 +1,395 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+#include "os/FreeRTOS.h"\r
+#include "os/task.h"\r
+#include "os/croutine.h"\r
+\r
+/* Remove the whole file is co-routines are not being used. */\r
+#if( configUSE_CO_ROUTINES != 0 )\r
+\r
+/*\r
+ * Some kernel aware debuggers require data to be viewed to be global, rather\r
+ * than file scope.\r
+ */\r
+#ifdef portREMOVE_STATIC_QUALIFIER\r
+       #define static\r
+#endif\r
+\r
+\r
+/* Lists for ready and blocked co-routines. --------------------*/\r
+static List_t pxReadyCoRoutineLists[ configMAX_CO_ROUTINE_PRIORITIES ];        /*< Prioritised ready co-routines. */\r
+static List_t xDelayedCoRoutineList1;                                                                  /*< Delayed co-routines. */\r
+static List_t xDelayedCoRoutineList2;                                                                  /*< Delayed co-routines (two lists are used - one for delays that have overflowed the current tick count. */\r
+static List_t * pxDelayedCoRoutineList;                                                                        /*< Points to the delayed co-routine list currently being used. */\r
+static List_t * pxOverflowDelayedCoRoutineList;                                                        /*< Points to the delayed co-routine list currently being used to hold co-routines that have overflowed the current tick count. */\r
+static List_t xPendingReadyCoRoutineList;                                                              /*< Holds co-routines that have been readied by an external event.  They cannot be added directly to the ready lists as the ready lists cannot be accessed by interrupts. */\r
+\r
+/* Other file private variables. --------------------------------*/\r
+CRCB_t * pxCurrentCoRoutine = NULL;\r
+static UBaseType_t uxTopCoRoutineReadyPriority = 0;\r
+static TickType_t xCoRoutineTickCount = 0, xLastTickCount = 0, xPassedTicks = 0;\r
+\r
+/* The initial state of the co-routine when it is created. */\r
+#define corINITIAL_STATE       ( 0 )\r
+\r
+/*\r
+ * Place the co-routine represented by pxCRCB into the appropriate ready queue\r
+ * for the priority.  It is inserted at the end of the list.\r
+ *\r
+ * This macro accesses the co-routine ready lists and therefore must not be\r
+ * used from within an ISR.\r
+ */\r
+#define prvAddCoRoutineToReadyQueue( pxCRCB )                                                                                                                                          \\r
+{                                                                                                                                                                                                                                      \\r
+       if( pxCRCB->uxPriority > uxTopCoRoutineReadyPriority )                                                                                                                  \\r
+       {                                                                                                                                                                                                                               \\r
+               uxTopCoRoutineReadyPriority = pxCRCB->uxPriority;                                                                                                                       \\r
+       }                                                                                                                                                                                                                               \\r
+       vListInsertEnd( ( List_t * ) &( pxReadyCoRoutineLists[ pxCRCB->uxPriority ] ), &( pxCRCB->xGenericListItem ) ); \\r
+}\r
+\r
+/*\r
+ * Utility to ready all the lists used by the scheduler.  This is called\r
+ * automatically upon the creation of the first co-routine.\r
+ */\r
+static void prvInitialiseCoRoutineLists( void );\r
+\r
+/*\r
+ * Co-routines that are readied by an interrupt cannot be placed directly into\r
+ * the ready lists (there is no mutual exclusion).  Instead they are placed in\r
+ * in the pending ready list in order that they can later be moved to the ready\r
+ * list by the co-routine scheduler.\r
+ */\r
+static void prvCheckPendingReadyList( void );\r
+\r
+/*\r
+ * Macro that looks at the list of co-routines that are currently delayed to\r
+ * see if any require waking.\r
+ *\r
+ * Co-routines are stored in the queue in the order of their wake time -\r
+ * meaning once one co-routine has been found whose timer has not expired\r
+ * we need not look any further down the list.\r
+ */\r
+static void prvCheckDelayedList( void );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex )\r
+{\r
+BaseType_t xReturn;\r
+CRCB_t *pxCoRoutine;\r
+\r
+       /* Allocate the memory that will store the co-routine control block. */\r
+       pxCoRoutine = ( CRCB_t * ) pvPortMalloc( sizeof( CRCB_t ) );\r
+       if( pxCoRoutine )\r
+       {\r
+               /* If pxCurrentCoRoutine is NULL then this is the first co-routine to\r
+               be created and the co-routine data structures need initialising. */\r
+               if( pxCurrentCoRoutine == NULL )\r
+               {\r
+                       pxCurrentCoRoutine = pxCoRoutine;\r
+                       prvInitialiseCoRoutineLists();\r
+               }\r
+\r
+               /* Check the priority is within limits. */\r
+               if( uxPriority >= configMAX_CO_ROUTINE_PRIORITIES )\r
+               {\r
+                       uxPriority = configMAX_CO_ROUTINE_PRIORITIES - 1;\r
+               }\r
+\r
+               /* Fill out the co-routine control block from the function parameters. */\r
+               pxCoRoutine->uxState = corINITIAL_STATE;\r
+               pxCoRoutine->uxPriority = uxPriority;\r
+               pxCoRoutine->uxIndex = uxIndex;\r
+               pxCoRoutine->pxCoRoutineFunction = pxCoRoutineCode;\r
+\r
+               /* Initialise all the other co-routine control block parameters. */\r
+               vListInitialiseItem( &( pxCoRoutine->xGenericListItem ) );\r
+               vListInitialiseItem( &( pxCoRoutine->xEventListItem ) );\r
+\r
+               /* Set the co-routine control block as a link back from the ListItem_t.\r
+               This is so we can get back to the containing CRCB from a generic item\r
+               in a list. */\r
+               listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xGenericListItem ), pxCoRoutine );\r
+               listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xEventListItem ), pxCoRoutine );\r
+\r
+               /* Event lists are always in priority order. */\r
+               listSET_LIST_ITEM_VALUE( &( pxCoRoutine->xEventListItem ), ( ( TickType_t ) configMAX_CO_ROUTINE_PRIORITIES - ( TickType_t ) uxPriority ) );\r
+\r
+               /* Now the co-routine has been initialised it can be added to the ready\r
+               list at the correct priority. */\r
+               prvAddCoRoutineToReadyQueue( pxCoRoutine );\r
+\r
+               xReturn = pdPASS;\r
+       }\r
+       else\r
+       {\r
+               xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList )\r
+{\r
+TickType_t xTimeToWake;\r
+\r
+       /* Calculate the time to wake - this may overflow but this is\r
+       not a problem. */\r
+       xTimeToWake = xCoRoutineTickCount + xTicksToDelay;\r
+\r
+       /* We must remove ourselves from the ready list before adding\r
+       ourselves to the blocked list as the same list item is used for\r
+       both lists. */\r
+       ( void ) uxListRemove( ( ListItem_t * ) &( pxCurrentCoRoutine->xGenericListItem ) );\r
+\r
+       /* The list item will be inserted in wake time order. */\r
+       listSET_LIST_ITEM_VALUE( &( pxCurrentCoRoutine->xGenericListItem ), xTimeToWake );\r
+\r
+       if( xTimeToWake < xCoRoutineTickCount )\r
+       {\r
+               /* Wake time has overflowed.  Place this item in the\r
+               overflow list. */\r
+               vListInsert( ( List_t * ) pxOverflowDelayedCoRoutineList, ( ListItem_t * ) &( pxCurrentCoRoutine->xGenericListItem ) );\r
+       }\r
+       else\r
+       {\r
+               /* The wake time has not overflowed, so we can use the\r
+               current block list. */\r
+               vListInsert( ( List_t * ) pxDelayedCoRoutineList, ( ListItem_t * ) &( pxCurrentCoRoutine->xGenericListItem ) );\r
+       }\r
+\r
+       if( pxEventList )\r
+       {\r
+               /* Also add the co-routine to an event list.  If this is done then the\r
+               function must be called with interrupts disabled. */\r
+               vListInsert( pxEventList, &( pxCurrentCoRoutine->xEventListItem ) );\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCheckPendingReadyList( void )\r
+{\r
+       /* Are there any co-routines waiting to get moved to the ready list?  These\r
+       are co-routines that have been readied by an ISR.  The ISR cannot access\r
+       the     ready lists itself. */\r
+       while( listLIST_IS_EMPTY( &xPendingReadyCoRoutineList ) == pdFALSE )\r
+       {\r
+               CRCB_t *pxUnblockedCRCB;\r
+\r
+               /* The pending ready list can be accessed by an ISR. */\r
+               portDISABLE_INTERRUPTS();\r
+               {\r
+                       pxUnblockedCRCB = ( CRCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( (&xPendingReadyCoRoutineList) );\r
+                       ( void ) uxListRemove( &( pxUnblockedCRCB->xEventListItem ) );\r
+               }\r
+               portENABLE_INTERRUPTS();\r
+\r
+               ( void ) uxListRemove( &( pxUnblockedCRCB->xGenericListItem ) );\r
+               prvAddCoRoutineToReadyQueue( pxUnblockedCRCB );\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCheckDelayedList( void )\r
+{\r
+CRCB_t *pxCRCB;\r
+\r
+       xPassedTicks = xTaskGetTickCount() - xLastTickCount;\r
+       while( xPassedTicks )\r
+       {\r
+               xCoRoutineTickCount++;\r
+               xPassedTicks--;\r
+\r
+               /* If the tick count has overflowed we need to swap the ready lists. */\r
+               if( xCoRoutineTickCount == 0 )\r
+               {\r
+                       List_t * pxTemp;\r
+\r
+                       /* Tick count has overflowed so we need to swap the delay lists.  If there are\r
+                       any items in pxDelayedCoRoutineList here then there is an error! */\r
+                       pxTemp = pxDelayedCoRoutineList;\r
+                       pxDelayedCoRoutineList = pxOverflowDelayedCoRoutineList;\r
+                       pxOverflowDelayedCoRoutineList = pxTemp;\r
+               }\r
+\r
+               /* See if this tick has made a timeout expire. */\r
+               while( listLIST_IS_EMPTY( pxDelayedCoRoutineList ) == pdFALSE )\r
+               {\r
+                       pxCRCB = ( CRCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedCoRoutineList );\r
+\r
+                       if( xCoRoutineTickCount < listGET_LIST_ITEM_VALUE( &( pxCRCB->xGenericListItem ) ) )\r
+                       {\r
+                               /* Timeout not yet expired. */\r
+                               break;\r
+                       }\r
+\r
+                       portDISABLE_INTERRUPTS();\r
+                       {\r
+                               /* The event could have occurred just before this critical\r
+                               section.  If this is the case then the generic list item will\r
+                               have been moved to the pending ready list and the following\r
+                               line is still valid.  Also the pvContainer parameter will have\r
+                               been set to NULL so the following lines are also valid. */\r
+                               ( void ) uxListRemove( &( pxCRCB->xGenericListItem ) );\r
+\r
+                               /* Is the co-routine waiting on an event also? */\r
+                               if( pxCRCB->xEventListItem.pvContainer )\r
+                               {\r
+                                       ( void ) uxListRemove( &( pxCRCB->xEventListItem ) );\r
+                               }\r
+                       }\r
+                       portENABLE_INTERRUPTS();\r
+\r
+                       prvAddCoRoutineToReadyQueue( pxCRCB );\r
+               }\r
+       }\r
+\r
+       xLastTickCount = xCoRoutineTickCount;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vCoRoutineSchedule( void )\r
+{\r
+       /* See if any co-routines readied by events need moving to the ready lists. */\r
+       prvCheckPendingReadyList();\r
+\r
+       /* See if any delayed co-routines have timed out. */\r
+       prvCheckDelayedList();\r
+\r
+       /* Find the highest priority queue that contains ready co-routines. */\r
+       while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) )\r
+       {\r
+               if( uxTopCoRoutineReadyPriority == 0 )\r
+               {\r
+                       /* No more co-routines to check. */\r
+                       return;\r
+               }\r
+               --uxTopCoRoutineReadyPriority;\r
+       }\r
+\r
+       /* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the co-routines\r
+        of the same priority get an equal share of the processor time. */\r
+       listGET_OWNER_OF_NEXT_ENTRY( pxCurrentCoRoutine, &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) );\r
+\r
+       /* Call the co-routine. */\r
+       ( pxCurrentCoRoutine->pxCoRoutineFunction )( pxCurrentCoRoutine, pxCurrentCoRoutine->uxIndex );\r
+\r
+       return;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvInitialiseCoRoutineLists( void )\r
+{\r
+UBaseType_t uxPriority;\r
+\r
+       for( uxPriority = 0; uxPriority < configMAX_CO_ROUTINE_PRIORITIES; uxPriority++ )\r
+       {\r
+               vListInitialise( ( List_t * ) &( pxReadyCoRoutineLists[ uxPriority ] ) );\r
+       }\r
+\r
+       vListInitialise( ( List_t * ) &xDelayedCoRoutineList1 );\r
+       vListInitialise( ( List_t * ) &xDelayedCoRoutineList2 );\r
+       vListInitialise( ( List_t * ) &xPendingReadyCoRoutineList );\r
+\r
+       /* Start with pxDelayedCoRoutineList using list1 and the\r
+       pxOverflowDelayedCoRoutineList using list2. */\r
+       pxDelayedCoRoutineList = &xDelayedCoRoutineList1;\r
+       pxOverflowDelayedCoRoutineList = &xDelayedCoRoutineList2;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xCoRoutineRemoveFromEventList( const List_t *pxEventList )\r
+{\r
+CRCB_t *pxUnblockedCRCB;\r
+BaseType_t xReturn;\r
+\r
+       /* This function is called from within an interrupt.  It can only access\r
+       event lists and the pending ready list.  This function assumes that a\r
+       check has already been made to ensure pxEventList is not empty. */\r
+       pxUnblockedCRCB = ( CRCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );\r
+       ( void ) uxListRemove( &( pxUnblockedCRCB->xEventListItem ) );\r
+       vListInsertEnd( ( List_t * ) &( xPendingReadyCoRoutineList ), &( pxUnblockedCRCB->xEventListItem ) );\r
+\r
+       if( pxUnblockedCRCB->uxPriority >= pxCurrentCoRoutine->uxPriority )\r
+       {\r
+               xReturn = pdTRUE;\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFALSE;\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+\r
+#endif /* configUSE_CO_ROUTINES == 0 */\r
+\r
diff --git a/os/8.2.2/src/os/event_groups.c b/os/8.2.2/src/os/event_groups.c
new file mode 100644 (file)
index 0000000..484e840
--- /dev/null
@@ -0,0 +1,683 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+/* Standard includes. */\r
+#include <stdlib.h>\r
+\r
+/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining\r
+all the API functions to use the MPU wrappers.  That should only be done when\r
+task.h is included from an application file. */\r
+#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+/* FreeRTOS includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+#include "timers.h"\r
+#include "event_groups.h"\r
+\r
+/* Lint e961 and e750 are suppressed as a MISRA exception justified because the\r
+MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the\r
+header files above, but not in this file, in order to generate the correct\r
+privileged Vs unprivileged linkage and placement. */\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */\r
+\r
+#if ( INCLUDE_xEventGroupSetBitFromISR == 1 ) && ( configUSE_TIMERS == 0 )\r
+       #error configUSE_TIMERS must be set to 1 to make the xEventGroupSetBitFromISR() function available.\r
+#endif\r
+\r
+#if ( INCLUDE_xEventGroupSetBitFromISR == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 0 )\r
+       #error INCLUDE_xTimerPendFunctionCall must also be set to one to make the xEventGroupSetBitFromISR() function available.\r
+#endif\r
+\r
+/* The following bit fields convey control information in a task's event list\r
+item value.  It is important they don't clash with the\r
+taskEVENT_LIST_ITEM_VALUE_IN_USE definition. */\r
+#if configUSE_16_BIT_TICKS == 1\r
+       #define eventCLEAR_EVENTS_ON_EXIT_BIT   0x0100U\r
+       #define eventUNBLOCKED_DUE_TO_BIT_SET   0x0200U\r
+       #define eventWAIT_FOR_ALL_BITS                  0x0400U\r
+       #define eventEVENT_BITS_CONTROL_BYTES   0xff00U\r
+#else\r
+       #define eventCLEAR_EVENTS_ON_EXIT_BIT   0x01000000UL\r
+       #define eventUNBLOCKED_DUE_TO_BIT_SET   0x02000000UL\r
+       #define eventWAIT_FOR_ALL_BITS                  0x04000000UL\r
+       #define eventEVENT_BITS_CONTROL_BYTES   0xff000000UL\r
+#endif\r
+\r
+typedef struct xEventGroupDefinition\r
+{\r
+       EventBits_t uxEventBits;\r
+       List_t xTasksWaitingForBits;            /*< List of tasks waiting for a bit to be set. */\r
+\r
+       #if( configUSE_TRACE_FACILITY == 1 )\r
+               UBaseType_t uxEventGroupNumber;\r
+       #endif\r
+\r
+} EventGroup_t;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Test the bits set in uxCurrentEventBits to see if the wait condition is met.\r
+ * The wait condition is defined by xWaitForAllBits.  If xWaitForAllBits is\r
+ * pdTRUE then the wait condition is met if all the bits set in uxBitsToWaitFor\r
+ * are also set in uxCurrentEventBits.  If xWaitForAllBits is pdFALSE then the\r
+ * wait condition is met if any of the bits set in uxBitsToWait for are also set\r
+ * in uxCurrentEventBits.\r
+ */\r
+static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, const EventBits_t uxBitsToWaitFor, const BaseType_t xWaitForAllBits );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+EventGroupHandle_t xEventGroupCreate( void )\r
+{\r
+EventGroup_t *pxEventBits;\r
+\r
+       pxEventBits = ( EventGroup_t * ) pvPortMalloc( sizeof( EventGroup_t ) );\r
+       if( pxEventBits != NULL )\r
+       {\r
+               pxEventBits->uxEventBits = 0;\r
+               vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );\r
+               traceEVENT_GROUP_CREATE( pxEventBits );\r
+       }\r
+       else\r
+       {\r
+               traceEVENT_GROUP_CREATE_FAILED();\r
+       }\r
+\r
+       return ( EventGroupHandle_t ) pxEventBits;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait )\r
+{\r
+EventBits_t uxOriginalBitValue, uxReturn;\r
+EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;\r
+BaseType_t xAlreadyYielded;\r
+BaseType_t xTimeoutOccurred = pdFALSE;\r
+\r
+       configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 );\r
+       configASSERT( uxBitsToWaitFor != 0 );\r
+       #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r
+       {\r
+               configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );\r
+       }\r
+       #endif\r
+\r
+       vTaskSuspendAll();\r
+       {\r
+               uxOriginalBitValue = pxEventBits->uxEventBits;\r
+\r
+               ( void ) xEventGroupSetBits( xEventGroup, uxBitsToSet );\r
+\r
+               if( ( ( uxOriginalBitValue | uxBitsToSet ) & uxBitsToWaitFor ) == uxBitsToWaitFor )\r
+               {\r
+                       /* All the rendezvous bits are now set - no need to block. */\r
+                       uxReturn = ( uxOriginalBitValue | uxBitsToSet );\r
+\r
+                       /* Rendezvous always clear the bits.  They will have been cleared\r
+                       already unless this is the only task in the rendezvous. */\r
+                       pxEventBits->uxEventBits &= ~uxBitsToWaitFor;\r
+\r
+                       xTicksToWait = 0;\r
+               }\r
+               else\r
+               {\r
+                       if( xTicksToWait != ( TickType_t ) 0 )\r
+                       {\r
+                               traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor );\r
+\r
+                               /* Store the bits that the calling task is waiting for in the\r
+                               task's event list item so the kernel knows when a match is\r
+                               found.  Then enter the blocked state. */\r
+                               vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | eventCLEAR_EVENTS_ON_EXIT_BIT | eventWAIT_FOR_ALL_BITS ), xTicksToWait );\r
+\r
+                               /* This assignment is obsolete as uxReturn will get set after\r
+                               the task unblocks, but some compilers mistakenly generate a\r
+                               warning about uxReturn being returned without being set if the\r
+                               assignment is omitted. */\r
+                               uxReturn = 0;\r
+                       }\r
+                       else\r
+                       {\r
+                               /* The rendezvous bits were not set, but no block time was\r
+                               specified - just return the current event bit value. */\r
+                               uxReturn = pxEventBits->uxEventBits;\r
+                       }\r
+               }\r
+       }\r
+       xAlreadyYielded = xTaskResumeAll();\r
+\r
+       if( xTicksToWait != ( TickType_t ) 0 )\r
+       {\r
+               if( xAlreadyYielded == pdFALSE )\r
+               {\r
+                       portYIELD_WITHIN_API();\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               /* The task blocked to wait for its required bits to be set - at this\r
+               point either the required bits were set or the block time expired.  If\r
+               the required bits were set they will have been stored in the task's\r
+               event list item, and they should now be retrieved then cleared. */\r
+               uxReturn = uxTaskResetEventItemValue();\r
+\r
+               if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 )\r
+               {\r
+                       /* The task timed out, just return the current event bit value. */\r
+                       taskENTER_CRITICAL();\r
+                       {\r
+                               uxReturn = pxEventBits->uxEventBits;\r
+\r
+                               /* Although the task got here because it timed out before the\r
+                               bits it was waiting for were set, it is possible that since it\r
+                               unblocked another task has set the bits.  If this is the case\r
+                               then it needs to clear the bits before exiting. */\r
+                               if( ( uxReturn & uxBitsToWaitFor ) == uxBitsToWaitFor )\r
+                               {\r
+                                       pxEventBits->uxEventBits &= ~uxBitsToWaitFor;\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       taskEXIT_CRITICAL();\r
+\r
+                       xTimeoutOccurred = pdTRUE;\r
+               }\r
+               else\r
+               {\r
+                       /* The task unblocked because the bits were set. */\r
+               }\r
+\r
+               /* Control bits might be set as the task had blocked should not be\r
+               returned. */\r
+               uxReturn &= ~eventEVENT_BITS_CONTROL_BYTES;\r
+       }\r
+\r
+       traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred );\r
+\r
+       return uxReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait )\r
+{\r
+EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;\r
+EventBits_t uxReturn, uxControlBits = 0;\r
+BaseType_t xWaitConditionMet, xAlreadyYielded;\r
+BaseType_t xTimeoutOccurred = pdFALSE;\r
+\r
+       /* Check the user is not attempting to wait on the bits used by the kernel\r
+       itself, and that at least one bit is being requested. */\r
+       configASSERT( xEventGroup );\r
+       configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 );\r
+       configASSERT( uxBitsToWaitFor != 0 );\r
+       #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r
+       {\r
+               configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );\r
+       }\r
+       #endif\r
+\r
+       vTaskSuspendAll();\r
+       {\r
+               const EventBits_t uxCurrentEventBits = pxEventBits->uxEventBits;\r
+\r
+               /* Check to see if the wait condition is already met or not. */\r
+               xWaitConditionMet = prvTestWaitCondition( uxCurrentEventBits, uxBitsToWaitFor, xWaitForAllBits );\r
+\r
+               if( xWaitConditionMet != pdFALSE )\r
+               {\r
+                       /* The wait condition has already been met so there is no need to\r
+                       block. */\r
+                       uxReturn = uxCurrentEventBits;\r
+                       xTicksToWait = ( TickType_t ) 0;\r
+\r
+                       /* Clear the wait bits if requested to do so. */\r
+                       if( xClearOnExit != pdFALSE )\r
+                       {\r
+                               pxEventBits->uxEventBits &= ~uxBitsToWaitFor;\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else if( xTicksToWait == ( TickType_t ) 0 )\r
+               {\r
+                       /* The wait condition has not been met, but no block time was\r
+                       specified, so just return the current value. */\r
+                       uxReturn = uxCurrentEventBits;\r
+               }\r
+               else\r
+               {\r
+                       /* The task is going to block to wait for its required bits to be\r
+                       set.  uxControlBits are used to remember the specified behaviour of\r
+                       this call to xEventGroupWaitBits() - for use when the event bits\r
+                       unblock the task. */\r
+                       if( xClearOnExit != pdFALSE )\r
+                       {\r
+                               uxControlBits |= eventCLEAR_EVENTS_ON_EXIT_BIT;\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       if( xWaitForAllBits != pdFALSE )\r
+                       {\r
+                               uxControlBits |= eventWAIT_FOR_ALL_BITS;\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       /* Store the bits that the calling task is waiting for in the\r
+                       task's event list item so the kernel knows when a match is\r
+                       found.  Then enter the blocked state. */\r
+                       vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | uxControlBits ), xTicksToWait );\r
+\r
+                       /* This is obsolete as it will get set after the task unblocks, but\r
+                       some compilers mistakenly generate a warning about the variable\r
+                       being returned without being set if it is not done. */\r
+                       uxReturn = 0;\r
+\r
+                       traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor );\r
+               }\r
+       }\r
+       xAlreadyYielded = xTaskResumeAll();\r
+\r
+       if( xTicksToWait != ( TickType_t ) 0 )\r
+       {\r
+               if( xAlreadyYielded == pdFALSE )\r
+               {\r
+                       portYIELD_WITHIN_API();\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               /* The task blocked to wait for its required bits to be set - at this\r
+               point either the required bits were set or the block time expired.  If\r
+               the required bits were set they will have been stored in the task's\r
+               event list item, and they should now be retrieved then cleared. */\r
+               uxReturn = uxTaskResetEventItemValue();\r
+\r
+               if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 )\r
+               {\r
+                       taskENTER_CRITICAL();\r
+                       {\r
+                               /* The task timed out, just return the current event bit value. */\r
+                               uxReturn = pxEventBits->uxEventBits;\r
+\r
+                               /* It is possible that the event bits were updated between this\r
+                               task leaving the Blocked state and running again. */\r
+                               if( prvTestWaitCondition( uxReturn, uxBitsToWaitFor, xWaitForAllBits ) != pdFALSE )\r
+                               {\r
+                                       if( xClearOnExit != pdFALSE )\r
+                                       {\r
+                                               pxEventBits->uxEventBits &= ~uxBitsToWaitFor;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       taskEXIT_CRITICAL();\r
+\r
+                       /* Prevent compiler warnings when trace macros are not used. */\r
+                       xTimeoutOccurred = pdFALSE;\r
+               }\r
+               else\r
+               {\r
+                       /* The task unblocked because the bits were set. */\r
+               }\r
+\r
+               /* The task blocked so control bits may have been set. */\r
+               uxReturn &= ~eventEVENT_BITS_CONTROL_BYTES;\r
+       }\r
+       traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred );\r
+\r
+       return uxReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear )\r
+{\r
+EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;\r
+EventBits_t uxReturn;\r
+\r
+       /* Check the user is not attempting to clear the bits used by the kernel\r
+       itself. */\r
+       configASSERT( xEventGroup );\r
+       configASSERT( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0 );\r
+\r
+       taskENTER_CRITICAL();\r
+       {\r
+               traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear );\r
+\r
+               /* The value returned is the event group value prior to the bits being\r
+               cleared. */\r
+               uxReturn = pxEventBits->uxEventBits;\r
+\r
+               /* Clear the bits. */\r
+               pxEventBits->uxEventBits &= ~uxBitsToClear;\r
+       }\r
+       taskEXIT_CRITICAL();\r
+\r
+       return uxReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )\r
+\r
+       BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear )\r
+       {\r
+               BaseType_t xReturn;\r
+\r
+               traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear );\r
+               xReturn = xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL );\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup )\r
+{\r
+UBaseType_t uxSavedInterruptStatus;\r
+EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;\r
+EventBits_t uxReturn;\r
+\r
+       uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
+       {\r
+               uxReturn = pxEventBits->uxEventBits;\r
+       }\r
+       portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+\r
+       return uxReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet )\r
+{\r
+ListItem_t *pxListItem, *pxNext;\r
+ListItem_t const *pxListEnd;\r
+List_t *pxList;\r
+EventBits_t uxBitsToClear = 0, uxBitsWaitedFor, uxControlBits;\r
+EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;\r
+BaseType_t xMatchFound = pdFALSE;\r
+\r
+       /* Check the user is not attempting to set the bits used by the kernel\r
+       itself. */\r
+       configASSERT( xEventGroup );\r
+       configASSERT( ( uxBitsToSet & eventEVENT_BITS_CONTROL_BYTES ) == 0 );\r
+\r
+       pxList = &( pxEventBits->xTasksWaitingForBits );\r
+       pxListEnd = listGET_END_MARKER( pxList ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM.  This is checked and valid. */\r
+       vTaskSuspendAll();\r
+       {\r
+               traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet );\r
+\r
+               pxListItem = listGET_HEAD_ENTRY( pxList );\r
+\r
+               /* Set the bits. */\r
+               pxEventBits->uxEventBits |= uxBitsToSet;\r
+\r
+               /* See if the new bit value should unblock any tasks. */\r
+               while( pxListItem != pxListEnd )\r
+               {\r
+                       pxNext = listGET_NEXT( pxListItem );\r
+                       uxBitsWaitedFor = listGET_LIST_ITEM_VALUE( pxListItem );\r
+                       xMatchFound = pdFALSE;\r
+\r
+                       /* Split the bits waited for from the control bits. */\r
+                       uxControlBits = uxBitsWaitedFor & eventEVENT_BITS_CONTROL_BYTES;\r
+                       uxBitsWaitedFor &= ~eventEVENT_BITS_CONTROL_BYTES;\r
+\r
+                       if( ( uxControlBits & eventWAIT_FOR_ALL_BITS ) == ( EventBits_t ) 0 )\r
+                       {\r
+                               /* Just looking for single bit being set. */\r
+                               if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) != ( EventBits_t ) 0 )\r
+                               {\r
+                                       xMatchFound = pdTRUE;\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) == uxBitsWaitedFor )\r
+                       {\r
+                               /* All bits are set. */\r
+                               xMatchFound = pdTRUE;\r
+                       }\r
+                       else\r
+                       {\r
+                               /* Need all bits to be set, but not all the bits were set. */\r
+                       }\r
+\r
+                       if( xMatchFound != pdFALSE )\r
+                       {\r
+                               /* The bits match.  Should the bits be cleared on exit? */\r
+                               if( ( uxControlBits & eventCLEAR_EVENTS_ON_EXIT_BIT ) != ( EventBits_t ) 0 )\r
+                               {\r
+                                       uxBitsToClear |= uxBitsWaitedFor;\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+\r
+                               /* Store the actual event flag value in the task's event list\r
+                               item before removing the task from the event list.  The\r
+                               eventUNBLOCKED_DUE_TO_BIT_SET bit is set so the task knows\r
+                               that is was unblocked due to its required bits matching, rather\r
+                               than because it timed out. */\r
+                               ( void ) xTaskRemoveFromUnorderedEventList( pxListItem, pxEventBits->uxEventBits | eventUNBLOCKED_DUE_TO_BIT_SET );\r
+                       }\r
+\r
+                       /* Move onto the next list item.  Note pxListItem->pxNext is not\r
+                       used here as the list item may have been removed from the event list\r
+                       and inserted into the ready/pending reading list. */\r
+                       pxListItem = pxNext;\r
+               }\r
+\r
+               /* Clear any bits that matched when the eventCLEAR_EVENTS_ON_EXIT_BIT\r
+               bit was set in the control word. */\r
+               pxEventBits->uxEventBits &= ~uxBitsToClear;\r
+       }\r
+       ( void ) xTaskResumeAll();\r
+\r
+       return pxEventBits->uxEventBits;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vEventGroupDelete( EventGroupHandle_t xEventGroup )\r
+{\r
+EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;\r
+const List_t *pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits );\r
+\r
+       vTaskSuspendAll();\r
+       {\r
+               traceEVENT_GROUP_DELETE( xEventGroup );\r
+\r
+               while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( UBaseType_t ) 0 )\r
+               {\r
+                       /* Unblock the task, returning 0 as the event list is being deleted\r
+                       and     cannot therefore have any bits set. */\r
+                       configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) );\r
+                       ( void ) xTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );\r
+               }\r
+\r
+               vPortFree( pxEventBits );\r
+       }\r
+       ( void ) xTaskResumeAll();\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/* For internal use only - execute a 'set bits' command that was pended from\r
+an interrupt. */\r
+void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet )\r
+{\r
+       ( void ) xEventGroupSetBits( pvEventGroup, ( EventBits_t ) ulBitsToSet );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/* For internal use only - execute a 'clear bits' command that was pended from\r
+an interrupt. */\r
+void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear )\r
+{\r
+       ( void ) xEventGroupClearBits( pvEventGroup, ( EventBits_t ) ulBitsToClear );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, const EventBits_t uxBitsToWaitFor, const BaseType_t xWaitForAllBits )\r
+{\r
+BaseType_t xWaitConditionMet = pdFALSE;\r
+\r
+       if( xWaitForAllBits == pdFALSE )\r
+       {\r
+               /* Task only has to wait for one bit within uxBitsToWaitFor to be\r
+               set.  Is one already set? */\r
+               if( ( uxCurrentEventBits & uxBitsToWaitFor ) != ( EventBits_t ) 0 )\r
+               {\r
+                       xWaitConditionMet = pdTRUE;\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+       else\r
+       {\r
+               /* Task has to wait for all the bits in uxBitsToWaitFor to be set.\r
+               Are they set already? */\r
+               if( ( uxCurrentEventBits & uxBitsToWaitFor ) == uxBitsToWaitFor )\r
+               {\r
+                       xWaitConditionMet = pdTRUE;\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+\r
+       return xWaitConditionMet;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )\r
+\r
+       BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken )\r
+       {\r
+       BaseType_t xReturn;\r
+\r
+               traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet );\r
+               xReturn = xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken );\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+#if (configUSE_TRACE_FACILITY == 1)\r
+\r
+       UBaseType_t uxEventGroupGetNumber( void* xEventGroup )\r
+       {\r
+       UBaseType_t xReturn;\r
+       EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;\r
+\r
+               if( xEventGroup == NULL )\r
+               {\r
+                       xReturn = 0;\r
+               }\r
+               else\r
+               {\r
+                       xReturn = pxEventBits->uxEventGroupNumber;\r
+               }\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif\r
+\r
diff --git a/os/8.2.2/src/os/heap.c b/os/8.2.2/src/os/heap.c
new file mode 100644 (file)
index 0000000..8c01b77
--- /dev/null
@@ -0,0 +1,174 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+\r
+/*\r
+ * The simplest possible implementation of pvPortMalloc().  Note that this\r
+ * implementation does NOT allow allocated memory to be freed again.\r
+ *\r
+ * See heap_2.c, heap_3.c and heap_4.c for alternative implementations, and the\r
+ * memory management pages of http://www.FreeRTOS.org for more information.\r
+ */\r
+#include <stdlib.h>\r
+\r
+/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining\r
+all the API functions to use the MPU wrappers.  That should only be done when\r
+task.h is included from an application file. */\r
+#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+#include "os/FreeRTOS.h"\r
+#include "os/task.h"\r
+\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+/* A few bytes might be lost to byte aligning the heap start address. */\r
+#define configADJUSTED_HEAP_SIZE       ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT )\r
+\r
+/* Allocate the memory for the heap. */\r
+static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];\r
+static size_t xNextFreeByte = ( size_t ) 0;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void *pvPortMalloc( size_t xWantedSize )\r
+{\r
+void *pvReturn = NULL;\r
+static uint8_t *pucAlignedHeap = NULL;\r
+\r
+       /* Ensure that blocks are always aligned to the required number of bytes. */\r
+       #if portBYTE_ALIGNMENT != 1\r
+               if( xWantedSize & portBYTE_ALIGNMENT_MASK )\r
+               {\r
+                       /* Byte alignment required. */\r
+                       xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );\r
+               }\r
+       #endif\r
+\r
+       vTaskSuspendAll();\r
+       {\r
+               if( pucAlignedHeap == NULL )\r
+               {\r
+                       /* Ensure the heap starts on a correctly aligned boundary. */\r
+                       pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );\r
+               }\r
+\r
+               /* Check there is enough room left for the allocation. */\r
+               if( ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) &&\r
+                       ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte )     )/* Check for overflow. */\r
+               {\r
+                       /* Return the next free byte then increment the index past this\r
+                       block. */\r
+                       pvReturn = pucAlignedHeap + xNextFreeByte;\r
+                       xNextFreeByte += xWantedSize;\r
+               }\r
+\r
+               traceMALLOC( pvReturn, xWantedSize );\r
+       }\r
+       ( void ) xTaskResumeAll();\r
+\r
+       #if( configUSE_MALLOC_FAILED_HOOK == 1 )\r
+       {\r
+               if( pvReturn == NULL )\r
+               {\r
+                       extern void vApplicationMallocFailedHook( void );\r
+                       vApplicationMallocFailedHook();\r
+               }\r
+       }\r
+       #endif\r
+\r
+       return pvReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortFree( void *pv )\r
+{\r
+       /* Memory cannot be freed using this scheme.  See heap_2.c, heap_3.c and\r
+       heap_4.c for alternative implementations, and the memory management pages of\r
+       http://www.FreeRTOS.org for more information. */\r
+       ( void ) pv;\r
+\r
+       /* Force an assert as it is invalid to call this function. */\r
+       configASSERT( pv == NULL );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortInitialiseBlocks( void )\r
+{\r
+       /* Only required when static memory is not cleared. */\r
+       xNextFreeByte = ( size_t ) 0;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+size_t xPortGetFreeHeapSize( void )\r
+{\r
+       return ( configADJUSTED_HEAP_SIZE - xNextFreeByte );\r
+}\r
+\r
+\r
+\r
diff --git a/os/8.2.2/src/os/heap_1.c b/os/8.2.2/src/os/heap_1.c
new file mode 100644 (file)
index 0000000..560b256
--- /dev/null
@@ -0,0 +1,174 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+\r
+/*\r
+ * The simplest possible implementation of pvPortMalloc().  Note that this\r
+ * implementation does NOT allow allocated memory to be freed again.\r
+ *\r
+ * See heap_2.c, heap_3.c and heap_4.c for alternative implementations, and the\r
+ * memory management pages of http://www.FreeRTOS.org for more information.\r
+ */\r
+#include <stdlib.h>\r
+\r
+/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining\r
+all the API functions to use the MPU wrappers.  That should only be done when\r
+task.h is included from an application file. */\r
+#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+/* A few bytes might be lost to byte aligning the heap start address. */\r
+#define configADJUSTED_HEAP_SIZE       ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT )\r
+\r
+/* Allocate the memory for the heap. */\r
+static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];\r
+static size_t xNextFreeByte = ( size_t ) 0;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void *pvPortMalloc( size_t xWantedSize )\r
+{\r
+void *pvReturn = NULL;\r
+static uint8_t *pucAlignedHeap = NULL;\r
+\r
+       /* Ensure that blocks are always aligned to the required number of bytes. */\r
+       #if portBYTE_ALIGNMENT != 1\r
+               if( xWantedSize & portBYTE_ALIGNMENT_MASK )\r
+               {\r
+                       /* Byte alignment required. */\r
+                       xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );\r
+               }\r
+       #endif\r
+\r
+       vTaskSuspendAll();\r
+       {\r
+               if( pucAlignedHeap == NULL )\r
+               {\r
+                       /* Ensure the heap starts on a correctly aligned boundary. */\r
+                       pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );\r
+               }\r
+\r
+               /* Check there is enough room left for the allocation. */\r
+               if( ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) &&\r
+                       ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte )     )/* Check for overflow. */\r
+               {\r
+                       /* Return the next free byte then increment the index past this\r
+                       block. */\r
+                       pvReturn = pucAlignedHeap + xNextFreeByte;\r
+                       xNextFreeByte += xWantedSize;\r
+               }\r
+\r
+               traceMALLOC( pvReturn, xWantedSize );\r
+       }\r
+       ( void ) xTaskResumeAll();\r
+\r
+       #if( configUSE_MALLOC_FAILED_HOOK == 1 )\r
+       {\r
+               if( pvReturn == NULL )\r
+               {\r
+                       extern void vApplicationMallocFailedHook( void );\r
+                       vApplicationMallocFailedHook();\r
+               }\r
+       }\r
+       #endif\r
+\r
+       return pvReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortFree( void *pv )\r
+{\r
+       /* Memory cannot be freed using this scheme.  See heap_2.c, heap_3.c and\r
+       heap_4.c for alternative implementations, and the memory management pages of\r
+       http://www.FreeRTOS.org for more information. */\r
+       ( void ) pv;\r
+\r
+       /* Force an assert as it is invalid to call this function. */\r
+       configASSERT( pv == NULL );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortInitialiseBlocks( void )\r
+{\r
+       /* Only required when static memory is not cleared. */\r
+       xNextFreeByte = ( size_t ) 0;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+size_t xPortGetFreeHeapSize( void )\r
+{\r
+       return ( configADJUSTED_HEAP_SIZE - xNextFreeByte );\r
+}\r
+\r
+\r
+\r
diff --git a/os/8.2.2/src/os/heap_2.c b/os/8.2.2/src/os/heap_2.c
new file mode 100644 (file)
index 0000000..4e0c92e
--- /dev/null
@@ -0,0 +1,303 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+/*\r
+ * A sample implementation of pvPortMalloc() and vPortFree() that permits\r
+ * allocated blocks to be freed, but does not combine adjacent free blocks\r
+ * into a single larger block (and so will fragment memory).  See heap_4.c for\r
+ * an equivalent that does combine adjacent blocks into single larger blocks.\r
+ *\r
+ * See heap_1.c, heap_3.c and heap_4.c for alternative implementations, and the\r
+ * memory management pages of http://www.FreeRTOS.org for more information.\r
+ */\r
+#include <stdlib.h>\r
+\r
+/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining\r
+all the API functions to use the MPU wrappers.  That should only be done when\r
+task.h is included from an application file. */\r
+#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+/* A few bytes might be lost to byte aligning the heap start address. */\r
+#define configADJUSTED_HEAP_SIZE       ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT )\r
+\r
+/*\r
+ * Initialises the heap structures before their first use.\r
+ */\r
+static void prvHeapInit( void );\r
+\r
+/* Allocate the memory for the heap. */\r
+static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];\r
+\r
+/* Define the linked list structure.  This is used to link free blocks in order\r
+of their size. */\r
+typedef struct A_BLOCK_LINK\r
+{\r
+       struct A_BLOCK_LINK *pxNextFreeBlock;   /*<< The next free block in the list. */\r
+       size_t xBlockSize;                                              /*<< The size of the free block. */\r
+} BlockLink_t;\r
+\r
+\r
+static const uint16_t heapSTRUCT_SIZE  = ( ( sizeof ( BlockLink_t ) + ( portBYTE_ALIGNMENT - 1 ) ) & ~portBYTE_ALIGNMENT_MASK );\r
+#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( heapSTRUCT_SIZE * 2 ) )\r
+\r
+/* Create a couple of list links to mark the start and end of the list. */\r
+static BlockLink_t xStart, xEnd;\r
+\r
+/* Keeps track of the number of free bytes remaining, but says nothing about\r
+fragmentation. */\r
+static size_t xFreeBytesRemaining = configADJUSTED_HEAP_SIZE;\r
+\r
+/* STATIC FUNCTIONS ARE DEFINED AS MACROS TO MINIMIZE THE FUNCTION CALL DEPTH. */\r
+\r
+/*\r
+ * Insert a block into the list of free blocks - which is ordered by size of\r
+ * the block.  Small blocks at the start of the list and large blocks at the end\r
+ * of the list.\r
+ */\r
+#define prvInsertBlockIntoFreeList( pxBlockToInsert )                                                          \\r
+{                                                                                                                                                                      \\r
+BlockLink_t *pxIterator;                                                                                                                               \\r
+size_t xBlockSize;                                                                                                                                     \\r
+                                                                                                                                                                       \\r
+       xBlockSize = pxBlockToInsert->xBlockSize;                                                                               \\r
+                                                                                                                                                                       \\r
+       /* Iterate through the list until a block is found that has a larger size */    \\r
+       /* than the block we are inserting. */                                                                                  \\r
+       for( pxIterator = &xStart; pxIterator->pxNextFreeBlock->xBlockSize < xBlockSize; pxIterator = pxIterator->pxNextFreeBlock )     \\r
+       {                                                                                                                                                               \\r
+               /* There is nothing to do here - just iterate to the correct position. */       \\r
+       }                                                                                                                                                               \\r
+                                                                                                                                                                       \\r
+       /* Update the list to include the block being inserted in the correct */                \\r
+       /* position. */                                                                                                                                 \\r
+       pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock;                                 \\r
+       pxIterator->pxNextFreeBlock = pxBlockToInsert;                                                                  \\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void *pvPortMalloc( size_t xWantedSize )\r
+{\r
+BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;\r
+static BaseType_t xHeapHasBeenInitialised = pdFALSE;\r
+void *pvReturn = NULL;\r
+\r
+       vTaskSuspendAll();\r
+       {\r
+               /* If this is the first call to malloc then the heap will require\r
+               initialisation to setup the list of free blocks. */\r
+               if( xHeapHasBeenInitialised == pdFALSE )\r
+               {\r
+                       prvHeapInit();\r
+                       xHeapHasBeenInitialised = pdTRUE;\r
+               }\r
+\r
+               /* The wanted size is increased so it can contain a BlockLink_t\r
+               structure in addition to the requested amount of bytes. */\r
+               if( xWantedSize > 0 )\r
+               {\r
+                       xWantedSize += heapSTRUCT_SIZE;\r
+\r
+                       /* Ensure that blocks are always aligned to the required number of bytes. */\r
+                       if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0 )\r
+                       {\r
+                               /* Byte alignment required. */\r
+                               xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );\r
+                       }\r
+               }\r
+\r
+               if( ( xWantedSize > 0 ) && ( xWantedSize < configADJUSTED_HEAP_SIZE ) )\r
+               {\r
+                       /* Blocks are stored in byte order - traverse the list from the start\r
+                       (smallest) block until one of adequate size is found. */\r
+                       pxPreviousBlock = &xStart;\r
+                       pxBlock = xStart.pxNextFreeBlock;\r
+                       while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) )\r
+                       {\r
+                               pxPreviousBlock = pxBlock;\r
+                               pxBlock = pxBlock->pxNextFreeBlock;\r
+                       }\r
+\r
+                       /* If we found the end marker then a block of adequate size was not found. */\r
+                       if( pxBlock != &xEnd )\r
+                       {\r
+                               /* Return the memory space - jumping over the BlockLink_t structure\r
+                               at its start. */\r
+                               pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + heapSTRUCT_SIZE );\r
+\r
+                               /* This block is being returned for use so must be taken out of the\r
+                               list of free blocks. */\r
+                               pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;\r
+\r
+                               /* If the block is larger than required it can be split into two. */\r
+                               if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )\r
+                               {\r
+                                       /* This block is to be split into two.  Create a new block\r
+                                       following the number of bytes requested. The void cast is\r
+                                       used to prevent byte alignment warnings from the compiler. */\r
+                                       pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );\r
+\r
+                                       /* Calculate the sizes of two blocks split from the single\r
+                                       block. */\r
+                                       pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;\r
+                                       pxBlock->xBlockSize = xWantedSize;\r
+\r
+                                       /* Insert the new block into the list of free blocks. */\r
+                                       prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );\r
+                               }\r
+\r
+                               xFreeBytesRemaining -= pxBlock->xBlockSize;\r
+                       }\r
+               }\r
+\r
+               traceMALLOC( pvReturn, xWantedSize );\r
+       }\r
+       ( void ) xTaskResumeAll();\r
+\r
+       #if( configUSE_MALLOC_FAILED_HOOK == 1 )\r
+       {\r
+               if( pvReturn == NULL )\r
+               {\r
+                       extern void vApplicationMallocFailedHook( void );\r
+                       vApplicationMallocFailedHook();\r
+               }\r
+       }\r
+       #endif\r
+\r
+       return pvReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortFree( void *pv )\r
+{\r
+uint8_t *puc = ( uint8_t * ) pv;\r
+BlockLink_t *pxLink;\r
+\r
+       if( pv != NULL )\r
+       {\r
+               /* The memory being freed will have an BlockLink_t structure immediately\r
+               before it. */\r
+               puc -= heapSTRUCT_SIZE;\r
+\r
+               /* This unexpected casting is to keep some compilers from issuing\r
+               byte alignment warnings. */\r
+               pxLink = ( void * ) puc;\r
+\r
+               vTaskSuspendAll();\r
+               {\r
+                       /* Add this block to the list of free blocks. */\r
+                       prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) );\r
+                       xFreeBytesRemaining += pxLink->xBlockSize;\r
+                       traceFREE( pv, pxLink->xBlockSize );\r
+               }\r
+               ( void ) xTaskResumeAll();\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+size_t xPortGetFreeHeapSize( void )\r
+{\r
+       return xFreeBytesRemaining;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortInitialiseBlocks( void )\r
+{\r
+       /* This just exists to keep the linker quiet. */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvHeapInit( void )\r
+{\r
+BlockLink_t *pxFirstFreeBlock;\r
+uint8_t *pucAlignedHeap;\r
+\r
+       /* Ensure the heap starts on a correctly aligned boundary. */\r
+       pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );\r
+\r
+       /* xStart is used to hold a pointer to the first item in the list of free\r
+       blocks.  The void cast is used to prevent compiler warnings. */\r
+       xStart.pxNextFreeBlock = ( void * ) pucAlignedHeap;\r
+       xStart.xBlockSize = ( size_t ) 0;\r
+\r
+       /* xEnd is used to mark the end of the list of free blocks. */\r
+       xEnd.xBlockSize = configADJUSTED_HEAP_SIZE;\r
+       xEnd.pxNextFreeBlock = NULL;\r
+\r
+       /* To start with there is a single free block that is sized to take up the\r
+       entire heap space. */\r
+       pxFirstFreeBlock = ( void * ) pucAlignedHeap;\r
+       pxFirstFreeBlock->xBlockSize = configADJUSTED_HEAP_SIZE;\r
+       pxFirstFreeBlock->pxNextFreeBlock = &xEnd;\r
+}\r
+/*-----------------------------------------------------------*/\r
diff --git a/os/8.2.2/src/os/heap_3.c b/os/8.2.2/src/os/heap_3.c
new file mode 100644 (file)
index 0000000..0fa88f5
--- /dev/null
@@ -0,0 +1,135 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+\r
+/*\r
+ * Implementation of pvPortMalloc() and vPortFree() that relies on the\r
+ * compilers own malloc() and free() implementations.\r
+ *\r
+ * This file can only be used if the linker is configured to to generate\r
+ * a heap memory area.\r
+ *\r
+ * See heap_1.c, heap_2.c and heap_4.c for alternative implementations, and the\r
+ * memory management pages of http://www.FreeRTOS.org for more information.\r
+ */\r
+\r
+#include <stdlib.h>\r
+\r
+/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining\r
+all the API functions to use the MPU wrappers.  That should only be done when\r
+task.h is included from an application file. */\r
+#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void *pvPortMalloc( size_t xWantedSize )\r
+{\r
+void *pvReturn;\r
+\r
+       vTaskSuspendAll();\r
+       {\r
+               pvReturn = malloc( xWantedSize );\r
+               traceMALLOC( pvReturn, xWantedSize );\r
+       }\r
+       ( void ) xTaskResumeAll();\r
+\r
+       #if( configUSE_MALLOC_FAILED_HOOK == 1 )\r
+       {\r
+               if( pvReturn == NULL )\r
+               {\r
+                       extern void vApplicationMallocFailedHook( void );\r
+                       vApplicationMallocFailedHook();\r
+               }\r
+       }\r
+       #endif\r
+\r
+       return pvReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortFree( void *pv )\r
+{\r
+       if( pv )\r
+       {\r
+               vTaskSuspendAll();\r
+               {\r
+                       free( pv );\r
+                       traceFREE( pv, 0 );\r
+               }\r
+               ( void ) xTaskResumeAll();\r
+       }\r
+}\r
+\r
+\r
+\r
diff --git a/os/8.2.2/src/os/heap_4.c b/os/8.2.2/src/os/heap_4.c
new file mode 100644 (file)
index 0000000..ce482d0
--- /dev/null
@@ -0,0 +1,474 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+/*\r
+ * A sample implementation of pvPortMalloc() and vPortFree() that combines\r
+ * (coalescences) adjacent memory blocks as they are freed, and in so doing\r
+ * limits memory fragmentation.\r
+ *\r
+ * See heap_1.c, heap_2.c and heap_3.c for alternative implementations, and the\r
+ * memory management pages of http://www.FreeRTOS.org for more information.\r
+ */\r
+#include <stdlib.h>\r
+\r
+/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining\r
+all the API functions to use the MPU wrappers.  That should only be done when\r
+task.h is included from an application file. */\r
+#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+/* Block sizes must not get too small. */\r
+#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) )\r
+\r
+/* Assumes 8bit bytes! */\r
+#define heapBITS_PER_BYTE              ( ( size_t ) 8 )\r
+\r
+/* Allocate the memory for the heap. */\r
+#if( configAPPLICATION_ALLOCATED_HEAP == 1 )\r
+       /* The application writer has already defined the array used for the RTOS\r
+       heap - probably so it can be placed in a special segment or address. */\r
+       extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];\r
+#else\r
+       static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];\r
+#endif /* configAPPLICATION_ALLOCATED_HEAP */\r
+\r
+/* Define the linked list structure.  This is used to link free blocks in order\r
+of their memory address. */\r
+typedef struct A_BLOCK_LINK\r
+{\r
+       struct A_BLOCK_LINK *pxNextFreeBlock;   /*<< The next free block in the list. */\r
+       size_t xBlockSize;                                              /*<< The size of the free block. */\r
+} BlockLink_t;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Inserts a block of memory that is being freed into the correct position in\r
+ * the list of free memory blocks.  The block being freed will be merged with\r
+ * the block in front it and/or the block behind it if the memory blocks are\r
+ * adjacent to each other.\r
+ */\r
+static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert );\r
+\r
+/*\r
+ * Called automatically to setup the required heap structures the first time\r
+ * pvPortMalloc() is called.\r
+ */\r
+static void prvHeapInit( void );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* The size of the structure placed at the beginning of each allocated memory\r
+block must by correctly byte aligned. */\r
+static const size_t xHeapStructSize    = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK );\r
+\r
+/* Create a couple of list links to mark the start and end of the list. */\r
+static BlockLink_t xStart, *pxEnd = NULL;\r
+\r
+/* Keeps track of the number of free bytes remaining, but says nothing about\r
+fragmentation. */\r
+static size_t xFreeBytesRemaining = 0U;\r
+static size_t xMinimumEverFreeBytesRemaining = 0U;\r
+\r
+/* Gets set to the top bit of an size_t type.  When this bit in the xBlockSize\r
+member of an BlockLink_t structure is set then the block belongs to the\r
+application.  When the bit is free the block is still part of the free heap\r
+space. */\r
+static size_t xBlockAllocatedBit = 0;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void *pvPortMalloc( size_t xWantedSize )\r
+{\r
+BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;\r
+void *pvReturn = NULL;\r
+\r
+       vTaskSuspendAll();\r
+       {\r
+               /* If this is the first call to malloc then the heap will require\r
+               initialisation to setup the list of free blocks. */\r
+               if( pxEnd == NULL )\r
+               {\r
+                       prvHeapInit();\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               /* Check the requested block size is not so large that the top bit is\r
+               set.  The top bit of the block size member of the BlockLink_t structure\r
+               is used to determine who owns the block - the application or the\r
+               kernel, so it must be free. */\r
+               if( ( xWantedSize & xBlockAllocatedBit ) == 0 )\r
+               {\r
+                       /* The wanted size is increased so it can contain a BlockLink_t\r
+                       structure in addition to the requested amount of bytes. */\r
+                       if( xWantedSize > 0 )\r
+                       {\r
+                               xWantedSize += xHeapStructSize;\r
+\r
+                               /* Ensure that blocks are always aligned to the required number\r
+                               of bytes. */\r
+                               if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 )\r
+                               {\r
+                                       /* Byte alignment required. */\r
+                                       xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );\r
+                                       configASSERT( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) == 0 );\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) )\r
+                       {\r
+                               /* Traverse the list from the start     (lowest address) block until\r
+                               one     of adequate size is found. */\r
+                               pxPreviousBlock = &xStart;\r
+                               pxBlock = xStart.pxNextFreeBlock;\r
+                               while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) )\r
+                               {\r
+                                       pxPreviousBlock = pxBlock;\r
+                                       pxBlock = pxBlock->pxNextFreeBlock;\r
+                               }\r
+\r
+                               /* If the end marker was reached then a block of adequate size\r
+                               was     not found. */\r
+                               if( pxBlock != pxEnd )\r
+                               {\r
+                                       /* Return the memory space pointed to - jumping over the\r
+                                       BlockLink_t structure at its start. */\r
+                                       pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize );\r
+\r
+                                       /* This block is being returned for use so must be taken out\r
+                                       of the list of free blocks. */\r
+                                       pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;\r
+\r
+                                       /* If the block is larger than required it can be split into\r
+                                       two. */\r
+                                       if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )\r
+                                       {\r
+                                               /* This block is to be split into two.  Create a new\r
+                                               block following the number of bytes requested. The void\r
+                                               cast is used to prevent byte alignment warnings from the\r
+                                               compiler. */\r
+                                               pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );\r
+                                               configASSERT( ( ( ( size_t ) pxNewBlockLink ) & portBYTE_ALIGNMENT_MASK ) == 0 );\r
+\r
+                                               /* Calculate the sizes of two blocks split from the\r
+                                               single block. */\r
+                                               pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;\r
+                                               pxBlock->xBlockSize = xWantedSize;\r
+\r
+                                               /* Insert the new block into the list of free blocks. */\r
+                                               prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+\r
+                                       xFreeBytesRemaining -= pxBlock->xBlockSize;\r
+\r
+                                       if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining )\r
+                                       {\r
+                                               xMinimumEverFreeBytesRemaining = xFreeBytesRemaining;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+\r
+                                       /* The block is being returned - it is allocated and owned\r
+                                       by the application and has no "next" block. */\r
+                                       pxBlock->xBlockSize |= xBlockAllocatedBit;\r
+                                       pxBlock->pxNextFreeBlock = NULL;\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               traceMALLOC( pvReturn, xWantedSize );\r
+       }\r
+       ( void ) xTaskResumeAll();\r
+\r
+       #if( configUSE_MALLOC_FAILED_HOOK == 1 )\r
+       {\r
+               if( pvReturn == NULL )\r
+               {\r
+                       extern void vApplicationMallocFailedHook( void );\r
+                       vApplicationMallocFailedHook();\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+       #endif\r
+\r
+       configASSERT( ( ( ( uint32_t ) pvReturn ) & portBYTE_ALIGNMENT_MASK ) == 0 );\r
+       return pvReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortFree( void *pv )\r
+{\r
+uint8_t *puc = ( uint8_t * ) pv;\r
+BlockLink_t *pxLink;\r
+\r
+       if( pv != NULL )\r
+       {\r
+               /* The memory being freed will have an BlockLink_t structure immediately\r
+               before it. */\r
+               puc -= xHeapStructSize;\r
+\r
+               /* This casting is to keep the compiler from issuing warnings. */\r
+               pxLink = ( void * ) puc;\r
+\r
+               /* Check the block is actually allocated. */\r
+               configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 );\r
+               configASSERT( pxLink->pxNextFreeBlock == NULL );\r
+\r
+               if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 )\r
+               {\r
+                       if( pxLink->pxNextFreeBlock == NULL )\r
+                       {\r
+                               /* The block is being returned to the heap - it is no longer\r
+                               allocated. */\r
+                               pxLink->xBlockSize &= ~xBlockAllocatedBit;\r
+\r
+                               vTaskSuspendAll();\r
+                               {\r
+                                       /* Add this block to the list of free blocks. */\r
+                                       xFreeBytesRemaining += pxLink->xBlockSize;\r
+                                       traceFREE( pv, pxLink->xBlockSize );\r
+                                       prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) );\r
+                               }\r
+                               ( void ) xTaskResumeAll();\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+size_t xPortGetFreeHeapSize( void )\r
+{\r
+       return xFreeBytesRemaining;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+size_t xPortGetMinimumEverFreeHeapSize( void )\r
+{\r
+       return xMinimumEverFreeBytesRemaining;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortInitialiseBlocks( void )\r
+{\r
+       /* This just exists to keep the linker quiet. */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvHeapInit( void )\r
+{\r
+BlockLink_t *pxFirstFreeBlock;\r
+uint8_t *pucAlignedHeap;\r
+size_t uxAddress;\r
+size_t xTotalHeapSize = configTOTAL_HEAP_SIZE;\r
+\r
+       /* Ensure the heap starts on a correctly aligned boundary. */\r
+       uxAddress = ( size_t ) ucHeap;\r
+\r
+       if( ( uxAddress & portBYTE_ALIGNMENT_MASK ) != 0 )\r
+       {\r
+               uxAddress += ( portBYTE_ALIGNMENT - 1 );\r
+               uxAddress &= ~( ( size_t ) portBYTE_ALIGNMENT_MASK );\r
+               xTotalHeapSize -= uxAddress - ( size_t ) ucHeap;\r
+       }\r
+\r
+       pucAlignedHeap = ( uint8_t * ) uxAddress;\r
+\r
+       /* xStart is used to hold a pointer to the first item in the list of free\r
+       blocks.  The void cast is used to prevent compiler warnings. */\r
+       xStart.pxNextFreeBlock = ( void * ) pucAlignedHeap;\r
+       xStart.xBlockSize = ( size_t ) 0;\r
+\r
+       /* pxEnd is used to mark the end of the list of free blocks and is inserted\r
+       at the end of the heap space. */\r
+       uxAddress = ( ( size_t ) pucAlignedHeap ) + xTotalHeapSize;\r
+       uxAddress -= xHeapStructSize;\r
+       uxAddress &= ~( ( size_t ) portBYTE_ALIGNMENT_MASK );\r
+       pxEnd = ( void * ) uxAddress;\r
+       pxEnd->xBlockSize = 0;\r
+       pxEnd->pxNextFreeBlock = NULL;\r
+\r
+       /* To start with there is a single free block that is sized to take up the\r
+       entire heap space, minus the space taken by pxEnd. */\r
+       pxFirstFreeBlock = ( void * ) pucAlignedHeap;\r
+       pxFirstFreeBlock->xBlockSize = uxAddress - ( size_t ) pxFirstFreeBlock;\r
+       pxFirstFreeBlock->pxNextFreeBlock = pxEnd;\r
+\r
+       /* Only one block exists - and it covers the entire usable heap space. */\r
+       xMinimumEverFreeBytesRemaining = pxFirstFreeBlock->xBlockSize;\r
+       xFreeBytesRemaining = pxFirstFreeBlock->xBlockSize;\r
+\r
+       /* Work out the position of the top bit in a size_t variable. */\r
+       xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert )\r
+{\r
+BlockLink_t *pxIterator;\r
+uint8_t *puc;\r
+\r
+       /* Iterate through the list until a block is found that has a higher address\r
+       than the block being inserted. */\r
+       for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock )\r
+       {\r
+               /* Nothing to do here, just iterate to the right position. */\r
+       }\r
+\r
+       /* Do the block being inserted, and the block it is being inserted after\r
+       make a contiguous block of memory? */\r
+       puc = ( uint8_t * ) pxIterator;\r
+       if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert )\r
+       {\r
+               pxIterator->xBlockSize += pxBlockToInsert->xBlockSize;\r
+               pxBlockToInsert = pxIterator;\r
+       }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
+       }\r
+\r
+       /* Do the block being inserted, and the block it is being inserted before\r
+       make a contiguous block of memory? */\r
+       puc = ( uint8_t * ) pxBlockToInsert;\r
+       if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock )\r
+       {\r
+               if( pxIterator->pxNextFreeBlock != pxEnd )\r
+               {\r
+                       /* Form one big block from the two blocks. */\r
+                       pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize;\r
+                       pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock;\r
+               }\r
+               else\r
+               {\r
+                       pxBlockToInsert->pxNextFreeBlock = pxEnd;\r
+               }\r
+       }\r
+       else\r
+       {\r
+               pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock;\r
+       }\r
+\r
+       /* If the block being inserted plugged a gab, so was merged with the block\r
+       before and the block after, then it's pxNextFreeBlock pointer will have\r
+       already been set, and should not be set here as that would make it point\r
+       to itself. */\r
+       if( pxIterator != pxBlockToInsert )\r
+       {\r
+               pxIterator->pxNextFreeBlock = pxBlockToInsert;\r
+       }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
+       }\r
+}\r
+\r
diff --git a/os/8.2.2/src/os/heap_5.c b/os/8.2.2/src/os/heap_5.c
new file mode 100644 (file)
index 0000000..666ec65
--- /dev/null
@@ -0,0 +1,523 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+/*\r
+ * A sample implementation of pvPortMalloc() that allows the heap to be defined\r
+ * across multiple non-contigous blocks and combines (coalescences) adjacent\r
+ * memory blocks as they are freed.\r
+ *\r
+ * See heap_1.c, heap_2.c, heap_3.c and heap_4.c for alternative\r
+ * implementations, and the memory management pages of http://www.FreeRTOS.org\r
+ * for more information.\r
+ *\r
+ * Usage notes:\r
+ *\r
+ * vPortDefineHeapRegions() ***must*** be called before pvPortMalloc().\r
+ * pvPortMalloc() will be called if any task objects (tasks, queues, event\r
+ * groups, etc.) are created, therefore vPortDefineHeapRegions() ***must*** be\r
+ * called before any other objects are defined.\r
+ *\r
+ * vPortDefineHeapRegions() takes a single parameter.  The parameter is an array\r
+ * of HeapRegion_t structures.  HeapRegion_t is defined in portable.h as\r
+ *\r
+ * typedef struct HeapRegion\r
+ * {\r
+ *     uint8_t *pucStartAddress; << Start address of a block of memory that will be part of the heap.\r
+ *     size_t xSizeInBytes;      << Size of the block of memory.\r
+ * } HeapRegion_t;\r
+ *\r
+ * The array is terminated using a NULL zero sized region definition, and the\r
+ * memory regions defined in the array ***must*** appear in address order from\r
+ * low address to high address.  So the following is a valid example of how\r
+ * to use the function.\r
+ *\r
+ * HeapRegion_t xHeapRegions[] =\r
+ * {\r
+ *     { ( uint8_t * ) 0x80000000UL, 0x10000 }, << Defines a block of 0x10000 bytes starting at address 0x80000000\r
+ *     { ( uint8_t * ) 0x90000000UL, 0xa0000 }, << Defines a block of 0xa0000 bytes starting at address of 0x90000000\r
+ *     { NULL, 0 }                << Terminates the array.\r
+ * };\r
+ *\r
+ * vPortDefineHeapRegions( xHeapRegions ); << Pass the array into vPortDefineHeapRegions().\r
+ *\r
+ * Note 0x80000000 is the lower address so appears in the array first.\r
+ *\r
+ */\r
+#include <stdlib.h>\r
+\r
+/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining\r
+all the API functions to use the MPU wrappers.  That should only be done when\r
+task.h is included from an application file. */\r
+#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+/* Block sizes must not get too small. */\r
+#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) )\r
+\r
+/* Assumes 8bit bytes! */\r
+#define heapBITS_PER_BYTE              ( ( size_t ) 8 )\r
+\r
+/* Define the linked list structure.  This is used to link free blocks in order\r
+of their memory address. */\r
+typedef struct A_BLOCK_LINK\r
+{\r
+       struct A_BLOCK_LINK *pxNextFreeBlock;   /*<< The next free block in the list. */\r
+       size_t xBlockSize;                                              /*<< The size of the free block. */\r
+} BlockLink_t;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Inserts a block of memory that is being freed into the correct position in\r
+ * the list of free memory blocks.  The block being freed will be merged with\r
+ * the block in front it and/or the block behind it if the memory blocks are\r
+ * adjacent to each other.\r
+ */\r
+static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* The size of the structure placed at the beginning of each allocated memory\r
+block must by correctly byte aligned. */\r
+static const size_t xHeapStructSize    = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK );\r
+\r
+/* Create a couple of list links to mark the start and end of the list. */\r
+static BlockLink_t xStart, *pxEnd = NULL;\r
+\r
+/* Keeps track of the number of free bytes remaining, but says nothing about\r
+fragmentation. */\r
+static size_t xFreeBytesRemaining = 0U;\r
+static size_t xMinimumEverFreeBytesRemaining = 0U;\r
+\r
+/* Gets set to the top bit of an size_t type.  When this bit in the xBlockSize\r
+member of an BlockLink_t structure is set then the block belongs to the\r
+application.  When the bit is free the block is still part of the free heap\r
+space. */\r
+static size_t xBlockAllocatedBit = 0;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void *pvPortMalloc( size_t xWantedSize )\r
+{\r
+BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;\r
+void *pvReturn = NULL;\r
+\r
+       /* The heap must be initialised before the first call to\r
+       prvPortMalloc(). */\r
+       configASSERT( pxEnd );\r
+\r
+       vTaskSuspendAll();\r
+       {\r
+               /* Check the requested block size is not so large that the top bit is\r
+               set.  The top bit of the block size member of the BlockLink_t structure\r
+               is used to determine who owns the block - the application or the\r
+               kernel, so it must be free. */\r
+               if( ( xWantedSize & xBlockAllocatedBit ) == 0 )\r
+               {\r
+                       /* The wanted size is increased so it can contain a BlockLink_t\r
+                       structure in addition to the requested amount of bytes. */\r
+                       if( xWantedSize > 0 )\r
+                       {\r
+                               xWantedSize += xHeapStructSize;\r
+\r
+                               /* Ensure that blocks are always aligned to the required number\r
+                               of bytes. */\r
+                               if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 )\r
+                               {\r
+                                       /* Byte alignment required. */\r
+                                       xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) )\r
+                       {\r
+                               /* Traverse the list from the start     (lowest address) block until\r
+                               one     of adequate size is found. */\r
+                               pxPreviousBlock = &xStart;\r
+                               pxBlock = xStart.pxNextFreeBlock;\r
+                               while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) )\r
+                               {\r
+                                       pxPreviousBlock = pxBlock;\r
+                                       pxBlock = pxBlock->pxNextFreeBlock;\r
+                               }\r
+\r
+                               /* If the end marker was reached then a block of adequate size\r
+                               was     not found. */\r
+                               if( pxBlock != pxEnd )\r
+                               {\r
+                                       /* Return the memory space pointed to - jumping over the\r
+                                       BlockLink_t structure at its start. */\r
+                                       pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize );\r
+\r
+                                       /* This block is being returned for use so must be taken out\r
+                                       of the list of free blocks. */\r
+                                       pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;\r
+\r
+                                       /* If the block is larger than required it can be split into\r
+                                       two. */\r
+                                       if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )\r
+                                       {\r
+                                               /* This block is to be split into two.  Create a new\r
+                                               block following the number of bytes requested. The void\r
+                                               cast is used to prevent byte alignment warnings from the\r
+                                               compiler. */\r
+                                               pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );\r
+\r
+                                               /* Calculate the sizes of two blocks split from the\r
+                                               single block. */\r
+                                               pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;\r
+                                               pxBlock->xBlockSize = xWantedSize;\r
+\r
+                                               /* Insert the new block into the list of free blocks. */\r
+                                               prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+\r
+                                       xFreeBytesRemaining -= pxBlock->xBlockSize;\r
+\r
+                                       if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining )\r
+                                       {\r
+                                               xMinimumEverFreeBytesRemaining = xFreeBytesRemaining;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+\r
+                                       /* The block is being returned - it is allocated and owned\r
+                                       by the application and has no "next" block. */\r
+                                       pxBlock->xBlockSize |= xBlockAllocatedBit;\r
+                                       pxBlock->pxNextFreeBlock = NULL;\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               traceMALLOC( pvReturn, xWantedSize );\r
+       }\r
+       ( void ) xTaskResumeAll();\r
+\r
+       #if( configUSE_MALLOC_FAILED_HOOK == 1 )\r
+       {\r
+               if( pvReturn == NULL )\r
+               {\r
+                       extern void vApplicationMallocFailedHook( void );\r
+                       vApplicationMallocFailedHook();\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+       #endif\r
+\r
+       return pvReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortFree( void *pv )\r
+{\r
+uint8_t *puc = ( uint8_t * ) pv;\r
+BlockLink_t *pxLink;\r
+\r
+       if( pv != NULL )\r
+       {\r
+               /* The memory being freed will have an BlockLink_t structure immediately\r
+               before it. */\r
+               puc -= xHeapStructSize;\r
+\r
+               /* This casting is to keep the compiler from issuing warnings. */\r
+               pxLink = ( void * ) puc;\r
+\r
+               /* Check the block is actually allocated. */\r
+               configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 );\r
+               configASSERT( pxLink->pxNextFreeBlock == NULL );\r
+\r
+               if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 )\r
+               {\r
+                       if( pxLink->pxNextFreeBlock == NULL )\r
+                       {\r
+                               /* The block is being returned to the heap - it is no longer\r
+                               allocated. */\r
+                               pxLink->xBlockSize &= ~xBlockAllocatedBit;\r
+\r
+                               vTaskSuspendAll();\r
+                               {\r
+                                       /* Add this block to the list of free blocks. */\r
+                                       xFreeBytesRemaining += pxLink->xBlockSize;\r
+                                       traceFREE( pv, pxLink->xBlockSize );\r
+                                       prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) );\r
+                               }\r
+                               ( void ) xTaskResumeAll();\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+size_t xPortGetFreeHeapSize( void )\r
+{\r
+       return xFreeBytesRemaining;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+size_t xPortGetMinimumEverFreeHeapSize( void )\r
+{\r
+       return xMinimumEverFreeBytesRemaining;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert )\r
+{\r
+BlockLink_t *pxIterator;\r
+uint8_t *puc;\r
+\r
+       /* Iterate through the list until a block is found that has a higher address\r
+       than the block being inserted. */\r
+       for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock )\r
+       {\r
+               /* Nothing to do here, just iterate to the right position. */\r
+       }\r
+\r
+       /* Do the block being inserted, and the block it is being inserted after\r
+       make a contiguous block of memory? */\r
+       puc = ( uint8_t * ) pxIterator;\r
+       if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert )\r
+       {\r
+               pxIterator->xBlockSize += pxBlockToInsert->xBlockSize;\r
+               pxBlockToInsert = pxIterator;\r
+       }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
+       }\r
+\r
+       /* Do the block being inserted, and the block it is being inserted before\r
+       make a contiguous block of memory? */\r
+       puc = ( uint8_t * ) pxBlockToInsert;\r
+       if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock )\r
+       {\r
+               if( pxIterator->pxNextFreeBlock != pxEnd )\r
+               {\r
+                       /* Form one big block from the two blocks. */\r
+                       pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize;\r
+                       pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock;\r
+               }\r
+               else\r
+               {\r
+                       pxBlockToInsert->pxNextFreeBlock = pxEnd;\r
+               }\r
+       }\r
+       else\r
+       {\r
+               pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock;\r
+       }\r
+\r
+       /* If the block being inserted plugged a gab, so was merged with the block\r
+       before and the block after, then it's pxNextFreeBlock pointer will have\r
+       already been set, and should not be set here as that would make it point\r
+       to itself. */\r
+       if( pxIterator != pxBlockToInsert )\r
+       {\r
+               pxIterator->pxNextFreeBlock = pxBlockToInsert;\r
+       }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions )\r
+{\r
+BlockLink_t *pxFirstFreeBlockInRegion = NULL, *pxPreviousFreeBlock;\r
+uint8_t *pucAlignedHeap;\r
+size_t xTotalRegionSize, xTotalHeapSize = 0;\r
+BaseType_t xDefinedRegions = 0;\r
+size_t xAddress;\r
+const HeapRegion_t *pxHeapRegion;\r
+\r
+       /* Can only call once! */\r
+       configASSERT( pxEnd == NULL );\r
+\r
+       pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] );\r
+\r
+       while( pxHeapRegion->xSizeInBytes > 0 )\r
+       {\r
+               xTotalRegionSize = pxHeapRegion->xSizeInBytes;\r
+\r
+               /* Ensure the heap region starts on a correctly aligned boundary. */\r
+               xAddress = ( size_t ) pxHeapRegion->pucStartAddress;\r
+               if( ( xAddress & portBYTE_ALIGNMENT_MASK ) != 0 )\r
+               {\r
+                       xAddress += ( portBYTE_ALIGNMENT - 1 );\r
+                       xAddress &= ~portBYTE_ALIGNMENT_MASK;\r
+\r
+                       /* Adjust the size for the bytes lost to alignment. */\r
+                       xTotalRegionSize -= xAddress - ( size_t ) pxHeapRegion->pucStartAddress;\r
+               }\r
+\r
+               pucAlignedHeap = ( uint8_t * ) xAddress;\r
+\r
+               /* Set xStart if it has not already been set. */\r
+               if( xDefinedRegions == 0 )\r
+               {\r
+                       /* xStart is used to hold a pointer to the first item in the list of\r
+                       free blocks.  The void cast is used to prevent compiler warnings. */\r
+                       xStart.pxNextFreeBlock = ( BlockLink_t * ) pucAlignedHeap;\r
+                       xStart.xBlockSize = ( size_t ) 0;\r
+               }\r
+               else\r
+               {\r
+                       /* Should only get here if one region has already been added to the\r
+                       heap. */\r
+                       configASSERT( pxEnd != NULL );\r
+\r
+                       /* Check blocks are passed in with increasing start addresses. */\r
+                       configASSERT( xAddress > ( size_t ) pxEnd );\r
+               }\r
+\r
+               /* Remember the location of the end marker in the previous region, if\r
+               any. */\r
+               pxPreviousFreeBlock = pxEnd;\r
+\r
+               /* pxEnd is used to mark the end of the list of free blocks and is\r
+               inserted at the end of the region space. */\r
+               xAddress = ( ( size_t ) pucAlignedHeap ) + xTotalRegionSize;\r
+               xAddress -= xHeapStructSize;\r
+               xAddress &= ~portBYTE_ALIGNMENT_MASK;\r
+               pxEnd = ( BlockLink_t * ) xAddress;\r
+               pxEnd->xBlockSize = 0;\r
+               pxEnd->pxNextFreeBlock = NULL;\r
+\r
+               /* To start with there is a single free block in this region that is\r
+               sized to take up the entire heap region minus the space taken by the\r
+               free block structure. */\r
+               pxFirstFreeBlockInRegion = ( BlockLink_t * ) pucAlignedHeap;\r
+               pxFirstFreeBlockInRegion->xBlockSize = xAddress - ( size_t ) pxFirstFreeBlockInRegion;\r
+               pxFirstFreeBlockInRegion->pxNextFreeBlock = pxEnd;\r
+\r
+               /* If this is not the first region that makes up the entire heap space\r
+               then link the previous region to this region. */\r
+               if( pxPreviousFreeBlock != NULL )\r
+               {\r
+                       pxPreviousFreeBlock->pxNextFreeBlock = pxFirstFreeBlockInRegion;\r
+               }\r
+\r
+               xTotalHeapSize += pxFirstFreeBlockInRegion->xBlockSize;\r
+\r
+               /* Move onto the next HeapRegion_t structure. */\r
+               xDefinedRegions++;\r
+               pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] );\r
+       }\r
+\r
+       xMinimumEverFreeBytesRemaining = xTotalHeapSize;\r
+       xFreeBytesRemaining = xTotalHeapSize;\r
+\r
+       /* Check something was actually defined before it is accessed. */\r
+       configASSERT( xTotalHeapSize );\r
+\r
+       /* Work out the position of the top bit in a size_t variable. */\r
+       xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 );\r
+}\r
+\r
diff --git a/os/8.2.2/src/os/list.c b/os/8.2.2/src/os/list.c
new file mode 100644 (file)
index 0000000..44eac9c
--- /dev/null
@@ -0,0 +1,240 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+\r
+#include <stdlib.h>\r
+#include "os/FreeRTOS.h"\r
+#include "os/list.h"\r
+\r
+/*-----------------------------------------------------------\r
+ * PUBLIC LIST API documented in list.h\r
+ *----------------------------------------------------------*/\r
+\r
+void vListInitialise( List_t * const pxList )\r
+{\r
+       /* The list structure contains a list item which is used to mark the\r
+       end of the list.  To initialise the list the list end is inserted\r
+       as the only list entry. */\r
+       pxList->pxIndex = ( ListItem_t * ) &( pxList->xListEnd );                       /*lint !e826 !e740 The mini list structure is used as the list end to save RAM.  This is checked and valid. */\r
+\r
+       /* The list end value is the highest possible value in the list to\r
+       ensure it remains at the end of the list. */\r
+       pxList->xListEnd.xItemValue = portMAX_DELAY;\r
+\r
+       /* The list end next and previous pointers point to itself so we know\r
+       when the list is empty. */\r
+       pxList->xListEnd.pxNext = ( ListItem_t * ) &( pxList->xListEnd );       /*lint !e826 !e740 The mini list structure is used as the list end to save RAM.  This is checked and valid. */\r
+       pxList->xListEnd.pxPrevious = ( ListItem_t * ) &( pxList->xListEnd );/*lint !e826 !e740 The mini list structure is used as the list end to save RAM.  This is checked and valid. */\r
+\r
+       pxList->uxNumberOfItems = ( UBaseType_t ) 0U;\r
+\r
+       /* Write known values into the list if\r
+       configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */\r
+       listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList );\r
+       listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vListInitialiseItem( ListItem_t * const pxItem )\r
+{\r
+       /* Make sure the list item is not recorded as being on a list. */\r
+       pxItem->pvContainer = NULL;\r
+\r
+       /* Write known values into the list item if\r
+       configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */\r
+       listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem );\r
+       listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem )\r
+{\r
+ListItem_t * const pxIndex = pxList->pxIndex;\r
+\r
+       /* Only effective when configASSERT() is also defined, these tests may catch\r
+       the list data structures being overwritten in memory.  They will not catch\r
+       data errors caused by incorrect configuration or use of FreeRTOS. */\r
+       listTEST_LIST_INTEGRITY( pxList );\r
+       listTEST_LIST_ITEM_INTEGRITY( pxNewListItem );\r
+\r
+       /* Insert a new list item into pxList, but rather than sort the list,\r
+       makes the new list item the last item to be removed by a call to\r
+       listGET_OWNER_OF_NEXT_ENTRY(). */\r
+       pxNewListItem->pxNext = pxIndex;\r
+       pxNewListItem->pxPrevious = pxIndex->pxPrevious;\r
+\r
+       /* Only used during decision coverage testing. */\r
+       mtCOVERAGE_TEST_DELAY();\r
+\r
+       pxIndex->pxPrevious->pxNext = pxNewListItem;\r
+       pxIndex->pxPrevious = pxNewListItem;\r
+\r
+       /* Remember which list the item is in. */\r
+       pxNewListItem->pvContainer = ( void * ) pxList;\r
+\r
+       ( pxList->uxNumberOfItems )++;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem )\r
+{\r
+ListItem_t *pxIterator;\r
+const TickType_t xValueOfInsertion = pxNewListItem->xItemValue;\r
+\r
+       /* Only effective when configASSERT() is also defined, these tests may catch\r
+       the list data structures being overwritten in memory.  They will not catch\r
+       data errors caused by incorrect configuration or use of FreeRTOS. */\r
+       listTEST_LIST_INTEGRITY( pxList );\r
+       listTEST_LIST_ITEM_INTEGRITY( pxNewListItem );\r
+\r
+       /* Insert the new list item into the list, sorted in xItemValue order.\r
+\r
+       If the list already contains a list item with the same item value then the\r
+       new list item should be placed after it.  This ensures that TCB's which are\r
+       stored in ready lists (all of which have the same xItemValue value) get a\r
+       share of the CPU.  However, if the xItemValue is the same as the back marker\r
+       the iteration loop below will not end.  Therefore the value is checked\r
+       first, and the algorithm slightly modified if necessary. */\r
+       if( xValueOfInsertion == portMAX_DELAY )\r
+       {\r
+               pxIterator = pxList->xListEnd.pxPrevious;\r
+       }\r
+       else\r
+       {\r
+               /* *** NOTE ***********************************************************\r
+               If you find your application is crashing here then likely causes are\r
+               listed below.  In addition see http://www.freertos.org/FAQHelp.html for\r
+               more tips, and ensure configASSERT() is defined!\r
+               http://www.freertos.org/a00110.html#configASSERT\r
+\r
+                       1) Stack overflow -\r
+                          see http://www.freertos.org/Stacks-and-stack-overflow-checking.html\r
+                       2) Incorrect interrupt priority assignment, especially on Cortex-M\r
+                          parts where numerically high priority values denote low actual\r
+                          interrupt priorities, which can seem counter intuitive.  See\r
+                          http://www.freertos.org/RTOS-Cortex-M3-M4.html and the definition\r
+                          of configMAX_SYSCALL_INTERRUPT_PRIORITY on\r
+                          http://www.freertos.org/a00110.html\r
+                       3) Calling an API function from within a critical section or when\r
+                          the scheduler is suspended, or calling an API function that does\r
+                          not end in "FromISR" from an interrupt.\r
+                       4) Using a queue or semaphore before it has been initialised or\r
+                          before the scheduler has been started (are interrupts firing\r
+                          before vTaskStartScheduler() has been called?).\r
+               **********************************************************************/\r
+\r
+               for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 The mini list structure is used as the list end to save RAM.  This is checked and valid. */\r
+               {\r
+                       /* There is nothing to do here, just iterating to the wanted\r
+                       insertion position. */\r
+               }\r
+       }\r
+\r
+       pxNewListItem->pxNext = pxIterator->pxNext;\r
+       pxNewListItem->pxNext->pxPrevious = pxNewListItem;\r
+       pxNewListItem->pxPrevious = pxIterator;\r
+       pxIterator->pxNext = pxNewListItem;\r
+\r
+       /* Remember which list the item is in.  This allows fast removal of the\r
+       item later. */\r
+       pxNewListItem->pvContainer = ( void * ) pxList;\r
+\r
+       ( pxList->uxNumberOfItems )++;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove )\r
+{\r
+/* The list item knows which list it is in.  Obtain the list from the list\r
+item. */\r
+List_t * const pxList = ( List_t * ) pxItemToRemove->pvContainer;\r
+\r
+       pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious;\r
+       pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext;\r
+\r
+       /* Only used during decision coverage testing. */\r
+       mtCOVERAGE_TEST_DELAY();\r
+\r
+       /* Make sure the index is left pointing to a valid item. */\r
+       if( pxList->pxIndex == pxItemToRemove )\r
+       {\r
+               pxList->pxIndex = pxItemToRemove->pxPrevious;\r
+       }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
+       }\r
+\r
+       pxItemToRemove->pvContainer = NULL;\r
+       ( pxList->uxNumberOfItems )--;\r
+\r
+       return pxList->uxNumberOfItems;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
diff --git a/os/8.2.2/src/os/port.c b/os/8.2.2/src/os/port.c
new file mode 100644 (file)
index 0000000..79b6922
--- /dev/null
@@ -0,0 +1,354 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+/* FreeRTOS includes. */\r
+#include "os/FreeRTOS.h"\r
+#include "os/task.h"\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Count of the critical section nesting depth. */\r
+uint32_t ulCriticalNesting = 9999;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Registers required to configure the RTI. */\r
+#define portRTI_GCTRL_REG              ( * ( ( volatile uint32_t * ) 0xFFFFFC00 ) )\r
+#define portRTI_TBCTRL_REG     ( * ( ( volatile uint32_t * ) 0xFFFFFC04 ) )\r
+#define portRTI_COMPCTRL_REG   ( * ( ( volatile uint32_t * ) 0xFFFFFC0C ) )\r
+#define portRTI_CNT0_FRC0_REG          ( * ( ( volatile uint32_t * ) 0xFFFFFC10 ) )\r
+#define portRTI_CNT0_UC0_REG   ( * ( ( volatile uint32_t * ) 0xFFFFFC14 ) )\r
+#define portRTI_CNT0_CPUC0_REG  ( * ( ( volatile uint32_t * ) 0xFFFFFC18 ) )\r
+#define portRTI_CNT0_COMP0_REG  ( * ( ( volatile uint32_t * ) 0xFFFFFC50 ) )\r
+#define portRTI_CNT0_UDCP0_REG  ( * ( ( volatile uint32_t * ) 0xFFFFFC54 ) )\r
+#define portRTI_SETINTENA_REG          ( * ( ( volatile uint32_t * ) 0xFFFFFC80 ) )\r
+#define portRTI_CLEARINTENA_REG ( * ( ( volatile uint32_t * ) 0xFFFFFC84 ) )\r
+#define portRTI_INTFLAG_REG    ( * ( ( volatile uint32_t * ) 0xFFFFFC88 ) )\r
+\r
+\r
+/* Constants required to set up the initial stack of each task. */\r
+#define portINITIAL_SPSR               ( ( StackType_t ) 0x1F )\r
+#define portINITIAL_FPSCR              ( ( StackType_t ) 0x00 )\r
+#define portINSTRUCTION_SIZE           ( ( StackType_t ) 0x04 )\r
+#define portTHUMB_MODE_BIT             ( ( StackType_t ) 0x20 )\r
+\r
+/* The number of words on the stack frame between the saved Top Of Stack and\r
+R0 (in which the parameters are passed. */\r
+#define portSPACE_BETWEEN_TOS_AND_PARAMETERS   ( 12 )\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* vPortStartFirstSTask() is defined in portASM.asm */\r
+extern void vPortStartFirstTask( void );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Saved as part of the task context.  Set to pdFALSE if the task does not\r
+require an FPU context. */\r
+uint32_t ulTaskHasFPUContext = 0;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+\r
+/*\r
+ * See header file for description.\r
+ */\r
+StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )\r
+{\r
+StackType_t *pxOriginalTOS;\r
+\r
+       pxOriginalTOS = pxTopOfStack;\r
+\r
+       #if __TI_VFP_SUPPORT__\r
+       {\r
+               /* Ensure the stack is correctly aligned on exit. */\r
+               pxTopOfStack--;\r
+       }\r
+       #endif\r
+\r
+       /* Setup the initial stack of the task.  The stack is set exactly as\r
+       expected by the portRESTORE_CONTEXT() macro. */\r
+\r
+       /* First on the stack is the return address - which is the start of the as\r
+       the task has not executed yet.  The offset is added to make the return\r
+       address appear as it would within an IRQ ISR. */\r
+       *pxTopOfStack = ( StackType_t ) pxCode + portINSTRUCTION_SIZE;\r
+       pxTopOfStack--;\r
+\r
+       *pxTopOfStack = ( StackType_t ) 0x00000000;     /* R14 */\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( StackType_t ) pxOriginalTOS; /* Stack used when task starts goes in R13. */\r
+       pxTopOfStack--;\r
+\r
+       #ifdef portPRELOAD_TASK_REGISTERS\r
+       {\r
+               *pxTopOfStack = ( StackType_t ) 0x12121212;     /* R12 */\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( StackType_t ) 0x11111111;     /* R11 */\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( StackType_t ) 0x10101010;     /* R10 */\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( StackType_t ) 0x09090909;     /* R9 */\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( StackType_t ) 0x08080808;     /* R8 */\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( StackType_t ) 0x07070707;     /* R7 */\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( StackType_t ) 0x06060606;     /* R6 */\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( StackType_t ) 0x05050505;     /* R5 */\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( StackType_t ) 0x04040404;     /* R4 */\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( StackType_t ) 0x03030303;     /* R3 */\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( StackType_t ) 0x02020202;     /* R2 */\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( StackType_t ) 0x01010101;     /* R1 */\r
+               pxTopOfStack--;\r
+       }\r
+       #else\r
+       {\r
+               pxTopOfStack -= portSPACE_BETWEEN_TOS_AND_PARAMETERS;\r
+       }\r
+       #endif\r
+\r
+       /* Function parameters are passed in R0. */\r
+       *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */\r
+       pxTopOfStack--;\r
+\r
+       /* Set the status register for system mode, with interrupts enabled. */\r
+       *pxTopOfStack = ( StackType_t ) ( ( _get_CPSR() & ~0xFF ) | portINITIAL_SPSR );\r
+\r
+       if( ( ( uint32_t ) pxCode & 0x01UL ) != 0x00 )\r
+       {\r
+               /* The task will start in thumb mode. */\r
+               *pxTopOfStack |= portTHUMB_MODE_BIT;\r
+       }\r
+\r
+       #ifdef __TI_VFP_SUPPORT__\r
+       {\r
+               pxTopOfStack--;\r
+\r
+               /* The last thing on the stack is the tasks ulUsingFPU value, which by\r
+               default is set to indicate that the stack frame does not include FPU\r
+               registers. */\r
+               *pxTopOfStack = pdFALSE;\r
+       }\r
+       #endif\r
+\r
+       return pxTopOfStack;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvSetupTimerInterrupt(void)\r
+{\r
+       /* Disable timer 0. */\r
+       portRTI_GCTRL_REG &= 0xFFFFFFFEUL;\r
+\r
+       /* Use the internal counter. */\r
+       portRTI_TBCTRL_REG = 0x00000000U;\r
+\r
+       /* COMPSEL0 will use the RTIFRC0 counter. */\r
+       portRTI_COMPCTRL_REG = 0x00000000U;\r
+\r
+       /* Initialise the counter and the prescale counter registers. */\r
+       portRTI_CNT0_UC0_REG =  0x00000000U;\r
+       portRTI_CNT0_FRC0_REG =  0x00000000U;\r
+\r
+       /* Set Prescalar for RTI clock. */\r
+       portRTI_CNT0_CPUC0_REG = 0x00000001U;\r
+       portRTI_CNT0_COMP0_REG = ( configCPU_CLOCK_HZ / 2 ) / configTICK_RATE_HZ;\r
+       portRTI_CNT0_UDCP0_REG = ( configCPU_CLOCK_HZ / 2 ) / configTICK_RATE_HZ;\r
+\r
+       /* Clear interrupts. */\r
+       portRTI_INTFLAG_REG =  0x0007000FU;\r
+       portRTI_CLEARINTENA_REG = 0x00070F0FU;\r
+\r
+       /* Enable the compare 0 interrupt. */\r
+       portRTI_SETINTENA_REG = 0x00000001U;\r
+       portRTI_GCTRL_REG |= 0x00000001U;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * See header file for description.\r
+ */\r
+BaseType_t xPortStartScheduler(void)\r
+{\r
+       /* Start the timer that generates the tick ISR. */\r
+       prvSetupTimerInterrupt();\r
+\r
+       /* Reset the critical section nesting count read to execute the first task. */\r
+       ulCriticalNesting = 0;\r
+\r
+       /* Start the first task.  This is done from portASM.asm as ARM mode must be\r
+       used. */\r
+       vPortStartFirstTask();\r
+\r
+       /* Should not get here! */\r
+       return pdFAIL;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * See header file for description.\r
+ */\r
+void vPortEndScheduler(void)\r
+{\r
+       /* Not implemented in ports where there is nothing to return to.\r
+       Artificially force an assert. */\r
+       configASSERT( ulCriticalNesting == 1000UL );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if configUSE_PREEMPTION == 0\r
+\r
+       /* The cooperative scheduler requires a normal IRQ service routine to\r
+        * simply increment the system tick. */\r
+       __interrupt void vPortNonPreemptiveTick( void )\r
+       {\r
+               /* clear clock interrupt flag */\r
+               portRTI_INTFLAG_REG = 0x00000001;\r
+\r
+               /* Increment the tick count - this may make a delaying task ready\r
+               to run - but a context switch is not performed. */\r
+               xTaskIncrementTick();\r
+       }\r
+\r
+ #else\r
+\r
+       /*\r
+        **************************************************************************\r
+        * The preemptive scheduler ISR is written in assembler and can be found\r
+        * in the portASM.asm file. This will only get used if portUSE_PREEMPTION\r
+        * is set to 1 in portmacro.h\r
+        **************************************************************************\r
+        */\r
+       void vPortPreemptiveTick( void );\r
+\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+\r
+/*\r
+ * Disable interrupts, and keep a count of the nesting depth.\r
+ */\r
+void vPortEnterCritical( void )\r
+{\r
+       /* Disable interrupts as per portDISABLE_INTERRUPTS(); */\r
+       portDISABLE_INTERRUPTS();\r
+\r
+       /* Now interrupts are disabled ulCriticalNesting can be accessed\r
+       directly.  Increment ulCriticalNesting to keep a count of how many times\r
+       portENTER_CRITICAL() has been called. */\r
+       ulCriticalNesting++;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Decrement the critical nesting count, and if it has reached zero, re-enable\r
+ * interrupts.\r
+ */\r
+void vPortExitCritical( void )\r
+{\r
+       if( ulCriticalNesting > 0 )\r
+       {\r
+               /* Decrement the nesting count as we are leaving a critical section. */\r
+               ulCriticalNesting--;\r
+\r
+               /* If the nesting level has reached zero then interrupts should be\r
+               re-enabled. */\r
+               if( ulCriticalNesting == 0 )\r
+               {\r
+                       /* Enable interrupts as per portENABLE_INTERRUPTS(). */\r
+                       portENABLE_INTERRUPTS();\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if __TI_VFP_SUPPORT__\r
+\r
+       void vPortTaskUsesFPU( void )\r
+       {\r
+       extern void vPortInitialiseFPSCR( void );\r
+\r
+               /* A task is registering the fact that it needs an FPU context.  Set the\r
+               FPU flag (saved as part of the task context. */\r
+               ulTaskHasFPUContext = pdTRUE;\r
+\r
+               /* Initialise the floating point status register. */\r
+               vPortInitialiseFPSCR();\r
+       }\r
+\r
+#endif /* __TI_VFP_SUPPORT__ */\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
diff --git a/os/8.2.2/src/os/portASM.asm b/os/8.2.2/src/os/portASM.asm
new file mode 100644 (file)
index 0000000..9e9620b
--- /dev/null
@@ -0,0 +1,256 @@
+;/*\r
+;    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+;    All rights reserved\r
+;\r
+;\r
+;    ***************************************************************************\r
+;     *                                                                       *\r
+;     *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
+;     *    Complete, revised, and edited pdf reference manuals are also       *\r
+;     *    available.                                                         *\r
+;     *                                                                       *\r
+;     *    Purchasing FreeRTOS documentation will not only help you, by       *\r
+;     *    ensuring you get running as quickly as possible and with an        *\r
+;     *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
+;     *    the FreeRTOS project to continue with its mission of providing     *\r
+;     *    professional grade, cross platform, de facto standard solutions    *\r
+;     *    for microcontrollers - completely free of charge!                  *\r
+;     *                                                                       *\r
+;     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
+;     *                                                                       *\r
+;     *    Thank you for using FreeRTOS, and thank you for your support!      *\r
+;     *                                                                       *\r
+;    ***************************************************************************\r
+;\r
+;\r
+;    This file is part of the FreeRTOS distribution.\r
+;\r
+;    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+;    the terms of the GNU General Public License (version 2) as published by the\r
+;    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
+;    >>>NOTE<<< The modification to the GPL is included to allow you to\r
+;    distribute a combined work that includes FreeRTOS without being obliged to\r
+;    provide the source code for proprietary components outside of the FreeRTOS\r
+;    kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
+;    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+;    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
+;    more details. You should have received a copy of the GNU General Public\r
+;    License and the FreeRTOS license exception along with FreeRTOS; if not it\r
+;    can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
+;    by writing to Richard Barry, contact details for whom are available on the\r
+;    FreeRTOS WEB site.\r
+;\r
+;    1 tab == 4 spaces!\r
+;\r
+;    http://www.FreeRTOS.org - Documentation, latest information, license and\r
+;    contact details.\r
+;\r
+;    http://www.SafeRTOS.com - A version that is certified for use in safety\r
+;    critical systems.\r
+;\r
+;    http://www.OpenRTOS.com - Commercial support, development, porting,\r
+;    licensing and training services.\r
+;*/\r
+\r
+        .text\r
+        .arm\r
+        .ref vTaskSwitchContext\r
+        .ref xTaskIncrementTick\r
+        .ref ulTaskHasFPUContext\r
+               .ref pxCurrentTCB\r
+\r
+;/*-----------------------------------------------------------*/\r
+;\r
+; Save Task Context\r
+;\r
+portSAVE_CONTEXT .macro\r
+               DSB\r
+\r
+               ; Push R0 as we are going to use it\r
+               STMDB   SP!, {R0}\r
+\r
+               ; Set R0 to point to the task stack pointer.\r
+               STMDB   SP,{SP}^\r
+               SUB     SP, SP, #4\r
+               LDMIA   SP!,{R0}\r
+\r
+               ; Push the return address onto the stack.\r
+               STMDB   R0!, {LR}\r
+\r
+               ; Now LR has been saved, it can be used instead of R0.\r
+               MOV     LR, R0\r
+\r
+               ; Pop R0 so it can be saved onto the task stack.\r
+               LDMIA   SP!, {R0}\r
+\r
+               ; Push all the system mode registers onto the task stack.\r
+               STMDB   LR,{R0-LR}^\r
+               SUB     LR, LR, #60\r
+\r
+               ; Push the SPSR onto the task stack.\r
+               MRS     R0, SPSR\r
+               STMDB   LR!, {R0}\r
+\r
+    .if (__TI_VFP_SUPPORT__)\r
+               ;Determine if the task maintains an FPU context.\r
+               LDR     R0, ulFPUContextConst\r
+               LDR     R0, [R0]\r
+\r
+               ; Test the flag\r
+               CMP             R0, #0\r
+\r
+               ; If the task is not using a floating point context then skip the\r
+               ; saving of the FPU registers.\r
+               BEQ             $+16\r
+               FSTMDBD LR!, {D0-D15}\r
+               FMRX    R1,  FPSCR\r
+               STMFD   LR!, {R1}\r
+\r
+               ; Save the flag\r
+               STMDB   LR!, {R0}\r
+       .endif\r
+\r
+               ; Store the new top of stack for the task.\r
+               LDR     R0, pxCurrentTCBConst\r
+               LDR     R0, [R0]\r
+               STR     LR, [R0]\r
+\r
+        .endm\r
+\r
+;/*-----------------------------------------------------------*/\r
+;\r
+; Restore Task Context\r
+;\r
+portRESTORE_CONTEXT .macro\r
+               LDR             R0, pxCurrentTCBConst\r
+               LDR             R0, [R0]\r
+               LDR             LR, [R0]\r
+\r
+       .if (__TI_VFP_SUPPORT__)\r
+               ; The floating point context flag is the first thing on the stack.\r
+               LDR             R0, ulFPUContextConst\r
+               LDMFD   LR!, {R1}\r
+               STR             R1, [R0]\r
+\r
+               ; Test the flag\r
+               CMP             R1, #0\r
+\r
+               ; If the task is not using a floating point context then skip the\r
+               ; VFP register loads.\r
+               BEQ             $+16\r
+\r
+               ; Restore the floating point context.\r
+               LDMFD   LR!, {R0}\r
+               FLDMIAD LR!, {D0-D15}\r
+               FMXR    FPSCR, R0\r
+       .endif\r
+\r
+               ; Get the SPSR from the stack.\r
+               LDMFD   LR!, {R0}\r
+               MSR             SPSR_CSXF, R0\r
+\r
+               ; Restore all system mode registers for the task.\r
+               LDMFD   LR, {R0-R14}^\r
+\r
+               ; Restore the return address.\r
+               LDR             LR, [LR, #+60]\r
+\r
+               ; And return - correcting the offset in the LR to obtain the\r
+               ; correct address.\r
+               SUBS    PC, LR, #4\r
+        .endm\r
+\r
+;/*-----------------------------------------------------------*/\r
+; Start the first task by restoring its context.\r
+\r
+        .def vPortStartFirstTask\r
+\r
+vPortStartFirstTask:\r
+        portRESTORE_CONTEXT\r
+\r
+;/*-----------------------------------------------------------*/\r
+; Yield to another task.\r
+\r
+        .def vPortYieldProcessor\r
+\r
+vPortYieldProcessor:\r
+               ; Within an IRQ ISR the link register has an offset from the true return\r
+               ; address.  SWI doesn't do this. Add the offset manually so the ISR\r
+               ; return code can be used.\r
+        ADD     LR, LR, #4\r
+\r
+        ; First save the context of the current task.\r
+        portSAVE_CONTEXT\r
+\r
+        ; Select the next task to execute. */\r
+        BL      vTaskSwitchContext\r
+\r
+        ; Restore the context of the task selected to execute.\r
+        portRESTORE_CONTEXT\r
+\r
+;/*-----------------------------------------------------------*/\r
+; Yield to another task from within the FreeRTOS API\r
+\r
+               .def vPortYeildWithinAPI\r
+\r
+vPortYeildWithinAPI:\r
+               ; Save the context of the current task.\r
+\r
+        portSAVE_CONTEXT\r
+               ; Clear SSI flag.\r
+               MOVW    R0, #0xFFF4\r
+               MOVT    R0, #0xFFFF\r
+               LDR     R0, [R0]\r
+\r
+               ; Select the next task to execute. */\r
+        BL      vTaskSwitchContext\r
+\r
+        ; Restore the context of the task selected to execute.\r
+        portRESTORE_CONTEXT\r
+\r
+;/*-----------------------------------------------------------*/\r
+; Preemptive Tick\r
+\r
+        .def vPortPreemptiveTick\r
+\r
+vPortPreemptiveTick:\r
+\r
+               ; Save the context of the current task.\r
+        portSAVE_CONTEXT\r
+\r
+        ; Clear interrupt flag\r
+        MOVW    R0, #0xFC88\r
+        MOVT    R0, #0xFFFF\r
+        MOV     R1, #1\r
+        STR     R1, [R0]\r
+\r
+        ; Increment the tick count, making any adjustments to the blocked lists\r
+        ; that may be necessary.\r
+        BL      xTaskIncrementTick\r
+\r
+        ; Select the next task to execute.\r
+        CMP    R0, #0\r
+        BLNE    vTaskSwitchContext\r
+\r
+        ; Restore the context of the task selected to execute.\r
+        portRESTORE_CONTEXT\r
+\r
+;-------------------------------------------------------------------------------\r
+\r
+       .if (__TI_VFP_SUPPORT__)\r
+\r
+               .def vPortInitialiseFPSCR\r
+\r
+vPortInitialiseFPSCR:\r
+\r
+               MOV             R0, #0\r
+               FMXR    FPSCR, R0\r
+               BX              LR\r
+\r
+       .endif ;__TI_VFP_SUPPORT__\r
+\r
+\r
+pxCurrentTCBConst      .word   pxCurrentTCB\r
+ulFPUContextConst      .word   ulTaskHasFPUContext\r
+;-------------------------------------------------------------------------------\r
+\r
diff --git a/os/8.2.2/src/os/queue.c b/os/8.2.2/src/os/queue.c
new file mode 100644 (file)
index 0000000..1e99696
--- /dev/null
@@ -0,0 +1,2609 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
+/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining\r
+all the API functions to use the MPU wrappers.  That should only be done when\r
+task.h is included from an application file. */\r
+#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+#include "os/FreeRTOS.h"\r
+#include "os/task.h"\r
+#include "os/queue.h"\r
+\r
+#if ( configUSE_CO_ROUTINES == 1 )\r
+       #include "croutine.h"\r
+#endif\r
+\r
+/* Lint e961 and e750 are suppressed as a MISRA exception justified because the\r
+MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the\r
+header files above, but not in this file, in order to generate the correct\r
+privileged Vs unprivileged linkage and placement. */\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */\r
+\r
+\r
+/* Constants used with the xRxLock and xTxLock structure members. */\r
+#define queueUNLOCKED                                  ( ( BaseType_t ) -1 )\r
+#define queueLOCKED_UNMODIFIED                 ( ( BaseType_t ) 0 )\r
+\r
+/* When the Queue_t structure is used to represent a base queue its pcHead and\r
+pcTail members are used as pointers into the queue storage area.  When the\r
+Queue_t structure is used to represent a mutex pcHead and pcTail pointers are\r
+not necessary, and the pcHead pointer is set to NULL to indicate that the\r
+pcTail pointer actually points to the mutex holder (if any).  Map alternative\r
+names to the pcHead and pcTail structure members to ensure the readability of\r
+the code is maintained despite this dual use of two structure members.  An\r
+alternative implementation would be to use a union, but use of a union is\r
+against the coding standard (although an exception to the standard has been\r
+permitted where the dual use also significantly changes the type of the\r
+structure member). */\r
+#define pxMutexHolder                                  pcTail\r
+#define uxQueueType                                            pcHead\r
+#define queueQUEUE_IS_MUTEX                            NULL\r
+\r
+/* Semaphores do not actually store or copy data, so have an item size of\r
+zero. */\r
+#define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( UBaseType_t ) 0 )\r
+#define queueMUTEX_GIVE_BLOCK_TIME              ( ( TickType_t ) 0U )\r
+\r
+#if( configUSE_PREEMPTION == 0 )\r
+       /* If the cooperative scheduler is being used then a yield should not be\r
+       performed just because a higher priority task has been woken. */\r
+       #define queueYIELD_IF_USING_PREEMPTION()\r
+#else\r
+       #define queueYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API()\r
+#endif\r
+\r
+/*\r
+ * Definition of the queue used by the scheduler.\r
+ * Items are queued by copy, not reference.  See the following link for the\r
+ * rationale: http://www.freertos.org/Embedded-RTOS-Queues.html\r
+ */\r
+typedef struct QueueDefinition\r
+{\r
+       int8_t *pcHead;                                 /*< Points to the beginning of the queue storage area. */\r
+       int8_t *pcTail;                                 /*< Points to the byte at the end of the queue storage area.  Once more byte is allocated than necessary to store the queue items, this is used as a marker. */\r
+       int8_t *pcWriteTo;                              /*< Points to the free next place in the storage area. */\r
+\r
+       union                                                   /* Use of a union is an exception to the coding standard to ensure two mutually exclusive structure members don't appear simultaneously (wasting RAM). */\r
+       {\r
+               int8_t *pcReadFrom;                     /*< Points to the last place that a queued item was read from when the structure is used as a queue. */\r
+               UBaseType_t uxRecursiveCallCount;/*< Maintains a count of the number of times a recursive mutex has been recursively 'taken' when the structure is used as a mutex. */\r
+       } u;\r
+\r
+       List_t xTasksWaitingToSend;             /*< List of tasks that are blocked waiting to post onto this queue.  Stored in priority order. */\r
+       List_t xTasksWaitingToReceive;  /*< List of tasks that are blocked waiting to read from this queue.  Stored in priority order. */\r
+\r
+       volatile UBaseType_t uxMessagesWaiting;/*< The number of items currently in the queue. */\r
+       UBaseType_t uxLength;                   /*< The length of the queue defined as the number of items it will hold, not the number of bytes. */\r
+       UBaseType_t uxItemSize;                 /*< The size of each items that the queue will hold. */\r
+\r
+       volatile BaseType_t xRxLock;    /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked.  Set to queueUNLOCKED when the queue is not locked. */\r
+       volatile BaseType_t xTxLock;    /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked.  Set to queueUNLOCKED when the queue is not locked. */\r
+\r
+       #if ( configUSE_TRACE_FACILITY == 1 )\r
+               UBaseType_t uxQueueNumber;\r
+               uint8_t ucQueueType;\r
+       #endif\r
+\r
+       #if ( configUSE_QUEUE_SETS == 1 )\r
+               struct QueueDefinition *pxQueueSetContainer;\r
+       #endif\r
+\r
+} xQUEUE;\r
+\r
+/* The old xQUEUE name is maintained above then typedefed to the new Queue_t\r
+name below to enable the use of older kernel aware debuggers. */\r
+typedef xQUEUE Queue_t;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * The queue registry is just a means for kernel aware debuggers to locate\r
+ * queue structures.  It has no other purpose so is an optional component.\r
+ */\r
+#if ( configQUEUE_REGISTRY_SIZE > 0 )\r
+\r
+       /* The type stored within the queue registry array.  This allows a name\r
+       to be assigned to each queue making kernel aware debugging a little\r
+       more user friendly. */\r
+       typedef struct QUEUE_REGISTRY_ITEM\r
+       {\r
+               const char *pcQueueName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+               QueueHandle_t xHandle;\r
+       } xQueueRegistryItem;\r
+\r
+       /* The old xQueueRegistryItem name is maintained above then typedefed to the\r
+       new xQueueRegistryItem name below to enable the use of older kernel aware\r
+       debuggers. */\r
+       typedef xQueueRegistryItem QueueRegistryItem_t;\r
+\r
+       /* The queue registry is simply an array of QueueRegistryItem_t structures.\r
+       The pcQueueName member of a structure being NULL is indicative of the\r
+       array position being vacant. */\r
+       PRIVILEGED_DATA QueueRegistryItem_t xQueueRegistry[ configQUEUE_REGISTRY_SIZE ];\r
+\r
+#endif /* configQUEUE_REGISTRY_SIZE */\r
+\r
+/*\r
+ * Unlocks a queue locked by a call to prvLockQueue.  Locking a queue does not\r
+ * prevent an ISR from adding or removing items to the queue, but does prevent\r
+ * an ISR from removing tasks from the queue event lists.  If an ISR finds a\r
+ * queue is locked it will instead increment the appropriate queue lock count\r
+ * to indicate that a task may require unblocking.  When the queue in unlocked\r
+ * these lock counts are inspected, and the appropriate action taken.\r
+ */\r
+static void prvUnlockQueue( Queue_t * const pxQueue ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Uses a critical section to determine if there is any data in a queue.\r
+ *\r
+ * @return pdTRUE if the queue contains no items, otherwise pdFALSE.\r
+ */\r
+static BaseType_t prvIsQueueEmpty( const Queue_t *pxQueue ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Uses a critical section to determine if there is any space in a queue.\r
+ *\r
+ * @return pdTRUE if there is no space, otherwise pdFALSE;\r
+ */\r
+static BaseType_t prvIsQueueFull( const Queue_t *pxQueue ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Copies an item into the queue, either at the front of the queue or the\r
+ * back of the queue.\r
+ */\r
+static BaseType_t prvCopyDataToQueue( Queue_t * const pxQueue, const void *pvItemToQueue, const BaseType_t xPosition ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Copies an item out of a queue.\r
+ */\r
+static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION;\r
+\r
+#if ( configUSE_QUEUE_SETS == 1 )\r
+       /*\r
+        * Checks to see if a queue is a member of a queue set, and if so, notifies\r
+        * the queue set that the queue contains data.\r
+        */\r
+       static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;\r
+#endif\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Macro to mark a queue as locked.  Locking a queue prevents an ISR from\r
+ * accessing the queue event lists.\r
+ */\r
+#define prvLockQueue( pxQueue )                                                                \\r
+       taskENTER_CRITICAL();                                                                   \\r
+       {                                                                                                               \\r
+               if( ( pxQueue )->xRxLock == queueUNLOCKED )                     \\r
+               {                                                                                                       \\r
+                       ( pxQueue )->xRxLock = queueLOCKED_UNMODIFIED;  \\r
+               }                                                                                                       \\r
+               if( ( pxQueue )->xTxLock == queueUNLOCKED )                     \\r
+               {                                                                                                       \\r
+                       ( pxQueue )->xTxLock = queueLOCKED_UNMODIFIED;  \\r
+               }                                                                                                       \\r
+       }                                                                                                               \\r
+       taskEXIT_CRITICAL()\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue )\r
+{\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+       configASSERT( pxQueue );\r
+\r
+       taskENTER_CRITICAL();\r
+       {\r
+               pxQueue->pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize );\r
+               pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U;\r
+               pxQueue->pcWriteTo = pxQueue->pcHead;\r
+               pxQueue->u.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - ( UBaseType_t ) 1U ) * pxQueue->uxItemSize );\r
+               pxQueue->xRxLock = queueUNLOCKED;\r
+               pxQueue->xTxLock = queueUNLOCKED;\r
+\r
+               if( xNewQueue == pdFALSE )\r
+               {\r
+                       /* If there are tasks blocked waiting to read from the queue, then\r
+                       the tasks will remain blocked as after this function exits the queue\r
+                       will still be empty.  If there are tasks blocked waiting to write to\r
+                       the queue, then one should be unblocked as after this function exits\r
+                       it will be possible to write to it. */\r
+                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
+                       {\r
+                               if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )\r
+                               {\r
+                                       queueYIELD_IF_USING_PREEMPTION();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       /* Ensure the event queues start in the correct state. */\r
+                       vListInitialise( &( pxQueue->xTasksWaitingToSend ) );\r
+                       vListInitialise( &( pxQueue->xTasksWaitingToReceive ) );\r
+               }\r
+       }\r
+       taskEXIT_CRITICAL();\r
+\r
+       /* A value is returned for calling semantic consistency with previous\r
+       versions. */\r
+       return pdPASS;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType )\r
+{\r
+Queue_t *pxNewQueue;\r
+size_t xQueueSizeInBytes;\r
+QueueHandle_t xReturn = NULL;\r
+\r
+       /* Remove compiler warnings about unused parameters should\r
+       configUSE_TRACE_FACILITY not be set to 1. */\r
+       ( void ) ucQueueType;\r
+\r
+       configASSERT( uxQueueLength > ( UBaseType_t ) 0 );\r
+\r
+       if( uxItemSize == ( UBaseType_t ) 0 )\r
+       {\r
+               /* There is not going to be a queue storage area. */\r
+               xQueueSizeInBytes = ( size_t ) 0;\r
+       }\r
+       else\r
+       {\r
+               /* The queue is one byte longer than asked for to make wrap checking\r
+               easier/faster. */\r
+               xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+       }\r
+\r
+       /* Allocate the new queue structure and storage area. */\r
+       pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes );\r
+\r
+       if( pxNewQueue != NULL )\r
+       {\r
+               if( uxItemSize == ( UBaseType_t ) 0 )\r
+               {\r
+                       /* No RAM was allocated for the queue storage area, but PC head\r
+                       cannot be set to NULL because NULL is used as a key to say the queue\r
+                       is used as a mutex.  Therefore just set pcHead to point to the queue\r
+                       as a benign value that is known to be within the memory map. */\r
+                       pxNewQueue->pcHead = ( int8_t * ) pxNewQueue;\r
+               }\r
+               else\r
+               {\r
+                       /* Jump past the queue structure to find the location of the queue\r
+                       storage area. */\r
+                       pxNewQueue->pcHead = ( ( int8_t * ) pxNewQueue ) + sizeof( Queue_t );\r
+               }\r
+\r
+               /* Initialise the queue members as described above where the queue type\r
+               is defined. */\r
+               pxNewQueue->uxLength = uxQueueLength;\r
+               pxNewQueue->uxItemSize = uxItemSize;\r
+               ( void ) xQueueGenericReset( pxNewQueue, pdTRUE );\r
+\r
+               #if ( configUSE_TRACE_FACILITY == 1 )\r
+               {\r
+                       pxNewQueue->ucQueueType = ucQueueType;\r
+               }\r
+               #endif /* configUSE_TRACE_FACILITY */\r
+\r
+               #if( configUSE_QUEUE_SETS == 1 )\r
+               {\r
+                       pxNewQueue->pxQueueSetContainer = NULL;\r
+               }\r
+               #endif /* configUSE_QUEUE_SETS */\r
+\r
+               traceQUEUE_CREATE( pxNewQueue );\r
+               xReturn = pxNewQueue;\r
+       }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
+       }\r
+\r
+       configASSERT( xReturn );\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_MUTEXES == 1 )\r
+\r
+       QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType )\r
+       {\r
+       Queue_t *pxNewQueue;\r
+\r
+               /* Prevent compiler warnings about unused parameters if\r
+               configUSE_TRACE_FACILITY does not equal 1. */\r
+               ( void ) ucQueueType;\r
+\r
+               /* Allocate the new queue structure. */\r
+               pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) );\r
+               if( pxNewQueue != NULL )\r
+               {\r
+                       /* Information required for priority inheritance. */\r
+                       pxNewQueue->pxMutexHolder = NULL;\r
+                       pxNewQueue->uxQueueType = queueQUEUE_IS_MUTEX;\r
+\r
+                       /* Queues used as a mutex no data is actually copied into or out\r
+                       of the queue. */\r
+                       pxNewQueue->pcWriteTo = NULL;\r
+                       pxNewQueue->u.pcReadFrom = NULL;\r
+\r
+                       /* Each mutex has a length of 1 (like a binary semaphore) and\r
+                       an item size of 0 as nothing is actually copied into or out\r
+                       of the mutex. */\r
+                       pxNewQueue->uxMessagesWaiting = ( UBaseType_t ) 0U;\r
+                       pxNewQueue->uxLength = ( UBaseType_t ) 1U;\r
+                       pxNewQueue->uxItemSize = ( UBaseType_t ) 0U;\r
+                       pxNewQueue->xRxLock = queueUNLOCKED;\r
+                       pxNewQueue->xTxLock = queueUNLOCKED;\r
+\r
+                       #if ( configUSE_TRACE_FACILITY == 1 )\r
+                       {\r
+                               pxNewQueue->ucQueueType = ucQueueType;\r
+                       }\r
+                       #endif\r
+\r
+                       #if ( configUSE_QUEUE_SETS == 1 )\r
+                       {\r
+                               pxNewQueue->pxQueueSetContainer = NULL;\r
+                       }\r
+                       #endif\r
+\r
+                       /* Ensure the event queues start with the correct state. */\r
+                       vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) );\r
+                       vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );\r
+\r
+                       traceCREATE_MUTEX( pxNewQueue );\r
+\r
+                       /* Start with the semaphore in the expected state. */\r
+                       ( void ) xQueueGenericSend( pxNewQueue, NULL, ( TickType_t ) 0U, queueSEND_TO_BACK );\r
+               }\r
+               else\r
+               {\r
+                       traceCREATE_MUTEX_FAILED();\r
+               }\r
+\r
+               configASSERT( pxNewQueue );\r
+               return pxNewQueue;\r
+       }\r
+\r
+#endif /* configUSE_MUTEXES */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )\r
+\r
+       void* xQueueGetMutexHolder( QueueHandle_t xSemaphore )\r
+       {\r
+       void *pxReturn;\r
+\r
+               /* This function is called by xSemaphoreGetMutexHolder(), and should not\r
+               be called directly.  Note:  This is a good way of determining if the\r
+               calling task is the mutex holder, but not a good way of determining the\r
+               identity of the mutex holder, as the holder may change between the\r
+               following critical section exiting and the function returning. */\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX )\r
+                       {\r
+                               pxReturn = ( void * ) ( ( Queue_t * ) xSemaphore )->pxMutexHolder;\r
+                       }\r
+                       else\r
+                       {\r
+                               pxReturn = NULL;\r
+                       }\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               return pxReturn;\r
+       } /*lint !e818 xSemaphore cannot be a pointer to const because it is a typedef. */\r
+\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_RECURSIVE_MUTEXES == 1 )\r
+\r
+       BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex )\r
+       {\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxMutex = ( Queue_t * ) xMutex;\r
+\r
+               configASSERT( pxMutex );\r
+\r
+               /* If this is the task that holds the mutex then pxMutexHolder will not\r
+               change outside of this task.  If this task does not hold the mutex then\r
+               pxMutexHolder can never coincidentally equal the tasks handle, and as\r
+               this is the only condition we are interested in it does not matter if\r
+               pxMutexHolder is accessed simultaneously by another task.  Therefore no\r
+               mutual exclusion is required to test the pxMutexHolder variable. */\r
+               if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Not a redundant cast as TaskHandle_t is a typedef. */\r
+               {\r
+                       traceGIVE_MUTEX_RECURSIVE( pxMutex );\r
+\r
+                       /* uxRecursiveCallCount cannot be zero if pxMutexHolder is equal to\r
+                       the task handle, therefore no underflow check is required.  Also,\r
+                       uxRecursiveCallCount is only modified by the mutex holder, and as\r
+                       there can only be one, no mutual exclusion is required to modify the\r
+                       uxRecursiveCallCount member. */\r
+                       ( pxMutex->u.uxRecursiveCallCount )--;\r
+\r
+                       /* Have we unwound the call count? */\r
+                       if( pxMutex->u.uxRecursiveCallCount == ( UBaseType_t ) 0 )\r
+                       {\r
+                               /* Return the mutex.  This will automatically unblock any other\r
+                               task that might be waiting to access the mutex. */\r
+                               ( void ) xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK );\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       xReturn = pdPASS;\r
+               }\r
+               else\r
+               {\r
+                       /* The mutex cannot be given because the calling task is not the\r
+                       holder. */\r
+                       xReturn = pdFAIL;\r
+\r
+                       traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex );\r
+               }\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_RECURSIVE_MUTEXES */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_RECURSIVE_MUTEXES == 1 )\r
+\r
+       BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait )\r
+       {\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxMutex = ( Queue_t * ) xMutex;\r
+\r
+               configASSERT( pxMutex );\r
+\r
+               /* Comments regarding mutual exclusion as per those within\r
+               xQueueGiveMutexRecursive(). */\r
+\r
+               traceTAKE_MUTEX_RECURSIVE( pxMutex );\r
+\r
+               if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */\r
+               {\r
+                       ( pxMutex->u.uxRecursiveCallCount )++;\r
+                       xReturn = pdPASS;\r
+               }\r
+               else\r
+               {\r
+                       xReturn = xQueueGenericReceive( pxMutex, NULL, xTicksToWait, pdFALSE );\r
+\r
+                       /* pdPASS will only be returned if the mutex was successfully\r
+                       obtained.  The calling task may have entered the Blocked state\r
+                       before reaching here. */\r
+                       if( xReturn == pdPASS )\r
+                       {\r
+                               ( pxMutex->u.uxRecursiveCallCount )++;\r
+                       }\r
+                       else\r
+                       {\r
+                               traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex );\r
+                       }\r
+               }\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_RECURSIVE_MUTEXES */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_COUNTING_SEMAPHORES == 1 )\r
+\r
+       QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount )\r
+       {\r
+       QueueHandle_t xHandle;\r
+\r
+               configASSERT( uxMaxCount != 0 );\r
+               configASSERT( uxInitialCount <= uxMaxCount );\r
+\r
+               xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );\r
+\r
+               if( xHandle != NULL )\r
+               {\r
+                       ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount;\r
+\r
+                       traceCREATE_COUNTING_SEMAPHORE();\r
+               }\r
+               else\r
+               {\r
+                       traceCREATE_COUNTING_SEMAPHORE_FAILED();\r
+               }\r
+\r
+               configASSERT( xHandle );\r
+               return xHandle;\r
+       }\r
+\r
+#endif /* configUSE_COUNTING_SEMAPHORES */\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition )\r
+{\r
+BaseType_t xEntryTimeSet = pdFALSE, xYieldRequired;\r
+TimeOut_t xTimeOut;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+       configASSERT( pxQueue );\r
+       configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
+       configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) );\r
+       #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r
+       {\r
+               configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );\r
+       }\r
+       #endif\r
+\r
+\r
+       /* This function relaxes the coding standard somewhat to allow return\r
+       statements within the function itself.  This is done in the interest\r
+       of execution time efficiency. */\r
+       for( ;; )\r
+       {\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       /* Is there room on the queue now?  The running task must be the\r
+                       highest priority task wanting to access the queue.  If the head item\r
+                       in the queue is to be overwritten then it does not matter if the\r
+                       queue is full. */\r
+                       if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )\r
+                       {\r
+                               traceQUEUE_SEND( pxQueue );\r
+                               xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
+\r
+                               #if ( configUSE_QUEUE_SETS == 1 )\r
+                               {\r
+                                       if( pxQueue->pxQueueSetContainer != NULL )\r
+                                       {\r
+                                               if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) == pdTRUE )\r
+                                               {\r
+                                                       /* The queue is a member of a queue set, and posting\r
+                                                       to the queue set caused a higher priority task to\r
+                                                       unblock. A context switch is required. */\r
+                                                       queueYIELD_IF_USING_PREEMPTION();\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               /* If there was a task waiting for data to arrive on the\r
+                                               queue then unblock it now. */\r
+                                               if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+                                               {\r
+                                                       if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE )\r
+                                                       {\r
+                                                               /* The unblocked task has a priority higher than\r
+                                                               our own so yield immediately.  Yes it is ok to\r
+                                                               do this from within the critical section - the\r
+                                                               kernel takes care of that. */\r
+                                                               queueYIELD_IF_USING_PREEMPTION();\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                               else if( xYieldRequired != pdFALSE )\r
+                                               {\r
+                                                       /* This path is a special case that will only get\r
+                                                       executed if the task was holding multiple mutexes\r
+                                                       and the mutexes were given back in an order that is\r
+                                                       different to that in which they were taken. */\r
+                                                       queueYIELD_IF_USING_PREEMPTION();\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                               }\r
+                               #else /* configUSE_QUEUE_SETS */\r
+                               {\r
+                                       /* If there was a task waiting for data to arrive on the\r
+                                       queue then unblock it now. */\r
+                                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+                                       {\r
+                                               if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE )\r
+                                               {\r
+                                                       /* The unblocked task has a priority higher than\r
+                                                       our own so yield immediately.  Yes it is ok to do\r
+                                                       this from within the critical section - the kernel\r
+                                                       takes care of that. */\r
+                                                       queueYIELD_IF_USING_PREEMPTION();\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else if( xYieldRequired != pdFALSE )\r
+                                       {\r
+                                               /* This path is a special case that will only get\r
+                                               executed if the task was holding multiple mutexes and\r
+                                               the mutexes were given back in an order that is\r
+                                               different to that in which they were taken. */\r
+                                               queueYIELD_IF_USING_PREEMPTION();\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               #endif /* configUSE_QUEUE_SETS */\r
+\r
+                               taskEXIT_CRITICAL();\r
+                               return pdPASS;\r
+                       }\r
+                       else\r
+                       {\r
+                               if( xTicksToWait == ( TickType_t ) 0 )\r
+                               {\r
+                                       /* The queue was full and no block time is specified (or\r
+                                       the block time has expired) so leave now. */\r
+                                       taskEXIT_CRITICAL();\r
+\r
+                                       /* Return to the original privilege level before exiting\r
+                                       the function. */\r
+                                       traceQUEUE_SEND_FAILED( pxQueue );\r
+                                       return errQUEUE_FULL;\r
+                               }\r
+                               else if( xEntryTimeSet == pdFALSE )\r
+                               {\r
+                                       /* The queue was full and a block time was specified so\r
+                                       configure the timeout structure. */\r
+                                       vTaskSetTimeOutState( &xTimeOut );\r
+                                       xEntryTimeSet = pdTRUE;\r
+                               }\r
+                               else\r
+                               {\r
+                                       /* Entry time was already set. */\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               /* Interrupts and other tasks can send to and receive from the queue\r
+               now the critical section has been exited. */\r
+\r
+               vTaskSuspendAll();\r
+               prvLockQueue( pxQueue );\r
+\r
+               /* Update the timeout state to see if it has expired yet. */\r
+               if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )\r
+               {\r
+                       if( prvIsQueueFull( pxQueue ) != pdFALSE )\r
+                       {\r
+                               traceBLOCKING_ON_QUEUE_SEND( pxQueue );\r
+                               vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );\r
+\r
+                               /* Unlocking the queue means queue events can effect the\r
+                               event list.  It is possible     that interrupts occurring now\r
+                               remove this task from the event list again - but as the\r
+                               scheduler is suspended the task will go onto the pending\r
+                               ready last instead of the actual ready list. */\r
+                               prvUnlockQueue( pxQueue );\r
+\r
+                               /* Resuming the scheduler will move tasks from the pending\r
+                               ready list into the ready list - so it is feasible that this\r
+                               task is already in a ready list before it yields - in which\r
+                               case the yield will not cause a context switch unless there\r
+                               is also a higher priority task in the pending ready list. */\r
+                               if( xTaskResumeAll() == pdFALSE )\r
+                               {\r
+                                       portYIELD_WITHIN_API();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               /* Try again. */\r
+                               prvUnlockQueue( pxQueue );\r
+                               ( void ) xTaskResumeAll();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       /* The timeout has expired. */\r
+                       prvUnlockQueue( pxQueue );\r
+                       ( void ) xTaskResumeAll();\r
+\r
+                       /* Return to the original privilege level before exiting the\r
+                       function. */\r
+                       traceQUEUE_SEND_FAILED( pxQueue );\r
+                       return errQUEUE_FULL;\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_ALTERNATIVE_API == 1 )\r
+\r
+       BaseType_t xQueueAltGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, BaseType_t xCopyPosition )\r
+       {\r
+       BaseType_t xEntryTimeSet = pdFALSE;\r
+       TimeOut_t xTimeOut;\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+               configASSERT( pxQueue );\r
+               configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
+\r
+               for( ;; )\r
+               {\r
+                       taskENTER_CRITICAL();\r
+                       {\r
+                               /* Is there room on the queue now?  To be running we must be\r
+                               the highest priority task wanting to access the queue. */\r
+                               if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
+                               {\r
+                                       traceQUEUE_SEND( pxQueue );\r
+                                       prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
+\r
+                                       /* If there was a task waiting for data to arrive on the\r
+                                       queue then unblock it now. */\r
+                                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+                                       {\r
+                                               if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE )\r
+                                               {\r
+                                                       /* The unblocked task has a priority higher than\r
+                                                       our own so yield immediately. */\r
+                                                       portYIELD_WITHIN_API();\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+\r
+                                       taskEXIT_CRITICAL();\r
+                                       return pdPASS;\r
+                               }\r
+                               else\r
+                               {\r
+                                       if( xTicksToWait == ( TickType_t ) 0 )\r
+                                       {\r
+                                               taskEXIT_CRITICAL();\r
+                                               return errQUEUE_FULL;\r
+                                       }\r
+                                       else if( xEntryTimeSet == pdFALSE )\r
+                                       {\r
+                                               vTaskSetTimeOutState( &xTimeOut );\r
+                                               xEntryTimeSet = pdTRUE;\r
+                                       }\r
+                               }\r
+                       }\r
+                       taskEXIT_CRITICAL();\r
+\r
+                       taskENTER_CRITICAL();\r
+                       {\r
+                               if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )\r
+                               {\r
+                                       if( prvIsQueueFull( pxQueue ) != pdFALSE )\r
+                                       {\r
+                                               traceBLOCKING_ON_QUEUE_SEND( pxQueue );\r
+                                               vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );\r
+                                               portYIELD_WITHIN_API();\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       taskEXIT_CRITICAL();\r
+                                       traceQUEUE_SEND_FAILED( pxQueue );\r
+                                       return errQUEUE_FULL;\r
+                               }\r
+                       }\r
+                       taskEXIT_CRITICAL();\r
+               }\r
+       }\r
+\r
+#endif /* configUSE_ALTERNATIVE_API */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_ALTERNATIVE_API == 1 )\r
+\r
+       BaseType_t xQueueAltGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, BaseType_t xJustPeeking )\r
+       {\r
+       BaseType_t xEntryTimeSet = pdFALSE;\r
+       TimeOut_t xTimeOut;\r
+       int8_t *pcOriginalReadPosition;\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+               configASSERT( pxQueue );\r
+               configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
+\r
+               for( ;; )\r
+               {\r
+                       taskENTER_CRITICAL();\r
+                       {\r
+                               if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
+                               {\r
+                                       /* Remember our read position in case we are just peeking. */\r
+                                       pcOriginalReadPosition = pxQueue->u.pcReadFrom;\r
+\r
+                                       prvCopyDataFromQueue( pxQueue, pvBuffer );\r
+\r
+                                       if( xJustPeeking == pdFALSE )\r
+                                       {\r
+                                               traceQUEUE_RECEIVE( pxQueue );\r
+\r
+                                               /* Data is actually being removed (not just peeked). */\r
+                                               --( pxQueue->uxMessagesWaiting );\r
+\r
+                                               #if ( configUSE_MUTEXES == 1 )\r
+                                               {\r
+                                                       if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )\r
+                                                       {\r
+                                                               /* Record the information required to implement\r
+                                                               priority inheritance should it become necessary. */\r
+                                                               pxQueue->pxMutexHolder = ( int8_t * ) xTaskGetCurrentTaskHandle();\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                               #endif\r
+\r
+                                               if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
+                                               {\r
+                                                       if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )\r
+                                                       {\r
+                                                               portYIELD_WITHIN_API();\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               traceQUEUE_PEEK( pxQueue );\r
+\r
+                                               /* The data is not being removed, so reset our read\r
+                                               pointer. */\r
+                                               pxQueue->u.pcReadFrom = pcOriginalReadPosition;\r
+\r
+                                               /* The data is being left in the queue, so see if there are\r
+                                               any other tasks waiting for the data. */\r
+                                               if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+                                               {\r
+                                                       /* Tasks that are removed from the event list will get added to\r
+                                                       the pending ready list as the scheduler is still suspended. */\r
+                                                       if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+                                                       {\r
+                                                               /* The task waiting has a higher priority than this task. */\r
+                                                               portYIELD_WITHIN_API();\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+\r
+                                       taskEXIT_CRITICAL();\r
+                                       return pdPASS;\r
+                               }\r
+                               else\r
+                               {\r
+                                       if( xTicksToWait == ( TickType_t ) 0 )\r
+                                       {\r
+                                               taskEXIT_CRITICAL();\r
+                                               traceQUEUE_RECEIVE_FAILED( pxQueue );\r
+                                               return errQUEUE_EMPTY;\r
+                                       }\r
+                                       else if( xEntryTimeSet == pdFALSE )\r
+                                       {\r
+                                               vTaskSetTimeOutState( &xTimeOut );\r
+                                               xEntryTimeSet = pdTRUE;\r
+                                       }\r
+                               }\r
+                       }\r
+                       taskEXIT_CRITICAL();\r
+\r
+                       taskENTER_CRITICAL();\r
+                       {\r
+                               if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )\r
+                               {\r
+                                       if( prvIsQueueEmpty( pxQueue ) != pdFALSE )\r
+                                       {\r
+                                               traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );\r
+\r
+                                               #if ( configUSE_MUTEXES == 1 )\r
+                                               {\r
+                                                       if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )\r
+                                                       {\r
+                                                               taskENTER_CRITICAL();\r
+                                                               {\r
+                                                                       vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder );\r
+                                                               }\r
+                                                               taskEXIT_CRITICAL();\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                               #endif\r
+\r
+                                               vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );\r
+                                               portYIELD_WITHIN_API();\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       taskEXIT_CRITICAL();\r
+                                       traceQUEUE_RECEIVE_FAILED( pxQueue );\r
+                                       return errQUEUE_EMPTY;\r
+                               }\r
+                       }\r
+                       taskEXIT_CRITICAL();\r
+               }\r
+       }\r
+\r
+\r
+#endif /* configUSE_ALTERNATIVE_API */\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition )\r
+{\r
+BaseType_t xReturn;\r
+UBaseType_t uxSavedInterruptStatus;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+       configASSERT( pxQueue );\r
+       configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
+       configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) );\r
+\r
+       /* RTOS ports that support interrupt nesting have the concept of a maximum\r
+       system call (or maximum API call) interrupt priority.  Interrupts that are\r
+       above the maximum system call priority are kept permanently enabled, even\r
+       when the RTOS kernel is in a critical section, but cannot make any calls to\r
+       FreeRTOS API functions.  If configASSERT() is defined in FreeRTOSConfig.h\r
+       then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+       failure if a FreeRTOS API function is called from an interrupt that has been\r
+       assigned a priority above the configured maximum system call priority.\r
+       Only FreeRTOS functions that end in FromISR can be called from interrupts\r
+       that have been assigned a priority at or (logically) below the maximum\r
+       system call     interrupt priority.  FreeRTOS maintains a separate interrupt\r
+       safe API to ensure interrupt entry is as fast and as simple as possible.\r
+       More information (albeit Cortex-M specific) is provided on the following\r
+       link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+       portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+       /* Similar to xQueueGenericSend, except without blocking if there is no room\r
+       in the queue.  Also don't directly wake a task that was blocked on a queue\r
+       read, instead return a flag to say whether a context switch is required or\r
+       not (i.e. has a task with a higher priority than us been woken by this\r
+       post). */\r
+       uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
+       {\r
+               if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )\r
+               {\r
+                       traceQUEUE_SEND_FROM_ISR( pxQueue );\r
+\r
+                       /* Semaphores use xQueueGiveFromISR(), so pxQueue will not be a\r
+                       semaphore or mutex.  That means prvCopyDataToQueue() cannot result\r
+                       in a task disinheriting a priority and prvCopyDataToQueue() can be\r
+                       called here even though the disinherit function does not check if\r
+                       the scheduler is suspended before accessing the ready lists. */\r
+                       ( void ) prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
+\r
+                       /* The event list is not altered if the queue is locked.  This will\r
+                       be done when the queue is unlocked later. */\r
+                       if( pxQueue->xTxLock == queueUNLOCKED )\r
+                       {\r
+                               #if ( configUSE_QUEUE_SETS == 1 )\r
+                               {\r
+                                       if( pxQueue->pxQueueSetContainer != NULL )\r
+                                       {\r
+                                               if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) == pdTRUE )\r
+                                               {\r
+                                                       /* The queue is a member of a queue set, and posting\r
+                                                       to the queue set caused a higher priority task to\r
+                                                       unblock.  A context switch is required. */\r
+                                                       if( pxHigherPriorityTaskWoken != NULL )\r
+                                                       {\r
+                                                               *pxHigherPriorityTaskWoken = pdTRUE;\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+                                               {\r
+                                                       if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+                                                       {\r
+                                                               /* The task waiting has a higher priority so\r
+                                                               record that a context switch is required. */\r
+                                                               if( pxHigherPriorityTaskWoken != NULL )\r
+                                                               {\r
+                                                                       *pxHigherPriorityTaskWoken = pdTRUE;\r
+                                                               }\r
+                                                               else\r
+                                                               {\r
+                                                                       mtCOVERAGE_TEST_MARKER();\r
+                                                               }\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                               }\r
+                               #else /* configUSE_QUEUE_SETS */\r
+                               {\r
+                                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+                                       {\r
+                                               if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+                                               {\r
+                                                       /* The task waiting has a higher priority so record that a\r
+                                                       context switch is required. */\r
+                                                       if( pxHigherPriorityTaskWoken != NULL )\r
+                                                       {\r
+                                                               *pxHigherPriorityTaskWoken = pdTRUE;\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               #endif /* configUSE_QUEUE_SETS */\r
+                       }\r
+                       else\r
+                       {\r
+                               /* Increment the lock count so the task that unlocks the queue\r
+                               knows that data was posted while it was locked. */\r
+                               ++( pxQueue->xTxLock );\r
+                       }\r
+\r
+                       xReturn = pdPASS;\r
+               }\r
+               else\r
+               {\r
+                       traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue );\r
+                       xReturn = errQUEUE_FULL;\r
+               }\r
+       }\r
+       portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherPriorityTaskWoken )\r
+{\r
+BaseType_t xReturn;\r
+UBaseType_t uxSavedInterruptStatus;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+       /* Similar to xQueueGenericSendFromISR() but used with semaphores where the\r
+       item size is 0.  Don't directly wake a task that was blocked on a queue\r
+       read, instead return a flag to say whether a context switch is required or\r
+       not (i.e. has a task with a higher priority than us been woken by this\r
+       post). */\r
+\r
+       configASSERT( pxQueue );\r
+\r
+       /* xQueueGenericSendFromISR() should be used instead of xQueueGiveFromISR()\r
+       if the item size is not 0. */\r
+       configASSERT( pxQueue->uxItemSize == 0 );\r
+\r
+       /* Normally a mutex would not be given from an interrupt, especially if \r
+       there is a mutex holder, as priority inheritance makes no sense for an \r
+       interrupts, only tasks. */\r
+       configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->pxMutexHolder != NULL ) ) );\r
+\r
+       /* RTOS ports that support interrupt nesting have the concept of a maximum\r
+       system call (or maximum API call) interrupt priority.  Interrupts that are\r
+       above the maximum system call priority are kept permanently enabled, even\r
+       when the RTOS kernel is in a critical section, but cannot make any calls to\r
+       FreeRTOS API functions.  If configASSERT() is defined in FreeRTOSConfig.h\r
+       then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+       failure if a FreeRTOS API function is called from an interrupt that has been\r
+       assigned a priority above the configured maximum system call priority.\r
+       Only FreeRTOS functions that end in FromISR can be called from interrupts\r
+       that have been assigned a priority at or (logically) below the maximum\r
+       system call     interrupt priority.  FreeRTOS maintains a separate interrupt\r
+       safe API to ensure interrupt entry is as fast and as simple as possible.\r
+       More information (albeit Cortex-M specific) is provided on the following\r
+       link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+       portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+       uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
+       {\r
+               /* When the queue is used to implement a semaphore no data is ever\r
+               moved through the queue but it is still valid to see if the queue 'has\r
+               space'. */\r
+               if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
+               {\r
+                       traceQUEUE_SEND_FROM_ISR( pxQueue );\r
+\r
+                       /* A task can only have an inherited priority if it is a mutex\r
+                       holder - and if there is a mutex holder then the mutex cannot be\r
+                       given from an ISR.  As this is the ISR version of the function it\r
+                       can be assumed there is no mutex holder and no need to determine if\r
+                       priority disinheritance is needed.  Simply increase the count of\r
+                       messages (semaphores) available. */\r
+                       ++( pxQueue->uxMessagesWaiting );\r
+\r
+                       /* The event list is not altered if the queue is locked.  This will\r
+                       be done when the queue is unlocked later. */\r
+                       if( pxQueue->xTxLock == queueUNLOCKED )\r
+                       {\r
+                               #if ( configUSE_QUEUE_SETS == 1 )\r
+                               {\r
+                                       if( pxQueue->pxQueueSetContainer != NULL )\r
+                                       {\r
+                                               if( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) == pdTRUE )\r
+                                               {\r
+                                                       /* The semaphore is a member of a queue set, and\r
+                                                       posting to the queue set caused a higher priority\r
+                                                       task to unblock.  A context switch is required. */\r
+                                                       if( pxHigherPriorityTaskWoken != NULL )\r
+                                                       {\r
+                                                               *pxHigherPriorityTaskWoken = pdTRUE;\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+                                               {\r
+                                                       if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+                                                       {\r
+                                                               /* The task waiting has a higher priority so\r
+                                                               record that a context switch is required. */\r
+                                                               if( pxHigherPriorityTaskWoken != NULL )\r
+                                                               {\r
+                                                                       *pxHigherPriorityTaskWoken = pdTRUE;\r
+                                                               }\r
+                                                               else\r
+                                                               {\r
+                                                                       mtCOVERAGE_TEST_MARKER();\r
+                                                               }\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                               }\r
+                               #else /* configUSE_QUEUE_SETS */\r
+                               {\r
+                                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+                                       {\r
+                                               if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+                                               {\r
+                                                       /* The task waiting has a higher priority so record that a\r
+                                                       context switch is required. */\r
+                                                       if( pxHigherPriorityTaskWoken != NULL )\r
+                                                       {\r
+                                                               *pxHigherPriorityTaskWoken = pdTRUE;\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               #endif /* configUSE_QUEUE_SETS */\r
+                       }\r
+                       else\r
+                       {\r
+                               /* Increment the lock count so the task that unlocks the queue\r
+                               knows that data was posted while it was locked. */\r
+                               ++( pxQueue->xTxLock );\r
+                       }\r
+\r
+                       xReturn = pdPASS;\r
+               }\r
+               else\r
+               {\r
+                       traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue );\r
+                       xReturn = errQUEUE_FULL;\r
+               }\r
+       }\r
+       portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xQueueGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, const BaseType_t xJustPeeking )\r
+{\r
+BaseType_t xEntryTimeSet = pdFALSE;\r
+TimeOut_t xTimeOut;\r
+int8_t *pcOriginalReadPosition;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+       configASSERT( pxQueue );\r
+       configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
+       #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r
+       {\r
+               configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );\r
+       }\r
+       #endif\r
+\r
+       /* This function relaxes the coding standard somewhat to allow return\r
+       statements within the function itself.  This is done in the interest\r
+       of execution time efficiency. */\r
+\r
+       for( ;; )\r
+       {\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       /* Is there data in the queue now?  To be running the calling task\r
+                       must be the highest priority task wanting to access the queue. */\r
+                       if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
+                       {\r
+                               /* Remember the read position in case the queue is only being\r
+                               peeked. */\r
+                               pcOriginalReadPosition = pxQueue->u.pcReadFrom;\r
+\r
+                               prvCopyDataFromQueue( pxQueue, pvBuffer );\r
+\r
+                               if( xJustPeeking == pdFALSE )\r
+                               {\r
+                                       traceQUEUE_RECEIVE( pxQueue );\r
+\r
+                                       /* Actually removing data, not just peeking. */\r
+                                       --( pxQueue->uxMessagesWaiting );\r
+\r
+                                       #if ( configUSE_MUTEXES == 1 )\r
+                                       {\r
+                                               if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )\r
+                                               {\r
+                                                       /* Record the information required to implement\r
+                                                       priority inheritance should it become necessary. */\r
+                                                       pxQueue->pxMutexHolder = ( int8_t * ) pvTaskIncrementMutexHeldCount(); /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       #endif /* configUSE_MUTEXES */\r
+\r
+                                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
+                                       {\r
+                                               if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )\r
+                                               {\r
+                                                       queueYIELD_IF_USING_PREEMPTION();\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       traceQUEUE_PEEK( pxQueue );\r
+\r
+                                       /* The data is not being removed, so reset the read\r
+                                       pointer. */\r
+                                       pxQueue->u.pcReadFrom = pcOriginalReadPosition;\r
+\r
+                                       /* The data is being left in the queue, so see if there are\r
+                                       any other tasks waiting for the data. */\r
+                                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+                                       {\r
+                                               if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+                                               {\r
+                                                       /* The task waiting has a higher priority than this task. */\r
+                                                       queueYIELD_IF_USING_PREEMPTION();\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+\r
+                               taskEXIT_CRITICAL();\r
+                               return pdPASS;\r
+                       }\r
+                       else\r
+                       {\r
+                               if( xTicksToWait == ( TickType_t ) 0 )\r
+                               {\r
+                                       /* The queue was empty and no block time is specified (or\r
+                                       the block time has expired) so leave now. */\r
+                                       taskEXIT_CRITICAL();\r
+                                       traceQUEUE_RECEIVE_FAILED( pxQueue );\r
+                                       return errQUEUE_EMPTY;\r
+                               }\r
+                               else if( xEntryTimeSet == pdFALSE )\r
+                               {\r
+                                       /* The queue was empty and a block time was specified so\r
+                                       configure the timeout structure. */\r
+                                       vTaskSetTimeOutState( &xTimeOut );\r
+                                       xEntryTimeSet = pdTRUE;\r
+                               }\r
+                               else\r
+                               {\r
+                                       /* Entry time was already set. */\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               /* Interrupts and other tasks can send to and receive from the queue\r
+               now the critical section has been exited. */\r
+\r
+               vTaskSuspendAll();\r
+               prvLockQueue( pxQueue );\r
+\r
+               /* Update the timeout state to see if it has expired yet. */\r
+               if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )\r
+               {\r
+                       if( prvIsQueueEmpty( pxQueue ) != pdFALSE )\r
+                       {\r
+                               traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );\r
+\r
+                               #if ( configUSE_MUTEXES == 1 )\r
+                               {\r
+                                       if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )\r
+                                       {\r
+                                               taskENTER_CRITICAL();\r
+                                               {\r
+                                                       vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder );\r
+                                               }\r
+                                               taskEXIT_CRITICAL();\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               #endif\r
+\r
+                               vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );\r
+                               prvUnlockQueue( pxQueue );\r
+                               if( xTaskResumeAll() == pdFALSE )\r
+                               {\r
+                                       portYIELD_WITHIN_API();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               /* Try again. */\r
+                               prvUnlockQueue( pxQueue );\r
+                               ( void ) xTaskResumeAll();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       prvUnlockQueue( pxQueue );\r
+                       ( void ) xTaskResumeAll();\r
+                       traceQUEUE_RECEIVE_FAILED( pxQueue );\r
+                       return errQUEUE_EMPTY;\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void * const pvBuffer, BaseType_t * const pxHigherPriorityTaskWoken )\r
+{\r
+BaseType_t xReturn;\r
+UBaseType_t uxSavedInterruptStatus;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+       configASSERT( pxQueue );\r
+       configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
+\r
+       /* RTOS ports that support interrupt nesting have the concept of a maximum\r
+       system call (or maximum API call) interrupt priority.  Interrupts that are\r
+       above the maximum system call priority are kept permanently enabled, even\r
+       when the RTOS kernel is in a critical section, but cannot make any calls to\r
+       FreeRTOS API functions.  If configASSERT() is defined in FreeRTOSConfig.h\r
+       then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+       failure if a FreeRTOS API function is called from an interrupt that has been\r
+       assigned a priority above the configured maximum system call priority.\r
+       Only FreeRTOS functions that end in FromISR can be called from interrupts\r
+       that have been assigned a priority at or (logically) below the maximum\r
+       system call     interrupt priority.  FreeRTOS maintains a separate interrupt\r
+       safe API to ensure interrupt entry is as fast and as simple as possible.\r
+       More information (albeit Cortex-M specific) is provided on the following\r
+       link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+       portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+       uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
+       {\r
+               /* Cannot block in an ISR, so check there is data available. */\r
+               if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
+               {\r
+                       traceQUEUE_RECEIVE_FROM_ISR( pxQueue );\r
+\r
+                       prvCopyDataFromQueue( pxQueue, pvBuffer );\r
+                       --( pxQueue->uxMessagesWaiting );\r
+\r
+                       /* If the queue is locked the event list will not be modified.\r
+                       Instead update the lock count so the task that unlocks the queue\r
+                       will know that an ISR has removed data while the queue was\r
+                       locked. */\r
+                       if( pxQueue->xRxLock == queueUNLOCKED )\r
+                       {\r
+                               if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
+                               {\r
+                                       if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )\r
+                                       {\r
+                                               /* The task waiting has a higher priority than us so\r
+                                               force a context switch. */\r
+                                               if( pxHigherPriorityTaskWoken != NULL )\r
+                                               {\r
+                                                       *pxHigherPriorityTaskWoken = pdTRUE;\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               /* Increment the lock count so the task that unlocks the queue\r
+                               knows that data was removed while it was locked. */\r
+                               ++( pxQueue->xRxLock );\r
+                       }\r
+\r
+                       xReturn = pdPASS;\r
+               }\r
+               else\r
+               {\r
+                       xReturn = pdFAIL;\r
+                       traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue );\r
+               }\r
+       }\r
+       portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue,  void * const pvBuffer )\r
+{\r
+BaseType_t xReturn;\r
+UBaseType_t uxSavedInterruptStatus;\r
+int8_t *pcOriginalReadPosition;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+       configASSERT( pxQueue );\r
+       configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
+       configASSERT( pxQueue->uxItemSize != 0 ); /* Can't peek a semaphore. */\r
+\r
+       /* RTOS ports that support interrupt nesting have the concept of a maximum\r
+       system call (or maximum API call) interrupt priority.  Interrupts that are\r
+       above the maximum system call priority are kept permanently enabled, even\r
+       when the RTOS kernel is in a critical section, but cannot make any calls to\r
+       FreeRTOS API functions.  If configASSERT() is defined in FreeRTOSConfig.h\r
+       then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+       failure if a FreeRTOS API function is called from an interrupt that has been\r
+       assigned a priority above the configured maximum system call priority.\r
+       Only FreeRTOS functions that end in FromISR can be called from interrupts\r
+       that have been assigned a priority at or (logically) below the maximum\r
+       system call     interrupt priority.  FreeRTOS maintains a separate interrupt\r
+       safe API to ensure interrupt entry is as fast and as simple as possible.\r
+       More information (albeit Cortex-M specific) is provided on the following\r
+       link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+       portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+       uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
+       {\r
+               /* Cannot block in an ISR, so check there is data available. */\r
+               if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
+               {\r
+                       traceQUEUE_PEEK_FROM_ISR( pxQueue );\r
+\r
+                       /* Remember the read position so it can be reset as nothing is\r
+                       actually being removed from the queue. */\r
+                       pcOriginalReadPosition = pxQueue->u.pcReadFrom;\r
+                       prvCopyDataFromQueue( pxQueue, pvBuffer );\r
+                       pxQueue->u.pcReadFrom = pcOriginalReadPosition;\r
+\r
+                       xReturn = pdPASS;\r
+               }\r
+               else\r
+               {\r
+                       xReturn = pdFAIL;\r
+                       traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue );\r
+               }\r
+       }\r
+       portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue )\r
+{\r
+UBaseType_t uxReturn;\r
+\r
+       configASSERT( xQueue );\r
+\r
+       taskENTER_CRITICAL();\r
+       {\r
+               uxReturn = ( ( Queue_t * ) xQueue )->uxMessagesWaiting;\r
+       }\r
+       taskEXIT_CRITICAL();\r
+\r
+       return uxReturn;\r
+} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */\r
+/*-----------------------------------------------------------*/\r
+\r
+UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue )\r
+{\r
+UBaseType_t uxReturn;\r
+Queue_t *pxQueue;\r
+\r
+       pxQueue = ( Queue_t * ) xQueue;\r
+       configASSERT( pxQueue );\r
+\r
+       taskENTER_CRITICAL();\r
+       {\r
+               uxReturn = pxQueue->uxLength - pxQueue->uxMessagesWaiting;\r
+       }\r
+       taskEXIT_CRITICAL();\r
+\r
+       return uxReturn;\r
+} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */\r
+/*-----------------------------------------------------------*/\r
+\r
+UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue )\r
+{\r
+UBaseType_t uxReturn;\r
+\r
+       configASSERT( xQueue );\r
+\r
+       uxReturn = ( ( Queue_t * ) xQueue )->uxMessagesWaiting;\r
+\r
+       return uxReturn;\r
+} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */\r
+/*-----------------------------------------------------------*/\r
+\r
+void vQueueDelete( QueueHandle_t xQueue )\r
+{\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+       configASSERT( pxQueue );\r
+\r
+       traceQUEUE_DELETE( pxQueue );\r
+       #if ( configQUEUE_REGISTRY_SIZE > 0 )\r
+       {\r
+               vQueueUnregisterQueue( pxQueue );\r
+       }\r
+       #endif\r
+       vPortFree( pxQueue );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_TRACE_FACILITY == 1 )\r
+\r
+       UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue )\r
+       {\r
+               return ( ( Queue_t * ) xQueue )->uxQueueNumber;\r
+       }\r
+\r
+#endif /* configUSE_TRACE_FACILITY */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_TRACE_FACILITY == 1 )\r
+\r
+       void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber )\r
+       {\r
+               ( ( Queue_t * ) xQueue )->uxQueueNumber = uxQueueNumber;\r
+       }\r
+\r
+#endif /* configUSE_TRACE_FACILITY */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_TRACE_FACILITY == 1 )\r
+\r
+       uint8_t ucQueueGetQueueType( QueueHandle_t xQueue )\r
+       {\r
+               return ( ( Queue_t * ) xQueue )->ucQueueType;\r
+       }\r
+\r
+#endif /* configUSE_TRACE_FACILITY */\r
+/*-----------------------------------------------------------*/\r
+\r
+static BaseType_t prvCopyDataToQueue( Queue_t * const pxQueue, const void *pvItemToQueue, const BaseType_t xPosition )\r
+{\r
+BaseType_t xReturn = pdFALSE;\r
+\r
+       if( pxQueue->uxItemSize == ( UBaseType_t ) 0 )\r
+       {\r
+               #if ( configUSE_MUTEXES == 1 )\r
+               {\r
+                       if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )\r
+                       {\r
+                               /* The mutex is no longer being held. */\r
+                               xReturn = xTaskPriorityDisinherit( ( void * ) pxQueue->pxMutexHolder );\r
+                               pxQueue->pxMutexHolder = NULL;\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               #endif /* configUSE_MUTEXES */\r
+       }\r
+       else if( xPosition == queueSEND_TO_BACK )\r
+       {\r
+               ( void ) memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 MISRA exception as the casts are only redundant for some ports, plus previous logic ensures a null pointer can only be passed to memcpy() if the copy size is 0. */\r
+               pxQueue->pcWriteTo += pxQueue->uxItemSize;\r
+               if( pxQueue->pcWriteTo >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */\r
+               {\r
+                       pxQueue->pcWriteTo = pxQueue->pcHead;\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+       else\r
+       {\r
+               ( void ) memcpy( ( void * ) pxQueue->u.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+               pxQueue->u.pcReadFrom -= pxQueue->uxItemSize;\r
+               if( pxQueue->u.pcReadFrom < pxQueue->pcHead ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */\r
+               {\r
+                       pxQueue->u.pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize );\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               if( xPosition == queueOVERWRITE )\r
+               {\r
+                       if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
+                       {\r
+                               /* An item is not being added but overwritten, so subtract\r
+                               one from the recorded number of items in the queue so when\r
+                               one is added again below the number of recorded items remains\r
+                               correct. */\r
+                               --( pxQueue->uxMessagesWaiting );\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+\r
+       ++( pxQueue->uxMessagesWaiting );\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer )\r
+{\r
+       if( pxQueue->uxItemSize != ( UBaseType_t ) 0 )\r
+       {\r
+               pxQueue->u.pcReadFrom += pxQueue->uxItemSize;\r
+               if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as use of the relational operator is the cleanest solutions. */\r
+               {\r
+                       pxQueue->u.pcReadFrom = pxQueue->pcHead;\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+               ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 MISRA exception as the casts are only redundant for some ports.  Also previous logic ensures a null pointer can only be passed to memcpy() when the count is 0. */\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvUnlockQueue( Queue_t * const pxQueue )\r
+{\r
+       /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. */\r
+\r
+       /* The lock counts contains the number of extra data items placed or\r
+       removed from the queue while the queue was locked.  When a queue is\r
+       locked items can be added or removed, but the event lists cannot be\r
+       updated. */\r
+       taskENTER_CRITICAL();\r
+       {\r
+               /* See if data was added to the queue while it was locked. */\r
+               while( pxQueue->xTxLock > queueLOCKED_UNMODIFIED )\r
+               {\r
+                       /* Data was posted while the queue was locked.  Are any tasks\r
+                       blocked waiting for data to become available? */\r
+                       #if ( configUSE_QUEUE_SETS == 1 )\r
+                       {\r
+                               if( pxQueue->pxQueueSetContainer != NULL )\r
+                               {\r
+                                       if( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) == pdTRUE )\r
+                                       {\r
+                                               /* The queue is a member of a queue set, and posting to\r
+                                               the queue set caused a higher priority task to unblock.\r
+                                               A context switch is required. */\r
+                                               vTaskMissedYield();\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       /* Tasks that are removed from the event list will get added to\r
+                                       the pending ready list as the scheduler is still suspended. */\r
+                                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+                                       {\r
+                                               if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+                                               {\r
+                                                       /* The task waiting has a higher priority so record that a\r
+                                                       context switch is required. */\r
+                                                       vTaskMissedYield();\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               break;\r
+                                       }\r
+                               }\r
+                       }\r
+                       #else /* configUSE_QUEUE_SETS */\r
+                       {\r
+                               /* Tasks that are removed from the event list will get added to\r
+                               the pending ready list as the scheduler is still suspended. */\r
+                               if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+                               {\r
+                                       if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+                                       {\r
+                                               /* The task waiting has a higher priority so record that a\r
+                                               context switch is required. */\r
+                                               vTaskMissedYield();\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       break;\r
+                               }\r
+                       }\r
+                       #endif /* configUSE_QUEUE_SETS */\r
+\r
+                       --( pxQueue->xTxLock );\r
+               }\r
+\r
+               pxQueue->xTxLock = queueUNLOCKED;\r
+       }\r
+       taskEXIT_CRITICAL();\r
+\r
+       /* Do the same for the Rx lock. */\r
+       taskENTER_CRITICAL();\r
+       {\r
+               while( pxQueue->xRxLock > queueLOCKED_UNMODIFIED )\r
+               {\r
+                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
+                       {\r
+                               if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )\r
+                               {\r
+                                       vTaskMissedYield();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+\r
+                               --( pxQueue->xRxLock );\r
+                       }\r
+                       else\r
+                       {\r
+                               break;\r
+                       }\r
+               }\r
+\r
+               pxQueue->xRxLock = queueUNLOCKED;\r
+       }\r
+       taskEXIT_CRITICAL();\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static BaseType_t prvIsQueueEmpty( const Queue_t *pxQueue )\r
+{\r
+BaseType_t xReturn;\r
+\r
+       taskENTER_CRITICAL();\r
+       {\r
+               if( pxQueue->uxMessagesWaiting == ( UBaseType_t )  0 )\r
+               {\r
+                       xReturn = pdTRUE;\r
+               }\r
+               else\r
+               {\r
+                       xReturn = pdFALSE;\r
+               }\r
+       }\r
+       taskEXIT_CRITICAL();\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue )\r
+{\r
+BaseType_t xReturn;\r
+\r
+       configASSERT( xQueue );\r
+       if( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( UBaseType_t ) 0 )\r
+       {\r
+               xReturn = pdTRUE;\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFALSE;\r
+       }\r
+\r
+       return xReturn;\r
+} /*lint !e818 xQueue could not be pointer to const because it is a typedef. */\r
+/*-----------------------------------------------------------*/\r
+\r
+static BaseType_t prvIsQueueFull( const Queue_t *pxQueue )\r
+{\r
+BaseType_t xReturn;\r
+\r
+       taskENTER_CRITICAL();\r
+       {\r
+               if( pxQueue->uxMessagesWaiting == pxQueue->uxLength )\r
+               {\r
+                       xReturn = pdTRUE;\r
+               }\r
+               else\r
+               {\r
+                       xReturn = pdFALSE;\r
+               }\r
+       }\r
+       taskEXIT_CRITICAL();\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue )\r
+{\r
+BaseType_t xReturn;\r
+\r
+       configASSERT( xQueue );\r
+       if( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( ( Queue_t * ) xQueue )->uxLength )\r
+       {\r
+               xReturn = pdTRUE;\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFALSE;\r
+       }\r
+\r
+       return xReturn;\r
+} /*lint !e818 xQueue could not be pointer to const because it is a typedef. */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_CO_ROUTINES == 1 )\r
+\r
+       BaseType_t xQueueCRSend( QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait )\r
+       {\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+               /* If the queue is already full we may have to block.  A critical section\r
+               is required to prevent an interrupt removing something from the queue\r
+               between the check to see if the queue is full and blocking on the queue. */\r
+               portDISABLE_INTERRUPTS();\r
+               {\r
+                       if( prvIsQueueFull( pxQueue ) != pdFALSE )\r
+                       {\r
+                               /* The queue is full - do we want to block or just leave without\r
+                               posting? */\r
+                               if( xTicksToWait > ( TickType_t ) 0 )\r
+                               {\r
+                                       /* As this is called from a coroutine we cannot block directly, but\r
+                                       return indicating that we need to block. */\r
+                                       vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToSend ) );\r
+                                       portENABLE_INTERRUPTS();\r
+                                       return errQUEUE_BLOCKED;\r
+                               }\r
+                               else\r
+                               {\r
+                                       portENABLE_INTERRUPTS();\r
+                                       return errQUEUE_FULL;\r
+                               }\r
+                       }\r
+               }\r
+               portENABLE_INTERRUPTS();\r
+\r
+               portDISABLE_INTERRUPTS();\r
+               {\r
+                       if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
+                       {\r
+                               /* There is room in the queue, copy the data into the queue. */\r
+                               prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK );\r
+                               xReturn = pdPASS;\r
+\r
+                               /* Were any co-routines waiting for data to become available? */\r
+                               if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+                               {\r
+                                       /* In this instance the co-routine could be placed directly\r
+                                       into the ready list as we are within a critical section.\r
+                                       Instead the same pending ready list mechanism is used as if\r
+                                       the event were caused from within an interrupt. */\r
+                                       if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+                                       {\r
+                                               /* The co-routine waiting has a higher priority so record\r
+                                               that a yield might be appropriate. */\r
+                                               xReturn = errQUEUE_YIELD;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               xReturn = errQUEUE_FULL;\r
+                       }\r
+               }\r
+               portENABLE_INTERRUPTS();\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_CO_ROUTINES */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_CO_ROUTINES == 1 )\r
+\r
+       BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait )\r
+       {\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+               /* If the queue is already empty we may have to block.  A critical section\r
+               is required to prevent an interrupt adding something to the queue\r
+               between the check to see if the queue is empty and blocking on the queue. */\r
+               portDISABLE_INTERRUPTS();\r
+               {\r
+                       if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 )\r
+                       {\r
+                               /* There are no messages in the queue, do we want to block or just\r
+                               leave with nothing? */\r
+                               if( xTicksToWait > ( TickType_t ) 0 )\r
+                               {\r
+                                       /* As this is a co-routine we cannot block directly, but return\r
+                                       indicating that we need to block. */\r
+                                       vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToReceive ) );\r
+                                       portENABLE_INTERRUPTS();\r
+                                       return errQUEUE_BLOCKED;\r
+                               }\r
+                               else\r
+                               {\r
+                                       portENABLE_INTERRUPTS();\r
+                                       return errQUEUE_FULL;\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               portENABLE_INTERRUPTS();\r
+\r
+               portDISABLE_INTERRUPTS();\r
+               {\r
+                       if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
+                       {\r
+                               /* Data is available from the queue. */\r
+                               pxQueue->u.pcReadFrom += pxQueue->uxItemSize;\r
+                               if( pxQueue->u.pcReadFrom >= pxQueue->pcTail )\r
+                               {\r
+                                       pxQueue->u.pcReadFrom = pxQueue->pcHead;\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                               --( pxQueue->uxMessagesWaiting );\r
+                               ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
+\r
+                               xReturn = pdPASS;\r
+\r
+                               /* Were any co-routines waiting for space to become available? */\r
+                               if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
+                               {\r
+                                       /* In this instance the co-routine could be placed directly\r
+                                       into the ready list as we are within a critical section.\r
+                                       Instead the same pending ready list mechanism is used as if\r
+                                       the event were caused from within an interrupt. */\r
+                                       if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )\r
+                                       {\r
+                                               xReturn = errQUEUE_YIELD;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               xReturn = pdFAIL;\r
+                       }\r
+               }\r
+               portENABLE_INTERRUPTS();\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_CO_ROUTINES */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_CO_ROUTINES == 1 )\r
+\r
+       BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken )\r
+       {\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+               /* Cannot block within an ISR so if there is no space on the queue then\r
+               exit without doing anything. */\r
+               if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
+               {\r
+                       prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK );\r
+\r
+                       /* We only want to wake one co-routine per ISR, so check that a\r
+                       co-routine has not already been woken. */\r
+                       if( xCoRoutinePreviouslyWoken == pdFALSE )\r
+                       {\r
+                               if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+                               {\r
+                                       if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+                                       {\r
+                                               return pdTRUE;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               return xCoRoutinePreviouslyWoken;\r
+       }\r
+\r
+#endif /* configUSE_CO_ROUTINES */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_CO_ROUTINES == 1 )\r
+\r
+       BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxCoRoutineWoken )\r
+       {\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+               /* We cannot block from an ISR, so check there is data available. If\r
+               not then just leave without doing anything. */\r
+               if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
+               {\r
+                       /* Copy the data from the queue. */\r
+                       pxQueue->u.pcReadFrom += pxQueue->uxItemSize;\r
+                       if( pxQueue->u.pcReadFrom >= pxQueue->pcTail )\r
+                       {\r
+                               pxQueue->u.pcReadFrom = pxQueue->pcHead;\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+                       --( pxQueue->uxMessagesWaiting );\r
+                       ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
+\r
+                       if( ( *pxCoRoutineWoken ) == pdFALSE )\r
+                       {\r
+                               if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
+                               {\r
+                                       if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )\r
+                                       {\r
+                                               *pxCoRoutineWoken = pdTRUE;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       xReturn = pdPASS;\r
+               }\r
+               else\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_CO_ROUTINES */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configQUEUE_REGISTRY_SIZE > 0 )\r
+\r
+       void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcQueueName ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+       {\r
+       UBaseType_t ux;\r
+\r
+               /* See if there is an empty space in the registry.  A NULL name denotes\r
+               a free slot. */\r
+               for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ )\r
+               {\r
+                       if( xQueueRegistry[ ux ].pcQueueName == NULL )\r
+                       {\r
+                               /* Store the information on this queue. */\r
+                               xQueueRegistry[ ux ].pcQueueName = pcQueueName;\r
+                               xQueueRegistry[ ux ].xHandle = xQueue;\r
+\r
+                               traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName );\r
+                               break;\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+       }\r
+\r
+#endif /* configQUEUE_REGISTRY_SIZE */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configQUEUE_REGISTRY_SIZE > 0 )\r
+\r
+       void vQueueUnregisterQueue( QueueHandle_t xQueue )\r
+       {\r
+       UBaseType_t ux;\r
+\r
+               /* See if the handle of the queue being unregistered in actually in the\r
+               registry. */\r
+               for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ )\r
+               {\r
+                       if( xQueueRegistry[ ux ].xHandle == xQueue )\r
+                       {\r
+                               /* Set the name to NULL to show that this slot if free again. */\r
+                               xQueueRegistry[ ux ].pcQueueName = NULL;\r
+                               break;\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+\r
+       } /*lint !e818 xQueue could not be pointer to const because it is a typedef. */\r
+\r
+#endif /* configQUEUE_REGISTRY_SIZE */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_TIMERS == 1 )\r
+\r
+       void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely )\r
+       {\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
+               /* This function should not be called by application code hence the\r
+               'Restricted' in its name.  It is not part of the public API.  It is\r
+               designed for use by kernel code, and has special calling requirements.\r
+               It can result in vListInsert() being called on a list that can only\r
+               possibly ever have one item in it, so the list will be fast, but even\r
+               so it should be called with the scheduler locked and not from a critical\r
+               section. */\r
+\r
+               /* Only do anything if there are no messages in the queue.  This function\r
+               will not actually cause the task to block, just place it on a blocked\r
+               list.  It will not block until the scheduler is unlocked - at which\r
+               time a yield will be performed.  If an item is added to the queue while\r
+               the queue is locked, and the calling task blocks on the queue, then the\r
+               calling task will be immediately unblocked when the queue is unlocked. */\r
+               prvLockQueue( pxQueue );\r
+               if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0U )\r
+               {\r
+                       /* There is nothing in the queue, block for the specified period. */\r
+                       vTaskPlaceOnEventListRestricted( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait, xWaitIndefinitely );\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+               prvUnlockQueue( pxQueue );\r
+       }\r
+\r
+#endif /* configUSE_TIMERS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_QUEUE_SETS == 1 )\r
+\r
+       QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength )\r
+       {\r
+       QueueSetHandle_t pxQueue;\r
+\r
+               pxQueue = xQueueGenericCreate( uxEventQueueLength, sizeof( Queue_t * ), queueQUEUE_TYPE_SET );\r
+\r
+               return pxQueue;\r
+       }\r
+\r
+#endif /* configUSE_QUEUE_SETS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_QUEUE_SETS == 1 )\r
+\r
+       BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet )\r
+       {\r
+       BaseType_t xReturn;\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       if( ( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer != NULL )\r
+                       {\r
+                               /* Cannot add a queue/semaphore to more than one queue set. */\r
+                               xReturn = pdFAIL;\r
+                       }\r
+                       else if( ( ( Queue_t * ) xQueueOrSemaphore )->uxMessagesWaiting != ( UBaseType_t ) 0 )\r
+                       {\r
+                               /* Cannot add a queue/semaphore to a queue set if there are already\r
+                               items in the queue/semaphore. */\r
+                               xReturn = pdFAIL;\r
+                       }\r
+                       else\r
+                       {\r
+                               ( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer = xQueueSet;\r
+                               xReturn = pdPASS;\r
+                       }\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_QUEUE_SETS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_QUEUE_SETS == 1 )\r
+\r
+       BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet )\r
+       {\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxQueueOrSemaphore = ( Queue_t * ) xQueueOrSemaphore;\r
+\r
+               if( pxQueueOrSemaphore->pxQueueSetContainer != xQueueSet )\r
+               {\r
+                       /* The queue was not a member of the set. */\r
+                       xReturn = pdFAIL;\r
+               }\r
+               else if( pxQueueOrSemaphore->uxMessagesWaiting != ( UBaseType_t ) 0 )\r
+               {\r
+                       /* It is dangerous to remove a queue from a set when the queue is\r
+                       not empty because the queue set will still hold pending events for\r
+                       the queue. */\r
+                       xReturn = pdFAIL;\r
+               }\r
+               else\r
+               {\r
+                       taskENTER_CRITICAL();\r
+                       {\r
+                               /* The queue is no longer contained in the set. */\r
+                               pxQueueOrSemaphore->pxQueueSetContainer = NULL;\r
+                       }\r
+                       taskEXIT_CRITICAL();\r
+                       xReturn = pdPASS;\r
+               }\r
+\r
+               return xReturn;\r
+       } /*lint !e818 xQueueSet could not be declared as pointing to const as it is a typedef. */\r
+\r
+#endif /* configUSE_QUEUE_SETS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_QUEUE_SETS == 1 )\r
+\r
+       QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, TickType_t const xTicksToWait )\r
+       {\r
+       QueueSetMemberHandle_t xReturn = NULL;\r
+\r
+               ( void ) xQueueGenericReceive( ( QueueHandle_t ) xQueueSet, &xReturn, xTicksToWait, pdFALSE ); /*lint !e961 Casting from one typedef to another is not redundant. */\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_QUEUE_SETS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_QUEUE_SETS == 1 )\r
+\r
+       QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet )\r
+       {\r
+       QueueSetMemberHandle_t xReturn = NULL;\r
+\r
+               ( void ) xQueueReceiveFromISR( ( QueueHandle_t ) xQueueSet, &xReturn, NULL ); /*lint !e961 Casting from one typedef to another is not redundant. */\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_QUEUE_SETS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_QUEUE_SETS == 1 )\r
+\r
+       static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue, const BaseType_t xCopyPosition )\r
+       {\r
+       Queue_t *pxQueueSetContainer = pxQueue->pxQueueSetContainer;\r
+       BaseType_t xReturn = pdFALSE;\r
+\r
+               /* This function must be called form a critical section. */\r
+\r
+               configASSERT( pxQueueSetContainer );\r
+               configASSERT( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength );\r
+\r
+               if( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength )\r
+               {\r
+                       traceQUEUE_SEND( pxQueueSetContainer );\r
+\r
+                       /* The data copied is the handle of the queue that contains data. */\r
+                       xReturn = prvCopyDataToQueue( pxQueueSetContainer, &pxQueue, xCopyPosition );\r
+\r
+                       if( pxQueueSetContainer->xTxLock == queueUNLOCKED )\r
+                       {\r
+                               if( listLIST_IS_EMPTY( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) == pdFALSE )\r
+                               {\r
+                                       if( xTaskRemoveFromEventList( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) != pdFALSE )\r
+                                       {\r
+                                               /* The task waiting has a higher priority. */\r
+                                               xReturn = pdTRUE;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               ( pxQueueSetContainer->xTxLock )++;\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_QUEUE_SETS */\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
diff --git a/os/8.2.2/src/os/readme.txt b/os/8.2.2/src/os/readme.txt
new file mode 100644 (file)
index 0000000..81518ec
--- /dev/null
@@ -0,0 +1,17 @@
+Each real time kernel port consists of three files that contain the core kernel\r
+components and are common to every port, and one or more files that are \r
+specific to a particular microcontroller and or compiler.\r
+\r
++ The FreeRTOS/Source directory contains the three files that are common to \r
+every port - list.c, queue.c and tasks.c.  The kernel is contained within these \r
+three files.  croutine.c implements the optional co-routine functionality - which\r
+is normally only used on very memory limited systems.\r
+\r
++ The FreeRTOS/Source/Portable directory contains the files that are specific to \r
+a particular microcontroller and or compiler.\r
+\r
++ The FreeRTOS/Source/include directory contains the real time kernel header \r
+files.\r
+\r
+See the readme file in the FreeRTOS/Source/Portable directory for more \r
+information.
\ No newline at end of file
diff --git a/os/8.2.2/src/os/tasks.c b/os/8.2.2/src/os/tasks.c
new file mode 100644 (file)
index 0000000..c813ca5
--- /dev/null
@@ -0,0 +1,4449 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+/* Standard includes. */\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
+/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining\r
+all the API functions to use the MPU wrappers.  That should only be done when\r
+task.h is included from an application file. */\r
+#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+/* FreeRTOS includes. */\r
+#include "os/FreeRTOS.h"\r
+#include "os/task.h"\r
+#include "os/timers.h"\r
+#include "os/StackMacros.h"\r
+\r
+/* Lint e961 and e750 are suppressed as a MISRA exception justified because the\r
+MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the\r
+header files above, but not in this file, in order to generate the correct\r
+privileged Vs unprivileged linkage and placement. */\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */\r
+\r
+/* Set configUSE_STATS_FORMATTING_FUNCTIONS to 2 to include the stats formatting\r
+functions but without including stdio.h here. */\r
+#if ( configUSE_STATS_FORMATTING_FUNCTIONS == 1 )\r
+       /* At the bottom of this file are two optional functions that can be used\r
+       to generate human readable text from the raw data generated by the\r
+       uxTaskGetSystemState() function.  Note the formatting functions are provided\r
+       for convenience only, and are NOT considered part of the kernel. */\r
+       #include <stdio.h>\r
+#endif /* configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) */\r
+\r
+/* Sanity check the configuration. */\r
+#if( configUSE_TICKLESS_IDLE != 0 )\r
+       #if( INCLUDE_vTaskSuspend != 1 )\r
+               #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0\r
+       #endif /* INCLUDE_vTaskSuspend */\r
+#endif /* configUSE_TICKLESS_IDLE */\r
+\r
+/*\r
+ * Defines the size, in words, of the stack allocated to the idle task.\r
+ */\r
+#define tskIDLE_STACK_SIZE     configMINIMAL_STACK_SIZE\r
+\r
+#if( configUSE_PREEMPTION == 0 )\r
+       /* If the cooperative scheduler is being used then a yield should not be\r
+       performed just because a higher priority task has been woken. */\r
+       #define taskYIELD_IF_USING_PREEMPTION()\r
+#else\r
+       #define taskYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API()\r
+#endif\r
+\r
+/* Value that can be assigned to the eNotifyState member of the TCB. */\r
+typedef enum\r
+{\r
+       eNotWaitingNotification = 0,\r
+       eWaitingNotification,\r
+       eNotified\r
+} eNotifyValue;\r
+\r
+/*\r
+ * Task control block.  A task control block (TCB) is allocated for each task,\r
+ * and stores task state information, including a pointer to the task's context\r
+ * (the task's run time environment, including register values)\r
+ */\r
+typedef struct tskTaskControlBlock\r
+{\r
+       volatile StackType_t    *pxTopOfStack;  /*< Points to the location of the last item placed on the tasks stack.  THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */\r
+\r
+       #if ( portUSING_MPU_WRAPPERS == 1 )\r
+               xMPU_SETTINGS   xMPUSettings;           /*< The MPU settings are defined as part of the port layer.  THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */\r
+               BaseType_t              xUsingStaticallyAllocatedStack; /* Set to pdTRUE if the stack is a statically allocated array, and pdFALSE if the stack is dynamically allocated. */\r
+       #endif\r
+\r
+       ListItem_t                      xGenericListItem;       /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */\r
+       ListItem_t                      xEventListItem;         /*< Used to reference a task from an event list. */\r
+       UBaseType_t                     uxPriority;                     /*< The priority of the task.  0 is the lowest priority. */\r
+       StackType_t                     *pxStack;                       /*< Points to the start of the stack. */\r
+       char                            pcTaskName[ configMAX_TASK_NAME_LEN ];/*< Descriptive name given to the task when created.  Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+\r
+       #if ( portSTACK_GROWTH > 0 )\r
+               StackType_t             *pxEndOfStack;          /*< Points to the end of the stack on architectures where the stack grows up from low memory. */\r
+       #endif\r
+\r
+       #if ( portCRITICAL_NESTING_IN_TCB == 1 )\r
+               UBaseType_t     uxCriticalNesting;      /*< Holds the critical section nesting depth for ports that do not maintain their own count in the port layer. */\r
+       #endif\r
+\r
+       #if ( configUSE_TRACE_FACILITY == 1 )\r
+               UBaseType_t             uxTCBNumber;            /*< Stores a number that increments each time a TCB is created.  It allows debuggers to determine when a task has been deleted and then recreated. */\r
+               UBaseType_t     uxTaskNumber;           /*< Stores a number specifically for use by third party trace code. */\r
+       #endif\r
+\r
+       #if ( configUSE_MUTEXES == 1 )\r
+               UBaseType_t     uxBasePriority;         /*< The priority last assigned to the task - used by the priority inheritance mechanism. */\r
+               UBaseType_t     uxMutexesHeld;\r
+       #endif\r
+\r
+       #if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
+               TaskHookFunction_t pxTaskTag;\r
+       #endif\r
+\r
+       #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )\r
+               void *pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];\r
+       #endif\r
+\r
+       #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
+               uint32_t                ulRunTimeCounter;       /*< Stores the amount of time the task has spent in the Running state. */\r
+       #endif\r
+\r
+       #if ( configUSE_NEWLIB_REENTRANT == 1 )\r
+               /* Allocate a Newlib reent structure that is specific to this task.\r
+               Note Newlib support has been included by popular demand, but is not\r
+               used by the FreeRTOS maintainers themselves.  FreeRTOS is not\r
+               responsible for resulting newlib operation.  User must be familiar with\r
+               newlib and must provide system-wide implementations of the necessary\r
+               stubs. Be warned that (at the time of writing) the current newlib design\r
+               implements a system-wide malloc() that must be provided with locks. */\r
+               struct  _reent xNewLib_reent;\r
+       #endif\r
+\r
+       #if ( configUSE_TASK_NOTIFICATIONS == 1 )\r
+               volatile uint32_t ulNotifiedValue;\r
+               volatile eNotifyValue eNotifyState;\r
+       #endif\r
+\r
+} tskTCB;\r
+\r
+/* The old tskTCB name is maintained above then typedefed to the new TCB_t name\r
+below to enable the use of older kernel aware debuggers. */\r
+typedef tskTCB TCB_t;\r
+\r
+/*\r
+ * Some kernel aware debuggers require the data the debugger needs access to to\r
+ * be global, rather than file scope.\r
+ */\r
+#ifdef portREMOVE_STATIC_QUALIFIER\r
+       #define static\r
+#endif\r
+\r
+/*lint -e956 A manual analysis and inspection has been used to determine which\r
+static variables must be declared volatile. */\r
+\r
+PRIVILEGED_DATA TCB_t * volatile pxCurrentTCB = NULL;\r
+\r
+/* Lists for ready and blocked tasks. --------------------*/\r
+PRIVILEGED_DATA static List_t pxReadyTasksLists[ configMAX_PRIORITIES ];/*< Prioritised ready tasks. */\r
+PRIVILEGED_DATA static List_t xDelayedTaskList1;                                               /*< Delayed tasks. */\r
+PRIVILEGED_DATA static List_t xDelayedTaskList2;                                               /*< Delayed tasks (two lists are used - one for delays that have overflowed the current tick count. */\r
+PRIVILEGED_DATA static List_t * volatile pxDelayedTaskList;                            /*< Points to the delayed task list currently being used. */\r
+PRIVILEGED_DATA static List_t * volatile pxOverflowDelayedTaskList;            /*< Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count. */\r
+PRIVILEGED_DATA static List_t xPendingReadyList;                                               /*< Tasks that have been readied while the scheduler was suspended.  They will be moved to the ready list when the scheduler is resumed. */\r
+\r
+#if ( INCLUDE_vTaskDelete == 1 )\r
+\r
+       PRIVILEGED_DATA static List_t xTasksWaitingTermination;                         /*< Tasks that have been deleted - but their memory not yet freed. */\r
+       PRIVILEGED_DATA static volatile UBaseType_t uxTasksDeleted = ( UBaseType_t ) 0U;\r
+\r
+#endif\r
+\r
+#if ( INCLUDE_vTaskSuspend == 1 )\r
+\r
+       PRIVILEGED_DATA static List_t xSuspendedTaskList;                                       /*< Tasks that are currently suspended. */\r
+\r
+#endif\r
+\r
+#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )\r
+\r
+       PRIVILEGED_DATA static TaskHandle_t xIdleTaskHandle = NULL;                     /*< Holds the handle of the idle task.  The idle task is created automatically when the scheduler is started. */\r
+\r
+#endif\r
+\r
+/* Other file private variables. --------------------------------*/\r
+PRIVILEGED_DATA static volatile UBaseType_t uxCurrentNumberOfTasks     = ( UBaseType_t ) 0U;\r
+PRIVILEGED_DATA static volatile TickType_t xTickCount                          = ( TickType_t ) 0U;\r
+PRIVILEGED_DATA static volatile UBaseType_t uxTopReadyPriority                 = tskIDLE_PRIORITY;\r
+PRIVILEGED_DATA static volatile BaseType_t xSchedulerRunning           = pdFALSE;\r
+PRIVILEGED_DATA static volatile UBaseType_t uxPendedTicks                      = ( UBaseType_t ) 0U;\r
+PRIVILEGED_DATA static volatile BaseType_t xYieldPending                       = pdFALSE;\r
+PRIVILEGED_DATA static volatile BaseType_t xNumOfOverflows                     = ( BaseType_t ) 0;\r
+PRIVILEGED_DATA static UBaseType_t uxTaskNumber                                        = ( UBaseType_t ) 0U;\r
+PRIVILEGED_DATA static volatile TickType_t xNextTaskUnblockTime                = ( TickType_t ) 0U; /* Initialised to portMAX_DELAY; before the scheduler starts. */\r
+\r
+/* Context switches are held pending while the scheduler is suspended.  Also,\r
+interrupts must not manipulate the xGenericListItem of a TCB, or any of the\r
+lists the xGenericListItem can be referenced from, if the scheduler is suspended.\r
+If an interrupt needs to unblock a task while the scheduler is suspended then it\r
+moves the task's event list item into the xPendingReadyList, ready for the\r
+kernel to move the task from the pending ready list into the real ready list\r
+when the scheduler is unsuspended.  The pending ready list itself can only be\r
+accessed from a critical section. */\r
+PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended       = ( UBaseType_t ) pdFALSE;\r
+\r
+#if ( configGENERATE_RUN_TIME_STATS == 1 )\r
+\r
+       PRIVILEGED_DATA static uint32_t ulTaskSwitchedInTime = 0UL;     /*< Holds the value of a timer/counter the last time a task was switched in. */\r
+       PRIVILEGED_DATA static uint32_t ulTotalRunTime = 0UL;           /*< Holds the total amount of execution time as defined by the run time counter clock. */\r
+\r
+#endif\r
+\r
+/*lint +e956 */\r
+\r
+/* Debugging and trace facilities private variables and macros. ------------*/\r
+\r
+/*\r
+ * The value used to fill the stack of a task when the task is created.  This\r
+ * is used purely for checking the high water mark for tasks.\r
+ */\r
+#define tskSTACK_FILL_BYTE     ( 0xa5U )\r
+\r
+/*\r
+ * Macros used by vListTask to indicate which state a task is in.\r
+ */\r
+#define tskBLOCKED_CHAR                ( 'B' )\r
+#define tskREADY_CHAR          ( 'R' )\r
+#define tskDELETED_CHAR                ( 'D' )\r
+#define tskSUSPENDED_CHAR      ( 'S' )\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 )\r
+\r
+       /* If configUSE_PORT_OPTIMISED_TASK_SELECTION is 0 then task selection is\r
+       performed in a generic way that is not optimised to any particular\r
+       microcontroller architecture. */\r
+\r
+       /* uxTopReadyPriority holds the priority of the highest priority ready\r
+       state task. */\r
+       #define taskRECORD_READY_PRIORITY( uxPriority )                                                                                                         \\r
+       {                                                                                                                                                                                                       \\r
+               if( ( uxPriority ) > uxTopReadyPriority )                                                                                                               \\r
+               {                                                                                                                                                                                               \\r
+                       uxTopReadyPriority = ( uxPriority );                                                                                                            \\r
+               }                                                                                                                                                                                               \\r
+       } /* taskRECORD_READY_PRIORITY */\r
+\r
+       /*-----------------------------------------------------------*/\r
+\r
+       #define taskSELECT_HIGHEST_PRIORITY_TASK()                                                                                                                      \\r
+       {                                                                                                                                                                                                       \\r
+               /* Find the highest priority queue that contains ready tasks. */                                                                \\r
+               while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) )                                              \\r
+               {                                                                                                                                                                                               \\r
+                       configASSERT( uxTopReadyPriority );                                                                                                                     \\r
+                       --uxTopReadyPriority;                                                                                                                                           \\r
+               }                                                                                                                                                                                               \\r
+                                                                                                                                                                                                               \\r
+               /* listGET_OWNER_OF_NEXT_ENTRY indexes through the list, so the tasks of                                                \\r
+               the     same priority get an equal share of the processor time. */                                                                      \\r
+               listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );              \\r
+       } /* taskSELECT_HIGHEST_PRIORITY_TASK */\r
+\r
+       /*-----------------------------------------------------------*/\r
+\r
+       /* Define away taskRESET_READY_PRIORITY() and portRESET_READY_PRIORITY() as\r
+       they are only required when a port optimised method of task selection is\r
+       being used. */\r
+       #define taskRESET_READY_PRIORITY( uxPriority )\r
+       #define portRESET_READY_PRIORITY( uxPriority, uxTopReadyPriority )\r
+\r
+#else /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
+\r
+       /* If configUSE_PORT_OPTIMISED_TASK_SELECTION is 1 then task selection is\r
+       performed in a way that is tailored to the particular microcontroller\r
+       architecture being used. */\r
+\r
+       /* A port optimised version is provided.  Call the port defined macros. */\r
+       #define taskRECORD_READY_PRIORITY( uxPriority ) portRECORD_READY_PRIORITY( uxPriority, uxTopReadyPriority )\r
+\r
+       /*-----------------------------------------------------------*/\r
+\r
+       #define taskSELECT_HIGHEST_PRIORITY_TASK()                                                                                                              \\r
+       {                                                                                                                                                                                               \\r
+       UBaseType_t uxTopPriority;                                                                                                                                              \\r
+                                                                                                                                                                                                       \\r
+               /* Find the highest priority queue that contains ready tasks. */                                                        \\r
+               portGET_HIGHEST_PRIORITY( uxTopPriority, uxTopReadyPriority );                                                          \\r
+               configASSERT( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ uxTopPriority ] ) ) > 0 );         \\r
+               listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopPriority ] ) );           \\r
+       } /* taskSELECT_HIGHEST_PRIORITY_TASK() */\r
+\r
+       /*-----------------------------------------------------------*/\r
+\r
+       /* A port optimised version is provided, call it only if the TCB being reset\r
+       is being referenced from a ready list.  If it is referenced from a delayed\r
+       or suspended list then it won't be in a ready list. */\r
+       #define taskRESET_READY_PRIORITY( uxPriority )                                                                                                          \\r
+       {                                                                                                                                                                                                       \\r
+               if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ ( uxPriority ) ] ) ) == ( UBaseType_t ) 0 )  \\r
+               {                                                                                                                                                                                               \\r
+                       portRESET_READY_PRIORITY( ( uxPriority ), ( uxTopReadyPriority ) );                                                     \\r
+               }                                                                                                                                                                                               \\r
+       }\r
+\r
+#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* pxDelayedTaskList and pxOverflowDelayedTaskList are switched when the tick\r
+count overflows. */\r
+#define taskSWITCH_DELAYED_LISTS()                                                                                                                                     \\r
+{                                                                                                                                                                                                      \\r
+       List_t *pxTemp;                                                                                                                                                                 \\r
+                                                                                                                                                                                                       \\r
+       /* The delayed tasks list should be empty when the lists are switched. */                                               \\r
+       configASSERT( ( listLIST_IS_EMPTY( pxDelayedTaskList ) ) );                                                                             \\r
+                                                                                                                                                                                                       \\r
+       pxTemp = pxDelayedTaskList;                                                                                                                                             \\r
+       pxDelayedTaskList = pxOverflowDelayedTaskList;                                                                                                  \\r
+       pxOverflowDelayedTaskList = pxTemp;                                                                                                                             \\r
+       xNumOfOverflows++;                                                                                                                                                              \\r
+       prvResetNextTaskUnblockTime();                                                                                                                                  \\r
+}\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Place the task represented by pxTCB into the appropriate ready list for\r
+ * the task.  It is inserted at the end of the list.\r
+ */\r
+#define prvAddTaskToReadyList( pxTCB )                                                                                                                         \\r
+       traceMOVED_TASK_TO_READY_STATE( pxTCB );                                                                                                                \\r
+       taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority );                                                                                             \\r
+       vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xGenericListItem ) )\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Several functions take an TaskHandle_t parameter that can optionally be NULL,\r
+ * where NULL is used to indicate that the handle of the currently executing\r
+ * task should be used in place of the parameter.  This macro simply checks to\r
+ * see if the parameter is NULL and returns a pointer to the appropriate TCB.\r
+ */\r
+#define prvGetTCBFromHandle( pxHandle ) ( ( ( pxHandle ) == NULL ) ? ( TCB_t * ) pxCurrentTCB : ( TCB_t * ) ( pxHandle ) )\r
+\r
+/* The item value of the event list item is normally used to hold the priority\r
+of the task to which it belongs (coded to allow it to be held in reverse\r
+priority order).  However, it is occasionally borrowed for other purposes.  It\r
+is important its value is not updated due to a task priority change while it is\r
+being used for another purpose.  The following bit definition is used to inform\r
+the scheduler that the value should not be changed - in which case it is the\r
+responsibility of whichever module is using the value to ensure it gets set back\r
+to its original value when it is released. */\r
+#if configUSE_16_BIT_TICKS == 1\r
+       #define taskEVENT_LIST_ITEM_VALUE_IN_USE        0x8000U\r
+#else\r
+       #define taskEVENT_LIST_ITEM_VALUE_IN_USE        0x80000000UL\r
+#endif\r
+\r
+/* Callback function prototypes. --------------------------*/\r
+#if configCHECK_FOR_STACK_OVERFLOW > 0\r
+       extern void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName );\r
+#endif\r
+\r
+#if configUSE_TICK_HOOK > 0\r
+       extern void vApplicationTickHook( void );\r
+#endif\r
+\r
+/* File private functions. --------------------------------*/\r
+\r
+/*\r
+ * Utility to ready a TCB for a given task.  Mainly just copies the parameters\r
+ * into the TCB structure.\r
+ */\r
+static void prvInitialiseTCBVariables( TCB_t * const pxTCB, const char * const pcName, UBaseType_t uxPriority, const MemoryRegion_t * const xRegions, const uint16_t usStackDepth ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+\r
+/**\r
+ * Utility task that simply returns pdTRUE if the task referenced by xTask is\r
+ * currently in the Suspended state, or pdFALSE if the task referenced by xTask\r
+ * is in any other state.\r
+ */\r
+#if ( INCLUDE_vTaskSuspend == 1 )\r
+       static BaseType_t prvTaskIsTaskSuspended( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+#endif /* INCLUDE_vTaskSuspend */\r
+\r
+/*\r
+ * Utility to ready all the lists used by the scheduler.  This is called\r
+ * automatically upon the creation of the first task.\r
+ */\r
+static void prvInitialiseTaskLists( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * The idle task, which as all tasks is implemented as a never ending loop.\r
+ * The idle task is automatically created and added to the ready lists upon\r
+ * creation of the first user task.\r
+ *\r
+ * The portTASK_FUNCTION_PROTO() macro is used to allow port/compiler specific\r
+ * language extensions.  The equivalent prototype for this function is:\r
+ *\r
+ * void prvIdleTask( void *pvParameters );\r
+ *\r
+ */\r
+static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters );\r
+\r
+/*\r
+ * Utility to free all memory allocated by the scheduler to hold a TCB,\r
+ * including the stack pointed to by the TCB.\r
+ *\r
+ * This does not free memory allocated by the task itself (i.e. memory\r
+ * allocated by calls to pvPortMalloc from within the tasks application code).\r
+ */\r
+#if ( INCLUDE_vTaskDelete == 1 )\r
+\r
+       static void prvDeleteTCB( TCB_t *pxTCB ) PRIVILEGED_FUNCTION;\r
+\r
+#endif\r
+\r
+/*\r
+ * Used only by the idle task.  This checks to see if anything has been placed\r
+ * in the list of tasks waiting to be deleted.  If so the task is cleaned up\r
+ * and its TCB deleted.\r
+ */\r
+static void prvCheckTasksWaitingTermination( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * The currently executing task is entering the Blocked state.  Add the task to\r
+ * either the current or the overflow delayed task list.\r
+ */\r
+static void prvAddCurrentTaskToDelayedList( const TickType_t xTimeToWake ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Allocates memory from the heap for a TCB and associated stack.  Checks the\r
+ * allocation was successful.\r
+ */\r
+static TCB_t *prvAllocateTCBAndStack( const uint16_t usStackDepth, StackType_t * const puxStackBuffer ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Fills an TaskStatus_t structure with information on each task that is\r
+ * referenced from the pxList list (which may be a ready list, a delayed list,\r
+ * a suspended list, etc.).\r
+ *\r
+ * THIS FUNCTION IS INTENDED FOR DEBUGGING ONLY, AND SHOULD NOT BE CALLED FROM\r
+ * NORMAL APPLICATION CODE.\r
+ */\r
+#if ( configUSE_TRACE_FACILITY == 1 )\r
+\r
+       static UBaseType_t prvListTaskWithinSingleList( TaskStatus_t *pxTaskStatusArray, List_t *pxList, eTaskState eState ) PRIVILEGED_FUNCTION;\r
+\r
+#endif\r
+\r
+/*\r
+ * When a task is created, the stack of the task is filled with a known value.\r
+ * This function determines the 'high water mark' of the task stack by\r
+ * determining how much of the stack remains at the original preset value.\r
+ */\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )\r
+\r
+       static uint16_t prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte ) PRIVILEGED_FUNCTION;\r
+\r
+#endif\r
+\r
+/*\r
+ * Return the amount of time, in ticks, that will pass before the kernel will\r
+ * next move a task from the Blocked state to the Running state.\r
+ *\r
+ * This conditional compilation should use inequality to 0, not equality to 1.\r
+ * This is to ensure portSUPPRESS_TICKS_AND_SLEEP() can be called when user\r
+ * defined low power mode implementations require configUSE_TICKLESS_IDLE to be\r
+ * set to a value other than 1.\r
+ */\r
+#if ( configUSE_TICKLESS_IDLE != 0 )\r
+\r
+       static TickType_t prvGetExpectedIdleTime( void ) PRIVILEGED_FUNCTION;\r
+\r
+#endif\r
+\r
+/*\r
+ * Set xNextTaskUnblockTime to the time at which the next Blocked state task\r
+ * will exit the Blocked state.\r
+ */\r
+static void prvResetNextTaskUnblockTime( void );\r
+\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) )\r
+\r
+       /*\r
+        * Helper function used to pad task names with spaces when printing out\r
+        * human readable tables of task information.\r
+        */\r
+       static char *prvWriteNameToBuffer( char *pcBuffer, const char *pcTaskName );\r
+\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+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 ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+{\r
+BaseType_t xReturn;\r
+TCB_t * pxNewTCB;\r
+StackType_t *pxTopOfStack;\r
+\r
+       configASSERT( pxTaskCode );\r
+       configASSERT( ( ( uxPriority & ( UBaseType_t ) ( ~portPRIVILEGE_BIT ) ) < ( UBaseType_t ) configMAX_PRIORITIES ) );\r
+\r
+       /* Allocate the memory required by the TCB and stack for the new task,\r
+       checking that the allocation was successful. */\r
+       pxNewTCB = prvAllocateTCBAndStack( usStackDepth, puxStackBuffer );\r
+\r
+       if( pxNewTCB != NULL )\r
+       {\r
+               #if( portUSING_MPU_WRAPPERS == 1 )\r
+                       /* Should the task be created in privileged mode? */\r
+                       BaseType_t xRunPrivileged;\r
+                       if( ( uxPriority & portPRIVILEGE_BIT ) != 0U )\r
+                       {\r
+                               xRunPrivileged = pdTRUE;\r
+                       }\r
+                       else\r
+                       {\r
+                               xRunPrivileged = pdFALSE;\r
+                       }\r
+                       uxPriority &= ~portPRIVILEGE_BIT;\r
+\r
+                       if( puxStackBuffer != NULL )\r
+                       {\r
+                               /* The application provided its own stack.  Note this so no\r
+                               attempt is made to delete the stack should that task be\r
+                               deleted. */\r
+                               pxNewTCB->xUsingStaticallyAllocatedStack = pdTRUE;\r
+                       }\r
+                       else\r
+                       {\r
+                               /* The stack was allocated dynamically.  Note this so it can be\r
+                               deleted again if the task is deleted. */\r
+                               pxNewTCB->xUsingStaticallyAllocatedStack = pdFALSE;\r
+                       }\r
+               #endif /* portUSING_MPU_WRAPPERS == 1 */\r
+\r
+               /* Calculate the top of stack address.  This depends on whether the\r
+               stack grows from high memory to low (as per the 80x86) or vice versa.\r
+               portSTACK_GROWTH is used to make the result positive or negative as\r
+               required by the port. */\r
+               #if( portSTACK_GROWTH < 0 )\r
+               {\r
+                       pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - ( uint16_t ) 1 );\r
+                       pxTopOfStack = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); /*lint !e923 MISRA exception.  Avoiding casts between pointers and integers is not practical.  Size differences accounted for using portPOINTER_SIZE_TYPE type. */\r
+\r
+                       /* Check the alignment of the calculated top of stack is correct. */\r
+                       configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );\r
+               }\r
+               #else /* portSTACK_GROWTH */\r
+               {\r
+                       pxTopOfStack = pxNewTCB->pxStack;\r
+\r
+                       /* Check the alignment of the stack buffer is correct. */\r
+                       configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxNewTCB->pxStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );\r
+\r
+                       /* If we want to use stack checking on architectures that use\r
+                       a positive stack growth direction then we also need to store the\r
+                       other extreme of the stack space. */\r
+                       pxNewTCB->pxEndOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 );\r
+               }\r
+               #endif /* portSTACK_GROWTH */\r
+\r
+               /* Setup the newly allocated TCB with the initial state of the task. */\r
+               prvInitialiseTCBVariables( pxNewTCB, pcName, uxPriority, xRegions, usStackDepth );\r
+\r
+               /* Initialize the TCB stack to look as if the task was already running,\r
+               but had been interrupted by the scheduler.  The return address is set\r
+               to the start of the task function. Once the stack has been initialised\r
+               the     top of stack variable is updated. */\r
+               #if( portUSING_MPU_WRAPPERS == 1 )\r
+               {\r
+                       pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters, xRunPrivileged );\r
+               }\r
+               #else /* portUSING_MPU_WRAPPERS */\r
+               {\r
+                       pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters );\r
+               }\r
+               #endif /* portUSING_MPU_WRAPPERS */\r
+\r
+               if( ( void * ) pxCreatedTask != NULL )\r
+               {\r
+                       /* Pass the TCB out - in an anonymous way.  The calling function/\r
+                       task can use this as a handle to delete the task later if\r
+                       required.*/\r
+                       *pxCreatedTask = ( TaskHandle_t ) pxNewTCB;\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               /* Ensure interrupts don't access the task lists while they are being\r
+               updated. */\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       uxCurrentNumberOfTasks++;\r
+                       if( pxCurrentTCB == NULL )\r
+                       {\r
+                               /* There are no other tasks, or all the other tasks are in\r
+                               the suspended state - make this the current task. */\r
+                               pxCurrentTCB =  pxNewTCB;\r
+\r
+                               if( uxCurrentNumberOfTasks == ( UBaseType_t ) 1 )\r
+                               {\r
+                                       /* This is the first task to be created so do the preliminary\r
+                                       initialisation required.  We will not recover if this call\r
+                                       fails, but we will report the failure. */\r
+                                       prvInitialiseTaskLists();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               /* If the scheduler is not already running, make this task the\r
+                               current task if it is the highest priority task to be created\r
+                               so far. */\r
+                               if( xSchedulerRunning == pdFALSE )\r
+                               {\r
+                                       if( pxCurrentTCB->uxPriority <= uxPriority )\r
+                                       {\r
+                                               pxCurrentTCB = pxNewTCB;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+\r
+                       uxTaskNumber++;\r
+\r
+                       #if ( configUSE_TRACE_FACILITY == 1 )\r
+                       {\r
+                               /* Add a counter into the TCB for tracing only. */\r
+                               pxNewTCB->uxTCBNumber = uxTaskNumber;\r
+                       }\r
+                       #endif /* configUSE_TRACE_FACILITY */\r
+                       traceTASK_CREATE( pxNewTCB );\r
+\r
+                       prvAddTaskToReadyList( pxNewTCB );\r
+\r
+                       xReturn = pdPASS;\r
+                       portSETUP_TCB( pxNewTCB );\r
+               }\r
+               taskEXIT_CRITICAL();\r
+       }\r
+       else\r
+       {\r
+               xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;\r
+               traceTASK_CREATE_FAILED();\r
+       }\r
+\r
+       if( xReturn == pdPASS )\r
+       {\r
+               if( xSchedulerRunning != pdFALSE )\r
+               {\r
+                       /* If the created task is of a higher priority than the current task\r
+                       then it should run now. */\r
+                       if( pxCurrentTCB->uxPriority < uxPriority )\r
+                       {\r
+                               taskYIELD_IF_USING_PREEMPTION();\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_vTaskDelete == 1 )\r
+\r
+       void vTaskDelete( TaskHandle_t xTaskToDelete )\r
+       {\r
+       TCB_t *pxTCB;\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       /* If null is passed in here then it is the calling task that is\r
+                       being deleted. */\r
+                       pxTCB = prvGetTCBFromHandle( xTaskToDelete );\r
+\r
+                       /* Remove task from the ready list and place in the     termination list.\r
+                       This will stop the task from be scheduled.  The idle task will check\r
+                       the termination list and free up any memory allocated by the\r
+                       scheduler for the TCB and stack. */\r
+                       if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+                       {\r
+                               taskRESET_READY_PRIORITY( pxTCB->uxPriority );\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       /* Is the task waiting on an event also? */\r
+                       if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL )\r
+                       {\r
+                               ( void ) uxListRemove( &( pxTCB->xEventListItem ) );\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       vListInsertEnd( &xTasksWaitingTermination, &( pxTCB->xGenericListItem ) );\r
+\r
+                       /* Increment the ucTasksDeleted variable so the idle task knows\r
+                       there is a task that has been deleted and that it should therefore\r
+                       check the xTasksWaitingTermination list. */\r
+                       ++uxTasksDeleted;\r
+\r
+                       /* Increment the uxTaskNumberVariable also so kernel aware debuggers\r
+                       can detect that the task lists need re-generating. */\r
+                       uxTaskNumber++;\r
+\r
+                       traceTASK_DELETE( pxTCB );\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               /* Force a reschedule if it is the currently running task that has just\r
+               been deleted. */\r
+               if( xSchedulerRunning != pdFALSE )\r
+               {\r
+                       if( pxTCB == pxCurrentTCB )\r
+                       {\r
+                               configASSERT( uxSchedulerSuspended == 0 );\r
+\r
+                               /* The pre-delete hook is primarily for the Windows simulator,\r
+                               in which Windows specific clean up operations are performed,\r
+                               after which it is not possible to yield away from this task -\r
+                               hence xYieldPending is used to latch that a context switch is\r
+                               required. */\r
+                               portPRE_TASK_DELETE_HOOK( pxTCB, &xYieldPending );\r
+                               portYIELD_WITHIN_API();\r
+                       }\r
+                       else\r
+                       {\r
+                               /* Reset the next expected unblock time in case it referred to\r
+                               the task that has just been deleted. */\r
+                               taskENTER_CRITICAL();\r
+                               {\r
+                                       prvResetNextTaskUnblockTime();\r
+                               }\r
+                               taskEXIT_CRITICAL();\r
+                       }\r
+               }\r
+       }\r
+\r
+#endif /* INCLUDE_vTaskDelete */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_vTaskDelayUntil == 1 )\r
+\r
+       void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement )\r
+       {\r
+       TickType_t xTimeToWake;\r
+       BaseType_t xAlreadyYielded, xShouldDelay = pdFALSE;\r
+\r
+               configASSERT( pxPreviousWakeTime );\r
+               configASSERT( ( xTimeIncrement > 0U ) );\r
+               configASSERT( uxSchedulerSuspended == 0 );\r
+\r
+               vTaskSuspendAll();\r
+               {\r
+                       /* Minor optimisation.  The tick count cannot change in this\r
+                       block. */\r
+                       const TickType_t xConstTickCount = xTickCount;\r
+\r
+                       /* Generate the tick time at which the task wants to wake. */\r
+                       xTimeToWake = *pxPreviousWakeTime + xTimeIncrement;\r
+\r
+                       if( xConstTickCount < *pxPreviousWakeTime )\r
+                       {\r
+                               /* The tick count has overflowed since this function was\r
+                               lasted called.  In this case the only time we should ever\r
+                               actually delay is if the wake time has also     overflowed,\r
+                               and the wake time is greater than the tick time.  When this\r
+                               is the case it is as if neither time had overflowed. */\r
+                               if( ( xTimeToWake < *pxPreviousWakeTime ) && ( xTimeToWake > xConstTickCount ) )\r
+                               {\r
+                                       xShouldDelay = pdTRUE;\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               /* The tick time has not overflowed.  In this case we will\r
+                               delay if either the wake time has overflowed, and/or the\r
+                               tick time is less than the wake time. */\r
+                               if( ( xTimeToWake < *pxPreviousWakeTime ) || ( xTimeToWake > xConstTickCount ) )\r
+                               {\r
+                                       xShouldDelay = pdTRUE;\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+\r
+                       /* Update the wake time ready for the next call. */\r
+                       *pxPreviousWakeTime = xTimeToWake;\r
+\r
+                       if( xShouldDelay != pdFALSE )\r
+                       {\r
+                               traceTASK_DELAY_UNTIL();\r
+\r
+                               /* Remove the task from the ready list before adding it to the\r
+                               blocked list as the same list item is used for both lists. */\r
+                               if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+                               {\r
+                                       /* The current task must be in a ready list, so there is\r
+                                       no need to check, and the port reset macro can be called\r
+                                       directly. */\r
+                                       portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+\r
+                               prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               xAlreadyYielded = xTaskResumeAll();\r
+\r
+               /* Force a reschedule if xTaskResumeAll has not already done so, we may\r
+               have put ourselves to sleep. */\r
+               if( xAlreadyYielded == pdFALSE )\r
+               {\r
+                       portYIELD_WITHIN_API();\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+\r
+#endif /* INCLUDE_vTaskDelayUntil */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_vTaskDelay == 1 )\r
+\r
+       void vTaskDelay( const TickType_t xTicksToDelay )\r
+       {\r
+       TickType_t xTimeToWake;\r
+       BaseType_t xAlreadyYielded = pdFALSE;\r
+\r
+\r
+               /* A delay time of zero just forces a reschedule. */\r
+               if( xTicksToDelay > ( TickType_t ) 0U )\r
+               {\r
+                       configASSERT( uxSchedulerSuspended == 0 );\r
+                       vTaskSuspendAll();\r
+                       {\r
+                               traceTASK_DELAY();\r
+\r
+                               /* A task that is removed from the event list while the\r
+                               scheduler is suspended will not get placed in the ready\r
+                               list or removed from the blocked list until the scheduler\r
+                               is resumed.\r
+\r
+                               This task cannot be in an event list as it is the currently\r
+                               executing task. */\r
+\r
+                               /* Calculate the time to wake - this may overflow but this is\r
+                               not a problem. */\r
+                               xTimeToWake = xTickCount + xTicksToDelay;\r
+\r
+                               /* We must remove ourselves from the ready list before adding\r
+                               ourselves to the blocked list as the same list item is used for\r
+                               both lists. */\r
+                               if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+                               {\r
+                                       /* The current task must be in a ready list, so there is\r
+                                       no need to check, and the port reset macro can be called\r
+                                       directly. */\r
+                                       portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                               prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+                       }\r
+                       xAlreadyYielded = xTaskResumeAll();\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               /* Force a reschedule if xTaskResumeAll has not already done so, we may\r
+               have put ourselves to sleep. */\r
+               if( xAlreadyYielded == pdFALSE )\r
+               {\r
+                       portYIELD_WITHIN_API();\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+\r
+#endif /* INCLUDE_vTaskDelay */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_eTaskGetState == 1 )\r
+\r
+       eTaskState eTaskGetState( TaskHandle_t xTask )\r
+       {\r
+       eTaskState eReturn;\r
+       List_t *pxStateList;\r
+       const TCB_t * const pxTCB = ( TCB_t * ) xTask;\r
+\r
+               configASSERT( pxTCB );\r
+\r
+               if( pxTCB == pxCurrentTCB )\r
+               {\r
+                       /* The task calling this function is querying its own state. */\r
+                       eReturn = eRunning;\r
+               }\r
+               else\r
+               {\r
+                       taskENTER_CRITICAL();\r
+                       {\r
+                               pxStateList = ( List_t * ) listLIST_ITEM_CONTAINER( &( pxTCB->xGenericListItem ) );\r
+                       }\r
+                       taskEXIT_CRITICAL();\r
+\r
+                       if( ( pxStateList == pxDelayedTaskList ) || ( pxStateList == pxOverflowDelayedTaskList ) )\r
+                       {\r
+                               /* The task being queried is referenced from one of the Blocked\r
+                               lists. */\r
+                               eReturn = eBlocked;\r
+                       }\r
+\r
+                       #if ( INCLUDE_vTaskSuspend == 1 )\r
+                               else if( pxStateList == &xSuspendedTaskList )\r
+                               {\r
+                                       /* The task being queried is referenced from the suspended\r
+                                       list.  Is it genuinely suspended or is it block\r
+                                       indefinitely? */\r
+                                       if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL )\r
+                                       {\r
+                                               eReturn = eSuspended;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               eReturn = eBlocked;\r
+                                       }\r
+                               }\r
+                       #endif\r
+\r
+                       #if ( INCLUDE_vTaskDelete == 1 )\r
+                               else if( pxStateList == &xTasksWaitingTermination )\r
+                               {\r
+                                       /* The task being queried is referenced from the deleted\r
+                                       tasks list. */\r
+                                       eReturn = eDeleted;\r
+                               }\r
+                       #endif\r
+\r
+                       else /*lint !e525 Negative indentation is intended to make use of pre-processor clearer. */\r
+                       {\r
+                               /* If the task is not in any other state, it must be in the\r
+                               Ready (including pending ready) state. */\r
+                               eReturn = eReady;\r
+                       }\r
+               }\r
+\r
+               return eReturn;\r
+       } /*lint !e818 xTask cannot be a pointer to const because it is a typedef. */\r
+\r
+#endif /* INCLUDE_eTaskGetState */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_uxTaskPriorityGet == 1 )\r
+\r
+       UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask )\r
+       {\r
+       TCB_t *pxTCB;\r
+       UBaseType_t uxReturn;\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       /* If null is passed in here then it is the priority of the that\r
+                       called uxTaskPriorityGet() that is being queried. */\r
+                       pxTCB = prvGetTCBFromHandle( xTask );\r
+                       uxReturn = pxTCB->uxPriority;\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               return uxReturn;\r
+       }\r
+\r
+#endif /* INCLUDE_uxTaskPriorityGet */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_uxTaskPriorityGet == 1 )\r
+\r
+       UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask )\r
+       {\r
+       TCB_t *pxTCB;\r
+       UBaseType_t uxReturn, uxSavedInterruptState;\r
+\r
+               /* RTOS ports that support interrupt nesting have the concept of a\r
+               maximum system call (or maximum API call) interrupt priority.\r
+               Interrupts that are     above the maximum system call priority are keep\r
+               permanently enabled, even when the RTOS kernel is in a critical section,\r
+               but cannot make any calls to FreeRTOS API functions.  If configASSERT()\r
+               is defined in FreeRTOSConfig.h then\r
+               portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+               failure if a FreeRTOS API function is called from an interrupt that has\r
+               been assigned a priority above the configured maximum system call\r
+               priority.  Only FreeRTOS functions that end in FromISR can be called\r
+               from interrupts that have been assigned a priority at or (logically)\r
+               below the maximum system call interrupt priority.  FreeRTOS maintains a\r
+               separate interrupt safe API to ensure interrupt entry is as fast and as\r
+               simple as possible.  More information (albeit Cortex-M specific) is\r
+               provided on the following link:\r
+               http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+               portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+               uxSavedInterruptState = portSET_INTERRUPT_MASK_FROM_ISR();\r
+               {\r
+                       /* If null is passed in here then it is the priority of the calling\r
+                       task that is being queried. */\r
+                       pxTCB = prvGetTCBFromHandle( xTask );\r
+                       uxReturn = pxTCB->uxPriority;\r
+               }\r
+               portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptState );\r
+\r
+               return uxReturn;\r
+       }\r
+\r
+#endif /* INCLUDE_uxTaskPriorityGet */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_vTaskPrioritySet == 1 )\r
+\r
+       void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority )\r
+       {\r
+       TCB_t *pxTCB;\r
+       UBaseType_t uxCurrentBasePriority, uxPriorityUsedOnEntry;\r
+       BaseType_t xYieldRequired = pdFALSE;\r
+\r
+               configASSERT( ( uxNewPriority < configMAX_PRIORITIES ) );\r
+\r
+               /* Ensure the new priority is valid. */\r
+               if( uxNewPriority >= ( UBaseType_t ) configMAX_PRIORITIES )\r
+               {\r
+                       uxNewPriority = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) 1U;\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       /* If null is passed in here then it is the priority of the calling\r
+                       task that is being changed. */\r
+                       pxTCB = prvGetTCBFromHandle( xTask );\r
+\r
+                       traceTASK_PRIORITY_SET( pxTCB, uxNewPriority );\r
+\r
+                       #if ( configUSE_MUTEXES == 1 )\r
+                       {\r
+                               uxCurrentBasePriority = pxTCB->uxBasePriority;\r
+                       }\r
+                       #else\r
+                       {\r
+                               uxCurrentBasePriority = pxTCB->uxPriority;\r
+                       }\r
+                       #endif\r
+\r
+                       if( uxCurrentBasePriority != uxNewPriority )\r
+                       {\r
+                               /* The priority change may have readied a task of higher\r
+                               priority than the calling task. */\r
+                               if( uxNewPriority > uxCurrentBasePriority )\r
+                               {\r
+                                       if( pxTCB != pxCurrentTCB )\r
+                                       {\r
+                                               /* The priority of a task other than the currently\r
+                                               running task is being raised.  Is the priority being\r
+                                               raised above that of the running task? */\r
+                                               if( uxNewPriority >= pxCurrentTCB->uxPriority )\r
+                                               {\r
+                                                       xYieldRequired = pdTRUE;\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               /* The priority of the running task is being raised,\r
+                                               but the running task must already be the highest\r
+                                               priority task able to run so no yield is required. */\r
+                                       }\r
+                               }\r
+                               else if( pxTCB == pxCurrentTCB )\r
+                               {\r
+                                       /* Setting the priority of the running task down means\r
+                                       there may now be another task of higher priority that\r
+                                       is ready to execute. */\r
+                                       xYieldRequired = pdTRUE;\r
+                               }\r
+                               else\r
+                               {\r
+                                       /* Setting the priority of any other task down does not\r
+                                       require a yield as the running task must be above the\r
+                                       new priority of the task being modified. */\r
+                               }\r
+\r
+                               /* Remember the ready list the task might be referenced from\r
+                               before its uxPriority member is changed so the\r
+                               taskRESET_READY_PRIORITY() macro can function correctly. */\r
+                               uxPriorityUsedOnEntry = pxTCB->uxPriority;\r
+\r
+                               #if ( configUSE_MUTEXES == 1 )\r
+                               {\r
+                                       /* Only change the priority being used if the task is not\r
+                                       currently using an inherited priority. */\r
+                                       if( pxTCB->uxBasePriority == pxTCB->uxPriority )\r
+                                       {\r
+                                               pxTCB->uxPriority = uxNewPriority;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+\r
+                                       /* The base priority gets set whatever. */\r
+                                       pxTCB->uxBasePriority = uxNewPriority;\r
+                               }\r
+                               #else\r
+                               {\r
+                                       pxTCB->uxPriority = uxNewPriority;\r
+                               }\r
+                               #endif\r
+\r
+                               /* Only reset the event list item value if the value is not\r
+                               being used for anything else. */\r
+                               if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL )\r
+                               {\r
+                                       listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxNewPriority ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+\r
+                               /* If the task is in the blocked or suspended list we need do\r
+                               nothing more than change it's priority variable. However, if\r
+                               the task is in a ready list it needs to be removed and placed\r
+                               in the list appropriate to its new priority. */\r
+                               if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ uxPriorityUsedOnEntry ] ), &( pxTCB->xGenericListItem ) ) != pdFALSE )\r
+                               {\r
+                                       /* The task is currently in its ready list - remove before adding\r
+                                       it to it's new ready list.  As we are in a critical section we\r
+                                       can do this even if the scheduler is suspended. */\r
+                                       if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+                                       {\r
+                                               /* It is known that the task is in its ready list so\r
+                                               there is no need to check again and the port level\r
+                                               reset macro can be called directly. */\r
+                                               portRESET_READY_PRIORITY( uxPriorityUsedOnEntry, uxTopReadyPriority );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                                       prvAddTaskToReadyList( pxTCB );\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+\r
+                               if( xYieldRequired == pdTRUE )\r
+                               {\r
+                                       taskYIELD_IF_USING_PREEMPTION();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+\r
+                               /* Remove compiler warning about unused variables when the port\r
+                               optimised task selection is not being used. */\r
+                               ( void ) uxPriorityUsedOnEntry;\r
+                       }\r
+               }\r
+               taskEXIT_CRITICAL();\r
+       }\r
+\r
+#endif /* INCLUDE_vTaskPrioritySet */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_vTaskSuspend == 1 )\r
+\r
+       void vTaskSuspend( TaskHandle_t xTaskToSuspend )\r
+       {\r
+       TCB_t *pxTCB;\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       /* If null is passed in here then it is the running task that is\r
+                       being suspended. */\r
+                       pxTCB = prvGetTCBFromHandle( xTaskToSuspend );\r
+\r
+                       traceTASK_SUSPEND( pxTCB );\r
+\r
+                       /* Remove task from the ready/delayed list and place in the\r
+                       suspended list. */\r
+                       if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+                       {\r
+                               taskRESET_READY_PRIORITY( pxTCB->uxPriority );\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       /* Is the task waiting on an event also? */\r
+                       if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL )\r
+                       {\r
+                               ( void ) uxListRemove( &( pxTCB->xEventListItem ) );\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       vListInsertEnd( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) );\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               if( pxTCB == pxCurrentTCB )\r
+               {\r
+                       if( xSchedulerRunning != pdFALSE )\r
+                       {\r
+                               /* The current task has just been suspended. */\r
+                               configASSERT( uxSchedulerSuspended == 0 );\r
+                               portYIELD_WITHIN_API();\r
+                       }\r
+                       else\r
+                       {\r
+                               /* The scheduler is not running, but the task that was pointed\r
+                               to by pxCurrentTCB has just been suspended and pxCurrentTCB\r
+                               must be adjusted to point to a different task. */\r
+                               if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == uxCurrentNumberOfTasks )\r
+                               {\r
+                                       /* No other tasks are ready, so set pxCurrentTCB back to\r
+                                       NULL so when the next task is created pxCurrentTCB will\r
+                                       be set to point to it no matter what its relative priority\r
+                                       is. */\r
+                                       pxCurrentTCB = NULL;\r
+                               }\r
+                               else\r
+                               {\r
+                                       vTaskSwitchContext();\r
+                               }\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       if( xSchedulerRunning != pdFALSE )\r
+                       {\r
+                               /* A task other than the currently running task was suspended,\r
+                               reset the next expected unblock time in case it referred to the\r
+                               task that is now in the Suspended state. */\r
+                               taskENTER_CRITICAL();\r
+                               {\r
+                                       prvResetNextTaskUnblockTime();\r
+                               }\r
+                               taskEXIT_CRITICAL();\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+       }\r
+\r
+#endif /* INCLUDE_vTaskSuspend */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_vTaskSuspend == 1 )\r
+\r
+       static BaseType_t prvTaskIsTaskSuspended( const TaskHandle_t xTask )\r
+       {\r
+       BaseType_t xReturn = pdFALSE;\r
+       const TCB_t * const pxTCB = ( TCB_t * ) xTask;\r
+\r
+               /* Accesses xPendingReadyList so must be called from a critical\r
+               section. */\r
+\r
+               /* It does not make sense to check if the calling task is suspended. */\r
+               configASSERT( xTask );\r
+\r
+               /* Is the task being resumed actually in the suspended list? */\r
+               if( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ) != pdFALSE )\r
+               {\r
+                       /* Has the task already been resumed from within an ISR? */\r
+                       if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxTCB->xEventListItem ) ) == pdFALSE )\r
+                       {\r
+                               /* Is it in the suspended list because it is in the     Suspended\r
+                               state, or because is is blocked with no timeout? */\r
+                               if( listIS_CONTAINED_WITHIN( NULL, &( pxTCB->xEventListItem ) ) != pdFALSE )\r
+                               {\r
+                                       xReturn = pdTRUE;\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               return xReturn;\r
+       } /*lint !e818 xTask cannot be a pointer to const because it is a typedef. */\r
+\r
+#endif /* INCLUDE_vTaskSuspend */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_vTaskSuspend == 1 )\r
+\r
+       void vTaskResume( TaskHandle_t xTaskToResume )\r
+       {\r
+       TCB_t * const pxTCB = ( TCB_t * ) xTaskToResume;\r
+\r
+               /* It does not make sense to resume the calling task. */\r
+               configASSERT( xTaskToResume );\r
+\r
+               /* The parameter cannot be NULL as it is impossible to resume the\r
+               currently executing task. */\r
+               if( ( pxTCB != NULL ) && ( pxTCB != pxCurrentTCB ) )\r
+               {\r
+                       taskENTER_CRITICAL();\r
+                       {\r
+                               if( prvTaskIsTaskSuspended( pxTCB ) == pdTRUE )\r
+                               {\r
+                                       traceTASK_RESUME( pxTCB );\r
+\r
+                                       /* As we are in a critical section we can access the ready\r
+                                       lists even if the scheduler is suspended. */\r
+                                       ( void ) uxListRemove(  &( pxTCB->xGenericListItem ) );\r
+                                       prvAddTaskToReadyList( pxTCB );\r
+\r
+                                       /* We may have just resumed a higher priority task. */\r
+                                       if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
+                                       {\r
+                                               /* This yield may not cause the task just resumed to run,\r
+                                               but will leave the lists in the correct state for the\r
+                                               next yield. */\r
+                                               taskYIELD_IF_USING_PREEMPTION();\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       taskEXIT_CRITICAL();\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+\r
+#endif /* INCLUDE_vTaskSuspend */\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) )\r
+\r
+       BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume )\r
+       {\r
+       BaseType_t xYieldRequired = pdFALSE;\r
+       TCB_t * const pxTCB = ( TCB_t * ) xTaskToResume;\r
+       UBaseType_t uxSavedInterruptStatus;\r
+\r
+               configASSERT( xTaskToResume );\r
+\r
+               /* RTOS ports that support interrupt nesting have the concept of a\r
+               maximum system call (or maximum API call) interrupt priority.\r
+               Interrupts that are     above the maximum system call priority are keep\r
+               permanently enabled, even when the RTOS kernel is in a critical section,\r
+               but cannot make any calls to FreeRTOS API functions.  If configASSERT()\r
+               is defined in FreeRTOSConfig.h then\r
+               portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+               failure if a FreeRTOS API function is called from an interrupt that has\r
+               been assigned a priority above the configured maximum system call\r
+               priority.  Only FreeRTOS functions that end in FromISR can be called\r
+               from interrupts that have been assigned a priority at or (logically)\r
+               below the maximum system call interrupt priority.  FreeRTOS maintains a\r
+               separate interrupt safe API to ensure interrupt entry is as fast and as\r
+               simple as possible.  More information (albeit Cortex-M specific) is\r
+               provided on the following link:\r
+               http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+               portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+               uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
+               {\r
+                       if( prvTaskIsTaskSuspended( pxTCB ) == pdTRUE )\r
+                       {\r
+                               traceTASK_RESUME_FROM_ISR( pxTCB );\r
+\r
+                               /* Check the ready lists can be accessed. */\r
+                               if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
+                               {\r
+                                       /* Ready lists can be accessed so move the task from the\r
+                                       suspended list to the ready list directly. */\r
+                                       if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
+                                       {\r
+                                               xYieldRequired = pdTRUE;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+\r
+                                       ( void ) uxListRemove(  &( pxTCB->xGenericListItem ) );\r
+                                       prvAddTaskToReadyList( pxTCB );\r
+                               }\r
+                               else\r
+                               {\r
+                                       /* The delayed or ready lists cannot be accessed so the task\r
+                                       is held in the pending ready list until the scheduler is\r
+                                       unsuspended. */\r
+                                       vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) );\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+\r
+               return xYieldRequired;\r
+       }\r
+\r
+#endif /* ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) ) */\r
+/*-----------------------------------------------------------*/\r
+\r
+void vTaskStartScheduler( void )\r
+{\r
+BaseType_t xReturn;\r
+\r
+       /* Add the idle task at the lowest priority. */\r
+       #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )\r
+       {\r
+               /* Create the idle task, storing its handle in xIdleTaskHandle so it can\r
+               be returned by the xTaskGetIdleTaskHandle() function. */\r
+               xReturn = xTaskCreate( prvIdleTask, "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), &xIdleTaskHandle ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */\r
+       }\r
+       #else\r
+       {\r
+               /* Create the idle task without storing its handle. */\r
+               xReturn = xTaskCreate( prvIdleTask, "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), NULL );  /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */\r
+       }\r
+       #endif /* INCLUDE_xTaskGetIdleTaskHandle */\r
+\r
+       #if ( configUSE_TIMERS == 1 )\r
+       {\r
+               if( xReturn == pdPASS )\r
+               {\r
+                       xReturn = xTimerCreateTimerTask();\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+       #endif /* configUSE_TIMERS */\r
+\r
+       if( xReturn == pdPASS )\r
+       {\r
+               /* Interrupts are turned off here, to ensure a tick does not occur\r
+               before or during the call to xPortStartScheduler().  The stacks of\r
+               the created tasks contain a status word with interrupts switched on\r
+               so interrupts will automatically get re-enabled when the first task\r
+               starts to run. */\r
+               portDISABLE_INTERRUPTS();\r
+\r
+               #if ( configUSE_NEWLIB_REENTRANT == 1 )\r
+               {\r
+                       /* Switch Newlib's _impure_ptr variable to point to the _reent\r
+                       structure specific to the task that will run first. */\r
+                       _impure_ptr = &( pxCurrentTCB->xNewLib_reent );\r
+               }\r
+               #endif /* configUSE_NEWLIB_REENTRANT */\r
+\r
+               xNextTaskUnblockTime = portMAX_DELAY;\r
+               xSchedulerRunning = pdTRUE;\r
+               xTickCount = ( TickType_t ) 0U;\r
+\r
+               /* If configGENERATE_RUN_TIME_STATS is defined then the following\r
+               macro must be defined to configure the timer/counter used to generate\r
+               the run time counter time base. */\r
+               portCONFIGURE_TIMER_FOR_RUN_TIME_STATS();\r
+\r
+               /* Setting up the timer tick is hardware specific and thus in the\r
+               portable interface. */\r
+               if( xPortStartScheduler() != pdFALSE )\r
+               {\r
+                       /* Should not reach here as if the scheduler is running the\r
+                       function will not return. */\r
+               }\r
+               else\r
+               {\r
+                       /* Should only reach here if a task calls xTaskEndScheduler(). */\r
+               }\r
+       }\r
+       else\r
+       {\r
+               /* This line will only be reached if the kernel could not be started,\r
+               because there was not enough FreeRTOS heap to create the idle task\r
+               or the timer task. */\r
+               configASSERT( xReturn );\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vTaskEndScheduler( void )\r
+{\r
+       /* Stop the scheduler interrupts and call the portable scheduler end\r
+       routine so the original ISRs can be restored if necessary.  The port\r
+       layer must ensure interrupts enable     bit is left in the correct state. */\r
+       portDISABLE_INTERRUPTS();\r
+       xSchedulerRunning = pdFALSE;\r
+       vPortEndScheduler();\r
+}\r
+/*----------------------------------------------------------*/\r
+\r
+void vTaskSuspendAll( void )\r
+{\r
+       /* A critical section is not required as the variable is of type\r
+       BaseType_t.  Please read Richard Barry's reply in the following link to a\r
+       post in the FreeRTOS support forum before reporting this as a bug! -\r
+       http://goo.gl/wu4acr */\r
+       ++uxSchedulerSuspended;\r
+}\r
+/*----------------------------------------------------------*/\r
+\r
+#if ( configUSE_TICKLESS_IDLE != 0 )\r
+\r
+       static TickType_t prvGetExpectedIdleTime( void )\r
+       {\r
+       TickType_t xReturn;\r
+\r
+               if( pxCurrentTCB->uxPriority > tskIDLE_PRIORITY )\r
+               {\r
+                       xReturn = 0;\r
+               }\r
+               else if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > 1 )\r
+               {\r
+                       /* There are other idle priority tasks in the ready state.  If\r
+                       time slicing is used then the very next tick interrupt must be\r
+                       processed. */\r
+                       xReturn = 0;\r
+               }\r
+               else\r
+               {\r
+                       xReturn = xNextTaskUnblockTime - xTickCount;\r
+               }\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_TICKLESS_IDLE */\r
+/*----------------------------------------------------------*/\r
+\r
+BaseType_t xTaskResumeAll( void )\r
+{\r
+TCB_t *pxTCB;\r
+BaseType_t xAlreadyYielded = pdFALSE;\r
+\r
+       /* If uxSchedulerSuspended is zero then this function does not match a\r
+       previous call to vTaskSuspendAll(). */\r
+       configASSERT( uxSchedulerSuspended );\r
+\r
+       /* It is possible that an ISR caused a task to be removed from an event\r
+       list while the scheduler was suspended.  If this was the case then the\r
+       removed task will have been added to the xPendingReadyList.  Once the\r
+       scheduler has been resumed it is safe to move all the pending ready\r
+       tasks from this list into their appropriate ready list. */\r
+       taskENTER_CRITICAL();\r
+       {\r
+               --uxSchedulerSuspended;\r
+\r
+               if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
+               {\r
+                       if( uxCurrentNumberOfTasks > ( UBaseType_t ) 0U )\r
+                       {\r
+                               /* Move any readied tasks from the pending list into the\r
+                               appropriate ready list. */\r
+                               while( listLIST_IS_EMPTY( &xPendingReadyList ) == pdFALSE )\r
+                               {\r
+                                       pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xPendingReadyList ) );\r
+                                       ( void ) uxListRemove( &( pxTCB->xEventListItem ) );\r
+                                       ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
+                                       prvAddTaskToReadyList( pxTCB );\r
+\r
+                                       /* If the moved task has a priority higher than the current\r
+                                       task then a yield must be performed. */\r
+                                       if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
+                                       {\r
+                                               xYieldPending = pdTRUE;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+\r
+                               /* If any ticks occurred while the scheduler was suspended then\r
+                               they should be processed now.  This ensures the tick count does\r
+                               not     slip, and that any delayed tasks are resumed at the correct\r
+                               time. */\r
+                               if( uxPendedTicks > ( UBaseType_t ) 0U )\r
+                               {\r
+                                       while( uxPendedTicks > ( UBaseType_t ) 0U )\r
+                                       {\r
+                                               if( xTaskIncrementTick() != pdFALSE )\r
+                                               {\r
+                                                       xYieldPending = pdTRUE;\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                               --uxPendedTicks;\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+\r
+                               if( xYieldPending == pdTRUE )\r
+                               {\r
+                                       #if( configUSE_PREEMPTION != 0 )\r
+                                       {\r
+                                               xAlreadyYielded = pdTRUE;\r
+                                       }\r
+                                       #endif\r
+                                       taskYIELD_IF_USING_PREEMPTION();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+       taskEXIT_CRITICAL();\r
+\r
+       return xAlreadyYielded;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+TickType_t xTaskGetTickCount( void )\r
+{\r
+TickType_t xTicks;\r
+\r
+       /* Critical section required if running on a 16 bit processor. */\r
+       portTICK_TYPE_ENTER_CRITICAL();\r
+       {\r
+               xTicks = xTickCount;\r
+       }\r
+       portTICK_TYPE_EXIT_CRITICAL();\r
+\r
+       return xTicks;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+TickType_t xTaskGetTickCountFromISR( void )\r
+{\r
+TickType_t xReturn;\r
+UBaseType_t uxSavedInterruptStatus;\r
+\r
+       /* RTOS ports that support interrupt nesting have the concept of a maximum\r
+       system call (or maximum API call) interrupt priority.  Interrupts that are\r
+       above the maximum system call priority are kept permanently enabled, even\r
+       when the RTOS kernel is in a critical section, but cannot make any calls to\r
+       FreeRTOS API functions.  If configASSERT() is defined in FreeRTOSConfig.h\r
+       then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+       failure if a FreeRTOS API function is called from an interrupt that has been\r
+       assigned a priority above the configured maximum system call priority.\r
+       Only FreeRTOS functions that end in FromISR can be called from interrupts\r
+       that have been assigned a priority at or (logically) below the maximum\r
+       system call     interrupt priority.  FreeRTOS maintains a separate interrupt\r
+       safe API to ensure interrupt entry is as fast and as simple as possible.\r
+       More information (albeit Cortex-M specific) is provided on the following\r
+       link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+       portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+       uxSavedInterruptStatus = portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR();\r
+       {\r
+               xReturn = xTickCount;\r
+       }\r
+       portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+UBaseType_t uxTaskGetNumberOfTasks( void )\r
+{\r
+       /* A critical section is not required because the variables are of type\r
+       BaseType_t. */\r
+       return uxCurrentNumberOfTasks;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_pcTaskGetTaskName == 1 )\r
+\r
+       char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+       {\r
+       TCB_t *pxTCB;\r
+\r
+               /* If null is passed in here then the name of the calling task is being queried. */\r
+               pxTCB = prvGetTCBFromHandle( xTaskToQuery );\r
+               configASSERT( pxTCB );\r
+               return &( pxTCB->pcTaskName[ 0 ] );\r
+       }\r
+\r
+#endif /* INCLUDE_pcTaskGetTaskName */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_TRACE_FACILITY == 1 )\r
+\r
+       UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime )\r
+       {\r
+       UBaseType_t uxTask = 0, uxQueue = configMAX_PRIORITIES;\r
+\r
+               vTaskSuspendAll();\r
+               {\r
+                       /* Is there a space in the array for each task in the system? */\r
+                       if( uxArraySize >= uxCurrentNumberOfTasks )\r
+                       {\r
+                               /* Fill in an TaskStatus_t structure with information on each\r
+                               task in the Ready state. */\r
+                               do\r
+                               {\r
+                                       uxQueue--;\r
+                                       uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &( pxReadyTasksLists[ uxQueue ] ), eReady );\r
+\r
+                               } while( uxQueue > ( UBaseType_t ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+\r
+                               /* Fill in an TaskStatus_t structure with information on each\r
+                               task in the Blocked state. */\r
+                               uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxDelayedTaskList, eBlocked );\r
+                               uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxOverflowDelayedTaskList, eBlocked );\r
+\r
+                               #if( INCLUDE_vTaskDelete == 1 )\r
+                               {\r
+                                       /* Fill in an TaskStatus_t structure with information on\r
+                                       each task that has been deleted but not yet cleaned up. */\r
+                                       uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xTasksWaitingTermination, eDeleted );\r
+                               }\r
+                               #endif\r
+\r
+                               #if ( INCLUDE_vTaskSuspend == 1 )\r
+                               {\r
+                                       /* Fill in an TaskStatus_t structure with information on\r
+                                       each task in the Suspended state. */\r
+                                       uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xSuspendedTaskList, eSuspended );\r
+                               }\r
+                               #endif\r
+\r
+                               #if ( configGENERATE_RUN_TIME_STATS == 1)\r
+                               {\r
+                                       if( pulTotalRunTime != NULL )\r
+                                       {\r
+                                               #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE\r
+                                                       portALT_GET_RUN_TIME_COUNTER_VALUE( ( *pulTotalRunTime ) );\r
+                                               #else\r
+                                                       *pulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE();\r
+                                               #endif\r
+                                       }\r
+                               }\r
+                               #else\r
+                               {\r
+                                       if( pulTotalRunTime != NULL )\r
+                                       {\r
+                                               *pulTotalRunTime = 0;\r
+                                       }\r
+                               }\r
+                               #endif\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               ( void ) xTaskResumeAll();\r
+\r
+               return uxTask;\r
+       }\r
+\r
+#endif /* configUSE_TRACE_FACILITY */\r
+/*----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )\r
+\r
+       TaskHandle_t xTaskGetIdleTaskHandle( void )\r
+       {\r
+               /* If xTaskGetIdleTaskHandle() is called before the scheduler has been\r
+               started, then xIdleTaskHandle will be NULL. */\r
+               configASSERT( ( xIdleTaskHandle != NULL ) );\r
+               return xIdleTaskHandle;\r
+       }\r
+\r
+#endif /* INCLUDE_xTaskGetIdleTaskHandle */\r
+/*----------------------------------------------------------*/\r
+\r
+/* This conditional compilation should use inequality to 0, not equality to 1.\r
+This is to ensure vTaskStepTick() is available when user defined low power mode\r
+implementations require configUSE_TICKLESS_IDLE to be set to a value other than\r
+1. */\r
+#if ( configUSE_TICKLESS_IDLE != 0 )\r
+\r
+       void vTaskStepTick( const TickType_t xTicksToJump )\r
+       {\r
+               /* Correct the tick count value after a period during which the tick\r
+               was suppressed.  Note this does *not* call the tick hook function for\r
+               each stepped tick. */\r
+               configASSERT( ( xTickCount + xTicksToJump ) <= xNextTaskUnblockTime );\r
+               xTickCount += xTicksToJump;\r
+               traceINCREASE_TICK_COUNT( xTicksToJump );\r
+       }\r
+\r
+#endif /* configUSE_TICKLESS_IDLE */\r
+/*----------------------------------------------------------*/\r
+\r
+BaseType_t xTaskIncrementTick( void )\r
+{\r
+TCB_t * pxTCB;\r
+TickType_t xItemValue;\r
+BaseType_t xSwitchRequired = pdFALSE;\r
+\r
+       /* Called by the portable layer each time a tick interrupt occurs.\r
+       Increments the tick then checks to see if the new tick value will cause any\r
+       tasks to be unblocked. */\r
+       traceTASK_INCREMENT_TICK( xTickCount );\r
+       if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
+       {\r
+               /* Increment the RTOS tick, switching the delayed and overflowed\r
+               delayed lists if it wraps to 0. */\r
+               ++xTickCount;\r
+\r
+               {\r
+                       /* Minor optimisation.  The tick count cannot change in this\r
+                       block. */\r
+                       const TickType_t xConstTickCount = xTickCount;\r
+\r
+                       if( xConstTickCount == ( TickType_t ) 0U )\r
+                       {\r
+                               taskSWITCH_DELAYED_LISTS();\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       /* See if this tick has made a timeout expire.  Tasks are stored in\r
+                       the     queue in the order of their wake time - meaning once one task\r
+                       has been found whose block time has not expired there is no need to\r
+                       look any further down the list. */\r
+                       if( xConstTickCount >= xNextTaskUnblockTime )\r
+                       {\r
+                               for( ;; )\r
+                               {\r
+                                       if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE )\r
+                                       {\r
+                                               /* The delayed list is empty.  Set xNextTaskUnblockTime\r
+                                               to the maximum possible value so it is extremely\r
+                                               unlikely that the\r
+                                               if( xTickCount >= xNextTaskUnblockTime ) test will pass\r
+                                               next time through. */\r
+                                               xNextTaskUnblockTime = portMAX_DELAY;\r
+                                               break;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               /* The delayed list is not empty, get the value of the\r
+                                               item at the head of the delayed list.  This is the time\r
+                                               at which the task at the head of the delayed list must\r
+                                               be removed from the Blocked state. */\r
+                                               pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList );\r
+                                               xItemValue = listGET_LIST_ITEM_VALUE( &( pxTCB->xGenericListItem ) );\r
+\r
+                                               if( xConstTickCount < xItemValue )\r
+                                               {\r
+                                                       /* It is not time to unblock this item yet, but the\r
+                                                       item value is the time at which the task at the head\r
+                                                       of the blocked list must be removed from the Blocked\r
+                                                       state - so record the item value in\r
+                                                       xNextTaskUnblockTime. */\r
+                                                       xNextTaskUnblockTime = xItemValue;\r
+                                                       break;\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+\r
+                                               /* It is time to remove the item from the Blocked state. */\r
+                                               ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
+\r
+                                               /* Is the task waiting on an event also?  If so remove\r
+                                               it from the event list. */\r
+                                               if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL )\r
+                                               {\r
+                                                       ( void ) uxListRemove( &( pxTCB->xEventListItem ) );\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+\r
+                                               /* Place the unblocked task into the appropriate ready\r
+                                               list. */\r
+                                               prvAddTaskToReadyList( pxTCB );\r
+\r
+                                               /* A task being unblocked cannot cause an immediate\r
+                                               context switch if preemption is turned off. */\r
+                                               #if (  configUSE_PREEMPTION == 1 )\r
+                                               {\r
+                                                       /* Preemption is on, but a context switch should\r
+                                                       only be performed if the unblocked task has a\r
+                                                       priority that is equal to or higher than the\r
+                                                       currently executing task. */\r
+                                                       if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
+                                                       {\r
+                                                               xSwitchRequired = pdTRUE;\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                               #endif /* configUSE_PREEMPTION */\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+\r
+               /* Tasks of equal priority to the currently running task will share\r
+               processing time (time slice) if preemption is on, and the application\r
+               writer has not explicitly turned time slicing off. */\r
+               #if ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) )\r
+               {\r
+                       if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCB->uxPriority ] ) ) > ( UBaseType_t ) 1 )\r
+                       {\r
+                               xSwitchRequired = pdTRUE;\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               #endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) */\r
+\r
+               #if ( configUSE_TICK_HOOK == 1 )\r
+               {\r
+                       /* Guard against the tick hook being called when the pended tick\r
+                       count is being unwound (when the scheduler is being unlocked). */\r
+                       if( uxPendedTicks == ( UBaseType_t ) 0U )\r
+                       {\r
+                               vApplicationTickHook();\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               #endif /* configUSE_TICK_HOOK */\r
+       }\r
+       else\r
+       {\r
+               ++uxPendedTicks;\r
+\r
+               /* The tick hook gets called at regular intervals, even if the\r
+               scheduler is locked. */\r
+               #if ( configUSE_TICK_HOOK == 1 )\r
+               {\r
+                       vApplicationTickHook();\r
+               }\r
+               #endif\r
+       }\r
+\r
+       #if ( configUSE_PREEMPTION == 1 )\r
+       {\r
+               if( xYieldPending != pdFALSE )\r
+               {\r
+                       xSwitchRequired = pdTRUE;\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+       #endif /* configUSE_PREEMPTION */\r
+\r
+       return xSwitchRequired;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
+\r
+       void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction )\r
+       {\r
+       TCB_t *xTCB;\r
+\r
+               /* If xTask is NULL then it is the task hook of the calling task that is\r
+               getting set. */\r
+               if( xTask == NULL )\r
+               {\r
+                       xTCB = ( TCB_t * ) pxCurrentTCB;\r
+               }\r
+               else\r
+               {\r
+                       xTCB = ( TCB_t * ) xTask;\r
+               }\r
+\r
+               /* Save the hook function in the TCB.  A critical section is required as\r
+               the value can be accessed from an interrupt. */\r
+               taskENTER_CRITICAL();\r
+                       xTCB->pxTaskTag = pxHookFunction;\r
+               taskEXIT_CRITICAL();\r
+       }\r
+\r
+#endif /* configUSE_APPLICATION_TASK_TAG */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
+\r
+       TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask )\r
+       {\r
+       TCB_t *xTCB;\r
+       TaskHookFunction_t xReturn;\r
+\r
+               /* If xTask is NULL then we are setting our own task hook. */\r
+               if( xTask == NULL )\r
+               {\r
+                       xTCB = ( TCB_t * ) pxCurrentTCB;\r
+               }\r
+               else\r
+               {\r
+                       xTCB = ( TCB_t * ) xTask;\r
+               }\r
+\r
+               /* Save the hook function in the TCB.  A critical section is required as\r
+               the value can be accessed from an interrupt. */\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       xReturn = xTCB->pxTaskTag;\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_APPLICATION_TASK_TAG */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
+\r
+       BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter )\r
+       {\r
+       TCB_t *xTCB;\r
+       BaseType_t xReturn;\r
+\r
+               /* If xTask is NULL then we are calling our own task hook. */\r
+               if( xTask == NULL )\r
+               {\r
+                       xTCB = ( TCB_t * ) pxCurrentTCB;\r
+               }\r
+               else\r
+               {\r
+                       xTCB = ( TCB_t * ) xTask;\r
+               }\r
+\r
+               if( xTCB->pxTaskTag != NULL )\r
+               {\r
+                       xReturn = xTCB->pxTaskTag( pvParameter );\r
+               }\r
+               else\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_APPLICATION_TASK_TAG */\r
+/*-----------------------------------------------------------*/\r
+\r
+void vTaskSwitchContext( void )\r
+{\r
+       if( uxSchedulerSuspended != ( UBaseType_t ) pdFALSE )\r
+       {\r
+               /* The scheduler is currently suspended - do not allow a context\r
+               switch. */\r
+               xYieldPending = pdTRUE;\r
+       }\r
+       else\r
+       {\r
+               xYieldPending = pdFALSE;\r
+               traceTASK_SWITCHED_OUT();\r
+\r
+               #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
+               {\r
+                               #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE\r
+                                       portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime );\r
+                               #else\r
+                                       ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE();\r
+                               #endif\r
+\r
+                               /* Add the amount of time the task has been running to the\r
+                               accumulated     time so far.  The time the task started running was\r
+                               stored in ulTaskSwitchedInTime.  Note that there is no overflow\r
+                               protection here so count values are only valid until the timer\r
+                               overflows.  The guard against negative values is to protect\r
+                               against suspect run time stat counter implementations - which\r
+                               are provided by the application, not the kernel. */\r
+                               if( ulTotalRunTime > ulTaskSwitchedInTime )\r
+                               {\r
+                                       pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime );\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                               ulTaskSwitchedInTime = ulTotalRunTime;\r
+               }\r
+               #endif /* configGENERATE_RUN_TIME_STATS */\r
+\r
+               /* Check for stack overflow, if configured. */\r
+               taskFIRST_CHECK_FOR_STACK_OVERFLOW();\r
+               taskSECOND_CHECK_FOR_STACK_OVERFLOW();\r
+\r
+               /* Select a new task to run using either the generic C or port\r
+               optimised asm code. */\r
+               taskSELECT_HIGHEST_PRIORITY_TASK();\r
+               traceTASK_SWITCHED_IN();\r
+\r
+               #if ( configUSE_NEWLIB_REENTRANT == 1 )\r
+               {\r
+                       /* Switch Newlib's _impure_ptr variable to point to the _reent\r
+                       structure specific to this task. */\r
+                       _impure_ptr = &( pxCurrentTCB->xNewLib_reent );\r
+               }\r
+               #endif /* configUSE_NEWLIB_REENTRANT */\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait )\r
+{\r
+TickType_t xTimeToWake;\r
+\r
+       configASSERT( pxEventList );\r
+\r
+       /* THIS FUNCTION MUST BE CALLED WITH EITHER INTERRUPTS DISABLED OR THE\r
+       SCHEDULER SUSPENDED AND THE QUEUE BEING ACCESSED LOCKED. */\r
+\r
+       /* Place the event list item of the TCB in the appropriate event list.\r
+       This is placed in the list in priority order so the highest priority task\r
+       is the first to be woken by the event.  The queue that contains the event\r
+       list is locked, preventing simultaneous access from interrupts. */\r
+       vListInsert( pxEventList, &( pxCurrentTCB->xEventListItem ) );\r
+\r
+       /* The task must be removed from from the ready list before it is added to\r
+       the blocked list as the same list item is used for both lists.  Exclusive\r
+       access to the ready lists guaranteed because the scheduler is locked. */\r
+       if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+       {\r
+               /* The current task must be in a ready list, so there is no need to\r
+               check, and the port reset macro can be called directly. */\r
+               portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
+       }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
+       }\r
+\r
+       #if ( INCLUDE_vTaskSuspend == 1 )\r
+       {\r
+               if( xTicksToWait == portMAX_DELAY )\r
+               {\r
+                       /* Add the task to the suspended task list instead of a delayed task\r
+                       list to ensure the task is not woken by a timing event.  It will\r
+                       block indefinitely. */\r
+                       vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+               }\r
+               else\r
+               {\r
+                       /* Calculate the time at which the task should be woken if the event\r
+                       does not occur.  This may overflow but this doesn't matter, the\r
+                       scheduler will handle it. */\r
+                       xTimeToWake = xTickCount + xTicksToWait;\r
+                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+               }\r
+       }\r
+       #else /* INCLUDE_vTaskSuspend */\r
+       {\r
+                       /* Calculate the time at which the task should be woken if the event does\r
+                       not occur.  This may overflow but this doesn't matter, the scheduler\r
+                       will handle it. */\r
+                       xTimeToWake = xTickCount + xTicksToWait;\r
+                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+       }\r
+       #endif /* INCLUDE_vTaskSuspend */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait )\r
+{\r
+TickType_t xTimeToWake;\r
+\r
+       configASSERT( pxEventList );\r
+\r
+       /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED.  It is used by\r
+       the event groups implementation. */\r
+       configASSERT( uxSchedulerSuspended != 0 );\r
+\r
+       /* Store the item value in the event list item.  It is safe to access the\r
+       event list item here as interrupts won't access the event list item of a\r
+       task that is not in the Blocked state. */\r
+       listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ), xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE );\r
+\r
+       /* Place the event list item of the TCB at the end of the appropriate event\r
+       list.  It is safe to access the event list here because it is part of an\r
+       event group implementation - and interrupts don't access event groups\r
+       directly (instead they access them indirectly by pending function calls to\r
+       the task level). */\r
+       vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) );\r
+\r
+       /* The task must be removed from the ready list before it is added to the\r
+       blocked list.  Exclusive access can be assured to the ready list as the\r
+       scheduler is locked. */\r
+       if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+       {\r
+               /* The current task must be in a ready list, so there is no need to\r
+               check, and the port reset macro can be called directly. */\r
+               portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
+       }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
+       }\r
+\r
+       #if ( INCLUDE_vTaskSuspend == 1 )\r
+       {\r
+               if( xTicksToWait == portMAX_DELAY )\r
+               {\r
+                       /* Add the task to the suspended task list instead of a delayed task\r
+                       list to ensure it is not woken by a timing event.  It will block\r
+                       indefinitely. */\r
+                       vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+               }\r
+               else\r
+               {\r
+                       /* Calculate the time at which the task should be woken if the event\r
+                       does not occur.  This may overflow but this doesn't matter, the\r
+                       kernel will manage it correctly. */\r
+                       xTimeToWake = xTickCount + xTicksToWait;\r
+                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+               }\r
+       }\r
+       #else /* INCLUDE_vTaskSuspend */\r
+       {\r
+                       /* Calculate the time at which the task should be woken if the event does\r
+                       not occur.  This may overflow but this doesn't matter, the kernel\r
+                       will manage it correctly. */\r
+                       xTimeToWake = xTickCount + xTicksToWait;\r
+                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+       }\r
+       #endif /* INCLUDE_vTaskSuspend */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if configUSE_TIMERS == 1\r
+\r
+       void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely )\r
+       {\r
+       TickType_t xTimeToWake;\r
+\r
+               configASSERT( pxEventList );\r
+\r
+               /* This function should not be called by application code hence the\r
+               'Restricted' in its name.  It is not part of the public API.  It is\r
+               designed for use by kernel code, and has special calling requirements -\r
+               it should be called with the scheduler suspended. */\r
+\r
+\r
+               /* Place the event list item of the TCB in the appropriate event list.\r
+               In this case it is assume that this is the only task that is going to\r
+               be waiting on this event list, so the faster vListInsertEnd() function\r
+               can be used in place of vListInsert. */\r
+               vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) );\r
+\r
+               /* We must remove this task from the ready list before adding it to the\r
+               blocked list as the same list item is used for both lists.  This\r
+               function is called with the scheduler locked so interrupts will not\r
+               access the lists at the same time. */\r
+               if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+               {\r
+                       /* The current task must be in a ready list, so there is no need to\r
+                       check, and the port reset macro can be called directly. */\r
+                       portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               /* If vTaskSuspend() is available then the suspended task list is also\r
+               available and a task that is blocking indefinitely can enter the\r
+               suspended state (it is not really suspended as it will re-enter the\r
+               Ready state when the event it is waiting indefinitely for occurs).\r
+               Blocking indefinitely is useful when using tickless idle mode as when\r
+               all tasks are blocked indefinitely all timers can be turned off. */\r
+               #if( INCLUDE_vTaskSuspend == 1 )\r
+               {\r
+                       if( xWaitIndefinitely == pdTRUE )\r
+                       {\r
+                               /* Add the task to the suspended task list instead of a delayed\r
+                               task list to ensure the task is not woken by a timing event.  It\r
+                               will block indefinitely. */\r
+                               traceTASK_DELAY_SUSPEND( pxCurrentTCB );\r
+                               vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+                       }\r
+                       else\r
+                       {\r
+                               /* Calculate the time at which the task should be woken if the\r
+                               event does not occur.  This may overflow but this doesn't\r
+                               matter. */\r
+                               xTimeToWake = xTickCount + xTicksToWait;\r
+                               traceTASK_DELAY_UNTIL();\r
+                               prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+                       }\r
+               }\r
+               #else\r
+               {\r
+                       /* Calculate the time at which the task should be woken if the event\r
+                       does not occur.  This may overflow but this doesn't matter. */\r
+                       xTimeToWake = xTickCount + xTicksToWait;\r
+                       traceTASK_DELAY_UNTIL();\r
+                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+\r
+                       /* Remove compiler warnings when INCLUDE_vTaskSuspend() is not\r
+                       defined. */\r
+                       ( void ) xWaitIndefinitely;\r
+               }\r
+               #endif\r
+       }\r
+\r
+#endif /* configUSE_TIMERS */\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList )\r
+{\r
+TCB_t *pxUnblockedTCB;\r
+BaseType_t xReturn;\r
+\r
+       /* THIS FUNCTION MUST BE CALLED FROM A CRITICAL SECTION.  It can also be\r
+       called from a critical section within an ISR. */\r
+\r
+       /* The event list is sorted in priority order, so the first in the list can\r
+       be removed as it is known to be the highest priority.  Remove the TCB from\r
+       the delayed list, and add it to the ready list.\r
+\r
+       If an event is for a queue that is locked then this function will never\r
+       get called - the lock count on the queue will get modified instead.  This\r
+       means exclusive access to the event list is guaranteed here.\r
+\r
+       This function assumes that a check has already been made to ensure that\r
+       pxEventList is not empty. */\r
+       pxUnblockedTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );\r
+       configASSERT( pxUnblockedTCB );\r
+       ( void ) uxListRemove( &( pxUnblockedTCB->xEventListItem ) );\r
+\r
+       if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
+       {\r
+               ( void ) uxListRemove( &( pxUnblockedTCB->xGenericListItem ) );\r
+               prvAddTaskToReadyList( pxUnblockedTCB );\r
+       }\r
+       else\r
+       {\r
+               /* The delayed and ready lists cannot be accessed, so hold this task\r
+               pending until the scheduler is resumed. */\r
+               vListInsertEnd( &( xPendingReadyList ), &( pxUnblockedTCB->xEventListItem ) );\r
+       }\r
+\r
+       if( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority )\r
+       {\r
+               /* Return true if the task removed from the event list has a higher\r
+               priority than the calling task.  This allows the calling task to know if\r
+               it should force a context switch now. */\r
+               xReturn = pdTRUE;\r
+\r
+               /* Mark that a yield is pending in case the user is not using the\r
+               "xHigherPriorityTaskWoken" parameter to an ISR safe FreeRTOS function. */\r
+               xYieldPending = pdTRUE;\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFALSE;\r
+       }\r
+\r
+       #if( configUSE_TICKLESS_IDLE != 0 )\r
+       {\r
+               /* If a task is blocked on a kernel object then xNextTaskUnblockTime\r
+               might be set to the blocked task's time out time.  If the task is\r
+               unblocked for a reason other than a timeout xNextTaskUnblockTime is\r
+               normally left unchanged, because it is automatically reset to a new\r
+               value when the tick count equals xNextTaskUnblockTime.  However if\r
+               tickless idling is used it might be more important to enter sleep mode\r
+               at the earliest possible time - so reset xNextTaskUnblockTime here to\r
+               ensure it is updated at the earliest possible time. */\r
+               prvResetNextTaskUnblockTime();\r
+       }\r
+       #endif\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue )\r
+{\r
+TCB_t *pxUnblockedTCB;\r
+BaseType_t xReturn;\r
+\r
+       /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED.  It is used by\r
+       the event flags implementation. */\r
+       configASSERT( uxSchedulerSuspended != pdFALSE );\r
+\r
+       /* Store the new item value in the event list. */\r
+       listSET_LIST_ITEM_VALUE( pxEventListItem, xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE );\r
+\r
+       /* Remove the event list form the event flag.  Interrupts do not access\r
+       event flags. */\r
+       pxUnblockedTCB = ( TCB_t * ) listGET_LIST_ITEM_OWNER( pxEventListItem );\r
+       configASSERT( pxUnblockedTCB );\r
+       ( void ) uxListRemove( pxEventListItem );\r
+\r
+       /* Remove the task from the delayed list and add it to the ready list.  The\r
+       scheduler is suspended so interrupts will not be accessing the ready\r
+       lists. */\r
+       ( void ) uxListRemove( &( pxUnblockedTCB->xGenericListItem ) );\r
+       prvAddTaskToReadyList( pxUnblockedTCB );\r
+\r
+       if( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority )\r
+       {\r
+               /* Return true if the task removed from the event list has\r
+               a higher priority than the calling task.  This allows\r
+               the calling task to know if it should force a context\r
+               switch now. */\r
+               xReturn = pdTRUE;\r
+\r
+               /* Mark that a yield is pending in case the user is not using the\r
+               "xHigherPriorityTaskWoken" parameter to an ISR safe FreeRTOS function. */\r
+               xYieldPending = pdTRUE;\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFALSE;\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut )\r
+{\r
+       configASSERT( pxTimeOut );\r
+       pxTimeOut->xOverflowCount = xNumOfOverflows;\r
+       pxTimeOut->xTimeOnEntering = xTickCount;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait )\r
+{\r
+BaseType_t xReturn;\r
+\r
+       configASSERT( pxTimeOut );\r
+       configASSERT( pxTicksToWait );\r
+\r
+       taskENTER_CRITICAL();\r
+       {\r
+               /* Minor optimisation.  The tick count cannot change in this block. */\r
+               const TickType_t xConstTickCount = xTickCount;\r
+\r
+               #if ( INCLUDE_vTaskSuspend == 1 )\r
+                       /* If INCLUDE_vTaskSuspend is set to 1 and the block time specified is\r
+                       the maximum block time then the task should block indefinitely, and\r
+                       therefore never time out. */\r
+                       if( *pxTicksToWait == portMAX_DELAY )\r
+                       {\r
+                               xReturn = pdFALSE;\r
+                       }\r
+                       else /* We are not blocking indefinitely, perform the checks below. */\r
+               #endif\r
+\r
+               if( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( xConstTickCount >= pxTimeOut->xTimeOnEntering ) ) /*lint !e525 Indentation preferred as is to make code within pre-processor directives clearer. */\r
+               {\r
+                       /* The tick count is greater than the time at which vTaskSetTimeout()\r
+                       was called, but has also overflowed since vTaskSetTimeOut() was called.\r
+                       It must have wrapped all the way around and gone past us again. This\r
+                       passed since vTaskSetTimeout() was called. */\r
+                       xReturn = pdTRUE;\r
+               }\r
+               else if( ( xConstTickCount - pxTimeOut->xTimeOnEntering ) < *pxTicksToWait )\r
+               {\r
+                       /* Not a genuine timeout. Adjust parameters for time remaining. */\r
+                       *pxTicksToWait -= ( xConstTickCount -  pxTimeOut->xTimeOnEntering );\r
+                       vTaskSetTimeOutState( pxTimeOut );\r
+                       xReturn = pdFALSE;\r
+               }\r
+               else\r
+               {\r
+                       xReturn = pdTRUE;\r
+               }\r
+       }\r
+       taskEXIT_CRITICAL();\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vTaskMissedYield( void )\r
+{\r
+       xYieldPending = pdTRUE;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_TRACE_FACILITY == 1 )\r
+\r
+       UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask )\r
+       {\r
+       UBaseType_t uxReturn;\r
+       TCB_t *pxTCB;\r
+\r
+               if( xTask != NULL )\r
+               {\r
+                       pxTCB = ( TCB_t * ) xTask;\r
+                       uxReturn = pxTCB->uxTaskNumber;\r
+               }\r
+               else\r
+               {\r
+                       uxReturn = 0U;\r
+               }\r
+\r
+               return uxReturn;\r
+       }\r
+\r
+#endif /* configUSE_TRACE_FACILITY */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_TRACE_FACILITY == 1 )\r
+\r
+       void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle )\r
+       {\r
+       TCB_t *pxTCB;\r
+\r
+               if( xTask != NULL )\r
+               {\r
+                       pxTCB = ( TCB_t * ) xTask;\r
+                       pxTCB->uxTaskNumber = uxHandle;\r
+               }\r
+       }\r
+\r
+#endif /* configUSE_TRACE_FACILITY */\r
+\r
+/*\r
+ * -----------------------------------------------------------\r
+ * The Idle task.\r
+ * ----------------------------------------------------------\r
+ *\r
+ * The portTASK_FUNCTION() macro is used to allow port/compiler specific\r
+ * language extensions.  The equivalent prototype for this function is:\r
+ *\r
+ * void prvIdleTask( void *pvParameters );\r
+ *\r
+ */\r
+static portTASK_FUNCTION( prvIdleTask, pvParameters )\r
+{\r
+       /* Stop warnings. */\r
+       ( void ) pvParameters;\r
+\r
+       for( ;; )\r
+       {\r
+               /* See if any tasks have been deleted. */\r
+               prvCheckTasksWaitingTermination();\r
+\r
+               #if ( configUSE_PREEMPTION == 0 )\r
+               {\r
+                       /* If we are not using preemption we keep forcing a task switch to\r
+                       see if any other task has become available.  If we are using\r
+                       preemption we don't need to do this as any task becoming available\r
+                       will automatically get the processor anyway. */\r
+                       taskYIELD();\r
+               }\r
+               #endif /* configUSE_PREEMPTION */\r
+\r
+               #if ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) )\r
+               {\r
+                       /* When using preemption tasks of equal priority will be\r
+                       timesliced.  If a task that is sharing the idle priority is ready\r
+                       to run then the idle task should yield before the end of the\r
+                       timeslice.\r
+\r
+                       A critical region is not required here as we are just reading from\r
+                       the list, and an occasional incorrect value will not matter.  If\r
+                       the ready list at the idle priority contains more than one task\r
+                       then a task other than the idle task is ready to execute. */\r
+                       if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > ( UBaseType_t ) 1 )\r
+                       {\r
+                               taskYIELD();\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               #endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) ) */\r
+\r
+               #if ( configUSE_IDLE_HOOK == 1 )\r
+               {\r
+                       extern void vApplicationIdleHook( void );\r
+\r
+                       /* Call the user defined function from within the idle task.  This\r
+                       allows the application designer to add background functionality\r
+                       without the overhead of a separate task.\r
+                       NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES,\r
+                       CALL A FUNCTION THAT MIGHT BLOCK. */\r
+                       vApplicationIdleHook();\r
+               }\r
+               #endif /* configUSE_IDLE_HOOK */\r
+\r
+               /* This conditional compilation should use inequality to 0, not equality\r
+               to 1.  This is to ensure portSUPPRESS_TICKS_AND_SLEEP() is called when\r
+               user defined low power mode     implementations require\r
+               configUSE_TICKLESS_IDLE to be set to a value other than 1. */\r
+               #if ( configUSE_TICKLESS_IDLE != 0 )\r
+               {\r
+               TickType_t xExpectedIdleTime;\r
+\r
+                       /* It is not desirable to suspend then resume the scheduler on\r
+                       each iteration of the idle task.  Therefore, a preliminary\r
+                       test of the expected idle time is performed without the\r
+                       scheduler suspended.  The result here is not necessarily\r
+                       valid. */\r
+                       xExpectedIdleTime = prvGetExpectedIdleTime();\r
+\r
+                       if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP )\r
+                       {\r
+                               vTaskSuspendAll();\r
+                               {\r
+                                       /* Now the scheduler is suspended, the expected idle\r
+                                       time can be sampled again, and this time its value can\r
+                                       be used. */\r
+                                       configASSERT( xNextTaskUnblockTime >= xTickCount );\r
+                                       xExpectedIdleTime = prvGetExpectedIdleTime();\r
+\r
+                                       if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP )\r
+                                       {\r
+                                               traceLOW_POWER_IDLE_BEGIN();\r
+                                               portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime );\r
+                                               traceLOW_POWER_IDLE_END();\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               ( void ) xTaskResumeAll();\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               #endif /* configUSE_TICKLESS_IDLE */\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( configUSE_TICKLESS_IDLE != 0 )\r
+\r
+       eSleepModeStatus eTaskConfirmSleepModeStatus( void )\r
+       {\r
+       /* The idle task exists in addition to the application tasks. */\r
+       const UBaseType_t uxNonApplicationTasks = 1;\r
+       eSleepModeStatus eReturn = eStandardSleep;\r
+\r
+               if( listCURRENT_LIST_LENGTH( &xPendingReadyList ) != 0 )\r
+               {\r
+                       /* A task was made ready while the scheduler was suspended. */\r
+                       eReturn = eAbortSleep;\r
+               }\r
+               else if( xYieldPending != pdFALSE )\r
+               {\r
+                       /* A yield was pended while the scheduler was suspended. */\r
+                       eReturn = eAbortSleep;\r
+               }\r
+               else\r
+               {\r
+                       /* If all the tasks are in the suspended list (which might mean they\r
+                       have an infinite block time rather than actually being suspended)\r
+                       then it is safe to turn all clocks off and just wait for external\r
+                       interrupts. */\r
+                       if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == ( uxCurrentNumberOfTasks - uxNonApplicationTasks ) )\r
+                       {\r
+                               eReturn = eNoTasksWaitingTimeout;\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+\r
+               return eReturn;\r
+       }\r
+\r
+#endif /* configUSE_TICKLESS_IDLE */\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvInitialiseTCBVariables( TCB_t * const pxTCB, const char * const pcName, UBaseType_t uxPriority, const MemoryRegion_t * const xRegions, const uint16_t usStackDepth ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+{\r
+UBaseType_t x;\r
+\r
+       /* Store the task name in the TCB. */\r
+       for( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ )\r
+       {\r
+               pxTCB->pcTaskName[ x ] = pcName[ x ];\r
+\r
+               /* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than\r
+               configMAX_TASK_NAME_LEN characters just in case the memory after the\r
+               string is not accessible (extremely unlikely). */\r
+               if( pcName[ x ] == 0x00 )\r
+               {\r
+                       break;\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+\r
+       /* Ensure the name string is terminated in the case that the string length\r
+       was greater or equal to configMAX_TASK_NAME_LEN. */\r
+       pxTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0';\r
+\r
+       /* This is used as an array index so must ensure it's not too large.  First\r
+       remove the privilege bit if one is present. */\r
+       if( uxPriority >= ( UBaseType_t ) configMAX_PRIORITIES )\r
+       {\r
+               uxPriority = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) 1U;\r
+       }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
+       }\r
+\r
+       pxTCB->uxPriority = uxPriority;\r
+       #if ( configUSE_MUTEXES == 1 )\r
+       {\r
+               pxTCB->uxBasePriority = uxPriority;\r
+               pxTCB->uxMutexesHeld = 0;\r
+       }\r
+       #endif /* configUSE_MUTEXES */\r
+\r
+       vListInitialiseItem( &( pxTCB->xGenericListItem ) );\r
+       vListInitialiseItem( &( pxTCB->xEventListItem ) );\r
+\r
+       /* Set the pxTCB as a link back from the ListItem_t.  This is so we can get\r
+       back to the containing TCB from a generic item in a list. */\r
+       listSET_LIST_ITEM_OWNER( &( pxTCB->xGenericListItem ), pxTCB );\r
+\r
+       /* Event lists are always in priority order. */\r
+       listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+       listSET_LIST_ITEM_OWNER( &( pxTCB->xEventListItem ), pxTCB );\r
+\r
+       #if ( portCRITICAL_NESTING_IN_TCB == 1 )\r
+       {\r
+               pxTCB->uxCriticalNesting = ( UBaseType_t ) 0U;\r
+       }\r
+       #endif /* portCRITICAL_NESTING_IN_TCB */\r
+\r
+       #if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
+       {\r
+               pxTCB->pxTaskTag = NULL;\r
+       }\r
+       #endif /* configUSE_APPLICATION_TASK_TAG */\r
+\r
+       #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
+       {\r
+               pxTCB->ulRunTimeCounter = 0UL;\r
+       }\r
+       #endif /* configGENERATE_RUN_TIME_STATS */\r
+\r
+       #if ( portUSING_MPU_WRAPPERS == 1 )\r
+       {\r
+               vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, pxTCB->pxStack, usStackDepth );\r
+       }\r
+       #else /* portUSING_MPU_WRAPPERS */\r
+       {\r
+               ( void ) xRegions;\r
+               ( void ) usStackDepth;\r
+       }\r
+       #endif /* portUSING_MPU_WRAPPERS */\r
+\r
+       #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )\r
+       {\r
+               for( x = 0; x < ( UBaseType_t ) configNUM_THREAD_LOCAL_STORAGE_POINTERS; x++ )\r
+               {\r
+                       pxTCB->pvThreadLocalStoragePointers[ x ] = NULL;\r
+               }\r
+       }\r
+       #endif\r
+\r
+       #if ( configUSE_TASK_NOTIFICATIONS == 1 )\r
+       {\r
+               pxTCB->ulNotifiedValue = 0;\r
+               pxTCB->eNotifyState = eNotWaitingNotification;\r
+       }\r
+       #endif\r
+\r
+       #if ( configUSE_NEWLIB_REENTRANT == 1 )\r
+       {\r
+               /* Initialise this task's Newlib reent structure. */\r
+               _REENT_INIT_PTR( ( &( pxTCB->xNewLib_reent ) ) );\r
+       }\r
+       #endif /* configUSE_NEWLIB_REENTRANT */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )\r
+\r
+       void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue )\r
+       {\r
+       TCB_t *pxTCB;\r
+\r
+               if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS )\r
+               {\r
+                       pxTCB = prvGetTCBFromHandle( xTaskToSet );\r
+                       pxTCB->pvThreadLocalStoragePointers[ xIndex ] = pvValue;\r
+               }\r
+       }\r
+\r
+#endif /* configNUM_THREAD_LOCAL_STORAGE_POINTERS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )\r
+\r
+       void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex )\r
+       {\r
+       void *pvReturn = NULL;\r
+       TCB_t *pxTCB;\r
+\r
+               if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS )\r
+               {\r
+                       pxTCB = prvGetTCBFromHandle( xTaskToQuery );\r
+                       pvReturn = pxTCB->pvThreadLocalStoragePointers[ xIndex ];\r
+               }\r
+               else\r
+               {\r
+                       pvReturn = NULL;\r
+               }\r
+\r
+               return pvReturn;\r
+       }\r
+\r
+#endif /* configNUM_THREAD_LOCAL_STORAGE_POINTERS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( portUSING_MPU_WRAPPERS == 1 )\r
+\r
+       void vTaskAllocateMPURegions( TaskHandle_t xTaskToModify, const MemoryRegion_t * const xRegions )\r
+       {\r
+       TCB_t *pxTCB;\r
+\r
+               /* If null is passed in here then we are modifying the MPU settings of\r
+               the calling task. */\r
+               pxTCB = prvGetTCBFromHandle( xTaskToModify );\r
+\r
+        vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, NULL, 0 );\r
+       }\r
+\r
+#endif /* portUSING_MPU_WRAPPERS */\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvInitialiseTaskLists( void )\r
+{\r
+UBaseType_t uxPriority;\r
+\r
+       for( uxPriority = ( UBaseType_t ) 0U; uxPriority < ( UBaseType_t ) configMAX_PRIORITIES; uxPriority++ )\r
+       {\r
+               vListInitialise( &( pxReadyTasksLists[ uxPriority ] ) );\r
+       }\r
+\r
+       vListInitialise( &xDelayedTaskList1 );\r
+       vListInitialise( &xDelayedTaskList2 );\r
+       vListInitialise( &xPendingReadyList );\r
+\r
+       #if ( INCLUDE_vTaskDelete == 1 )\r
+       {\r
+               vListInitialise( &xTasksWaitingTermination );\r
+       }\r
+       #endif /* INCLUDE_vTaskDelete */\r
+\r
+       #if ( INCLUDE_vTaskSuspend == 1 )\r
+       {\r
+               vListInitialise( &xSuspendedTaskList );\r
+       }\r
+       #endif /* INCLUDE_vTaskSuspend */\r
+\r
+       /* Start with pxDelayedTaskList using list1 and the pxOverflowDelayedTaskList\r
+       using list2. */\r
+       pxDelayedTaskList = &xDelayedTaskList1;\r
+       pxOverflowDelayedTaskList = &xDelayedTaskList2;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCheckTasksWaitingTermination( void )\r
+{\r
+       #if ( INCLUDE_vTaskDelete == 1 )\r
+       {\r
+               BaseType_t xListIsEmpty;\r
+\r
+               /* ucTasksDeleted is used to prevent vTaskSuspendAll() being called\r
+               too often in the idle task. */\r
+               while( uxTasksDeleted > ( UBaseType_t ) 0U )\r
+               {\r
+                       vTaskSuspendAll();\r
+                       {\r
+                               xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination );\r
+                       }\r
+                       ( void ) xTaskResumeAll();\r
+\r
+                       if( xListIsEmpty == pdFALSE )\r
+                       {\r
+                               TCB_t *pxTCB;\r
+\r
+                               taskENTER_CRITICAL();\r
+                               {\r
+                                       pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) );\r
+                                       ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
+                                       --uxCurrentNumberOfTasks;\r
+                                       --uxTasksDeleted;\r
+                               }\r
+                               taskEXIT_CRITICAL();\r
+\r
+                               prvDeleteTCB( pxTCB );\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+       }\r
+       #endif /* vTaskDelete */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvAddCurrentTaskToDelayedList( const TickType_t xTimeToWake )\r
+{\r
+       /* The list item will be inserted in wake time order. */\r
+       listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake );\r
+\r
+       if( xTimeToWake < xTickCount )\r
+       {\r
+               /* Wake time has overflowed.  Place this item in the overflow list. */\r
+               vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+       }\r
+       else\r
+       {\r
+               /* The wake time has not overflowed, so the current block list is used. */\r
+               vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+\r
+               /* If the task entering the blocked state was placed at the head of the\r
+               list of blocked tasks then xNextTaskUnblockTime needs to be updated\r
+               too. */\r
+               if( xTimeToWake < xNextTaskUnblockTime )\r
+               {\r
+                       xNextTaskUnblockTime = xTimeToWake;\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static TCB_t *prvAllocateTCBAndStack( const uint16_t usStackDepth, StackType_t * const puxStackBuffer )\r
+{\r
+TCB_t *pxNewTCB;\r
+\r
+       /* If the stack grows down then allocate the stack then the TCB so the stack\r
+       does not grow into the TCB.  Likewise if the stack grows up then allocate\r
+       the TCB then the stack. */\r
+       #if( portSTACK_GROWTH > 0 )\r
+       {\r
+               /* Allocate space for the TCB.  Where the memory comes from depends on\r
+               the implementation of the port malloc function. */\r
+               pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) );\r
+\r
+               if( pxNewTCB != NULL )\r
+               {\r
+                       /* Allocate space for the stack used by the task being created.\r
+                       The base of the stack memory stored in the TCB so the task can\r
+                       be deleted later if required. */\r
+                       pxNewTCB->pxStack = ( StackType_t * ) pvPortMallocAligned( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ), puxStackBuffer ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+\r
+                       if( pxNewTCB->pxStack == NULL )\r
+                       {\r
+                               /* Could not allocate the stack.  Delete the allocated TCB. */\r
+                               vPortFree( pxNewTCB );\r
+                               pxNewTCB = NULL;\r
+                       }\r
+               }\r
+       }\r
+       #else /* portSTACK_GROWTH */\r
+       {\r
+       StackType_t *pxStack;\r
+\r
+               /* Allocate space for the stack used by the task being created. */\r
+               pxStack = ( StackType_t * ) pvPortMallocAligned( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ), puxStackBuffer ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+\r
+               if( pxStack != NULL )\r
+               {\r
+                       /* Allocate space for the TCB.  Where the memory comes from depends\r
+                       on the implementation of the port malloc function. */\r
+                       pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) );\r
+\r
+                       if( pxNewTCB != NULL )\r
+                       {\r
+                               /* Store the stack location in the TCB. */\r
+                               pxNewTCB->pxStack = pxStack;\r
+                       }\r
+                       else\r
+                       {\r
+                               /* The stack cannot be used as the TCB was not created.  Free it\r
+                               again. */\r
+                               vPortFree( pxStack );\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       pxNewTCB = NULL;\r
+               }\r
+       }\r
+       #endif /* portSTACK_GROWTH */\r
+\r
+       if( pxNewTCB != NULL )\r
+       {\r
+               /* Avoid dependency on memset() if it is not required. */\r
+               #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )\r
+               {\r
+                       /* Just to help debugging. */\r
+                       ( void ) memset( pxNewTCB->pxStack, ( int ) tskSTACK_FILL_BYTE, ( size_t ) usStackDepth * sizeof( StackType_t ) );\r
+               }\r
+               #endif /* ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) ) */\r
+       }\r
+\r
+       return pxNewTCB;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_TRACE_FACILITY == 1 )\r
+\r
+       static UBaseType_t prvListTaskWithinSingleList( TaskStatus_t *pxTaskStatusArray, List_t *pxList, eTaskState eState )\r
+       {\r
+       volatile TCB_t *pxNextTCB, *pxFirstTCB;\r
+       UBaseType_t uxTask = 0;\r
+\r
+               if( listCURRENT_LIST_LENGTH( pxList ) > ( UBaseType_t ) 0 )\r
+               {\r
+                       listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList );\r
+\r
+                       /* Populate an TaskStatus_t structure within the\r
+                       pxTaskStatusArray array for each task that is referenced from\r
+                       pxList.  See the definition of TaskStatus_t in task.h for the\r
+                       meaning of each TaskStatus_t structure member. */\r
+                       do\r
+                       {\r
+                               listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList );\r
+\r
+                               pxTaskStatusArray[ uxTask ].xHandle = ( TaskHandle_t ) pxNextTCB;\r
+                               pxTaskStatusArray[ uxTask ].pcTaskName = ( const char * ) &( pxNextTCB->pcTaskName [ 0 ] );\r
+                               pxTaskStatusArray[ uxTask ].xTaskNumber = pxNextTCB->uxTCBNumber;\r
+                               pxTaskStatusArray[ uxTask ].eCurrentState = eState;\r
+                               pxTaskStatusArray[ uxTask ].uxCurrentPriority = pxNextTCB->uxPriority;\r
+\r
+                               #if ( INCLUDE_vTaskSuspend == 1 )\r
+                               {\r
+                                       /* If the task is in the suspended list then there is a chance\r
+                                       it is actually just blocked indefinitely - so really it should\r
+                                       be reported as being in the Blocked state. */\r
+                                       if( eState == eSuspended )\r
+                                       {\r
+                                               if( listLIST_ITEM_CONTAINER( &( pxNextTCB->xEventListItem ) ) != NULL )\r
+                                               {\r
+                                                       pxTaskStatusArray[ uxTask ].eCurrentState = eBlocked;\r
+                                               }\r
+                                       }\r
+                               }\r
+                               #endif /* INCLUDE_vTaskSuspend */\r
+\r
+                               #if ( configUSE_MUTEXES == 1 )\r
+                               {\r
+                                       pxTaskStatusArray[ uxTask ].uxBasePriority = pxNextTCB->uxBasePriority;\r
+                               }\r
+                               #else\r
+                               {\r
+                                       pxTaskStatusArray[ uxTask ].uxBasePriority = 0;\r
+                               }\r
+                               #endif\r
+\r
+                               #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
+                               {\r
+                                       pxTaskStatusArray[ uxTask ].ulRunTimeCounter = pxNextTCB->ulRunTimeCounter;\r
+                               }\r
+                               #else\r
+                               {\r
+                                       pxTaskStatusArray[ uxTask ].ulRunTimeCounter = 0;\r
+                               }\r
+                               #endif\r
+\r
+                               #if ( portSTACK_GROWTH > 0 )\r
+                               {\r
+                                       pxTaskStatusArray[ uxTask ].usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( uint8_t * ) pxNextTCB->pxEndOfStack );\r
+                               }\r
+                               #else\r
+                               {\r
+                                       pxTaskStatusArray[ uxTask ].usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( uint8_t * ) pxNextTCB->pxStack );\r
+                               }\r
+                               #endif\r
+\r
+                               uxTask++;\r
+\r
+                       } while( pxNextTCB != pxFirstTCB );\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               return uxTask;\r
+       }\r
+\r
+#endif /* configUSE_TRACE_FACILITY */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )\r
+\r
+       static uint16_t prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte )\r
+       {\r
+       uint32_t ulCount = 0U;\r
+\r
+               while( *pucStackByte == ( uint8_t ) tskSTACK_FILL_BYTE )\r
+               {\r
+                       pucStackByte -= portSTACK_GROWTH;\r
+                       ulCount++;\r
+               }\r
+\r
+               ulCount /= ( uint32_t ) sizeof( StackType_t ); /*lint !e961 Casting is not redundant on smaller architectures. */\r
+\r
+               return ( uint16_t ) ulCount;\r
+       }\r
+\r
+#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )\r
+\r
+       UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask )\r
+       {\r
+       TCB_t *pxTCB;\r
+       uint8_t *pucEndOfStack;\r
+       UBaseType_t uxReturn;\r
+\r
+               pxTCB = prvGetTCBFromHandle( xTask );\r
+\r
+               #if portSTACK_GROWTH < 0\r
+               {\r
+                       pucEndOfStack = ( uint8_t * ) pxTCB->pxStack;\r
+               }\r
+               #else\r
+               {\r
+                       pucEndOfStack = ( uint8_t * ) pxTCB->pxEndOfStack;\r
+               }\r
+               #endif\r
+\r
+               uxReturn = ( UBaseType_t ) prvTaskCheckFreeStackSpace( pucEndOfStack );\r
+\r
+               return uxReturn;\r
+       }\r
+\r
+#endif /* INCLUDE_uxTaskGetStackHighWaterMark */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_vTaskDelete == 1 )\r
+\r
+       static void prvDeleteTCB( TCB_t *pxTCB )\r
+       {\r
+               /* This call is required specifically for the TriCore port.  It must be\r
+               above the vPortFree() calls.  The call is also used by ports/demos that\r
+               want to allocate and clean RAM statically. */\r
+               portCLEAN_UP_TCB( pxTCB );\r
+\r
+               /* Free up the memory allocated by the scheduler for the task.  It is up\r
+               to the task to free any memory allocated at the application level. */\r
+               #if ( configUSE_NEWLIB_REENTRANT == 1 )\r
+               {\r
+                       _reclaim_reent( &( pxTCB->xNewLib_reent ) );\r
+               }\r
+               #endif /* configUSE_NEWLIB_REENTRANT */\r
+\r
+               #if( portUSING_MPU_WRAPPERS == 1 )\r
+               {\r
+                       /* Only free the stack if it was allocated dynamically in the first\r
+                       place. */\r
+                       if( pxTCB->xUsingStaticallyAllocatedStack == pdFALSE )\r
+                       {\r
+                               vPortFreeAligned( pxTCB->pxStack );\r
+                       }\r
+               }\r
+               #else\r
+               {\r
+                       vPortFreeAligned( pxTCB->pxStack );\r
+               }\r
+               #endif\r
+\r
+               vPortFree( pxTCB );\r
+       }\r
+\r
+#endif /* INCLUDE_vTaskDelete */\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvResetNextTaskUnblockTime( void )\r
+{\r
+TCB_t *pxTCB;\r
+\r
+       if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE )\r
+       {\r
+               /* The new current delayed list is empty.  Set xNextTaskUnblockTime to\r
+               the maximum possible value so it is     extremely unlikely that the\r
+               if( xTickCount >= xNextTaskUnblockTime ) test will pass until\r
+               there is an item in the delayed list. */\r
+               xNextTaskUnblockTime = portMAX_DELAY;\r
+       }\r
+       else\r
+       {\r
+               /* The new current delayed list is not empty, get the value of\r
+               the item at the head of the delayed list.  This is the time at\r
+               which the task at the head of the delayed list should be removed\r
+               from the Blocked state. */\r
+               ( pxTCB ) = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList );\r
+               xNextTaskUnblockTime = listGET_LIST_ITEM_VALUE( &( ( pxTCB )->xGenericListItem ) );\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) )\r
+\r
+       TaskHandle_t xTaskGetCurrentTaskHandle( void )\r
+       {\r
+       TaskHandle_t xReturn;\r
+\r
+               /* A critical section is not required as this is not called from\r
+               an interrupt and the current TCB will always be the same for any\r
+               individual execution thread. */\r
+               xReturn = pxCurrentTCB;\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r
+\r
+       BaseType_t xTaskGetSchedulerState( void )\r
+       {\r
+       BaseType_t xReturn;\r
+\r
+               if( xSchedulerRunning == pdFALSE )\r
+               {\r
+                       xReturn = taskSCHEDULER_NOT_STARTED;\r
+               }\r
+               else\r
+               {\r
+                       if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
+                       {\r
+                               xReturn = taskSCHEDULER_RUNNING;\r
+                       }\r
+                       else\r
+                       {\r
+                               xReturn = taskSCHEDULER_SUSPENDED;\r
+                       }\r
+               }\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_MUTEXES == 1 )\r
+\r
+       void vTaskPriorityInherit( TaskHandle_t const pxMutexHolder )\r
+       {\r
+       TCB_t * const pxTCB = ( TCB_t * ) pxMutexHolder;\r
+\r
+               /* If the mutex was given back by an interrupt while the queue was\r
+               locked then the mutex holder might now be NULL. */\r
+               if( pxMutexHolder != NULL )\r
+               {\r
+                       /* If the holder of the mutex has a priority below the priority of\r
+                       the task attempting to obtain the mutex then it will temporarily\r
+                       inherit the priority of the task attempting to obtain the mutex. */\r
+                       if( pxTCB->uxPriority < pxCurrentTCB->uxPriority )\r
+                       {\r
+                               /* Adjust the mutex holder state to account for its new\r
+                               priority.  Only reset the event list item value if the value is\r
+                               not     being used for anything else. */\r
+                               if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL )\r
+                               {\r
+                                       listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+\r
+                               /* If the task being modified is in the ready state it will need\r
+                               to be moved into a new list. */\r
+                               if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ) != pdFALSE )\r
+                               {\r
+                                       if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+                                       {\r
+                                               taskRESET_READY_PRIORITY( pxTCB->uxPriority );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+\r
+                                       /* Inherit the priority before being moved into the new list. */\r
+                                       pxTCB->uxPriority = pxCurrentTCB->uxPriority;\r
+                                       prvAddTaskToReadyList( pxTCB );\r
+                               }\r
+                               else\r
+                               {\r
+                                       /* Just inherit the priority. */\r
+                                       pxTCB->uxPriority = pxCurrentTCB->uxPriority;\r
+                               }\r
+\r
+                               traceTASK_PRIORITY_INHERIT( pxTCB, pxCurrentTCB->uxPriority );\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+\r
+#endif /* configUSE_MUTEXES */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_MUTEXES == 1 )\r
+\r
+       BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder )\r
+       {\r
+       TCB_t * const pxTCB = ( TCB_t * ) pxMutexHolder;\r
+       BaseType_t xReturn = pdFALSE;\r
+\r
+               if( pxMutexHolder != NULL )\r
+               {\r
+                       /* A task can only have an inherited priority if it holds the mutex.\r
+                       If the mutex is held by a task then it cannot be given from an\r
+                       interrupt, and if a mutex is given by the holding task then it must\r
+                       be the running state task. */\r
+                       configASSERT( pxTCB == pxCurrentTCB );\r
+\r
+                       configASSERT( pxTCB->uxMutexesHeld );\r
+                       ( pxTCB->uxMutexesHeld )--;\r
+\r
+                       /* Has the holder of the mutex inherited the priority of another\r
+                       task? */\r
+                       if( pxTCB->uxPriority != pxTCB->uxBasePriority )\r
+                       {\r
+                               /* Only disinherit if no other mutexes are held. */\r
+                               if( pxTCB->uxMutexesHeld == ( UBaseType_t ) 0 )\r
+                               {\r
+                                       /* A task can only have an inherited priority if it holds\r
+                                       the mutex.  If the mutex is held by a task then it cannot be\r
+                                       given from an interrupt, and if a mutex is given by the\r
+                                       holding task then it must be the running state task.  Remove\r
+                                       the     holding task from the ready     list. */\r
+                                       if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+                                       {\r
+                                               taskRESET_READY_PRIORITY( pxTCB->uxPriority );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+\r
+                                       /* Disinherit the priority before adding the task into the\r
+                                       new     ready list. */\r
+                                       traceTASK_PRIORITY_DISINHERIT( pxTCB, pxTCB->uxBasePriority );\r
+                                       pxTCB->uxPriority = pxTCB->uxBasePriority;\r
+\r
+                                       /* Reset the event list item value.  It cannot be in use for\r
+                                       any other purpose if this task is running, and it must be\r
+                                       running to give back the mutex. */\r
+                                       listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+                                       prvAddTaskToReadyList( pxTCB );\r
+\r
+                                       /* Return true to indicate that a context switch is required.\r
+                                       This is only actually required in the corner case whereby\r
+                                       multiple mutexes were held and the mutexes were given back\r
+                                       in an order different to that in which they were taken.\r
+                                       If a context switch did not occur when the first mutex was\r
+                                       returned, even if a task was waiting on it, then a context\r
+                                       switch should occur when the last mutex is returned whether\r
+                                       a task is waiting on it or not. */\r
+                                       xReturn = pdTRUE;\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_MUTEXES */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( portCRITICAL_NESTING_IN_TCB == 1 )\r
+\r
+       void vTaskEnterCritical( void )\r
+       {\r
+               portDISABLE_INTERRUPTS();\r
+\r
+               if( xSchedulerRunning != pdFALSE )\r
+               {\r
+                       ( pxCurrentTCB->uxCriticalNesting )++;\r
+\r
+                       /* This is not the interrupt safe version of the enter critical\r
+                       function so     assert() if it is being called from an interrupt\r
+                       context.  Only API functions that end in "FromISR" can be used in an\r
+                       interrupt.  Only assert if the critical nesting count is 1 to\r
+                       protect against recursive calls if the assert function also uses a\r
+                       critical section. */\r
+                       if( pxCurrentTCB->uxCriticalNesting == 1 )\r
+                       {\r
+                               portASSERT_IF_IN_ISR();\r
+                       }\r
+\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+\r
+#endif /* portCRITICAL_NESTING_IN_TCB */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( portCRITICAL_NESTING_IN_TCB == 1 )\r
+\r
+       void vTaskExitCritical( void )\r
+       {\r
+               if( xSchedulerRunning != pdFALSE )\r
+               {\r
+                       if( pxCurrentTCB->uxCriticalNesting > 0U )\r
+                       {\r
+                               ( pxCurrentTCB->uxCriticalNesting )--;\r
+\r
+                               if( pxCurrentTCB->uxCriticalNesting == 0U )\r
+                               {\r
+                                       portENABLE_INTERRUPTS();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+\r
+#endif /* portCRITICAL_NESTING_IN_TCB */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) )\r
+\r
+       static char *prvWriteNameToBuffer( char *pcBuffer, const char *pcTaskName )\r
+       {\r
+       BaseType_t x;\r
+\r
+               /* Start by copying the entire string. */\r
+               strcpy( pcBuffer, pcTaskName );\r
+\r
+               /* Pad the end of the string with spaces to ensure columns line up when\r
+               printed out. */\r
+               for( x = strlen( pcBuffer ); x < ( configMAX_TASK_NAME_LEN - 1 ); x++ )\r
+               {\r
+                       pcBuffer[ x ] = ' ';\r
+               }\r
+\r
+               /* Terminate. */\r
+               pcBuffer[ x ] = 0x00;\r
+\r
+               /* Return the new end of string. */\r
+               return &( pcBuffer[ x ] );\r
+       }\r
+\r
+#endif /* ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) )\r
+\r
+       void vTaskList( char * pcWriteBuffer )\r
+       {\r
+       TaskStatus_t *pxTaskStatusArray;\r
+       volatile UBaseType_t uxArraySize, x;\r
+       char cStatus;\r
+\r
+               /*\r
+                * PLEASE NOTE:\r
+                *\r
+                * This function is provided for convenience only, and is used by many\r
+                * of the demo applications.  Do not consider it to be part of the\r
+                * scheduler.\r
+                *\r
+                * vTaskList() calls uxTaskGetSystemState(), then formats part of the\r
+                * uxTaskGetSystemState() output into a human readable table that\r
+                * displays task names, states and stack usage.\r
+                *\r
+                * vTaskList() has a dependency on the sprintf() C library function that\r
+                * might bloat the code size, use a lot of stack, and provide different\r
+                * results on different platforms.  An alternative, tiny, third party,\r
+                * and limited functionality implementation of sprintf() is provided in\r
+                * many of the FreeRTOS/Demo sub-directories in a file called\r
+                * printf-stdarg.c (note printf-stdarg.c does not provide a full\r
+                * snprintf() implementation!).\r
+                *\r
+                * It is recommended that production systems call uxTaskGetSystemState()\r
+                * directly to get access to raw stats data, rather than indirectly\r
+                * through a call to vTaskList().\r
+                */\r
+\r
+\r
+               /* Make sure the write buffer does not contain a string. */\r
+               *pcWriteBuffer = 0x00;\r
+\r
+               /* Take a snapshot of the number of tasks in case it changes while this\r
+               function is executing. */\r
+               uxArraySize = uxCurrentNumberOfTasks;\r
+\r
+               /* Allocate an array index for each task. */\r
+               pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) );\r
+\r
+               if( pxTaskStatusArray != NULL )\r
+               {\r
+                       /* Generate the (binary) data. */\r
+                       uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, NULL );\r
+\r
+                       /* Create a human readable table from the binary data. */\r
+                       for( x = 0; x < uxArraySize; x++ )\r
+                       {\r
+                               switch( pxTaskStatusArray[ x ].eCurrentState )\r
+                               {\r
+                                       case eReady:            cStatus = tskREADY_CHAR;\r
+                                                                               break;\r
+\r
+                                       case eBlocked:          cStatus = tskBLOCKED_CHAR;\r
+                                                                               break;\r
+\r
+                                       case eSuspended:        cStatus = tskSUSPENDED_CHAR;\r
+                                                                               break;\r
+\r
+                                       case eDeleted:          cStatus = tskDELETED_CHAR;\r
+                                                                               break;\r
+\r
+                                       default:                        /* Should not get here, but it is included\r
+                                                                               to prevent static checking errors. */\r
+                                                                               cStatus = 0x00;\r
+                                                                               break;\r
+                               }\r
+\r
+                               /* Write the task name to the string, padding with spaces so it\r
+                               can be printed in tabular form more easily. */\r
+                               pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName );\r
+\r
+                               /* Write the rest of the string. */\r
+                               sprintf( pcWriteBuffer, "\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber );\r
+                               pcWriteBuffer += strlen( pcWriteBuffer );\r
+                       }\r
+\r
+                       /* Free the array again. */\r
+                       vPortFree( pxTaskStatusArray );\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+\r
+#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) */\r
+/*----------------------------------------------------------*/\r
+\r
+#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) )\r
+\r
+       void vTaskGetRunTimeStats( char *pcWriteBuffer )\r
+       {\r
+       TaskStatus_t *pxTaskStatusArray;\r
+       volatile UBaseType_t uxArraySize, x;\r
+       uint32_t ulTotalTime, ulStatsAsPercentage;\r
+\r
+               #if( configUSE_TRACE_FACILITY != 1 )\r
+               {\r
+                       #error configUSE_TRACE_FACILITY must also be set to 1 in FreeRTOSConfig.h to use vTaskGetRunTimeStats().\r
+               }\r
+               #endif\r
+\r
+               /*\r
+                * PLEASE NOTE:\r
+                *\r
+                * This function is provided for convenience only, and is used by many\r
+                * of the demo applications.  Do not consider it to be part of the\r
+                * scheduler.\r
+                *\r
+                * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part\r
+                * of the uxTaskGetSystemState() output into a human readable table that\r
+                * displays the amount of time each task has spent in the Running state\r
+                * in both absolute and percentage terms.\r
+                *\r
+                * vTaskGetRunTimeStats() has a dependency on the sprintf() C library\r
+                * function that might bloat the code size, use a lot of stack, and\r
+                * provide different results on different platforms.  An alternative,\r
+                * tiny, third party, and limited functionality implementation of\r
+                * sprintf() is provided in many of the FreeRTOS/Demo sub-directories in\r
+                * a file called printf-stdarg.c (note printf-stdarg.c does not provide\r
+                * a full snprintf() implementation!).\r
+                *\r
+                * It is recommended that production systems call uxTaskGetSystemState()\r
+                * directly to get access to raw stats data, rather than indirectly\r
+                * through a call to vTaskGetRunTimeStats().\r
+                */\r
+\r
+               /* Make sure the write buffer does not contain a string. */\r
+               *pcWriteBuffer = 0x00;\r
+\r
+               /* Take a snapshot of the number of tasks in case it changes while this\r
+               function is executing. */\r
+               uxArraySize = uxCurrentNumberOfTasks;\r
+\r
+               /* Allocate an array index for each task. */\r
+               pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) );\r
+\r
+               if( pxTaskStatusArray != NULL )\r
+               {\r
+                       /* Generate the (binary) data. */\r
+                       uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalTime );\r
+\r
+                       /* For percentage calculations. */\r
+                       ulTotalTime /= 100UL;\r
+\r
+                       /* Avoid divide by zero errors. */\r
+                       if( ulTotalTime > 0 )\r
+                       {\r
+                               /* Create a human readable table from the binary data. */\r
+                               for( x = 0; x < uxArraySize; x++ )\r
+                               {\r
+                                       /* What percentage of the total run time has the task used?\r
+                                       This will always be rounded down to the nearest integer.\r
+                                       ulTotalRunTimeDiv100 has already been divided by 100. */\r
+                                       ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalTime;\r
+\r
+                                       /* Write the task name to the string, padding with\r
+                                       spaces so it can be printed in tabular form more\r
+                                       easily. */\r
+                                       pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName );\r
+\r
+                                       if( ulStatsAsPercentage > 0UL )\r
+                                       {\r
+                                               #ifdef portLU_PRINTF_SPECIFIER_REQUIRED\r
+                                               {\r
+                                                       sprintf( pcWriteBuffer, "\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );\r
+                                               }\r
+                                               #else\r
+                                               {\r
+                                                       /* sizeof( int ) == sizeof( long ) so a smaller\r
+                                                       printf() library can be used. */\r
+                                                       sprintf( pcWriteBuffer, "\t%u\t\t%u%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage );\r
+                                               }\r
+                                               #endif\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               /* If the percentage is zero here then the task has\r
+                                               consumed less than 1% of the total run time. */\r
+                                               #ifdef portLU_PRINTF_SPECIFIER_REQUIRED\r
+                                               {\r
+                                                       sprintf( pcWriteBuffer, "\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter );\r
+                                               }\r
+                                               #else\r
+                                               {\r
+                                                       /* sizeof( int ) == sizeof( long ) so a smaller\r
+                                                       printf() library can be used. */\r
+                                                       sprintf( pcWriteBuffer, "\t%u\t\t<1%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter );\r
+                                               }\r
+                                               #endif\r
+                                       }\r
+\r
+                                       pcWriteBuffer += strlen( pcWriteBuffer );\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       /* Free the array again. */\r
+                       vPortFree( pxTaskStatusArray );\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+\r
+#endif /* ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) */\r
+/*-----------------------------------------------------------*/\r
+\r
+TickType_t uxTaskResetEventItemValue( void )\r
+{\r
+TickType_t uxReturn;\r
+\r
+       uxReturn = listGET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ) );\r
+\r
+       /* Reset the event list item to its normal value - so it can be used with\r
+       queues and semaphores. */\r
+       listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ), ( ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB->uxPriority ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+\r
+       return uxReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_MUTEXES == 1 )\r
+\r
+       void *pvTaskIncrementMutexHeldCount( void )\r
+       {\r
+               /* If xSemaphoreCreateMutex() is called before any tasks have been created\r
+               then pxCurrentTCB will be NULL. */\r
+               if( pxCurrentTCB != NULL )\r
+               {\r
+                       ( pxCurrentTCB->uxMutexesHeld )++;\r
+               }\r
+\r
+               return pxCurrentTCB;\r
+       }\r
+\r
+#endif /* configUSE_MUTEXES */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( configUSE_TASK_NOTIFICATIONS == 1 )\r
+\r
+       uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait )\r
+       {\r
+       TickType_t xTimeToWake;\r
+       uint32_t ulReturn;\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       /* Only block if the notification count is not already non-zero. */\r
+                       if( pxCurrentTCB->ulNotifiedValue == 0UL )\r
+                       {\r
+                               /* Mark this task as waiting for a notification. */\r
+                               pxCurrentTCB->eNotifyState = eWaitingNotification;\r
+\r
+                               if( xTicksToWait > ( TickType_t ) 0 )\r
+                               {\r
+                                       /* The task is going to block.  First it must be removed\r
+                                       from the ready list. */\r
+                                       if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+                                       {\r
+                                               /* The current task must be in a ready list, so there is\r
+                                               no need to check, and the port reset macro can be called\r
+                                               directly. */\r
+                                               portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+\r
+                                       #if ( INCLUDE_vTaskSuspend == 1 )\r
+                                       {\r
+                                               if( xTicksToWait == portMAX_DELAY )\r
+                                               {\r
+                                                       /* Add the task to the suspended task list instead\r
+                                                       of a delayed task list to ensure the task is not\r
+                                                       woken by a timing event.  It will block\r
+                                                       indefinitely. */\r
+                                                       vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       /* Calculate the time at which the task should be\r
+                                                       woken if no notification events occur.  This may\r
+                                                       overflow but this doesn't matter, the scheduler will\r
+                                                       handle it. */\r
+                                                       xTimeToWake = xTickCount + xTicksToWait;\r
+                                                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+                                               }\r
+                                       }\r
+                                       #else /* INCLUDE_vTaskSuspend */\r
+                                       {\r
+                                                       /* Calculate the time at which the task should be\r
+                                                       woken if the event does not occur.  This may\r
+                                                       overflow but this doesn't matter, the scheduler will\r
+                                                       handle it. */\r
+                                                       xTimeToWake = xTickCount + xTicksToWait;\r
+                                                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+                                       }\r
+                                       #endif /* INCLUDE_vTaskSuspend */\r
+\r
+                                       traceTASK_NOTIFY_TAKE_BLOCK();\r
+\r
+                                       /* All ports are written to allow a yield in a critical\r
+                                       section (some will yield immediately, others wait until the\r
+                                       critical section exits) - but it is not something that\r
+                                       application code should ever do. */\r
+                                       portYIELD_WITHIN_API();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       traceTASK_NOTIFY_TAKE();\r
+                       ulReturn = pxCurrentTCB->ulNotifiedValue;\r
+\r
+                       if( ulReturn != 0UL )\r
+                       {\r
+                               if( xClearCountOnExit != pdFALSE )\r
+                               {\r
+                                       pxCurrentTCB->ulNotifiedValue = 0UL;\r
+                               }\r
+                               else\r
+                               {\r
+                                       ( pxCurrentTCB->ulNotifiedValue )--;\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       pxCurrentTCB->eNotifyState = eNotWaitingNotification;\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               return ulReturn;\r
+       }\r
+\r
+#endif /* configUSE_TASK_NOTIFICATIONS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( configUSE_TASK_NOTIFICATIONS == 1 )\r
+\r
+       BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait )\r
+       {\r
+       TickType_t xTimeToWake;\r
+       BaseType_t xReturn;\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       /* Only block if a notification is not already pending. */\r
+                       if( pxCurrentTCB->eNotifyState != eNotified )\r
+                       {\r
+                               /* Clear bits in the task's notification value as bits may get\r
+                               set     by the notifying task or interrupt.  This can be used to\r
+                               clear the value to zero. */\r
+                               pxCurrentTCB->ulNotifiedValue &= ~ulBitsToClearOnEntry;\r
+\r
+                               /* Mark this task as waiting for a notification. */\r
+                               pxCurrentTCB->eNotifyState = eWaitingNotification;\r
+\r
+                               if( xTicksToWait > ( TickType_t ) 0 )\r
+                               {\r
+                                       /* The task is going to block.  First it must be removed\r
+                                       from the        ready list. */\r
+                                       if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+                                       {\r
+                                               /* The current task must be in a ready list, so there is\r
+                                               no need to check, and the port reset macro can be called\r
+                                               directly. */\r
+                                               portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+\r
+                                       #if ( INCLUDE_vTaskSuspend == 1 )\r
+                                       {\r
+                                               if( xTicksToWait == portMAX_DELAY )\r
+                                               {\r
+                                                       /* Add the task to the suspended task list instead\r
+                                                       of a delayed task list to ensure the task is not\r
+                                                       woken by a timing event.  It will block\r
+                                                       indefinitely. */\r
+                                                       vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       /* Calculate the time at which the task should be\r
+                                                       woken if no notification events occur.  This may\r
+                                                       overflow but this doesn't matter, the scheduler will\r
+                                                       handle it. */\r
+                                                       xTimeToWake = xTickCount + xTicksToWait;\r
+                                                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+                                               }\r
+                                       }\r
+                                       #else /* INCLUDE_vTaskSuspend */\r
+                                       {\r
+                                                       /* Calculate the time at which the task should be\r
+                                                       woken if the event does not occur.  This may\r
+                                                       overflow but this doesn't matter, the scheduler will\r
+                                                       handle it. */\r
+                                                       xTimeToWake = xTickCount + xTicksToWait;\r
+                                                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+                                       }\r
+                                       #endif /* INCLUDE_vTaskSuspend */\r
+\r
+                                       traceTASK_NOTIFY_WAIT_BLOCK();\r
+                                       \r
+                                       /* All ports are written to allow a yield in a critical\r
+                                       section (some will yield immediately, others wait until the\r
+                                       critical section exits) - but it is not something that\r
+                                       application code should ever do. */\r
+                                       portYIELD_WITHIN_API();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       traceTASK_NOTIFY_WAIT();\r
+                       \r
+                       if( pulNotificationValue != NULL )\r
+                       {\r
+                               /* Output the current notification value, which may or may not\r
+                               have changed. */\r
+                               *pulNotificationValue = pxCurrentTCB->ulNotifiedValue;\r
+                       }\r
+\r
+                       /* If eNotifyValue is set then either the task never entered the\r
+                       blocked state (because a notification was already pending) or the\r
+                       task unblocked because of a notification.  Otherwise the task\r
+                       unblocked because of a timeout. */\r
+                       if( pxCurrentTCB->eNotifyState == eWaitingNotification )\r
+                       {\r
+                               /* A notification was not received. */\r
+                               xReturn = pdFALSE;\r
+                       }\r
+                       else\r
+                       {\r
+                               /* A notification was already pending or a notification was\r
+                               received while the task was waiting. */\r
+                               pxCurrentTCB->ulNotifiedValue &= ~ulBitsToClearOnExit;\r
+                               xReturn = pdTRUE;\r
+                       }\r
+\r
+                       pxCurrentTCB->eNotifyState = eNotWaitingNotification;\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_TASK_NOTIFICATIONS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( configUSE_TASK_NOTIFICATIONS == 1 )\r
+\r
+       BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue )\r
+       {\r
+       TCB_t * pxTCB;\r
+       eNotifyValue eOriginalNotifyState;\r
+       BaseType_t xReturn = pdPASS;\r
+\r
+               configASSERT( xTaskToNotify );\r
+               pxTCB = ( TCB_t * ) xTaskToNotify;\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       if( pulPreviousNotificationValue != NULL )\r
+                       {\r
+                               *pulPreviousNotificationValue = pxTCB->ulNotifiedValue;\r
+                       }\r
+\r
+                       eOriginalNotifyState = pxTCB->eNotifyState;\r
+\r
+                       pxTCB->eNotifyState = eNotified;\r
+\r
+                       switch( eAction )\r
+                       {\r
+                               case eSetBits   :\r
+                                       pxTCB->ulNotifiedValue |= ulValue;\r
+                                       break;\r
+\r
+                               case eIncrement :\r
+                                       ( pxTCB->ulNotifiedValue )++;\r
+                                       break;\r
+\r
+                               case eSetValueWithOverwrite     :\r
+                                       pxTCB->ulNotifiedValue = ulValue;\r
+                                       break;\r
+\r
+                               case eSetValueWithoutOverwrite :\r
+                                       if( eOriginalNotifyState != eNotified )\r
+                                       {\r
+                                               pxTCB->ulNotifiedValue = ulValue;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               /* The value could not be written to the task. */\r
+                                               xReturn = pdFAIL;\r
+                                       }\r
+                                       break;\r
+\r
+                               case eNoAction:\r
+                                       /* The task is being notified without its notify value being\r
+                                       updated. */\r
+                                       break;\r
+                       }\r
+\r
+                       traceTASK_NOTIFY();\r
+\r
+                       /* If the task is in the blocked state specifically to wait for a\r
+                       notification then unblock it now. */\r
+                       if( eOriginalNotifyState == eWaitingNotification )\r
+                       {\r
+                               ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
+                               prvAddTaskToReadyList( pxTCB );\r
+\r
+                               /* The task should not have been on an event list. */\r
+                               configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL );\r
+\r
+                               #if( configUSE_TICKLESS_IDLE != 0 )\r
+                               {\r
+                                       /* If a task is blocked waiting for a notification then\r
+                                       xNextTaskUnblockTime might be set to the blocked task's time\r
+                                       out time.  If the task is unblocked for a reason other than\r
+                                       a timeout xNextTaskUnblockTime is normally left unchanged,\r
+                                       because it will automatically get reset to a new value when\r
+                                       the tick count equals xNextTaskUnblockTime.  However if\r
+                                       tickless idling is used it might be more important to enter\r
+                                       sleep mode at the earliest possible time - so reset\r
+                                       xNextTaskUnblockTime here to ensure it is updated at the\r
+                                       earliest possible time. */\r
+                                       prvResetNextTaskUnblockTime();\r
+                               }\r
+                               #endif\r
+\r
+                               if( pxTCB->uxPriority > pxCurrentTCB->uxPriority )\r
+                               {\r
+                                       /* The notified task has a priority above the currently\r
+                                       executing task so a yield is required. */\r
+                                       taskYIELD_IF_USING_PREEMPTION();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_TASK_NOTIFICATIONS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( configUSE_TASK_NOTIFICATIONS == 1 )\r
+\r
+       BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken )\r
+       {\r
+       TCB_t * pxTCB;\r
+       eNotifyValue eOriginalNotifyState;\r
+       BaseType_t xReturn = pdPASS;\r
+       UBaseType_t uxSavedInterruptStatus;\r
+\r
+               configASSERT( xTaskToNotify );\r
+\r
+               /* RTOS ports that support interrupt nesting have the concept of a\r
+               maximum system call (or maximum API call) interrupt priority.\r
+               Interrupts that are     above the maximum system call priority are keep\r
+               permanently enabled, even when the RTOS kernel is in a critical section,\r
+               but cannot make any calls to FreeRTOS API functions.  If configASSERT()\r
+               is defined in FreeRTOSConfig.h then\r
+               portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+               failure if a FreeRTOS API function is called from an interrupt that has\r
+               been assigned a priority above the configured maximum system call\r
+               priority.  Only FreeRTOS functions that end in FromISR can be called\r
+               from interrupts that have been assigned a priority at or (logically)\r
+               below the maximum system call interrupt priority.  FreeRTOS maintains a\r
+               separate interrupt safe API to ensure interrupt entry is as fast and as\r
+               simple as possible.  More information (albeit Cortex-M specific) is\r
+               provided on the following link:\r
+               http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+               portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+               pxTCB = ( TCB_t * ) xTaskToNotify;\r
+\r
+               uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
+               {\r
+                       if( pulPreviousNotificationValue != NULL )\r
+                       {\r
+                               *pulPreviousNotificationValue = pxTCB->ulNotifiedValue;\r
+                       }\r
+\r
+                       eOriginalNotifyState = pxTCB->eNotifyState;\r
+                       pxTCB->eNotifyState = eNotified;\r
+\r
+                       switch( eAction )\r
+                       {\r
+                               case eSetBits   :\r
+                                       pxTCB->ulNotifiedValue |= ulValue;\r
+                                       break;\r
+\r
+                               case eIncrement :\r
+                                       ( pxTCB->ulNotifiedValue )++;\r
+                                       break;\r
+\r
+                               case eSetValueWithOverwrite     :\r
+                                       pxTCB->ulNotifiedValue = ulValue;\r
+                                       break;\r
+\r
+                               case eSetValueWithoutOverwrite :\r
+                                       if( eOriginalNotifyState != eNotified )\r
+                                       {\r
+                                               pxTCB->ulNotifiedValue = ulValue;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               /* The value could not be written to the task. */\r
+                                               xReturn = pdFAIL;\r
+                                       }\r
+                                       break;\r
+\r
+                               case eNoAction :\r
+                                       /* The task is being notified without its notify value being\r
+                                       updated. */\r
+                                       break;\r
+                       }\r
+\r
+                       traceTASK_NOTIFY_FROM_ISR();\r
+                       \r
+                       /* If the task is in the blocked state specifically to wait for a\r
+                       notification then unblock it now. */\r
+                       if( eOriginalNotifyState == eWaitingNotification )\r
+                       {\r
+                               /* The task should not have been on an event list. */\r
+                               configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL );\r
+\r
+                               if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
+                               {\r
+                                       ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
+                                       prvAddTaskToReadyList( pxTCB );\r
+                               }\r
+                               else\r
+                               {\r
+                                       /* The delayed and ready lists cannot be accessed, so hold\r
+                                       this task pending until the scheduler is resumed. */\r
+                                       vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) );\r
+                               }\r
+\r
+                               if( pxTCB->uxPriority > pxCurrentTCB->uxPriority )\r
+                               {\r
+                                       /* The notified task has a priority above the currently\r
+                                       executing task so a yield is required. */\r
+                                       if( pxHigherPriorityTaskWoken != NULL )\r
+                                       {\r
+                                               *pxHigherPriorityTaskWoken = pdTRUE;\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+               }\r
+               portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_TASK_NOTIFICATIONS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( configUSE_TASK_NOTIFICATIONS == 1 )\r
+\r
+       void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken )\r
+       {\r
+       TCB_t * pxTCB;\r
+       eNotifyValue eOriginalNotifyState;\r
+       UBaseType_t uxSavedInterruptStatus;\r
+\r
+               configASSERT( xTaskToNotify );\r
+\r
+               /* RTOS ports that support interrupt nesting have the concept of a\r
+               maximum system call (or maximum API call) interrupt priority.\r
+               Interrupts that are     above the maximum system call priority are keep\r
+               permanently enabled, even when the RTOS kernel is in a critical section,\r
+               but cannot make any calls to FreeRTOS API functions.  If configASSERT()\r
+               is defined in FreeRTOSConfig.h then\r
+               portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+               failure if a FreeRTOS API function is called from an interrupt that has\r
+               been assigned a priority above the configured maximum system call\r
+               priority.  Only FreeRTOS functions that end in FromISR can be called\r
+               from interrupts that have been assigned a priority at or (logically)\r
+               below the maximum system call interrupt priority.  FreeRTOS maintains a\r
+               separate interrupt safe API to ensure interrupt entry is as fast and as\r
+               simple as possible.  More information (albeit Cortex-M specific) is\r
+               provided on the following link:\r
+               http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+               portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+               pxTCB = ( TCB_t * ) xTaskToNotify;\r
+\r
+               uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
+               {\r
+                       eOriginalNotifyState = pxTCB->eNotifyState;\r
+                       pxTCB->eNotifyState = eNotified;\r
+\r
+                       /* 'Giving' is equivalent to incrementing a count in a counting\r
+                       semaphore. */\r
+                       ( pxTCB->ulNotifiedValue )++;\r
+                       \r
+                       traceTASK_NOTIFY_GIVE_FROM_ISR();\r
+\r
+                       /* If the task is in the blocked state specifically to wait for a\r
+                       notification then unblock it now. */\r
+                       if( eOriginalNotifyState == eWaitingNotification )\r
+                       {\r
+                               /* The task should not have been on an event list. */\r
+                               configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL );\r
+\r
+                               if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
+                               {\r
+                                       ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
+                                       prvAddTaskToReadyList( pxTCB );\r
+                               }\r
+                               else\r
+                               {\r
+                                       /* The delayed and ready lists cannot be accessed, so hold\r
+                                       this task pending until the scheduler is resumed. */\r
+                                       vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) );\r
+                               }\r
+\r
+                               if( pxTCB->uxPriority > pxCurrentTCB->uxPriority )\r
+                               {\r
+                                       /* The notified task has a priority above the currently\r
+                                       executing task so a yield is required. */\r
+                                       if( pxHigherPriorityTaskWoken != NULL )\r
+                                       {\r
+                                               *pxHigherPriorityTaskWoken = pdTRUE;\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+               }\r
+               portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+       }\r
+\r
+#endif /* configUSE_TASK_NOTIFICATIONS */\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+\r
+#ifdef FREERTOS_MODULE_TEST\r
+       #include "tasks_test_access_functions.h"\r
+#endif\r
+\r
diff --git a/os/8.2.2/src/os/timers.c b/os/8.2.2/src/os/timers.c
new file mode 100644 (file)
index 0000000..e72afce
--- /dev/null
@@ -0,0 +1,917 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+/* Standard includes. */\r
+#include <stdlib.h>\r
+\r
+/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining\r
+all the API functions to use the MPU wrappers.  That should only be done when\r
+task.h is included from an application file. */\r
+#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
+#include "os/FreeRTOS.h"\r
+#include "os/task.h"\r
+#include "os/queue.h"\r
+#include "os/timers.h"\r
+\r
+#if ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 0 )\r
+       #error configUSE_TIMERS must be set to 1 to make the xTimerPendFunctionCall() function available.\r
+#endif\r
+\r
+/* Lint e961 and e750 are suppressed as a MISRA exception justified because the\r
+MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the\r
+header files above, but not in this file, in order to generate the correct\r
+privileged Vs unprivileged linkage and placement. */\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */\r
+\r
+\r
+/* This entire source file will be skipped if the application is not configured\r
+to include software timer functionality.  This #if is closed at the very bottom\r
+of this file.  If you want to include software timer functionality then ensure\r
+configUSE_TIMERS is set to 1 in FreeRTOSConfig.h. */\r
+#if ( configUSE_TIMERS == 1 )\r
+\r
+/* Misc definitions. */\r
+#define tmrNO_DELAY            ( TickType_t ) 0U\r
+\r
+/* The definition of the timers themselves. */\r
+typedef struct tmrTimerControl\r
+{\r
+       const char                              *pcTimerName;           /*<< Text name.  This is not used by the kernel, it is included simply to make debugging easier. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+       ListItem_t                              xTimerListItem;         /*<< Standard linked list item as used by all kernel features for event management. */\r
+       TickType_t                              xTimerPeriodInTicks;/*<< How quickly and often the timer expires. */\r
+       UBaseType_t                             uxAutoReload;           /*<< Set to pdTRUE if the timer should be automatically restarted once expired.  Set to pdFALSE if the timer is, in effect, a one-shot timer. */\r
+       void                                    *pvTimerID;                     /*<< An ID to identify the timer.  This allows the timer to be identified when the same callback is used for multiple timers. */\r
+       TimerCallbackFunction_t pxCallbackFunction;     /*<< The function that will be called when the timer expires. */\r
+       #if( configUSE_TRACE_FACILITY == 1 )\r
+               UBaseType_t                     uxTimerNumber;          /*<< An ID assigned by trace tools such as FreeRTOS+Trace */\r
+       #endif\r
+} xTIMER;\r
+\r
+/* The old xTIMER name is maintained above then typedefed to the new Timer_t\r
+name below to enable the use of older kernel aware debuggers. */\r
+typedef xTIMER Timer_t;\r
+\r
+/* The definition of messages that can be sent and received on the timer queue.\r
+Two types of message can be queued - messages that manipulate a software timer,\r
+and messages that request the execution of a non-timer related callback.  The\r
+two message types are defined in two separate structures, xTimerParametersType\r
+and xCallbackParametersType respectively. */\r
+typedef struct tmrTimerParameters\r
+{\r
+       TickType_t                      xMessageValue;          /*<< An optional value used by a subset of commands, for example, when changing the period of a timer. */\r
+       Timer_t *                       pxTimer;                        /*<< The timer to which the command will be applied. */\r
+} TimerParameter_t;\r
+\r
+\r
+typedef struct tmrCallbackParameters\r
+{\r
+       PendedFunction_t        pxCallbackFunction;     /* << The callback function to execute. */\r
+       void *pvParameter1;                                             /* << The value that will be used as the callback functions first parameter. */\r
+       uint32_t ulParameter2;                                  /* << The value that will be used as the callback functions second parameter. */\r
+} CallbackParameters_t;\r
+\r
+/* The structure that contains the two message types, along with an identifier\r
+that is used to determine which message type is valid. */\r
+typedef struct tmrTimerQueueMessage\r
+{\r
+       BaseType_t                      xMessageID;                     /*<< The command being sent to the timer service task. */\r
+       union\r
+       {\r
+               TimerParameter_t xTimerParameters;\r
+\r
+               /* Don't include xCallbackParameters if it is not going to be used as\r
+               it makes the structure (and therefore the timer queue) larger. */\r
+               #if ( INCLUDE_xTimerPendFunctionCall == 1 )\r
+                       CallbackParameters_t xCallbackParameters;\r
+               #endif /* INCLUDE_xTimerPendFunctionCall */\r
+       } u;\r
+} DaemonTaskMessage_t;\r
+\r
+/*lint -e956 A manual analysis and inspection has been used to determine which\r
+static variables must be declared volatile. */\r
+\r
+/* The list in which active timers are stored.  Timers are referenced in expire\r
+time order, with the nearest expiry time at the front of the list.  Only the\r
+timer service task is allowed to access these lists. */\r
+PRIVILEGED_DATA static List_t xActiveTimerList1;\r
+PRIVILEGED_DATA static List_t xActiveTimerList2;\r
+PRIVILEGED_DATA static List_t *pxCurrentTimerList;\r
+PRIVILEGED_DATA static List_t *pxOverflowTimerList;\r
+\r
+/* A queue that is used to send commands to the timer service task. */\r
+PRIVILEGED_DATA static QueueHandle_t xTimerQueue = NULL;\r
+\r
+#if ( INCLUDE_xTimerGetTimerDaemonTaskHandle == 1 )\r
+\r
+       PRIVILEGED_DATA static TaskHandle_t xTimerTaskHandle = NULL;\r
+\r
+#endif\r
+\r
+/*lint +e956 */\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Initialise the infrastructure used by the timer service task if it has not\r
+ * been initialised already.\r
+ */\r
+static void prvCheckForValidListAndQueue( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * The timer service task (daemon).  Timer functionality is controlled by this\r
+ * task.  Other tasks communicate with the timer service task using the\r
+ * xTimerQueue queue.\r
+ */\r
+static void prvTimerTask( void *pvParameters ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Called by the timer service task to interpret and process a command it\r
+ * received on the timer queue.\r
+ */\r
+static void prvProcessReceivedCommands( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Insert the timer into either xActiveTimerList1, or xActiveTimerList2,\r
+ * depending on if the expire time causes a timer counter overflow.\r
+ */\r
+static BaseType_t prvInsertTimerInActiveList( Timer_t * const pxTimer, const TickType_t xNextExpiryTime, const TickType_t xTimeNow, const TickType_t xCommandTime ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * An active timer has reached its expire time.  Reload the timer if it is an\r
+ * auto reload timer, then call its callback.\r
+ */\r
+static void prvProcessExpiredTimer( const TickType_t xNextExpireTime, const TickType_t xTimeNow ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * The tick count has overflowed.  Switch the timer lists after ensuring the\r
+ * current timer list does not still reference some timers.\r
+ */\r
+static void prvSwitchTimerLists( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Obtain the current tick count, setting *pxTimerListsWereSwitched to pdTRUE\r
+ * if a tick count overflow occurred since prvSampleTimeNow() was last called.\r
+ */\r
+static TickType_t prvSampleTimeNow( BaseType_t * const pxTimerListsWereSwitched ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * If the timer list contains any active timers then return the expire time of\r
+ * the timer that will expire first and set *pxListWasEmpty to false.  If the\r
+ * timer list does not contain any timers then return 0 and set *pxListWasEmpty\r
+ * to pdTRUE.\r
+ */\r
+static TickType_t prvGetNextExpireTime( BaseType_t * const pxListWasEmpty ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * If a timer has expired, process it.  Otherwise, block the timer service task\r
+ * until either a timer does expire or a command is received.\r
+ */\r
+static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, const BaseType_t xListWasEmpty ) PRIVILEGED_FUNCTION;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xTimerCreateTimerTask( void )\r
+{\r
+BaseType_t xReturn = pdFAIL;\r
+\r
+       /* This function is called when the scheduler is started if\r
+       configUSE_TIMERS is set to 1.  Check that the infrastructure used by the\r
+       timer service task has been created/initialised.  If timers have already\r
+       been created then the initialisation will already have been performed. */\r
+       prvCheckForValidListAndQueue();\r
+\r
+       if( xTimerQueue != NULL )\r
+       {\r
+               #if ( INCLUDE_xTimerGetTimerDaemonTaskHandle == 1 )\r
+               {\r
+                       /* Create the timer task, storing its handle in xTimerTaskHandle so\r
+                       it can be returned by the xTimerGetTimerDaemonTaskHandle() function. */\r
+                       xReturn = xTaskCreate( prvTimerTask, "Tmr Svc", ( uint16_t ) configTIMER_TASK_STACK_DEPTH, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, &xTimerTaskHandle );\r
+               }\r
+               #else\r
+               {\r
+                       /* Create the timer task without storing its handle. */\r
+                       xReturn = xTaskCreate( prvTimerTask, "Tmr Svc", ( uint16_t ) configTIMER_TASK_STACK_DEPTH, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, NULL);\r
+               }\r
+               #endif\r
+       }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
+       }\r
+\r
+       configASSERT( xReturn );\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+{\r
+Timer_t *pxNewTimer;\r
+\r
+       /* Allocate the timer structure. */\r
+       if( xTimerPeriodInTicks == ( TickType_t ) 0U )\r
+       {\r
+               pxNewTimer = NULL;\r
+       }\r
+       else\r
+       {\r
+               pxNewTimer = ( Timer_t * ) pvPortMalloc( sizeof( Timer_t ) );\r
+               if( pxNewTimer != NULL )\r
+               {\r
+                       /* Ensure the infrastructure used by the timer service task has been\r
+                       created/initialised. */\r
+                       prvCheckForValidListAndQueue();\r
+\r
+                       /* Initialise the timer structure members using the function parameters. */\r
+                       pxNewTimer->pcTimerName = pcTimerName;\r
+                       pxNewTimer->xTimerPeriodInTicks = xTimerPeriodInTicks;\r
+                       pxNewTimer->uxAutoReload = uxAutoReload;\r
+                       pxNewTimer->pvTimerID = pvTimerID;\r
+                       pxNewTimer->pxCallbackFunction = pxCallbackFunction;\r
+                       vListInitialiseItem( &( pxNewTimer->xTimerListItem ) );\r
+\r
+                       traceTIMER_CREATE( pxNewTimer );\r
+               }\r
+               else\r
+               {\r
+                       traceTIMER_CREATE_FAILED();\r
+               }\r
+       }\r
+\r
+       /* 0 is not a valid value for xTimerPeriodInTicks. */\r
+       configASSERT( ( xTimerPeriodInTicks > 0 ) );\r
+\r
+       return ( TimerHandle_t ) pxNewTimer;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait )\r
+{\r
+BaseType_t xReturn = pdFAIL;\r
+DaemonTaskMessage_t xMessage;\r
+\r
+       /* Send a message to the timer service task to perform a particular action\r
+       on a particular timer definition. */\r
+       if( xTimerQueue != NULL )\r
+       {\r
+               /* Send a command to the timer service task to start the xTimer timer. */\r
+               xMessage.xMessageID = xCommandID;\r
+               xMessage.u.xTimerParameters.xMessageValue = xOptionalValue;\r
+               xMessage.u.xTimerParameters.pxTimer = ( Timer_t * ) xTimer;\r
+\r
+               if( xCommandID < tmrFIRST_FROM_ISR_COMMAND )\r
+               {\r
+                       if( xTaskGetSchedulerState() == taskSCHEDULER_RUNNING )\r
+                       {\r
+                               xReturn = xQueueSendToBack( xTimerQueue, &xMessage, xTicksToWait );\r
+                       }\r
+                       else\r
+                       {\r
+                               xReturn = xQueueSendToBack( xTimerQueue, &xMessage, tmrNO_DELAY );\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       xReturn = xQueueSendToBackFromISR( xTimerQueue, &xMessage, pxHigherPriorityTaskWoken );\r
+               }\r
+\r
+               traceTIMER_COMMAND_SEND( xTimer, xCommandID, xOptionalValue, xReturn );\r
+       }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( INCLUDE_xTimerGetTimerDaemonTaskHandle == 1 )\r
+\r
+       TaskHandle_t xTimerGetTimerDaemonTaskHandle( void )\r
+       {\r
+               /* If xTimerGetTimerDaemonTaskHandle() is called before the scheduler has been\r
+               started, then xTimerTaskHandle will be NULL. */\r
+               configASSERT( ( xTimerTaskHandle != NULL ) );\r
+               return xTimerTaskHandle;\r
+       }\r
+\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+const char * pcTimerGetTimerName( TimerHandle_t xTimer )\r
+{\r
+Timer_t *pxTimer = ( Timer_t * ) xTimer;\r
+\r
+       return pxTimer->pcTimerName;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvProcessExpiredTimer( const TickType_t xNextExpireTime, const TickType_t xTimeNow )\r
+{\r
+BaseType_t xResult;\r
+Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList );\r
+\r
+       /* Remove the timer from the list of active timers.  A check has already\r
+       been performed to ensure the list is not empty. */\r
+       ( void ) uxListRemove( &( pxTimer->xTimerListItem ) );\r
+       traceTIMER_EXPIRED( pxTimer );\r
+\r
+       /* If the timer is an auto reload timer then calculate the next\r
+       expiry time and re-insert the timer in the list of active timers. */\r
+       if( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE )\r
+       {\r
+               /* The timer is inserted into a list using a time relative to anything\r
+               other than the current time.  It will therefore be inserted into the\r
+               correct list relative to the time this task thinks it is now. */\r
+               if( prvInsertTimerInActiveList( pxTimer, ( xNextExpireTime + pxTimer->xTimerPeriodInTicks ), xTimeNow, xNextExpireTime ) == pdTRUE )\r
+               {\r
+                       /* The timer expired before it was added to the active timer\r
+                       list.  Reload it now.  */\r
+                       xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xNextExpireTime, NULL, tmrNO_DELAY );\r
+                       configASSERT( xResult );\r
+                       ( void ) xResult;\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
+       }\r
+\r
+       /* Call the timer callback. */\r
+       pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvTimerTask( void *pvParameters )\r
+{\r
+TickType_t xNextExpireTime;\r
+BaseType_t xListWasEmpty;\r
+\r
+       /* Just to avoid compiler warnings. */\r
+       ( void ) pvParameters;\r
+\r
+       for( ;; )\r
+       {\r
+               /* Query the timers list to see if it contains any timers, and if so,\r
+               obtain the time at which the next timer will expire. */\r
+               xNextExpireTime = prvGetNextExpireTime( &xListWasEmpty );\r
+\r
+               /* If a timer has expired, process it.  Otherwise, block this task\r
+               until either a timer does expire, or a command is received. */\r
+               prvProcessTimerOrBlockTask( xNextExpireTime, xListWasEmpty );\r
+\r
+               /* Empty the command queue. */\r
+               prvProcessReceivedCommands();\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, const BaseType_t xListWasEmpty )\r
+{\r
+TickType_t xTimeNow;\r
+BaseType_t xTimerListsWereSwitched;\r
+\r
+       vTaskSuspendAll();\r
+       {\r
+               /* Obtain the time now to make an assessment as to whether the timer\r
+               has expired or not.  If obtaining the time causes the lists to switch\r
+               then don't process this timer as any timers that remained in the list\r
+               when the lists were switched will have been processed within the\r
+               prvSampleTimeNow() function. */\r
+               xTimeNow = prvSampleTimeNow( &xTimerListsWereSwitched );\r
+               if( xTimerListsWereSwitched == pdFALSE )\r
+               {\r
+                       /* The tick count has not overflowed, has the timer expired? */\r
+                       if( ( xListWasEmpty == pdFALSE ) && ( xNextExpireTime <= xTimeNow ) )\r
+                       {\r
+                               ( void ) xTaskResumeAll();\r
+                               prvProcessExpiredTimer( xNextExpireTime, xTimeNow );\r
+                       }\r
+                       else\r
+                       {\r
+                               /* The tick count has not overflowed, and the next expire\r
+                               time has not been reached yet.  This task should therefore\r
+                               block to wait for the next expire time or a command to be\r
+                               received - whichever comes first.  The following line cannot\r
+                               be reached unless xNextExpireTime > xTimeNow, except in the\r
+                               case when the current timer list is empty. */\r
+                               vQueueWaitForMessageRestricted( xTimerQueue, ( xNextExpireTime - xTimeNow ), xListWasEmpty );\r
+\r
+                               if( xTaskResumeAll() == pdFALSE )\r
+                               {\r
+                                       /* Yield to wait for either a command to arrive, or the\r
+                                       block time to expire.  If a command arrived between the\r
+                                       critical section being exited and this yield then the yield\r
+                                       will not cause the task to block. */\r
+                                       portYIELD_WITHIN_API();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       ( void ) xTaskResumeAll();\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static TickType_t prvGetNextExpireTime( BaseType_t * const pxListWasEmpty )\r
+{\r
+TickType_t xNextExpireTime;\r
+\r
+       /* Timers are listed in expiry time order, with the head of the list\r
+       referencing the task that will expire first.  Obtain the time at which\r
+       the timer with the nearest expiry time will expire.  If there are no\r
+       active timers then just set the next expire time to 0.  That will cause\r
+       this task to unblock when the tick count overflows, at which point the\r
+       timer lists will be switched and the next expiry time can be\r
+       re-assessed.  */\r
+       *pxListWasEmpty = listLIST_IS_EMPTY( pxCurrentTimerList );\r
+       if( *pxListWasEmpty == pdFALSE )\r
+       {\r
+               xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList );\r
+       }\r
+       else\r
+       {\r
+               /* Ensure the task unblocks when the tick count rolls over. */\r
+               xNextExpireTime = ( TickType_t ) 0U;\r
+       }\r
+\r
+       return xNextExpireTime;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static TickType_t prvSampleTimeNow( BaseType_t * const pxTimerListsWereSwitched )\r
+{\r
+TickType_t xTimeNow;\r
+PRIVILEGED_DATA static TickType_t xLastTime = ( TickType_t ) 0U; /*lint !e956 Variable is only accessible to one task. */\r
+\r
+       xTimeNow = xTaskGetTickCount();\r
+\r
+       if( xTimeNow < xLastTime )\r
+       {\r
+               prvSwitchTimerLists();\r
+               *pxTimerListsWereSwitched = pdTRUE;\r
+       }\r
+       else\r
+       {\r
+               *pxTimerListsWereSwitched = pdFALSE;\r
+       }\r
+\r
+       xLastTime = xTimeNow;\r
+\r
+       return xTimeNow;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static BaseType_t prvInsertTimerInActiveList( Timer_t * const pxTimer, const TickType_t xNextExpiryTime, const TickType_t xTimeNow, const TickType_t xCommandTime )\r
+{\r
+BaseType_t xProcessTimerNow = pdFALSE;\r
+\r
+       listSET_LIST_ITEM_VALUE( &( pxTimer->xTimerListItem ), xNextExpiryTime );\r
+       listSET_LIST_ITEM_OWNER( &( pxTimer->xTimerListItem ), pxTimer );\r
+\r
+       if( xNextExpiryTime <= xTimeNow )\r
+       {\r
+               /* Has the expiry time elapsed between the command to start/reset a\r
+               timer was issued, and the time the command was processed? */\r
+               if( ( xTimeNow - xCommandTime ) >= pxTimer->xTimerPeriodInTicks )\r
+               {\r
+                       /* The time between a command being issued and the command being\r
+                       processed actually exceeds the timers period.  */\r
+                       xProcessTimerNow = pdTRUE;\r
+               }\r
+               else\r
+               {\r
+                       vListInsert( pxOverflowTimerList, &( pxTimer->xTimerListItem ) );\r
+               }\r
+       }\r
+       else\r
+       {\r
+               if( ( xTimeNow < xCommandTime ) && ( xNextExpiryTime >= xCommandTime ) )\r
+               {\r
+                       /* If, since the command was issued, the tick count has overflowed\r
+                       but the expiry time has not, then the timer must have already passed\r
+                       its expiry time and should be processed immediately. */\r
+                       xProcessTimerNow = pdTRUE;\r
+               }\r
+               else\r
+               {\r
+                       vListInsert( pxCurrentTimerList, &( pxTimer->xTimerListItem ) );\r
+               }\r
+       }\r
+\r
+       return xProcessTimerNow;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void    prvProcessReceivedCommands( void )\r
+{\r
+DaemonTaskMessage_t xMessage;\r
+Timer_t *pxTimer;\r
+BaseType_t xTimerListsWereSwitched, xResult;\r
+TickType_t xTimeNow;\r
+\r
+       while( xQueueReceive( xTimerQueue, &xMessage, tmrNO_DELAY ) != pdFAIL ) /*lint !e603 xMessage does not have to be initialised as it is passed out, not in, and it is not used unless xQueueReceive() returns pdTRUE. */\r
+       {\r
+               #if ( INCLUDE_xTimerPendFunctionCall == 1 )\r
+               {\r
+                       /* Negative commands are pended function calls rather than timer\r
+                       commands. */\r
+                       if( xMessage.xMessageID < ( BaseType_t ) 0 )\r
+                       {\r
+                               const CallbackParameters_t * const pxCallback = &( xMessage.u.xCallbackParameters );\r
+\r
+                               /* The timer uses the xCallbackParameters member to request a\r
+                               callback be executed.  Check the callback is not NULL. */\r
+                               configASSERT( pxCallback );\r
+\r
+                               /* Call the function. */\r
+                               pxCallback->pxCallbackFunction( pxCallback->pvParameter1, pxCallback->ulParameter2 );\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               #endif /* INCLUDE_xTimerPendFunctionCall */\r
+\r
+               /* Commands that are positive are timer commands rather than pended\r
+               function calls. */\r
+               if( xMessage.xMessageID >= ( BaseType_t ) 0 )\r
+               {\r
+                       /* The messages uses the xTimerParameters member to work on a\r
+                       software timer. */\r
+                       pxTimer = xMessage.u.xTimerParameters.pxTimer;\r
+\r
+                       if( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) == pdFALSE )\r
+                       {\r
+                               /* The timer is in a list, remove it. */\r
+                               ( void ) uxListRemove( &( pxTimer->xTimerListItem ) );\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       traceTIMER_COMMAND_RECEIVED( pxTimer, xMessage.xMessageID, xMessage.u.xTimerParameters.xMessageValue );\r
+\r
+                       /* In this case the xTimerListsWereSwitched parameter is not used, but\r
+                       it must be present in the function call.  prvSampleTimeNow() must be\r
+                       called after the message is received from xTimerQueue so there is no\r
+                       possibility of a higher priority task adding a message to the message\r
+                       queue with a time that is ahead of the timer daemon task (because it\r
+                       pre-empted the timer daemon task after the xTimeNow value was set). */\r
+                       xTimeNow = prvSampleTimeNow( &xTimerListsWereSwitched );\r
+\r
+                       switch( xMessage.xMessageID )\r
+                       {\r
+                               case tmrCOMMAND_START :\r
+                           case tmrCOMMAND_START_FROM_ISR :\r
+                           case tmrCOMMAND_RESET :\r
+                           case tmrCOMMAND_RESET_FROM_ISR :\r
+                               case tmrCOMMAND_START_DONT_TRACE :\r
+                                       /* Start or restart a timer. */\r
+                                       if( prvInsertTimerInActiveList( pxTimer,  xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, xTimeNow, xMessage.u.xTimerParameters.xMessageValue ) == pdTRUE )\r
+                                       {\r
+                                               /* The timer expired before it was added to the active\r
+                                               timer list.  Process it now. */\r
+                                               pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer );\r
+                                               traceTIMER_EXPIRED( pxTimer );\r
+\r
+                                               if( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE )\r
+                                               {\r
+                                                       xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, NULL, tmrNO_DELAY );\r
+                                                       configASSERT( xResult );\r
+                                                       ( void ) xResult;\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                                       break;\r
+\r
+                               case tmrCOMMAND_STOP :\r
+                               case tmrCOMMAND_STOP_FROM_ISR :\r
+                                       /* The timer has already been removed from the active list.\r
+                                       There is nothing to do here. */\r
+                                       break;\r
+\r
+                               case tmrCOMMAND_CHANGE_PERIOD :\r
+                               case tmrCOMMAND_CHANGE_PERIOD_FROM_ISR :\r
+                                       pxTimer->xTimerPeriodInTicks = xMessage.u.xTimerParameters.xMessageValue;\r
+                                       configASSERT( ( pxTimer->xTimerPeriodInTicks > 0 ) );\r
+\r
+                                       /* The new period does not really have a reference, and can be\r
+                                       longer or shorter than the old one.  The command time is\r
+                                       therefore set to the current time, and as the period cannot be\r
+                                       zero the next expiry time can only be in the future, meaning\r
+                                       (unlike for the xTimerStart() case above) there is no fail case\r
+                                       that needs to be handled here. */\r
+                                       ( void ) prvInsertTimerInActiveList( pxTimer, ( xTimeNow + pxTimer->xTimerPeriodInTicks ), xTimeNow, xTimeNow );\r
+                                       break;\r
+\r
+                               case tmrCOMMAND_DELETE :\r
+                                       /* The timer has already been removed from the active list,\r
+                                       just free up the memory. */\r
+                                       vPortFree( pxTimer );\r
+                                       break;\r
+\r
+                               default :\r
+                                       /* Don't expect to get here. */\r
+                                       break;\r
+                       }\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvSwitchTimerLists( void )\r
+{\r
+TickType_t xNextExpireTime, xReloadTime;\r
+List_t *pxTemp;\r
+Timer_t *pxTimer;\r
+BaseType_t xResult;\r
+\r
+       /* The tick count has overflowed.  The timer lists must be switched.\r
+       If there are any timers still referenced from the current timer list\r
+       then they must have expired and should be processed before the lists\r
+       are switched. */\r
+       while( listLIST_IS_EMPTY( pxCurrentTimerList ) == pdFALSE )\r
+       {\r
+               xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList );\r
+\r
+               /* Remove the timer from the list. */\r
+               pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList );\r
+               ( void ) uxListRemove( &( pxTimer->xTimerListItem ) );\r
+               traceTIMER_EXPIRED( pxTimer );\r
+\r
+               /* Execute its callback, then send a command to restart the timer if\r
+               it is an auto-reload timer.  It cannot be restarted here as the lists\r
+               have not yet been switched. */\r
+               pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer );\r
+\r
+               if( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE )\r
+               {\r
+                       /* Calculate the reload value, and if the reload value results in\r
+                       the timer going into the same timer list then it has already expired\r
+                       and the timer should be re-inserted into the current list so it is\r
+                       processed again within this loop.  Otherwise a command should be sent\r
+                       to restart the timer to ensure it is only inserted into a list after\r
+                       the lists have been swapped. */\r
+                       xReloadTime = ( xNextExpireTime + pxTimer->xTimerPeriodInTicks );\r
+                       if( xReloadTime > xNextExpireTime )\r
+                       {\r
+                               listSET_LIST_ITEM_VALUE( &( pxTimer->xTimerListItem ), xReloadTime );\r
+                               listSET_LIST_ITEM_OWNER( &( pxTimer->xTimerListItem ), pxTimer );\r
+                               vListInsert( pxCurrentTimerList, &( pxTimer->xTimerListItem ) );\r
+                       }\r
+                       else\r
+                       {\r
+                               xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xNextExpireTime, NULL, tmrNO_DELAY );\r
+                               configASSERT( xResult );\r
+                               ( void ) xResult;\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+\r
+       pxTemp = pxCurrentTimerList;\r
+       pxCurrentTimerList = pxOverflowTimerList;\r
+       pxOverflowTimerList = pxTemp;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCheckForValidListAndQueue( void )\r
+{\r
+       /* Check that the list from which active timers are referenced, and the\r
+       queue used to communicate with the timer service, have been\r
+       initialised. */\r
+       taskENTER_CRITICAL();\r
+       {\r
+               if( xTimerQueue == NULL )\r
+               {\r
+                       vListInitialise( &xActiveTimerList1 );\r
+                       vListInitialise( &xActiveTimerList2 );\r
+                       pxCurrentTimerList = &xActiveTimerList1;\r
+                       pxOverflowTimerList = &xActiveTimerList2;\r
+                       xTimerQueue = xQueueCreate( ( UBaseType_t ) configTIMER_QUEUE_LENGTH, sizeof( DaemonTaskMessage_t ) );\r
+                       configASSERT( xTimerQueue );\r
+\r
+                       #if ( configQUEUE_REGISTRY_SIZE > 0 )\r
+                       {\r
+                               if( xTimerQueue != NULL )\r
+                               {\r
+                                       vQueueAddToRegistry( xTimerQueue, "TmrQ" );\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       #endif /* configQUEUE_REGISTRY_SIZE */\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+       taskEXIT_CRITICAL();\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer )\r
+{\r
+BaseType_t xTimerIsInActiveList;\r
+Timer_t *pxTimer = ( Timer_t * ) xTimer;\r
+\r
+       /* Is the timer in the list of active timers? */\r
+       taskENTER_CRITICAL();\r
+       {\r
+               /* Checking to see if it is in the NULL list in effect checks to see if\r
+               it is referenced from either the current or the overflow timer lists in\r
+               one go, but the logic has to be reversed, hence the '!'. */\r
+               xTimerIsInActiveList = ( BaseType_t ) !( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) );\r
+       }\r
+       taskEXIT_CRITICAL();\r
+\r
+       return xTimerIsInActiveList;\r
+} /*lint !e818 Can't be pointer to const due to the typedef. */\r
+/*-----------------------------------------------------------*/\r
+\r
+void *pvTimerGetTimerID( const TimerHandle_t xTimer )\r
+{\r
+Timer_t * const pxTimer = ( Timer_t * ) xTimer;\r
+void *pvReturn;\r
+\r
+       configASSERT( xTimer );\r
+\r
+       taskENTER_CRITICAL();\r
+       {\r
+               pvReturn = pxTimer->pvTimerID;\r
+       }\r
+       taskEXIT_CRITICAL();\r
+\r
+       return pvReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID )\r
+{\r
+Timer_t * const pxTimer = ( Timer_t * ) xTimer;\r
+\r
+       configASSERT( xTimer );\r
+\r
+       taskENTER_CRITICAL();\r
+       {\r
+               pxTimer->pvTimerID = pvNewID;\r
+       }\r
+       taskEXIT_CRITICAL();\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( INCLUDE_xTimerPendFunctionCall == 1 )\r
+\r
+       BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken )\r
+       {\r
+       DaemonTaskMessage_t xMessage;\r
+       BaseType_t xReturn;\r
+\r
+               /* Complete the message with the function parameters and post it to the\r
+               daemon task. */\r
+               xMessage.xMessageID = tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR;\r
+               xMessage.u.xCallbackParameters.pxCallbackFunction = xFunctionToPend;\r
+               xMessage.u.xCallbackParameters.pvParameter1 = pvParameter1;\r
+               xMessage.u.xCallbackParameters.ulParameter2 = ulParameter2;\r
+\r
+               xReturn = xQueueSendFromISR( xTimerQueue, &xMessage, pxHigherPriorityTaskWoken );\r
+\r
+               tracePEND_FUNC_CALL_FROM_ISR( xFunctionToPend, pvParameter1, ulParameter2, xReturn );\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* INCLUDE_xTimerPendFunctionCall */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( INCLUDE_xTimerPendFunctionCall == 1 )\r
+\r
+       BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait )\r
+       {\r
+       DaemonTaskMessage_t xMessage;\r
+       BaseType_t xReturn;\r
+\r
+               /* This function can only be called after a timer has been created or\r
+               after the scheduler has been started because, until then, the timer\r
+               queue does not exist. */\r
+               configASSERT( xTimerQueue );\r
+\r
+               /* Complete the message with the function parameters and post it to the\r
+               daemon task. */\r
+               xMessage.xMessageID = tmrCOMMAND_EXECUTE_CALLBACK;\r
+               xMessage.u.xCallbackParameters.pxCallbackFunction = xFunctionToPend;\r
+               xMessage.u.xCallbackParameters.pvParameter1 = pvParameter1;\r
+               xMessage.u.xCallbackParameters.ulParameter2 = ulParameter2;\r
+\r
+               xReturn = xQueueSendToBack( xTimerQueue, &xMessage, xTicksToWait );\r
+\r
+               tracePEND_FUNC_CALL( xFunctionToPend, pvParameter1, ulParameter2, xReturn );\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* INCLUDE_xTimerPendFunctionCall */\r
+/*-----------------------------------------------------------*/\r
+\r
+/* This entire source file will be skipped if the application is not configured\r
+to include software timer functionality.  If you want to include software timer\r
+functionality then ensure configUSE_TIMERS is set to 1 in FreeRTOSConfig.h. */\r
+#endif /* configUSE_TIMERS == 1 */\r
+\r
+\r
+\r