queue.h 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691
  1. /*
  2. FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.
  3. All rights reserved
  4. VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
  5. This file is part of the FreeRTOS distribution.
  6. FreeRTOS is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU General Public License (version 2) as published by the
  8. Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
  9. ***************************************************************************
  10. >>! NOTE: The modification to the GPL is included to allow you to !<<
  11. >>! distribute a combined work that includes FreeRTOS without being !<<
  12. >>! obliged to provide the source code for proprietary components !<<
  13. >>! outside of the FreeRTOS kernel. !<<
  14. ***************************************************************************
  15. FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
  16. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17. FOR A PARTICULAR PURPOSE. Full license text is available on the following
  18. link: http://www.freertos.org/a00114.html
  19. ***************************************************************************
  20. * *
  21. * FreeRTOS provides completely free yet professionally developed, *
  22. * robust, strictly quality controlled, supported, and cross *
  23. * platform software that is more than just the market leader, it *
  24. * is the industry's de facto standard. *
  25. * *
  26. * Help yourself get started quickly while simultaneously helping *
  27. * to support the FreeRTOS project by purchasing a FreeRTOS *
  28. * tutorial book, reference manual, or both: *
  29. * http://www.FreeRTOS.org/Documentation *
  30. * *
  31. ***************************************************************************
  32. http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
  33. the FAQ page "My application does not run, what could be wrong?". Have you
  34. defined configASSERT()?
  35. http://www.FreeRTOS.org/support - In return for receiving this top quality
  36. embedded software for free we request you assist our global community by
  37. participating in the support forum.
  38. http://www.FreeRTOS.org/training - Investing in training allows your team to
  39. be as productive as possible as early as possible. Now you can receive
  40. FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
  41. Ltd, and the world's leading authority on the world's leading RTOS.
  42. http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
  43. including FreeRTOS+Trace - an indispensable productivity tool, a DOS
  44. compatible FAT file system, and our tiny thread aware UDP/IP stack.
  45. http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
  46. Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
  47. http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
  48. Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
  49. licenses offer ticketed support, indemnification and commercial middleware.
  50. http://www.SafeRTOS.com - High Integrity Systems also provide a safety
  51. engineered and independently SIL3 certified version for use in safety and
  52. mission critical applications that require provable dependability.
  53. 1 tab == 4 spaces!
  54. */
  55. #ifndef QUEUE_H
  56. #define QUEUE_H
  57. #ifndef INC_FREERTOS_H
  58. #error "include FreeRTOS.h" must appear in source files before "include queue.h"
  59. #endif
  60. #ifdef __cplusplus
  61. extern "C" {
  62. #endif
  63. /**
  64. * Type by which queues are referenced. For example, a call to xQueueCreate()
  65. * returns an QueueHandle_t variable that can then be used as a parameter to
  66. * xQueueSend(), xQueueReceive(), etc.
  67. */
  68. typedef void * QueueHandle_t;
  69. /**
  70. * Type by which queue sets are referenced. For example, a call to
  71. * xQueueCreateSet() returns an xQueueSet variable that can then be used as a
  72. * parameter to xQueueSelectFromSet(), xQueueAddToSet(), etc.
  73. */
  74. typedef void * QueueSetHandle_t;
  75. /**
  76. * Queue sets can contain both queues and semaphores, so the
  77. * QueueSetMemberHandle_t is defined as a type to be used where a parameter or
  78. * return value can be either an QueueHandle_t or an SemaphoreHandle_t.
  79. */
  80. typedef void * QueueSetMemberHandle_t;
  81. /* For internal use only. */
  82. #define queueSEND_TO_BACK ( ( BaseType_t ) 0 )
  83. #define queueSEND_TO_FRONT ( ( BaseType_t ) 1 )
  84. #define queueOVERWRITE ( ( BaseType_t ) 2 )
  85. /* For internal use only. These definitions *must* match those in queue.c. */
  86. #define queueQUEUE_TYPE_BASE ( ( uint8_t ) 0U )
  87. #define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U )
  88. #define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U )
  89. #define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( ( uint8_t ) 2U )
  90. #define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U )
  91. #define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U )
  92. /**
  93. * queue. h
  94. * <pre>
  95. QueueHandle_t xQueueCreate(
  96. UBaseType_t uxQueueLength,
  97. UBaseType_t uxItemSize
  98. );
  99. * </pre>
  100. *
  101. * Creates a new queue instance. This allocates the storage required by the
  102. * new queue and returns a handle for the queue.
  103. *
  104. * @param uxQueueLength The maximum number of items that the queue can contain.
  105. *
  106. * @param uxItemSize The number of bytes each item in the queue will require.
  107. * Items are queued by copy, not by reference, so this is the number of bytes
  108. * that will be copied for each posted item. Each item on the queue must be
  109. * the same size.
  110. *
  111. * @return If the queue is successfully create then a handle to the newly
  112. * created queue is returned. If the queue cannot be created then 0 is
  113. * returned.
  114. *
  115. * Example usage:
  116. <pre>
  117. struct AMessage
  118. {
  119. char ucMessageID;
  120. char ucData[ 20 ];
  121. };
  122. void vATask( void *pvParameters )
  123. {
  124. QueueHandle_t xQueue1, xQueue2;
  125. // Create a queue capable of containing 10 uint32_t values.
  126. xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
  127. if( xQueue1 == 0 )
  128. {
  129. // Queue was not created and must not be used.
  130. }
  131. // Create a queue capable of containing 10 pointers to AMessage structures.
  132. // These should be passed by pointer as they contain a lot of data.
  133. xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
  134. if( xQueue2 == 0 )
  135. {
  136. // Queue was not created and must not be used.
  137. }
  138. // ... Rest of task code.
  139. }
  140. </pre>
  141. * \defgroup xQueueCreate xQueueCreate
  142. * \ingroup QueueManagement
  143. */
  144. #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( uxQueueLength, uxItemSize, queueQUEUE_TYPE_BASE )
  145. /**
  146. * queue. h
  147. * <pre>
  148. BaseType_t xQueueSendToToFront(
  149. QueueHandle_t xQueue,
  150. const void *pvItemToQueue,
  151. TickType_t xTicksToWait
  152. );
  153. * </pre>
  154. *
  155. * This is a macro that calls xQueueGenericSend().
  156. *
  157. * Post an item to the front of a queue. The item is queued by copy, not by
  158. * reference. This function must not be called from an interrupt service
  159. * routine. See xQueueSendFromISR () for an alternative which may be used
  160. * in an ISR.
  161. *
  162. * @param xQueue The handle to the queue on which the item is to be posted.
  163. *
  164. * @param pvItemToQueue A pointer to the item that is to be placed on the
  165. * queue. The size of the items the queue will hold was defined when the
  166. * queue was created, so this many bytes will be copied from pvItemToQueue
  167. * into the queue storage area.
  168. *
  169. * @param xTicksToWait The maximum amount of time the task should block
  170. * waiting for space to become available on the queue, should it already
  171. * be full. The call will return immediately if this is set to 0 and the
  172. * queue is full. The time is defined in tick periods so the constant
  173. * portTICK_PERIOD_MS should be used to convert to real time if this is required.
  174. *
  175. * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
  176. *
  177. * Example usage:
  178. <pre>
  179. struct AMessage
  180. {
  181. char ucMessageID;
  182. char ucData[ 20 ];
  183. } xMessage;
  184. uint32_t ulVar = 10UL;
  185. void vATask( void *pvParameters )
  186. {
  187. QueueHandle_t xQueue1, xQueue2;
  188. struct AMessage *pxMessage;
  189. // Create a queue capable of containing 10 uint32_t values.
  190. xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
  191. // Create a queue capable of containing 10 pointers to AMessage structures.
  192. // These should be passed by pointer as they contain a lot of data.
  193. xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
  194. // ...
  195. if( xQueue1 != 0 )
  196. {
  197. // Send an uint32_t. Wait for 10 ticks for space to become
  198. // available if necessary.
  199. if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
  200. {
  201. // Failed to post the message, even after 10 ticks.
  202. }
  203. }
  204. if( xQueue2 != 0 )
  205. {
  206. // Send a pointer to a struct AMessage object. Don't block if the
  207. // queue is already full.
  208. pxMessage = & xMessage;
  209. xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
  210. }
  211. // ... Rest of task code.
  212. }
  213. </pre>
  214. * \defgroup xQueueSend xQueueSend
  215. * \ingroup QueueManagement
  216. */
  217. #define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT )
  218. /**
  219. * queue. h
  220. * <pre>
  221. BaseType_t xQueueSendToBack(
  222. QueueHandle_t xQueue,
  223. const void *pvItemToQueue,
  224. TickType_t xTicksToWait
  225. );
  226. * </pre>
  227. *
  228. * This is a macro that calls xQueueGenericSend().
  229. *
  230. * Post an item to the back of a queue. The item is queued by copy, not by
  231. * reference. This function must not be called from an interrupt service
  232. * routine. See xQueueSendFromISR () for an alternative which may be used
  233. * in an ISR.
  234. *
  235. * @param xQueue The handle to the queue on which the item is to be posted.
  236. *
  237. * @param pvItemToQueue A pointer to the item that is to be placed on the
  238. * queue. The size of the items the queue will hold was defined when the
  239. * queue was created, so this many bytes will be copied from pvItemToQueue
  240. * into the queue storage area.
  241. *
  242. * @param xTicksToWait The maximum amount of time the task should block
  243. * waiting for space to become available on the queue, should it already
  244. * be full. The call will return immediately if this is set to 0 and the queue
  245. * is full. The time is defined in tick periods so the constant
  246. * portTICK_PERIOD_MS should be used to convert to real time if this is required.
  247. *
  248. * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
  249. *
  250. * Example usage:
  251. <pre>
  252. struct AMessage
  253. {
  254. char ucMessageID;
  255. char ucData[ 20 ];
  256. } xMessage;
  257. uint32_t ulVar = 10UL;
  258. void vATask( void *pvParameters )
  259. {
  260. QueueHandle_t xQueue1, xQueue2;
  261. struct AMessage *pxMessage;
  262. // Create a queue capable of containing 10 uint32_t values.
  263. xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
  264. // Create a queue capable of containing 10 pointers to AMessage structures.
  265. // These should be passed by pointer as they contain a lot of data.
  266. xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
  267. // ...
  268. if( xQueue1 != 0 )
  269. {
  270. // Send an uint32_t. Wait for 10 ticks for space to become
  271. // available if necessary.
  272. if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
  273. {
  274. // Failed to post the message, even after 10 ticks.
  275. }
  276. }
  277. if( xQueue2 != 0 )
  278. {
  279. // Send a pointer to a struct AMessage object. Don't block if the
  280. // queue is already full.
  281. pxMessage = & xMessage;
  282. xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
  283. }
  284. // ... Rest of task code.
  285. }
  286. </pre>
  287. * \defgroup xQueueSend xQueueSend
  288. * \ingroup QueueManagement
  289. */
  290. #define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
  291. /**
  292. * queue. h
  293. * <pre>
  294. BaseType_t xQueueSend(
  295. QueueHandle_t xQueue,
  296. const void * pvItemToQueue,
  297. TickType_t xTicksToWait
  298. );
  299. * </pre>
  300. *
  301. * This is a macro that calls xQueueGenericSend(). It is included for
  302. * backward compatibility with versions of FreeRTOS.org that did not
  303. * include the xQueueSendToFront() and xQueueSendToBack() macros. It is
  304. * equivalent to xQueueSendToBack().
  305. *
  306. * Post an item on a queue. The item is queued by copy, not by reference.
  307. * This function must not be called from an interrupt service routine.
  308. * See xQueueSendFromISR () for an alternative which may be used in an ISR.
  309. *
  310. * @param xQueue The handle to the queue on which the item is to be posted.
  311. *
  312. * @param pvItemToQueue A pointer to the item that is to be placed on the
  313. * queue. The size of the items the queue will hold was defined when the
  314. * queue was created, so this many bytes will be copied from pvItemToQueue
  315. * into the queue storage area.
  316. *
  317. * @param xTicksToWait The maximum amount of time the task should block
  318. * waiting for space to become available on the queue, should it already
  319. * be full. The call will return immediately if this is set to 0 and the
  320. * queue is full. The time is defined in tick periods so the constant
  321. * portTICK_PERIOD_MS should be used to convert to real time if this is required.
  322. *
  323. * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
  324. *
  325. * Example usage:
  326. <pre>
  327. struct AMessage
  328. {
  329. char ucMessageID;
  330. char ucData[ 20 ];
  331. } xMessage;
  332. uint32_t ulVar = 10UL;
  333. void vATask( void *pvParameters )
  334. {
  335. QueueHandle_t xQueue1, xQueue2;
  336. struct AMessage *pxMessage;
  337. // Create a queue capable of containing 10 uint32_t values.
  338. xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
  339. // Create a queue capable of containing 10 pointers to AMessage structures.
  340. // These should be passed by pointer as they contain a lot of data.
  341. xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
  342. // ...
  343. if( xQueue1 != 0 )
  344. {
  345. // Send an uint32_t. Wait for 10 ticks for space to become
  346. // available if necessary.
  347. if( xQueueSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
  348. {
  349. // Failed to post the message, even after 10 ticks.
  350. }
  351. }
  352. if( xQueue2 != 0 )
  353. {
  354. // Send a pointer to a struct AMessage object. Don't block if the
  355. // queue is already full.
  356. pxMessage = & xMessage;
  357. xQueueSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
  358. }
  359. // ... Rest of task code.
  360. }
  361. </pre>
  362. * \defgroup xQueueSend xQueueSend
  363. * \ingroup QueueManagement
  364. */
  365. #define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
  366. /**
  367. * queue. h
  368. * <pre>
  369. BaseType_t xQueueOverwrite(
  370. QueueHandle_t xQueue,
  371. const void * pvItemToQueue
  372. );
  373. * </pre>
  374. *
  375. * Only for use with queues that have a length of one - so the queue is either
  376. * empty or full.
  377. *
  378. * Post an item on a queue. If the queue is already full then overwrite the
  379. * value held in the queue. The item is queued by copy, not by reference.
  380. *
  381. * This function must not be called from an interrupt service routine.
  382. * See xQueueOverwriteFromISR () for an alternative which may be used in an ISR.
  383. *
  384. * @param xQueue The handle of the queue to which the data is being sent.
  385. *
  386. * @param pvItemToQueue A pointer to the item that is to be placed on the
  387. * queue. The size of the items the queue will hold was defined when the
  388. * queue was created, so this many bytes will be copied from pvItemToQueue
  389. * into the queue storage area.
  390. *
  391. * @return xQueueOverwrite() is a macro that calls xQueueGenericSend(), and
  392. * therefore has the same return values as xQueueSendToFront(). However, pdPASS
  393. * is the only value that can be returned because xQueueOverwrite() will write
  394. * to the queue even when the queue is already full.
  395. *
  396. * Example usage:
  397. <pre>
  398. void vFunction( void *pvParameters )
  399. {
  400. QueueHandle_t xQueue;
  401. uint32_t ulVarToSend, ulValReceived;
  402. // Create a queue to hold one uint32_t value. It is strongly
  403. // recommended *not* to use xQueueOverwrite() on queues that can
  404. // contain more than one value, and doing so will trigger an assertion
  405. // if configASSERT() is defined.
  406. xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
  407. // Write the value 10 to the queue using xQueueOverwrite().
  408. ulVarToSend = 10;
  409. xQueueOverwrite( xQueue, &ulVarToSend );
  410. // Peeking the queue should now return 10, but leave the value 10 in
  411. // the queue. A block time of zero is used as it is known that the
  412. // queue holds a value.
  413. ulValReceived = 0;
  414. xQueuePeek( xQueue, &ulValReceived, 0 );
  415. if( ulValReceived != 10 )
  416. {
  417. // Error unless the item was removed by a different task.
  418. }
  419. // The queue is still full. Use xQueueOverwrite() to overwrite the
  420. // value held in the queue with 100.
  421. ulVarToSend = 100;
  422. xQueueOverwrite( xQueue, &ulVarToSend );
  423. // This time read from the queue, leaving the queue empty once more.
  424. // A block time of 0 is used again.
  425. xQueueReceive( xQueue, &ulValReceived, 0 );
  426. // The value read should be the last value written, even though the
  427. // queue was already full when the value was written.
  428. if( ulValReceived != 100 )
  429. {
  430. // Error!
  431. }
  432. // ...
  433. }
  434. </pre>
  435. * \defgroup xQueueOverwrite xQueueOverwrite
  436. * \ingroup QueueManagement
  437. */
  438. #define xQueueOverwrite( xQueue, pvItemToQueue ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE )
  439. /**
  440. * queue. h
  441. * <pre>
  442. BaseType_t xQueueGenericSend(
  443. QueueHandle_t xQueue,
  444. const void * pvItemToQueue,
  445. TickType_t xTicksToWait
  446. BaseType_t xCopyPosition
  447. );
  448. * </pre>
  449. *
  450. * It is preferred that the macros xQueueSend(), xQueueSendToFront() and
  451. * xQueueSendToBack() are used in place of calling this function directly.
  452. *
  453. * Post an item on a queue. The item is queued by copy, not by reference.
  454. * This function must not be called from an interrupt service routine.
  455. * See xQueueSendFromISR () for an alternative which may be used in an ISR.
  456. *
  457. * @param xQueue The handle to the queue on which the item is to be posted.
  458. *
  459. * @param pvItemToQueue A pointer to the item that is to be placed on the
  460. * queue. The size of the items the queue will hold was defined when the
  461. * queue was created, so this many bytes will be copied from pvItemToQueue
  462. * into the queue storage area.
  463. *
  464. * @param xTicksToWait The maximum amount of time the task should block
  465. * waiting for space to become available on the queue, should it already
  466. * be full. The call will return immediately if this is set to 0 and the
  467. * queue is full. The time is defined in tick periods so the constant
  468. * portTICK_PERIOD_MS should be used to convert to real time if this is required.
  469. *
  470. * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the
  471. * item at the back of the queue, or queueSEND_TO_FRONT to place the item
  472. * at the front of the queue (for high priority messages).
  473. *
  474. * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
  475. *
  476. * Example usage:
  477. <pre>
  478. struct AMessage
  479. {
  480. char ucMessageID;
  481. char ucData[ 20 ];
  482. } xMessage;
  483. uint32_t ulVar = 10UL;
  484. void vATask( void *pvParameters )
  485. {
  486. QueueHandle_t xQueue1, xQueue2;
  487. struct AMessage *pxMessage;
  488. // Create a queue capable of containing 10 uint32_t values.
  489. xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
  490. // Create a queue capable of containing 10 pointers to AMessage structures.
  491. // These should be passed by pointer as they contain a lot of data.
  492. xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
  493. // ...
  494. if( xQueue1 != 0 )
  495. {
  496. // Send an uint32_t. Wait for 10 ticks for space to become
  497. // available if necessary.
  498. if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10, queueSEND_TO_BACK ) != pdPASS )
  499. {
  500. // Failed to post the message, even after 10 ticks.
  501. }
  502. }
  503. if( xQueue2 != 0 )
  504. {
  505. // Send a pointer to a struct AMessage object. Don't block if the
  506. // queue is already full.
  507. pxMessage = & xMessage;
  508. xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0, queueSEND_TO_BACK );
  509. }
  510. // ... Rest of task code.
  511. }
  512. </pre>
  513. * \defgroup xQueueSend xQueueSend
  514. * \ingroup QueueManagement
  515. */
  516. BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;
  517. /**
  518. * queue. h
  519. * <pre>
  520. BaseType_t xQueuePeek(
  521. QueueHandle_t xQueue,
  522. void *pvBuffer,
  523. TickType_t xTicksToWait
  524. );</pre>
  525. *
  526. * This is a macro that calls the xQueueGenericReceive() function.
  527. *
  528. * Receive an item from a queue without removing the item from the queue.
  529. * The item is received by copy so a buffer of adequate size must be
  530. * provided. The number of bytes copied into the buffer was defined when
  531. * the queue was created.
  532. *
  533. * Successfully received items remain on the queue so will be returned again
  534. * by the next call, or a call to xQueueReceive().
  535. *
  536. * This macro must not be used in an interrupt service routine. See
  537. * xQueuePeekFromISR() for an alternative that can be called from an interrupt
  538. * service routine.
  539. *
  540. * @param xQueue The handle to the queue from which the item is to be
  541. * received.
  542. *
  543. * @param pvBuffer Pointer to the buffer into which the received item will
  544. * be copied.
  545. *
  546. * @param xTicksToWait The maximum amount of time the task should block
  547. * waiting for an item to receive should the queue be empty at the time
  548. * of the call. The time is defined in tick periods so the constant
  549. * portTICK_PERIOD_MS should be used to convert to real time if this is required.
  550. * xQueuePeek() will return immediately if xTicksToWait is 0 and the queue
  551. * is empty.
  552. *
  553. * @return pdTRUE if an item was successfully received from the queue,
  554. * otherwise pdFALSE.
  555. *
  556. * Example usage:
  557. <pre>
  558. struct AMessage
  559. {
  560. char ucMessageID;
  561. char ucData[ 20 ];
  562. } xMessage;
  563. QueueHandle_t xQueue;
  564. // Task to create a queue and post a value.
  565. void vATask( void *pvParameters )
  566. {
  567. struct AMessage *pxMessage;
  568. // Create a queue capable of containing 10 pointers to AMessage structures.
  569. // These should be passed by pointer as they contain a lot of data.
  570. xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
  571. if( xQueue == 0 )
  572. {
  573. // Failed to create the queue.
  574. }
  575. // ...
  576. // Send a pointer to a struct AMessage object. Don't block if the
  577. // queue is already full.
  578. pxMessage = & xMessage;
  579. xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
  580. // ... Rest of task code.
  581. }
  582. // Task to peek the data from the queue.
  583. void vADifferentTask( void *pvParameters )
  584. {
  585. struct AMessage *pxRxedMessage;
  586. if( xQueue != 0 )
  587. {
  588. // Peek a message on the created queue. Block for 10 ticks if a
  589. // message is not immediately available.
  590. if( xQueuePeek( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
  591. {
  592. // pcRxedMessage now points to the struct AMessage variable posted
  593. // by vATask, but the item still remains on the queue.
  594. }
  595. }
  596. // ... Rest of task code.
  597. }
  598. </pre>
  599. * \defgroup xQueueReceive xQueueReceive
  600. * \ingroup QueueManagement
  601. */
  602. #define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )
  603. /**
  604. * queue. h
  605. * <pre>
  606. BaseType_t xQueuePeekFromISR(
  607. QueueHandle_t xQueue,
  608. void *pvBuffer,
  609. );</pre>
  610. *
  611. * A version of xQueuePeek() that can be called from an interrupt service
  612. * routine (ISR).
  613. *
  614. * Receive an item from a queue without removing the item from the queue.
  615. * The item is received by copy so a buffer of adequate size must be
  616. * provided. The number of bytes copied into the buffer was defined when
  617. * the queue was created.
  618. *
  619. * Successfully received items remain on the queue so will be returned again
  620. * by the next call, or a call to xQueueReceive().
  621. *
  622. * @param xQueue The handle to the queue from which the item is to be
  623. * received.
  624. *
  625. * @param pvBuffer Pointer to the buffer into which the received item will
  626. * be copied.
  627. *
  628. * @return pdTRUE if an item was successfully received from the queue,
  629. * otherwise pdFALSE.
  630. *
  631. * \defgroup xQueuePeekFromISR xQueuePeekFromISR
  632. * \ingroup QueueManagement
  633. */
  634. BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION;
  635. /**
  636. * queue. h
  637. * <pre>
  638. BaseType_t xQueueReceive(
  639. QueueHandle_t xQueue,
  640. void *pvBuffer,
  641. TickType_t xTicksToWait
  642. );</pre>
  643. *
  644. * This is a macro that calls the xQueueGenericReceive() function.
  645. *
  646. * Receive an item from a queue. The item is received by copy so a buffer of
  647. * adequate size must be provided. The number of bytes copied into the buffer
  648. * was defined when the queue was created.
  649. *
  650. * Successfully received items are removed from the queue.
  651. *
  652. * This function must not be used in an interrupt service routine. See
  653. * xQueueReceiveFromISR for an alternative that can.
  654. *
  655. * @param xQueue The handle to the queue from which the item is to be
  656. * received.
  657. *
  658. * @param pvBuffer Pointer to the buffer into which the received item will
  659. * be copied.
  660. *
  661. * @param xTicksToWait The maximum amount of time the task should block
  662. * waiting for an item to receive should the queue be empty at the time
  663. * of the call. xQueueReceive() will return immediately if xTicksToWait
  664. * is zero and the queue is empty. The time is defined in tick periods so the
  665. * constant portTICK_PERIOD_MS should be used to convert to real time if this is
  666. * required.
  667. *
  668. * @return pdTRUE if an item was successfully received from the queue,
  669. * otherwise pdFALSE.
  670. *
  671. * Example usage:
  672. <pre>
  673. struct AMessage
  674. {
  675. char ucMessageID;
  676. char ucData[ 20 ];
  677. } xMessage;
  678. QueueHandle_t xQueue;
  679. // Task to create a queue and post a value.
  680. void vATask( void *pvParameters )
  681. {
  682. struct AMessage *pxMessage;
  683. // Create a queue capable of containing 10 pointers to AMessage structures.
  684. // These should be passed by pointer as they contain a lot of data.
  685. xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
  686. if( xQueue == 0 )
  687. {
  688. // Failed to create the queue.
  689. }
  690. // ...
  691. // Send a pointer to a struct AMessage object. Don't block if the
  692. // queue is already full.
  693. pxMessage = & xMessage;
  694. xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
  695. // ... Rest of task code.
  696. }
  697. // Task to receive from the queue.
  698. void vADifferentTask( void *pvParameters )
  699. {
  700. struct AMessage *pxRxedMessage;
  701. if( xQueue != 0 )
  702. {
  703. // Receive a message on the created queue. Block for 10 ticks if a
  704. // message is not immediately available.
  705. if( xQueueReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
  706. {
  707. // pcRxedMessage now points to the struct AMessage variable posted
  708. // by vATask.
  709. }
  710. }
  711. // ... Rest of task code.
  712. }
  713. </pre>
  714. * \defgroup xQueueReceive xQueueReceive
  715. * \ingroup QueueManagement
  716. */
  717. #define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )
  718. /**
  719. * queue. h
  720. * <pre>
  721. BaseType_t xQueueGenericReceive(
  722. QueueHandle_t xQueue,
  723. void *pvBuffer,
  724. TickType_t xTicksToWait
  725. BaseType_t xJustPeek
  726. );</pre>
  727. *
  728. * It is preferred that the macro xQueueReceive() be used rather than calling
  729. * this function directly.
  730. *
  731. * Receive an item from a queue. The item is received by copy so a buffer of
  732. * adequate size must be provided. The number of bytes copied into the buffer
  733. * was defined when the queue was created.
  734. *
  735. * This function must not be used in an interrupt service routine. See
  736. * xQueueReceiveFromISR for an alternative that can.
  737. *
  738. * @param xQueue The handle to the queue from which the item is to be
  739. * received.
  740. *
  741. * @param pvBuffer Pointer to the buffer into which the received item will
  742. * be copied.
  743. *
  744. * @param xTicksToWait The maximum amount of time the task should block
  745. * waiting for an item to receive should the queue be empty at the time
  746. * of the call. The time is defined in tick periods so the constant
  747. * portTICK_PERIOD_MS should be used to convert to real time if this is required.
  748. * xQueueGenericReceive() will return immediately if the queue is empty and
  749. * xTicksToWait is 0.
  750. *
  751. * @param xJustPeek When set to true, the item received from the queue is not
  752. * actually removed from the queue - meaning a subsequent call to
  753. * xQueueReceive() will return the same item. When set to false, the item
  754. * being received from the queue is also removed from the queue.
  755. *
  756. * @return pdTRUE if an item was successfully received from the queue,
  757. * otherwise pdFALSE.
  758. *
  759. * Example usage:
  760. <pre>
  761. struct AMessage
  762. {
  763. char ucMessageID;
  764. char ucData[ 20 ];
  765. } xMessage;
  766. QueueHandle_t xQueue;
  767. // Task to create a queue and post a value.
  768. void vATask( void *pvParameters )
  769. {
  770. struct AMessage *pxMessage;
  771. // Create a queue capable of containing 10 pointers to AMessage structures.
  772. // These should be passed by pointer as they contain a lot of data.
  773. xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
  774. if( xQueue == 0 )
  775. {
  776. // Failed to create the queue.
  777. }
  778. // ...
  779. // Send a pointer to a struct AMessage object. Don't block if the
  780. // queue is already full.
  781. pxMessage = & xMessage;
  782. xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
  783. // ... Rest of task code.
  784. }
  785. // Task to receive from the queue.
  786. void vADifferentTask( void *pvParameters )
  787. {
  788. struct AMessage *pxRxedMessage;
  789. if( xQueue != 0 )
  790. {
  791. // Receive a message on the created queue. Block for 10 ticks if a
  792. // message is not immediately available.
  793. if( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
  794. {
  795. // pcRxedMessage now points to the struct AMessage variable posted
  796. // by vATask.
  797. }
  798. }
  799. // ... Rest of task code.
  800. }
  801. </pre>
  802. * \defgroup xQueueReceive xQueueReceive
  803. * \ingroup QueueManagement
  804. */
  805. BaseType_t xQueueGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, const BaseType_t xJustPeek ) PRIVILEGED_FUNCTION;
  806. /**
  807. * queue. h
  808. * <pre>UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue );</pre>
  809. *
  810. * Return the number of messages stored in a queue.
  811. *
  812. * @param xQueue A handle to the queue being queried.
  813. *
  814. * @return The number of messages available in the queue.
  815. *
  816. * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting
  817. * \ingroup QueueManagement
  818. */
  819. UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
  820. /**
  821. * queue. h
  822. * <pre>UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue );</pre>
  823. *
  824. * Return the number of free spaces available in a queue. This is equal to the
  825. * number of items that can be sent to the queue before the queue becomes full
  826. * if no items are removed.
  827. *
  828. * @param xQueue A handle to the queue being queried.
  829. *
  830. * @return The number of spaces available in the queue.
  831. *
  832. * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting
  833. * \ingroup QueueManagement
  834. */
  835. UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
  836. /**
  837. * queue. h
  838. * <pre>void vQueueDelete( QueueHandle_t xQueue );</pre>
  839. *
  840. * Delete a queue - freeing all the memory allocated for storing of items
  841. * placed on the queue.
  842. *
  843. * @param xQueue A handle to the queue to be deleted.
  844. *
  845. * \defgroup vQueueDelete vQueueDelete
  846. * \ingroup QueueManagement
  847. */
  848. void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
  849. /**
  850. * queue. h
  851. * <pre>
  852. BaseType_t xQueueSendToFrontFromISR(
  853. QueueHandle_t xQueue,
  854. const void *pvItemToQueue,
  855. BaseType_t *pxHigherPriorityTaskWoken
  856. );
  857. </pre>
  858. *
  859. * This is a macro that calls xQueueGenericSendFromISR().
  860. *
  861. * Post an item to the front of a queue. It is safe to use this macro from
  862. * within an interrupt service routine.
  863. *
  864. * Items are queued by copy not reference so it is preferable to only
  865. * queue small items, especially when called from an ISR. In most cases
  866. * it would be preferable to store a pointer to the item being queued.
  867. *
  868. * @param xQueue The handle to the queue on which the item is to be posted.
  869. *
  870. * @param pvItemToQueue A pointer to the item that is to be placed on the
  871. * queue. The size of the items the queue will hold was defined when the
  872. * queue was created, so this many bytes will be copied from pvItemToQueue
  873. * into the queue storage area.
  874. *
  875. * @param pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set
  876. * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
  877. * to unblock, and the unblocked task has a priority higher than the currently
  878. * running task. If xQueueSendToFromFromISR() sets this value to pdTRUE then
  879. * a context switch should be requested before the interrupt is exited.
  880. *
  881. * @return pdTRUE if the data was successfully sent to the queue, otherwise
  882. * errQUEUE_FULL.
  883. *
  884. * Example usage for buffered IO (where the ISR can obtain more than one value
  885. * per call):
  886. <pre>
  887. void vBufferISR( void )
  888. {
  889. char cIn;
  890. BaseType_t xHigherPrioritTaskWoken;
  891. // We have not woken a task at the start of the ISR.
  892. xHigherPriorityTaskWoken = pdFALSE;
  893. // Loop until the buffer is empty.
  894. do
  895. {
  896. // Obtain a byte from the buffer.
  897. cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
  898. // Post the byte.
  899. xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
  900. } while( portINPUT_BYTE( BUFFER_COUNT ) );
  901. // Now the buffer is empty we can switch context if necessary.
  902. if( xHigherPriorityTaskWoken )
  903. {
  904. taskYIELD ();
  905. }
  906. }
  907. </pre>
  908. *
  909. * \defgroup xQueueSendFromISR xQueueSendFromISR
  910. * \ingroup QueueManagement
  911. */
  912. #define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT )
  913. /**
  914. * queue. h
  915. * <pre>
  916. BaseType_t xQueueSendToBackFromISR(
  917. QueueHandle_t xQueue,
  918. const void *pvItemToQueue,
  919. BaseType_t *pxHigherPriorityTaskWoken
  920. );
  921. </pre>
  922. *
  923. * This is a macro that calls xQueueGenericSendFromISR().
  924. *
  925. * Post an item to the back of a queue. It is safe to use this macro from
  926. * within an interrupt service routine.
  927. *
  928. * Items are queued by copy not reference so it is preferable to only
  929. * queue small items, especially when called from an ISR. In most cases
  930. * it would be preferable to store a pointer to the item being queued.
  931. *
  932. * @param xQueue The handle to the queue on which the item is to be posted.
  933. *
  934. * @param pvItemToQueue A pointer to the item that is to be placed on the
  935. * queue. The size of the items the queue will hold was defined when the
  936. * queue was created, so this many bytes will be copied from pvItemToQueue
  937. * into the queue storage area.
  938. *
  939. * @param pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set
  940. * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
  941. * to unblock, and the unblocked task has a priority higher than the currently
  942. * running task. If xQueueSendToBackFromISR() sets this value to pdTRUE then
  943. * a context switch should be requested before the interrupt is exited.
  944. *
  945. * @return pdTRUE if the data was successfully sent to the queue, otherwise
  946. * errQUEUE_FULL.
  947. *
  948. * Example usage for buffered IO (where the ISR can obtain more than one value
  949. * per call):
  950. <pre>
  951. void vBufferISR( void )
  952. {
  953. char cIn;
  954. BaseType_t xHigherPriorityTaskWoken;
  955. // We have not woken a task at the start of the ISR.
  956. xHigherPriorityTaskWoken = pdFALSE;
  957. // Loop until the buffer is empty.
  958. do
  959. {
  960. // Obtain a byte from the buffer.
  961. cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
  962. // Post the byte.
  963. xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
  964. } while( portINPUT_BYTE( BUFFER_COUNT ) );
  965. // Now the buffer is empty we can switch context if necessary.
  966. if( xHigherPriorityTaskWoken )
  967. {
  968. taskYIELD ();
  969. }
  970. }
  971. </pre>
  972. *
  973. * \defgroup xQueueSendFromISR xQueueSendFromISR
  974. * \ingroup QueueManagement
  975. */
  976. #define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )
  977. /**
  978. * queue. h
  979. * <pre>
  980. BaseType_t xQueueOverwriteFromISR(
  981. QueueHandle_t xQueue,
  982. const void * pvItemToQueue,
  983. BaseType_t *pxHigherPriorityTaskWoken
  984. );
  985. * </pre>
  986. *
  987. * A version of xQueueOverwrite() that can be used in an interrupt service
  988. * routine (ISR).
  989. *
  990. * Only for use with queues that can hold a single item - so the queue is either
  991. * empty or full.
  992. *
  993. * Post an item on a queue. If the queue is already full then overwrite the
  994. * value held in the queue. The item is queued by copy, not by reference.
  995. *
  996. * @param xQueue The handle to the queue on which the item is to be posted.
  997. *
  998. * @param pvItemToQueue A pointer to the item that is to be placed on the
  999. * queue. The size of the items the queue will hold was defined when the
  1000. * queue was created, so this many bytes will be copied from pvItemToQueue
  1001. * into the queue storage area.
  1002. *
  1003. * @param pxHigherPriorityTaskWoken xQueueOverwriteFromISR() will set
  1004. * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
  1005. * to unblock, and the unblocked task has a priority higher than the currently
  1006. * running task. If xQueueOverwriteFromISR() sets this value to pdTRUE then
  1007. * a context switch should be requested before the interrupt is exited.
  1008. *
  1009. * @return xQueueOverwriteFromISR() is a macro that calls
  1010. * xQueueGenericSendFromISR(), and therefore has the same return values as
  1011. * xQueueSendToFrontFromISR(). However, pdPASS is the only value that can be
  1012. * returned because xQueueOverwriteFromISR() will write to the queue even when
  1013. * the queue is already full.
  1014. *
  1015. * Example usage:
  1016. <pre>
  1017. QueueHandle_t xQueue;
  1018. void vFunction( void *pvParameters )
  1019. {
  1020. // Create a queue to hold one uint32_t value. It is strongly
  1021. // recommended *not* to use xQueueOverwriteFromISR() on queues that can
  1022. // contain more than one value, and doing so will trigger an assertion
  1023. // if configASSERT() is defined.
  1024. xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
  1025. }
  1026. void vAnInterruptHandler( void )
  1027. {
  1028. // xHigherPriorityTaskWoken must be set to pdFALSE before it is used.
  1029. BaseType_t xHigherPriorityTaskWoken = pdFALSE;
  1030. uint32_t ulVarToSend, ulValReceived;
  1031. // Write the value 10 to the queue using xQueueOverwriteFromISR().
  1032. ulVarToSend = 10;
  1033. xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );
  1034. // The queue is full, but calling xQueueOverwriteFromISR() again will still
  1035. // pass because the value held in the queue will be overwritten with the
  1036. // new value.
  1037. ulVarToSend = 100;
  1038. xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );
  1039. // Reading from the queue will now return 100.
  1040. // ...
  1041. if( xHigherPrioritytaskWoken == pdTRUE )
  1042. {
  1043. // Writing to the queue caused a task to unblock and the unblocked task
  1044. // has a priority higher than or equal to the priority of the currently
  1045. // executing task (the task this interrupt interrupted). Perform a context
  1046. // switch so this interrupt returns directly to the unblocked task.
  1047. portYIELD_FROM_ISR(); // or portEND_SWITCHING_ISR() depending on the port.
  1048. }
  1049. }
  1050. </pre>
  1051. * \defgroup xQueueOverwriteFromISR xQueueOverwriteFromISR
  1052. * \ingroup QueueManagement
  1053. */
  1054. #define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE )
  1055. /**
  1056. * queue. h
  1057. * <pre>
  1058. BaseType_t xQueueSendFromISR(
  1059. QueueHandle_t xQueue,
  1060. const void *pvItemToQueue,
  1061. BaseType_t *pxHigherPriorityTaskWoken
  1062. );
  1063. </pre>
  1064. *
  1065. * This is a macro that calls xQueueGenericSendFromISR(). It is included
  1066. * for backward compatibility with versions of FreeRTOS.org that did not
  1067. * include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR()
  1068. * macros.
  1069. *
  1070. * Post an item to the back of a queue. It is safe to use this function from
  1071. * within an interrupt service routine.
  1072. *
  1073. * Items are queued by copy not reference so it is preferable to only
  1074. * queue small items, especially when called from an ISR. In most cases
  1075. * it would be preferable to store a pointer to the item being queued.
  1076. *
  1077. * @param xQueue The handle to the queue on which the item is to be posted.
  1078. *
  1079. * @param pvItemToQueue A pointer to the item that is to be placed on the
  1080. * queue. The size of the items the queue will hold was defined when the
  1081. * queue was created, so this many bytes will be copied from pvItemToQueue
  1082. * into the queue storage area.
  1083. *
  1084. * @param pxHigherPriorityTaskWoken xQueueSendFromISR() will set
  1085. * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
  1086. * to unblock, and the unblocked task has a priority higher than the currently
  1087. * running task. If xQueueSendFromISR() sets this value to pdTRUE then
  1088. * a context switch should be requested before the interrupt is exited.
  1089. *
  1090. * @return pdTRUE if the data was successfully sent to the queue, otherwise
  1091. * errQUEUE_FULL.
  1092. *
  1093. * Example usage for buffered IO (where the ISR can obtain more than one value
  1094. * per call):
  1095. <pre>
  1096. void vBufferISR( void )
  1097. {
  1098. char cIn;
  1099. BaseType_t xHigherPriorityTaskWoken;
  1100. // We have not woken a task at the start of the ISR.
  1101. xHigherPriorityTaskWoken = pdFALSE;
  1102. // Loop until the buffer is empty.
  1103. do
  1104. {
  1105. // Obtain a byte from the buffer.
  1106. cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
  1107. // Post the byte.
  1108. xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
  1109. } while( portINPUT_BYTE( BUFFER_COUNT ) );
  1110. // Now the buffer is empty we can switch context if necessary.
  1111. if( xHigherPriorityTaskWoken )
  1112. {
  1113. // Actual macro used here is port specific.
  1114. portYIELD_FROM_ISR ();
  1115. }
  1116. }
  1117. </pre>
  1118. *
  1119. * \defgroup xQueueSendFromISR xQueueSendFromISR
  1120. * \ingroup QueueManagement
  1121. */
  1122. #define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )
  1123. /**
  1124. * queue. h
  1125. * <pre>
  1126. BaseType_t xQueueGenericSendFromISR(
  1127. QueueHandle_t xQueue,
  1128. const void *pvItemToQueue,
  1129. BaseType_t *pxHigherPriorityTaskWoken,
  1130. BaseType_t xCopyPosition
  1131. );
  1132. </pre>
  1133. *
  1134. * It is preferred that the macros xQueueSendFromISR(),
  1135. * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place
  1136. * of calling this function directly. xQueueGiveFromISR() is an
  1137. * equivalent for use by semaphores that don't actually copy any data.
  1138. *
  1139. * Post an item on a queue. It is safe to use this function from within an
  1140. * interrupt service routine.
  1141. *
  1142. * Items are queued by copy not reference so it is preferable to only
  1143. * queue small items, especially when called from an ISR. In most cases
  1144. * it would be preferable to store a pointer to the item being queued.
  1145. *
  1146. * @param xQueue The handle to the queue on which the item is to be posted.
  1147. *
  1148. * @param pvItemToQueue A pointer to the item that is to be placed on the
  1149. * queue. The size of the items the queue will hold was defined when the
  1150. * queue was created, so this many bytes will be copied from pvItemToQueue
  1151. * into the queue storage area.
  1152. *
  1153. * @param pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set
  1154. * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
  1155. * to unblock, and the unblocked task has a priority higher than the currently
  1156. * running task. If xQueueGenericSendFromISR() sets this value to pdTRUE then
  1157. * a context switch should be requested before the interrupt is exited.
  1158. *
  1159. * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the
  1160. * item at the back of the queue, or queueSEND_TO_FRONT to place the item
  1161. * at the front of the queue (for high priority messages).
  1162. *
  1163. * @return pdTRUE if the data was successfully sent to the queue, otherwise
  1164. * errQUEUE_FULL.
  1165. *
  1166. * Example usage for buffered IO (where the ISR can obtain more than one value
  1167. * per call):
  1168. <pre>
  1169. void vBufferISR( void )
  1170. {
  1171. char cIn;
  1172. BaseType_t xHigherPriorityTaskWokenByPost;
  1173. // We have not woken a task at the start of the ISR.
  1174. xHigherPriorityTaskWokenByPost = pdFALSE;
  1175. // Loop until the buffer is empty.
  1176. do
  1177. {
  1178. // Obtain a byte from the buffer.
  1179. cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
  1180. // Post each byte.
  1181. xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK );
  1182. } while( portINPUT_BYTE( BUFFER_COUNT ) );
  1183. // Now the buffer is empty we can switch context if necessary. Note that the
  1184. // name of the yield function required is port specific.
  1185. if( xHigherPriorityTaskWokenByPost )
  1186. {
  1187. taskYIELD_YIELD_FROM_ISR();
  1188. }
  1189. }
  1190. </pre>
  1191. *
  1192. * \defgroup xQueueSendFromISR xQueueSendFromISR
  1193. * \ingroup QueueManagement
  1194. */
  1195. BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;
  1196. BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
  1197. /**
  1198. * queue. h
  1199. * <pre>
  1200. BaseType_t xQueueReceiveFromISR(
  1201. QueueHandle_t xQueue,
  1202. void *pvBuffer,
  1203. BaseType_t *pxTaskWoken
  1204. );
  1205. * </pre>
  1206. *
  1207. * Receive an item from a queue. It is safe to use this function from within an
  1208. * interrupt service routine.
  1209. *
  1210. * @param xQueue The handle to the queue from which the item is to be
  1211. * received.
  1212. *
  1213. * @param pvBuffer Pointer to the buffer into which the received item will
  1214. * be copied.
  1215. *
  1216. * @param pxTaskWoken A task may be blocked waiting for space to become
  1217. * available on the queue. If xQueueReceiveFromISR causes such a task to
  1218. * unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will
  1219. * remain unchanged.
  1220. *
  1221. * @return pdTRUE if an item was successfully received from the queue,
  1222. * otherwise pdFALSE.
  1223. *
  1224. * Example usage:
  1225. <pre>
  1226. QueueHandle_t xQueue;
  1227. // Function to create a queue and post some values.
  1228. void vAFunction( void *pvParameters )
  1229. {
  1230. char cValueToPost;
  1231. const TickType_t xTicksToWait = ( TickType_t )0xff;
  1232. // Create a queue capable of containing 10 characters.
  1233. xQueue = xQueueCreate( 10, sizeof( char ) );
  1234. if( xQueue == 0 )
  1235. {
  1236. // Failed to create the queue.
  1237. }
  1238. // ...
  1239. // Post some characters that will be used within an ISR. If the queue
  1240. // is full then this task will block for xTicksToWait ticks.
  1241. cValueToPost = 'a';
  1242. xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
  1243. cValueToPost = 'b';
  1244. xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
  1245. // ... keep posting characters ... this task may block when the queue
  1246. // becomes full.
  1247. cValueToPost = 'c';
  1248. xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
  1249. }
  1250. // ISR that outputs all the characters received on the queue.
  1251. void vISR_Routine( void )
  1252. {
  1253. BaseType_t xTaskWokenByReceive = pdFALSE;
  1254. char cRxedChar;
  1255. while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )
  1256. {
  1257. // A character was received. Output the character now.
  1258. vOutputCharacter( cRxedChar );
  1259. // If removing the character from the queue woke the task that was
  1260. // posting onto the queue cTaskWokenByReceive will have been set to
  1261. // pdTRUE. No matter how many times this loop iterates only one
  1262. // task will be woken.
  1263. }
  1264. if( cTaskWokenByPost != ( char ) pdFALSE;
  1265. {
  1266. taskYIELD ();
  1267. }
  1268. }
  1269. </pre>
  1270. * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR
  1271. * \ingroup QueueManagement
  1272. */
  1273. BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void * const pvBuffer, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
  1274. /*
  1275. * Utilities to query queues that are safe to use from an ISR. These utilities
  1276. * should be used only from witin an ISR, or within a critical section.
  1277. */
  1278. BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
  1279. BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
  1280. UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
  1281. /*
  1282. * xQueueAltGenericSend() is an alternative version of xQueueGenericSend().
  1283. * Likewise xQueueAltGenericReceive() is an alternative version of
  1284. * xQueueGenericReceive().
  1285. *
  1286. * The source code that implements the alternative (Alt) API is much
  1287. * simpler because it executes everything from within a critical section.
  1288. * This is the approach taken by many other RTOSes, but FreeRTOS.org has the
  1289. * preferred fully featured API too. The fully featured API has more
  1290. * complex code that takes longer to execute, but makes much less use of
  1291. * critical sections. Therefore the alternative API sacrifices interrupt
  1292. * responsiveness to gain execution speed, whereas the fully featured API
  1293. * sacrifices execution speed to ensure better interrupt responsiveness.
  1294. */
  1295. BaseType_t xQueueAltGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;
  1296. BaseType_t xQueueAltGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, BaseType_t xJustPeeking ) PRIVILEGED_FUNCTION;
  1297. #define xQueueAltSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT )
  1298. #define xQueueAltSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
  1299. #define xQueueAltReceive( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )
  1300. #define xQueueAltPeek( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )
  1301. /*
  1302. * The functions defined above are for passing data to and from tasks. The
  1303. * functions below are the equivalents for passing data to and from
  1304. * co-routines.
  1305. *
  1306. * These functions are called from the co-routine macro implementation and
  1307. * should not be called directly from application code. Instead use the macro
  1308. * wrappers defined within croutine.h.
  1309. */
  1310. BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken );
  1311. BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxTaskWoken );
  1312. BaseType_t xQueueCRSend( QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait );
  1313. BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait );
  1314. /*
  1315. * For internal use only. Use xSemaphoreCreateMutex(),
  1316. * xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling
  1317. * these functions directly.
  1318. */
  1319. QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
  1320. QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION;
  1321. void* xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;
  1322. /*
  1323. * For internal use only. Use xSemaphoreTakeMutexRecursive() or
  1324. * xSemaphoreGiveMutexRecursive() instead of calling these functions directly.
  1325. */
  1326. BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
  1327. BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION;
  1328. /*
  1329. * Reset a queue back to its original empty state. The return value is now
  1330. * obsolete and is always set to pdPASS.
  1331. */
  1332. #define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE )
  1333. /*
  1334. * The registry is provided as a means for kernel aware debuggers to
  1335. * locate queues, semaphores and mutexes. Call vQueueAddToRegistry() add
  1336. * a queue, semaphore or mutex handle to the registry if you want the handle
  1337. * to be available to a kernel aware debugger. If you are not using a kernel
  1338. * aware debugger then this function can be ignored.
  1339. *
  1340. * configQUEUE_REGISTRY_SIZE defines the maximum number of handles the
  1341. * registry can hold. configQUEUE_REGISTRY_SIZE must be greater than 0
  1342. * within FreeRTOSConfig.h for the registry to be available. Its value
  1343. * does not effect the number of queues, semaphores and mutexes that can be
  1344. * created - just the number that the registry can hold.
  1345. *
  1346. * @param xQueue The handle of the queue being added to the registry. This
  1347. * is the handle returned by a call to xQueueCreate(). Semaphore and mutex
  1348. * handles can also be passed in here.
  1349. *
  1350. * @param pcName The name to be associated with the handle. This is the
  1351. * name that the kernel aware debugger will display. The queue registry only
  1352. * stores a pointer to the string - so the string must be persistent (global or
  1353. * preferably in ROM/Flash), not on the stack.
  1354. */
  1355. #if configQUEUE_REGISTRY_SIZE > 0
  1356. void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
  1357. #endif
  1358. /*
  1359. * The registry is provided as a means for kernel aware debuggers to
  1360. * locate queues, semaphores and mutexes. Call vQueueAddToRegistry() add
  1361. * a queue, semaphore or mutex handle to the registry if you want the handle
  1362. * to be available to a kernel aware debugger, and vQueueUnregisterQueue() to
  1363. * remove the queue, semaphore or mutex from the register. If you are not using
  1364. * a kernel aware debugger then this function can be ignored.
  1365. *
  1366. * @param xQueue The handle of the queue being removed from the registry.
  1367. */
  1368. #if configQUEUE_REGISTRY_SIZE > 0
  1369. void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
  1370. #endif
  1371. /*
  1372. * Generic version of the queue creation function, which is in turn called by
  1373. * any queue, semaphore or mutex creation function or macro.
  1374. */
  1375. QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
  1376. /*
  1377. * Queue sets provide a mechanism to allow a task to block (pend) on a read
  1378. * operation from multiple queues or semaphores simultaneously.
  1379. *
  1380. * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
  1381. * function.
  1382. *
  1383. * A queue set must be explicitly created using a call to xQueueCreateSet()
  1384. * before it can be used. Once created, standard FreeRTOS queues and semaphores
  1385. * can be added to the set using calls to xQueueAddToSet().
  1386. * xQueueSelectFromSet() is then used to determine which, if any, of the queues
  1387. * or semaphores contained in the set is in a state where a queue read or
  1388. * semaphore take operation would be successful.
  1389. *
  1390. * Note 1: See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html
  1391. * for reasons why queue sets are very rarely needed in practice as there are
  1392. * simpler methods of blocking on multiple objects.
  1393. *
  1394. * Note 2: Blocking on a queue set that contains a mutex will not cause the
  1395. * mutex holder to inherit the priority of the blocked task.
  1396. *
  1397. * Note 3: An additional 4 bytes of RAM is required for each space in a every
  1398. * queue added to a queue set. Therefore counting semaphores that have a high
  1399. * maximum count value should not be added to a queue set.
  1400. *
  1401. * Note 4: A receive (in the case of a queue) or take (in the case of a
  1402. * semaphore) operation must not be performed on a member of a queue set unless
  1403. * a call to xQueueSelectFromSet() has first returned a handle to that set member.
  1404. *
  1405. * @param uxEventQueueLength Queue sets store events that occur on
  1406. * the queues and semaphores contained in the set. uxEventQueueLength specifies
  1407. * the maximum number of events that can be queued at once. To be absolutely
  1408. * certain that events are not lost uxEventQueueLength should be set to the
  1409. * total sum of the length of the queues added to the set, where binary
  1410. * semaphores and mutexes have a length of 1, and counting semaphores have a
  1411. * length set by their maximum count value. Examples:
  1412. * + If a queue set is to hold a queue of length 5, another queue of length 12,
  1413. * and a binary semaphore, then uxEventQueueLength should be set to
  1414. * (5 + 12 + 1), or 18.
  1415. * + If a queue set is to hold three binary semaphores then uxEventQueueLength
  1416. * should be set to (1 + 1 + 1 ), or 3.
  1417. * + If a queue set is to hold a counting semaphore that has a maximum count of
  1418. * 5, and a counting semaphore that has a maximum count of 3, then
  1419. * uxEventQueueLength should be set to (5 + 3), or 8.
  1420. *
  1421. * @return If the queue set is created successfully then a handle to the created
  1422. * queue set is returned. Otherwise NULL is returned.
  1423. */
  1424. QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILEGED_FUNCTION;
  1425. /*
  1426. * Adds a queue or semaphore to a queue set that was previously created by a
  1427. * call to xQueueCreateSet().
  1428. *
  1429. * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
  1430. * function.
  1431. *
  1432. * Note 1: A receive (in the case of a queue) or take (in the case of a
  1433. * semaphore) operation must not be performed on a member of a queue set unless
  1434. * a call to xQueueSelectFromSet() has first returned a handle to that set member.
  1435. *
  1436. * @param xQueueOrSemaphore The handle of the queue or semaphore being added to
  1437. * the queue set (cast to an QueueSetMemberHandle_t type).
  1438. *
  1439. * @param xQueueSet The handle of the queue set to which the queue or semaphore
  1440. * is being added.
  1441. *
  1442. * @return If the queue or semaphore was successfully added to the queue set
  1443. * then pdPASS is returned. If the queue could not be successfully added to the
  1444. * queue set because it is already a member of a different queue set then pdFAIL
  1445. * is returned.
  1446. */
  1447. BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
  1448. /*
  1449. * Removes a queue or semaphore from a queue set. A queue or semaphore can only
  1450. * be removed from a set if the queue or semaphore is empty.
  1451. *
  1452. * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
  1453. * function.
  1454. *
  1455. * @param xQueueOrSemaphore The handle of the queue or semaphore being removed
  1456. * from the queue set (cast to an QueueSetMemberHandle_t type).
  1457. *
  1458. * @param xQueueSet The handle of the queue set in which the queue or semaphore
  1459. * is included.
  1460. *
  1461. * @return If the queue or semaphore was successfully removed from the queue set
  1462. * then pdPASS is returned. If the queue was not in the queue set, or the
  1463. * queue (or semaphore) was not empty, then pdFAIL is returned.
  1464. */
  1465. BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
  1466. /*
  1467. * xQueueSelectFromSet() selects from the members of a queue set a queue or
  1468. * semaphore that either contains data (in the case of a queue) or is available
  1469. * to take (in the case of a semaphore). xQueueSelectFromSet() effectively
  1470. * allows a task to block (pend) on a read operation on all the queues and
  1471. * semaphores in a queue set simultaneously.
  1472. *
  1473. * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
  1474. * function.
  1475. *
  1476. * Note 1: See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html
  1477. * for reasons why queue sets are very rarely needed in practice as there are
  1478. * simpler methods of blocking on multiple objects.
  1479. *
  1480. * Note 2: Blocking on a queue set that contains a mutex will not cause the
  1481. * mutex holder to inherit the priority of the blocked task.
  1482. *
  1483. * Note 3: A receive (in the case of a queue) or take (in the case of a
  1484. * semaphore) operation must not be performed on a member of a queue set unless
  1485. * a call to xQueueSelectFromSet() has first returned a handle to that set member.
  1486. *
  1487. * @param xQueueSet The queue set on which the task will (potentially) block.
  1488. *
  1489. * @param xTicksToWait The maximum time, in ticks, that the calling task will
  1490. * remain in the Blocked state (with other tasks executing) to wait for a member
  1491. * of the queue set to be ready for a successful queue read or semaphore take
  1492. * operation.
  1493. *
  1494. * @return xQueueSelectFromSet() will return the handle of a queue (cast to
  1495. * a QueueSetMemberHandle_t type) contained in the queue set that contains data,
  1496. * or the handle of a semaphore (cast to a QueueSetMemberHandle_t type) contained
  1497. * in the queue set that is available, or NULL if no such queue or semaphore
  1498. * exists before before the specified block time expires.
  1499. */
  1500. QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
  1501. /*
  1502. * A version of xQueueSelectFromSet() that can be used from an ISR.
  1503. */
  1504. QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
  1505. /* Not public API functions. */
  1506. void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;
  1507. BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) PRIVILEGED_FUNCTION;
  1508. void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ) PRIVILEGED_FUNCTION;
  1509. UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
  1510. uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
  1511. #ifdef __cplusplus
  1512. }
  1513. #endif
  1514. #endif /* QUEUE_H */