* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/
#include<stdlib.h>
#include<string.h>
/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
* all the API functions to use the MPU wrappers. That should only be done when
* task.h is included from an application file. */
#defineMPU_WRAPPERS_INCLUDED_FROM_API_FILE
#include"Arduino_FreeRTOS.h"
#include"task.h"
#include"queue.h"
/* The MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined
* for the header files above, but not in this file, in order to generate the
* correct privileged Vs unprivileged linkage and placement. */
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
/* Constants used with the cRxLock and cTxLock structure members. */
#definequeueUNLOCKED ( ( int8_t ) -1 )
#definequeueLOCKED_UNMODIFIED ( ( int8_t ) 0 )
#definequeueINT8_MAX ( ( int8_t ) 127 )
/* When the Queue_t structure is used to represent a base queue its pcHead and
* pcTail members are used as pointers into the queue storage area. When the
* Queue_t structure is used to represent a mutex pcHead and pcTail pointers are
* not necessary, and the pcHead pointer is set to NULL to indicate that the
* structure instead holds a pointer to the mutex holder (if any). Map alternative
* names to the pcHead and structure member to ensure the readability of the code
* is maintained. The QueuePointers_t and SemaphoreData_t types are used to form
* a union as their usage is mutually exclusive dependent on what the queue is
* being used for. */
#defineuxQueueType pcHead
#definequeueQUEUE_IS_MUTEX NULL
typedefstructQueuePointers
{
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. */
int8_t*pcReadFrom; /**< Points to the last place that a queued item was read from when the structure is used as a queue. */
} QueuePointers_t;
typedefstructSemaphoreData
{
TaskHandle_txMutexHolder; /**< The handle of the task that holds the mutex. */
UBaseType_tuxRecursiveCallCount; /**< Maintains a count of the number of times a recursive mutex has been recursively 'taken' when the structure is used as a mutex. */
} SemaphoreData_t;
/* Semaphores do not actually store or copy data, so have an item size of
int8_t*pcHead; /**< Points to the beginning of the queue storage area. */
int8_t*pcWriteTo; /**< Points to the free next place in the storage area. */
union
{
QueuePointers_txQueue; /**< Data required exclusively when this structure is used as a queue. */
SemaphoreData_txSemaphore; /**< Data required exclusively when this structure is used as a semaphore. */
} u;
List_txTasksWaitingToSend; /**< List of tasks that are blocked waiting to post onto this queue. Stored in priority order. */
List_txTasksWaitingToReceive; /**< List of tasks that are blocked waiting to read from this queue. Stored in priority order. */
volatileUBaseType_tuxMessagesWaiting; /**< The number of items currently in the queue. */
UBaseType_tuxLength; /**< The length of the queue defined as the number of items it will hold, not the number of bytes. */
UBaseType_tuxItemSize; /**< The size of each items that the queue will hold. */
volatileint8_tcRxLock; /**< 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. */
volatileint8_tcTxLock; /**< 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. */
uint8_tucStaticallyAllocated; /**< Set to pdTRUE if the memory used by the queue was statically allocated to ensure no attempt is made to free the memory. */