FreeRTOS Tetris
queue.h
1 /*
2  FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
3  All rights reserved
4 
5  VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
6 
7  This file is part of the FreeRTOS distribution.
8 
9  FreeRTOS is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License (version 2) as published by the
11  Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
12 
13  ***************************************************************************
14  >>! NOTE: The modification to the GPL is included to allow you to !<<
15  >>! distribute a combined work that includes FreeRTOS without being !<<
16  >>! obliged to provide the source code for proprietary components !<<
17  >>! outside of the FreeRTOS kernel. !<<
18  ***************************************************************************
19 
20  FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
21  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22  FOR A PARTICULAR PURPOSE. Full license text is available on the following
23  link: http://www.freertos.org/a00114.html
24 
25  ***************************************************************************
26  * *
27  * FreeRTOS provides completely free yet professionally developed, *
28  * robust, strictly quality controlled, supported, and cross *
29  * platform software that is more than just the market leader, it *
30  * is the industry's de facto standard. *
31  * *
32  * Help yourself get started quickly while simultaneously helping *
33  * to support the FreeRTOS project by purchasing a FreeRTOS *
34  * tutorial book, reference manual, or both: *
35  * http://www.FreeRTOS.org/Documentation *
36  * *
37  ***************************************************************************
38 
39  http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
40  the FAQ page "My application does not run, what could be wrong?". Have you
41  defined configASSERT()?
42 
43  http://www.FreeRTOS.org/support - In return for receiving this top quality
44  embedded software for free we request you assist our global community by
45  participating in the support forum.
46 
47  http://www.FreeRTOS.org/training - Investing in training allows your team to
48  be as productive as possible as early as possible. Now you can receive
49  FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
50  Ltd, and the world's leading authority on the world's leading RTOS.
51 
52  http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
53  including FreeRTOS+Trace - an indispensable productivity tool, a DOS
54  compatible FAT file system, and our tiny thread aware UDP/IP stack.
55 
56  http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
57  Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
58 
59  http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
60  Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
61  licenses offer ticketed support, indemnification and commercial middleware.
62 
63  http://www.SafeRTOS.com - High Integrity Systems also provide a safety
64  engineered and independently SIL3 certified version for use in safety and
65  mission critical applications that require provable dependability.
66 
67  1 tab == 4 spaces!
68 */
69 
70 // Doxygen Groups ***********************************************************************
114 #ifndef QUEUE_H
115 #define QUEUE_H
116 
117 #ifndef INC_FREERTOS_H
118 #error "include FreeRTOS.h" must appear in source files before "include queue.h"
119 #endif
120 
121 #ifdef __cplusplus
122 extern "C" {
123 #endif
124 
125 // **************************************************************************************
126 // Queue Handles ************************************************************************
127 // **************************************************************************************
128 
135 typedef void *QueueHandle_t;
136 
143 typedef void *QueueSetHandle_t;
144 
152 
153 /* For internal use only. */
154 #define queueSEND_TO_BACK ( ( BaseType_t ) 0 )
155 #define queueSEND_TO_FRONT ( ( BaseType_t ) 1 )
156 #define queueOVERWRITE ( ( BaseType_t ) 2 )
157 
158 /* For internal use only. These definitions *must* match those in queue.c. */
159 #define queueQUEUE_TYPE_BASE ( ( uint8_t ) 0U )
160 #define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U )
161 #define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U )
162 #define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( ( uint8_t ) 2U )
163 #define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U )
164 #define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U )
165 
166 // **************************************************************************************
167 // Queue Creation ***********************************************************************
168 // **************************************************************************************
169 
236 #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
237 #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( ( uxQueueLength ), ( uxItemSize ), ( queueQUEUE_TYPE_BASE ) )
238 #endif
239 
320 #if( configSUPPORT_STATIC_ALLOCATION == 1 )
321 #define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxQueueBuffer ) xQueueGenericCreateStatic( ( uxQueueLength ), ( uxItemSize ), ( pucQueueStorage ), ( pxQueueBuffer ), ( queueQUEUE_TYPE_BASE ) )
322 #endif /* configSUPPORT_STATIC_ALLOCATION */
323 
330 #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
331 QueueHandle_t xQueueGenericCreate(const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType) PRIVILEGED_FUNCTION;
332 #endif
333 
340 #if( configSUPPORT_STATIC_ALLOCATION == 1 )
341 QueueHandle_t xQueueGenericCreateStatic(const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType) PRIVILEGED_FUNCTION;
342 #endif
343 
344 // **************************************************************************************
345 // Queue Deletion ***********************************************************************
346 // **************************************************************************************
355 void vQueueDelete(QueueHandle_t xQueue) PRIVILEGED_FUNCTION;
356 
357 // **************************************************************************************
358 // xQueueSend ***************************************************************************
359 // **************************************************************************************
440 #define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
441 
520 #define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT )
521 
600 #define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
601 
677 BaseType_t xQueueGenericSend(QueueHandle_t xQueue, const void *const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition) PRIVILEGED_FUNCTION;
678 
758 #define xQueueOverwrite( xQueue, pvItemToQueue ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE )
759 
760 // **************************************************************************************
761 // Queue Sending from ISR ***************************************************************
762 // **************************************************************************************
763 
828 #define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT )
829 
830 
895 #define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )
896 
980 #define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE )
981 
1050 #define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )
1051 
1125 BaseType_t xQueueGenericSendFromISR(QueueHandle_t xQueue, const void *const pvItemToQueue, BaseType_t *const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition) PRIVILEGED_FUNCTION;
1126 
1127 //***************************************************************************************
1128 // Queue Receiving **********************************************************************
1129 //***************************************************************************************
1130 
1223 #define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )
1224 
1314 #define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )
1315 
1316 
1411 BaseType_t xQueueGenericReceive(QueueHandle_t xQueue, void *const pvBuffer, TickType_t xTicksToWait, const BaseType_t xJustPeek) PRIVILEGED_FUNCTION;
1412 
1413 // **************************************************************************************
1414 // Queue Receiving from ISR *************************************************************
1415 // **************************************************************************************
1444 BaseType_t xQueuePeekFromISR(QueueHandle_t xQueue, void *const pvBuffer) PRIVILEGED_FUNCTION;
1445 
1533 BaseType_t xQueueReceiveFromISR(QueueHandle_t xQueue, void *const pvBuffer, BaseType_t *const pxHigherPriorityTaskWoken) PRIVILEGED_FUNCTION;
1534 
1535 // **************************************************************************************
1536 // Queue Utility Functions **************************************************************
1537 // **************************************************************************************
1538 
1548 UBaseType_t uxQueueMessagesWaiting(const QueueHandle_t xQueue) PRIVILEGED_FUNCTION;
1549 
1561 UBaseType_t uxQueueSpacesAvailable(const QueueHandle_t xQueue) PRIVILEGED_FUNCTION;
1562 
1572 BaseType_t xQueueIsQueueEmptyFromISR(const QueueHandle_t xQueue) PRIVILEGED_FUNCTION;
1573 
1583 BaseType_t xQueueIsQueueFullFromISR(const QueueHandle_t xQueue) PRIVILEGED_FUNCTION;
1584 
1594 UBaseType_t uxQueueMessagesWaitingFromISR(const QueueHandle_t xQueue) PRIVILEGED_FUNCTION;
1595 
1596 /*
1597  * Reset a queue back to its original empty state. The return value is now
1598  * obsolete and is always set to pdPASS.
1599  */
1600 #define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE )
1601 
1602 // **************************************************************************************
1603 // Queue Registration *******************************************************************
1604 // **************************************************************************************
1628 #if( configQUEUE_REGISTRY_SIZE > 0 )
1629 void vQueueAddToRegistry(QueueHandle_t xQueue, const char *pcName) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1630 #endif
1631 
1643 #if( configQUEUE_REGISTRY_SIZE > 0 )
1644 void vQueueUnregisterQueue(QueueHandle_t xQueue) PRIVILEGED_FUNCTION;
1645 #endif
1646 
1659 #if( configQUEUE_REGISTRY_SIZE > 0 )
1660 const char *pcQueueGetName(QueueHandle_t xQueue) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1661 #endif
1662 
1663 // **************************************************************************************
1664 // Queue Sets ***************************************************************************
1665 // **************************************************************************************
1666 
1716 QueueSetHandle_t xQueueCreateSet(const UBaseType_t uxEventQueueLength) PRIVILEGED_FUNCTION;
1717 
1741 BaseType_t xQueueAddToSet(QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet) PRIVILEGED_FUNCTION;
1742 
1761 BaseType_t xQueueRemoveFromSet(QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet) PRIVILEGED_FUNCTION;
1762 
1798 QueueSetMemberHandle_t xQueueSelectFromSet(QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait) PRIVILEGED_FUNCTION;
1799 
1805 
1806 // **************************************************************************************
1807 // Other/Undocumented *******************************************************************
1808 // **************************************************************************************
1809 
1810 /* Not public API functions. */
1811 void vQueueWaitForMessageRestricted(QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely) PRIVILEGED_FUNCTION;
1812 BaseType_t xQueueGenericReset(QueueHandle_t xQueue, BaseType_t xNewQueue) PRIVILEGED_FUNCTION;
1813 void vQueueSetQueueNumber(QueueHandle_t xQueue, UBaseType_t uxQueueNumber) PRIVILEGED_FUNCTION;
1814 UBaseType_t uxQueueGetQueueNumber(QueueHandle_t xQueue) PRIVILEGED_FUNCTION;
1815 uint8_t ucQueueGetQueueType(QueueHandle_t xQueue) PRIVILEGED_FUNCTION;
1816 
1817 /*
1818  * The functions defined above are for passing data to and from tasks. The
1819  * functions below are the equivalents for passing data to and from
1820  * co-routines.
1821  *
1822  * These functions are called from the co-routine macro implementation and
1823  * should not be called directly from application code. Instead use the macro
1824  * wrappers defined within croutine.h.
1825  */
1826 BaseType_t xQueueCRSendFromISR(QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken);
1827 BaseType_t xQueueCRReceiveFromISR(QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxTaskWoken);
1828 BaseType_t xQueueCRSend(QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait);
1829 BaseType_t xQueueCRReceive(QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait);
1830 
1831 /*
1832  * For internal use only. Use xSemaphoreCreateMutex(),
1833  * xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling
1834  * these functions directly.
1835  */
1836 QueueHandle_t xQueueCreateMutex(const uint8_t ucQueueType) PRIVILEGED_FUNCTION;
1837 QueueHandle_t xQueueCreateMutexStatic(const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue) PRIVILEGED_FUNCTION;
1838 QueueHandle_t xQueueCreateCountingSemaphore(const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount) PRIVILEGED_FUNCTION;
1839 QueueHandle_t xQueueCreateCountingSemaphoreStatic(const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue) PRIVILEGED_FUNCTION;
1840 void *xQueueGetMutexHolder(QueueHandle_t xSemaphore) PRIVILEGED_FUNCTION;
1841 
1842 /*
1843  * For internal use only. Use xSemaphoreTakeMutexRecursive() or
1844  * xSemaphoreGiveMutexRecursive() instead of calling these functions directly.
1845  */
1846 BaseType_t xQueueTakeMutexRecursive(QueueHandle_t xMutex, TickType_t xTicksToWait) PRIVILEGED_FUNCTION;
1847 BaseType_t xQueueGiveMutexRecursive(QueueHandle_t pxMutex) PRIVILEGED_FUNCTION;
1848 BaseType_t xQueueGiveFromISR(QueueHandle_t xQueue, BaseType_t *const pxHigherPriorityTaskWoken) PRIVILEGED_FUNCTION;
1849 
1850 
1851 
1852 #ifdef __cplusplus
1853 }
1854 #endif
1855 
1856 #endif /* QUEUE_H */
1857 
pcQueueGetName
const char * pcQueueGetName(QueueHandle_t xQueue) PRIVILEGED_FUNCTION
Definition: queue.c:2308
xQueueGenericSend
BaseType_t xQueueGenericSend(QueueHandle_t xQueue, const void *const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition) PRIVILEGED_FUNCTION
Definition: queue.c:753
xQueueGenericCreate
QueueHandle_t xQueueGenericCreate(const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType) PRIVILEGED_FUNCTION
Definition: queue.c:402
xSTATIC_QUEUE
Definition: FreeRTOS.h:965
xQueueGenericReceive
BaseType_t xQueueGenericReceive(QueueHandle_t xQueue, void *const pvBuffer, TickType_t xTicksToWait, const BaseType_t xJustPeek) PRIVILEGED_FUNCTION
Definition: queue.c:1275
uxQueueMessagesWaiting
UBaseType_t uxQueueMessagesWaiting(const QueueHandle_t xQueue) PRIVILEGED_FUNCTION
Definition: queue.c:1610
TickType_t
uint32_t TickType_t
FreeRTOS definition for a single tick.
Definition: portmacro.h:98
xQueueGenericCreateStatic
QueueHandle_t xQueueGenericCreateStatic(const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType) PRIVILEGED_FUNCTION
Definition: queue.c:345
xQueueGenericSendFromISR
BaseType_t xQueueGenericSendFromISR(QueueHandle_t xQueue, const void *const pvItemToQueue, BaseType_t *const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition) PRIVILEGED_FUNCTION
Definition: queue.c:949
vQueueDelete
void vQueueDelete(QueueHandle_t xQueue) PRIVILEGED_FUNCTION
Definition: queue.c:1656
QueueHandle_t
void * QueueHandle_t
Definition: queue.h:135
UBaseType_t
unsigned long UBaseType_t
FreeRTOS definition for unsigned long ints.
Definition: portmacro.h:92
BaseType_t
long BaseType_t
FreeRTOS definition for long ints.
Definition: portmacro.h:91
xQueueIsQueueEmptyFromISR
BaseType_t xQueueIsQueueEmptyFromISR(const QueueHandle_t xQueue) PRIVILEGED_FUNCTION
Definition: queue.c:1962
xQueueIsQueueFullFromISR
BaseType_t xQueueIsQueueFullFromISR(const QueueHandle_t xQueue) PRIVILEGED_FUNCTION
Definition: queue.c:1997
xQueueRemoveFromSet
BaseType_t xQueueRemoveFromSet(QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet) PRIVILEGED_FUNCTION
vQueueUnregisterQueue
void vQueueUnregisterQueue(QueueHandle_t xQueue) PRIVILEGED_FUNCTION
Definition: queue.c:2337
uxQueueMessagesWaitingFromISR
UBaseType_t uxQueueMessagesWaitingFromISR(const QueueHandle_t xQueue) PRIVILEGED_FUNCTION
Definition: queue.c:1644
uxQueueSpacesAvailable
UBaseType_t uxQueueSpacesAvailable(const QueueHandle_t xQueue) PRIVILEGED_FUNCTION
Definition: queue.c:1626
QueueSetHandle_t
void * QueueSetHandle_t
Definition: queue.h:143
xQueueSelectFromSetFromISR
QueueSetMemberHandle_t xQueueSelectFromSetFromISR(QueueSetHandle_t xQueueSet) PRIVILEGED_FUNCTION
xQueueSelectFromSet
QueueSetMemberHandle_t xQueueSelectFromSet(QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait) PRIVILEGED_FUNCTION
xQueuePeekFromISR
BaseType_t xQueuePeekFromISR(QueueHandle_t xQueue, void *const pvBuffer) PRIVILEGED_FUNCTION
Definition: queue.c:1557
xQueueAddToSet
BaseType_t xQueueAddToSet(QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet) PRIVILEGED_FUNCTION
xQueueCreateSet
QueueSetHandle_t xQueueCreateSet(const UBaseType_t uxEventQueueLength) PRIVILEGED_FUNCTION
QueueSetMemberHandle_t
void * QueueSetMemberHandle_t
Definition: queue.h:151
vQueueAddToRegistry
void vQueueAddToRegistry(QueueHandle_t xQueue, const char *pcName) PRIVILEGED_FUNCTION
Definition: queue.c:2278