/*\r
- FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd.\r
+ FreeRTOS V8.2.1 - 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
- ***************************************************************************\r
- * *\r
- * FreeRTOS provides completely free yet professionally developed, *\r
- * robust, strictly quality controlled, supported, and cross *\r
- * platform software that has become a de facto standard. *\r
- * *\r
- * Help yourself get started quickly and support the FreeRTOS *\r
- * project by purchasing a FreeRTOS tutorial book, reference *\r
- * manual, or both from: http://www.FreeRTOS.org/Documentation *\r
- * *\r
- * Thank you! *\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
\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 from the following\r
+ FOR A PARTICULAR PURPOSE. Full license text is available on the following\r
link: http://www.freertos.org/a00114.html\r
\r
- 1 tab == 4 spaces!\r
-\r
***************************************************************************\r
* *\r
- * Having a problem? Start by reading the FAQ "My application does *\r
- * not run, what could be wrong?" *\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
- * http://www.FreeRTOS.org/FAQHelp.html *\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 - Documentation, books, training, latest versions,\r
- license and Real Time Engineers Ltd. contact details.\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.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
- Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS\r
- licenses offer ticketed support, indemnification and middleware.\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
\r
if( pcAllocatedBuffer != NULL )\r
{\r
- pxNewQueue = ( Queue_t * ) pcAllocatedBuffer; /*lint !e826 MISRA The buffer cannot be to small because it was dimensioned by sizeof( Queue_t ) + xQueueSizeInBytes. */\r
+ pxNewQueue = ( Queue_t * ) pcAllocatedBuffer; /*lint !e826 MISRA The buffer cannot be too small because it was dimensioned by sizeof( Queue_t ) + xQueueSizeInBytes. */\r
\r
if( uxItemSize == ( UBaseType_t ) 0 )\r
{\r
{\r
taskENTER_CRITICAL();\r
{\r
- /* Is there room on the queue now? The running task must be\r
- the highest priority task wanting to access the queue. If\r
- the head item in the queue is to be overwritten then it does\r
- not matter if the queue is full. */\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
{\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. Therefore, unlike the xQueueGenericGive()\r
- function, there is no need to determine the need for priority\r
- disinheritance here or to clear the mutex holder TCB member. */\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
}\r
/*-----------------------------------------------------------*/\r
\r
-BaseType_t xQueueGenericGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherPriorityTaskWoken )\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 in the item size is not 0. */\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, and doing so is\r
+ definitely wrong if there is a mutex holder as priority inheritance makes no\r
+ sense for an 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
link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\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
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
{\r
/* When the queue is used to implement a semaphore no data is ever\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. Therefore, unlike the xQueueGenericGive()\r
- function, there is no need to determine the need for priority\r
- disinheritance here or to clear the mutex holder TCB member. */\r
-\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
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
\r
#if ( configUSE_TIMERS == 1 )\r
\r
- void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait )\r
+ void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely )\r
{\r
Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
\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 );\r
+ vTaskPlaceOnEventListRestricted( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait, xWaitIndefinitely );\r
}\r
else\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( listLIST_IS_EMPTY( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) == pdFALSE )\r
+ if( pxQueueSetContainer->xTxLock == queueUNLOCKED )\r
{\r
- if( xTaskRemoveFromEventList( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) != pdFALSE )\r
+ if( listLIST_IS_EMPTY( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) == pdFALSE )\r
{\r
- /* The task waiting has a higher priority */\r
- xReturn = pdTRUE;\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
}\r
else\r
{\r
- mtCOVERAGE_TEST_MARKER();\r
+ ( pxQueueSetContainer->xTxLock )++;\r
}\r
}\r
else\r