queue.h 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191
  1. /*
  2. * FreeRTOS Kernel V10.4.6
  3. * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * SPDX-License-Identifier: MIT
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  8. * this software and associated documentation files (the "Software"), to deal in
  9. * the Software without restriction, including without limitation the rights to
  10. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  11. * the Software, and to permit persons to whom the Software is furnished to do so,
  12. * subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in all
  15. * copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  19. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  20. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  21. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * https://www.FreeRTOS.org
  25. * https://github.com/FreeRTOS
  26. *
  27. */
  28. #ifndef QUEUE_H
  29. #define QUEUE_H
  30. /* *INDENT-OFF* */
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /* *INDENT-ON* */
  35. #include "task.h"
  36. /**
  37. * Type by which queues are referenced. For example, a call to xQueueCreate()
  38. * returns an QueueHandle_t variable that can then be used as a parameter to
  39. * xQueueSend(), xQueueReceive(), etc.
  40. */
  41. struct QueueDefinition; /* Using old naming convention so as not to break kernel aware debuggers. */
  42. typedef struct QueueDefinition * QueueHandle_t;
  43. /* For internal use only. */
  44. #define queueSEND_TO_BACK ( ( BaseType_t ) 0 )
  45. #define queueSEND_TO_FRONT ( ( BaseType_t ) 1 )
  46. #define queueOVERWRITE ( ( BaseType_t ) 2 )
  47. /* For internal use only. These definitions *must* match those in queue.c. */
  48. #define queueQUEUE_TYPE_BASE ( ( uint8_t ) 0U )
  49. #define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U )
  50. #define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U )
  51. #define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( ( uint8_t ) 2U )
  52. #define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U )
  53. #define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U )
  54. /**
  55. * queue. h
  56. * @code{c}
  57. * QueueHandle_t xQueueCreate(
  58. * UBaseType_t uxQueueLength,
  59. * UBaseType_t uxItemSize
  60. * );
  61. * @endcode
  62. *
  63. * Creates a new queue instance, and returns a handle by which the new queue
  64. * can be referenced.
  65. *
  66. * Internally, within the FreeRTOS implementation, queues use two blocks of
  67. * memory. The first block is used to hold the queue's data structures. The
  68. * second block is used to hold items placed into the queue. If a queue is
  69. * created using xQueueCreate() then both blocks of memory are automatically
  70. * dynamically allocated inside the xQueueCreate() function. (see
  71. * https://www.FreeRTOS.org/a00111.html). If a queue is created using
  72. * xQueueCreateStatic() then the application writer must provide the memory that
  73. * will get used by the queue. xQueueCreateStatic() therefore allows a queue to
  74. * be created without using any dynamic memory allocation.
  75. *
  76. * https://www.FreeRTOS.org/Embedded-RTOS-Queues.html
  77. *
  78. * @param uxQueueLength The maximum number of items that the queue can contain.
  79. *
  80. * @param uxItemSize The number of bytes each item in the queue will require.
  81. * Items are queued by copy, not by reference, so this is the number of bytes
  82. * that will be copied for each posted item. Each item on the queue must be
  83. * the same size.
  84. *
  85. * @return If the queue is successfully create then a handle to the newly
  86. * created queue is returned. If the queue cannot be created then 0 is
  87. * returned.
  88. *
  89. * Example usage:
  90. * @code{c}
  91. * struct AMessage
  92. * {
  93. * char ucMessageID;
  94. * char ucData[ 20 ];
  95. * };
  96. *
  97. * void vATask( void *pvParameters )
  98. * {
  99. * QueueHandle_t xQueue1, xQueue2;
  100. *
  101. * // Create a queue capable of containing 10 uint32_t values.
  102. * xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
  103. * if( xQueue1 == 0 )
  104. * {
  105. * // Queue was not created and must not be used.
  106. * }
  107. *
  108. * // Create a queue capable of containing 10 pointers to AMessage structures.
  109. * // These should be passed by pointer as they contain a lot of data.
  110. * xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
  111. * if( xQueue2 == 0 )
  112. * {
  113. * // Queue was not created and must not be used.
  114. * }
  115. *
  116. * // ... Rest of task code.
  117. * }
  118. * @endcode
  119. * \defgroup xQueueCreate xQueueCreate
  120. * \ingroup QueueManagement
  121. */
  122. #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  123. #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( ( uxQueueLength ), ( uxItemSize ), ( queueQUEUE_TYPE_BASE ) )
  124. #endif
  125. /**
  126. * queue. h
  127. * @code{c}
  128. * QueueHandle_t xQueueCreateStatic(
  129. * UBaseType_t uxQueueLength,
  130. * UBaseType_t uxItemSize,
  131. * uint8_t *pucQueueStorage,
  132. * StaticQueue_t *pxQueueBuffer
  133. * );
  134. * @endcode
  135. *
  136. * Creates a new queue instance, and returns a handle by which the new queue
  137. * can be referenced.
  138. *
  139. * Internally, within the FreeRTOS implementation, queues use two blocks of
  140. * memory. The first block is used to hold the queue's data structures. The
  141. * second block is used to hold items placed into the queue. If a queue is
  142. * created using xQueueCreate() then both blocks of memory are automatically
  143. * dynamically allocated inside the xQueueCreate() function. (see
  144. * https://www.FreeRTOS.org/a00111.html). If a queue is created using
  145. * xQueueCreateStatic() then the application writer must provide the memory that
  146. * will get used by the queue. xQueueCreateStatic() therefore allows a queue to
  147. * be created without using any dynamic memory allocation.
  148. *
  149. * https://www.FreeRTOS.org/Embedded-RTOS-Queues.html
  150. *
  151. * @param uxQueueLength The maximum number of items that the queue can contain.
  152. *
  153. * @param uxItemSize The number of bytes each item in the queue will require.
  154. * Items are queued by copy, not by reference, so this is the number of bytes
  155. * that will be copied for each posted item. Each item on the queue must be
  156. * the same size.
  157. *
  158. * @param pucQueueStorage If uxItemSize is not zero then
  159. * pucQueueStorage must point to a uint8_t array that is at least large
  160. * enough to hold the maximum number of items that can be in the queue at any
  161. * one time - which is ( uxQueueLength * uxItemsSize ) bytes. If uxItemSize is
  162. * zero then pucQueueStorage can be NULL.
  163. *
  164. * @param pxQueueBuffer Must point to a variable of type StaticQueue_t, which
  165. * will be used to hold the queue's data structure.
  166. *
  167. * @return If the queue is created then a handle to the created queue is
  168. * returned. If pxQueueBuffer is NULL then NULL is returned.
  169. *
  170. * Example usage:
  171. * @code{c}
  172. * struct AMessage
  173. * {
  174. * char ucMessageID;
  175. * char ucData[ 20 ];
  176. * };
  177. *
  178. #define QUEUE_LENGTH 10
  179. #define ITEM_SIZE sizeof( uint32_t )
  180. *
  181. * // xQueueBuffer will hold the queue structure.
  182. * StaticQueue_t xQueueBuffer;
  183. *
  184. * // ucQueueStorage will hold the items posted to the queue. Must be at least
  185. * // [(queue length) * ( queue item size)] bytes long.
  186. * uint8_t ucQueueStorage[ QUEUE_LENGTH * ITEM_SIZE ];
  187. *
  188. * void vATask( void *pvParameters )
  189. * {
  190. * QueueHandle_t xQueue1;
  191. *
  192. * // Create a queue capable of containing 10 uint32_t values.
  193. * xQueue1 = xQueueCreate( QUEUE_LENGTH, // The number of items the queue can hold.
  194. * ITEM_SIZE // The size of each item in the queue
  195. * &( ucQueueStorage[ 0 ] ), // The buffer that will hold the items in the queue.
  196. * &xQueueBuffer ); // The buffer that will hold the queue structure.
  197. *
  198. * // The queue is guaranteed to be created successfully as no dynamic memory
  199. * // allocation is used. Therefore xQueue1 is now a handle to a valid queue.
  200. *
  201. * // ... Rest of task code.
  202. * }
  203. * @endcode
  204. * \defgroup xQueueCreateStatic xQueueCreateStatic
  205. * \ingroup QueueManagement
  206. */
  207. #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
  208. #define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxQueueBuffer ) xQueueGenericCreateStatic( ( uxQueueLength ), ( uxItemSize ), ( pucQueueStorage ), ( pxQueueBuffer ), ( queueQUEUE_TYPE_BASE ) )
  209. #endif /* configSUPPORT_STATIC_ALLOCATION */
  210. /**
  211. * queue. h
  212. * @code{c}
  213. * BaseType_t xQueueSendToToFront(
  214. * QueueHandle_t xQueue,
  215. * const void *pvItemToQueue,
  216. * TickType_t xTicksToWait
  217. * );
  218. * @endcode
  219. *
  220. * Post an item to the front of a queue. The item is queued by copy, not by
  221. * reference. This function must not be called from an interrupt service
  222. * routine. See xQueueSendFromISR () for an alternative which may be used
  223. * in an ISR.
  224. *
  225. * @param xQueue The handle to the queue on which the item is to be posted.
  226. *
  227. * @param pvItemToQueue A pointer to the item that is to be placed on the
  228. * queue. The size of the items the queue will hold was defined when the
  229. * queue was created, so this many bytes will be copied from pvItemToQueue
  230. * into the queue storage area.
  231. *
  232. * @param xTicksToWait The maximum amount of time the task should block
  233. * waiting for space to become available on the queue, should it already
  234. * be full. The call will return immediately if this is set to 0 and the
  235. * queue is full. The time is defined in tick periods so the constant
  236. * portTICK_PERIOD_MS should be used to convert to real time if this is required.
  237. *
  238. * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
  239. *
  240. * Example usage:
  241. * @code{c}
  242. * struct AMessage
  243. * {
  244. * char ucMessageID;
  245. * char ucData[ 20 ];
  246. * } xMessage;
  247. *
  248. * uint32_t ulVar = 10UL;
  249. *
  250. * void vATask( void *pvParameters )
  251. * {
  252. * QueueHandle_t xQueue1, xQueue2;
  253. * struct AMessage *pxMessage;
  254. *
  255. * // Create a queue capable of containing 10 uint32_t values.
  256. * xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
  257. *
  258. * // Create a queue capable of containing 10 pointers to AMessage structures.
  259. * // These should be passed by pointer as they contain a lot of data.
  260. * xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
  261. *
  262. * // ...
  263. *
  264. * if( xQueue1 != 0 )
  265. * {
  266. * // Send an uint32_t. Wait for 10 ticks for space to become
  267. * // available if necessary.
  268. * if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
  269. * {
  270. * // Failed to post the message, even after 10 ticks.
  271. * }
  272. * }
  273. *
  274. * if( xQueue2 != 0 )
  275. * {
  276. * // Send a pointer to a struct AMessage object. Don't block if the
  277. * // queue is already full.
  278. * pxMessage = & xMessage;
  279. * xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
  280. * }
  281. *
  282. * // ... Rest of task code.
  283. * }
  284. * @endcode
  285. * \defgroup xQueueSend xQueueSend
  286. * \ingroup QueueManagement
  287. */
  288. #define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) \
  289. xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT )
  290. /**
  291. * queue. h
  292. * @code{c}
  293. * BaseType_t xQueueSendToBack(
  294. * QueueHandle_t xQueue,
  295. * const void *pvItemToQueue,
  296. * TickType_t xTicksToWait
  297. * );
  298. * @endcode
  299. *
  300. * This is a macro that calls xQueueGenericSend().
  301. *
  302. * Post an item to the back of a queue. The item is queued by copy, not by
  303. * reference. This function must not be called from an interrupt service
  304. * routine. See xQueueSendFromISR () for an alternative which may be used
  305. * in an ISR.
  306. *
  307. * @param xQueue The handle to the queue on which the item is to be posted.
  308. *
  309. * @param pvItemToQueue A pointer to the item that is to be placed on the
  310. * queue. The size of the items the queue will hold was defined when the
  311. * queue was created, so this many bytes will be copied from pvItemToQueue
  312. * into the queue storage area.
  313. *
  314. * @param xTicksToWait The maximum amount of time the task should block
  315. * waiting for space to become available on the queue, should it already
  316. * be full. The call will return immediately if this is set to 0 and the queue
  317. * is full. The time is defined in tick periods so the constant
  318. * portTICK_PERIOD_MS should be used to convert to real time if this is required.
  319. *
  320. * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
  321. *
  322. * Example usage:
  323. * @code{c}
  324. * struct AMessage
  325. * {
  326. * char ucMessageID;
  327. * char ucData[ 20 ];
  328. * } xMessage;
  329. *
  330. * uint32_t ulVar = 10UL;
  331. *
  332. * void vATask( void *pvParameters )
  333. * {
  334. * QueueHandle_t xQueue1, xQueue2;
  335. * struct AMessage *pxMessage;
  336. *
  337. * // Create a queue capable of containing 10 uint32_t values.
  338. * xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
  339. *
  340. * // Create a queue capable of containing 10 pointers to AMessage structures.
  341. * // These should be passed by pointer as they contain a lot of data.
  342. * xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
  343. *
  344. * // ...
  345. *
  346. * if( xQueue1 != 0 )
  347. * {
  348. * // Send an uint32_t. Wait for 10 ticks for space to become
  349. * // available if necessary.
  350. * if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
  351. * {
  352. * // Failed to post the message, even after 10 ticks.
  353. * }
  354. * }
  355. *
  356. * if( xQueue2 != 0 )
  357. * {
  358. * // Send a pointer to a struct AMessage object. Don't block if the
  359. * // queue is already full.
  360. * pxMessage = & xMessage;
  361. * xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
  362. * }
  363. *
  364. * // ... Rest of task code.
  365. * }
  366. * @endcode
  367. * \defgroup xQueueSend xQueueSend
  368. * \ingroup QueueManagement
  369. */
  370. #define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) \
  371. xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
  372. /**
  373. * queue. h
  374. * @code{c}
  375. * BaseType_t xQueueSend(
  376. * QueueHandle_t xQueue,
  377. * const void * pvItemToQueue,
  378. * TickType_t xTicksToWait
  379. * );
  380. * @endcode
  381. *
  382. * This is a macro that calls xQueueGenericSend(). It is included for
  383. * backward compatibility with versions of FreeRTOS.org that did not
  384. * include the xQueueSendToFront() and xQueueSendToBack() macros. It is
  385. * equivalent to xQueueSendToBack().
  386. *
  387. * Post an item on a queue. The item is queued by copy, not by reference.
  388. * This function must not be called from an interrupt service routine.
  389. * See xQueueSendFromISR () for an alternative which may be used in an ISR.
  390. *
  391. * @param xQueue The handle to the queue on which the item is to be posted.
  392. *
  393. * @param pvItemToQueue A pointer to the item that is to be placed on the
  394. * queue. The size of the items the queue will hold was defined when the
  395. * queue was created, so this many bytes will be copied from pvItemToQueue
  396. * into the queue storage area.
  397. *
  398. * @param xTicksToWait The maximum amount of time the task should block
  399. * waiting for space to become available on the queue, should it already
  400. * be full. The call will return immediately if this is set to 0 and the
  401. * queue is full. The time is defined in tick periods so the constant
  402. * portTICK_PERIOD_MS should be used to convert to real time if this is required.
  403. *
  404. * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
  405. *
  406. * Example usage:
  407. * @code{c}
  408. * struct AMessage
  409. * {
  410. * char ucMessageID;
  411. * char ucData[ 20 ];
  412. * } xMessage;
  413. *
  414. * uint32_t ulVar = 10UL;
  415. *
  416. * void vATask( void *pvParameters )
  417. * {
  418. * QueueHandle_t xQueue1, xQueue2;
  419. * struct AMessage *pxMessage;
  420. *
  421. * // Create a queue capable of containing 10 uint32_t values.
  422. * xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
  423. *
  424. * // Create a queue capable of containing 10 pointers to AMessage structures.
  425. * // These should be passed by pointer as they contain a lot of data.
  426. * xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
  427. *
  428. * // ...
  429. *
  430. * if( xQueue1 != 0 )
  431. * {
  432. * // Send an uint32_t. Wait for 10 ticks for space to become
  433. * // available if necessary.
  434. * if( xQueueSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
  435. * {
  436. * // Failed to post the message, even after 10 ticks.
  437. * }
  438. * }
  439. *
  440. * if( xQueue2 != 0 )
  441. * {
  442. * // Send a pointer to a struct AMessage object. Don't block if the
  443. * // queue is already full.
  444. * pxMessage = & xMessage;
  445. * xQueueSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
  446. * }
  447. *
  448. * // ... Rest of task code.
  449. * }
  450. * @endcode
  451. * \defgroup xQueueSend xQueueSend
  452. * \ingroup QueueManagement
  453. */
  454. #define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) \
  455. xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
  456. /**
  457. * queue. h
  458. * @code{c}
  459. * BaseType_t xQueueGenericSend(
  460. * QueueHandle_t xQueue,
  461. * const void * pvItemToQueue,
  462. * TickType_t xTicksToWait
  463. * BaseType_t xCopyPosition
  464. * );
  465. * @endcode
  466. *
  467. * It is preferred that the macros xQueueSend(), xQueueSendToFront() and
  468. * xQueueSendToBack() are used in place of calling this function directly.
  469. *
  470. * Post an item on a queue. The item is queued by copy, not by reference.
  471. * This function must not be called from an interrupt service routine.
  472. * See xQueueSendFromISR () for an alternative which may be used in an ISR.
  473. *
  474. * @param xQueue The handle to the queue on which the item is to be posted.
  475. *
  476. * @param pvItemToQueue A pointer to the item that is to be placed on the
  477. * queue. The size of the items the queue will hold was defined when the
  478. * queue was created, so this many bytes will be copied from pvItemToQueue
  479. * into the queue storage area.
  480. *
  481. * @param xTicksToWait The maximum amount of time the task should block
  482. * waiting for space to become available on the queue, should it already
  483. * be full. The call will return immediately if this is set to 0 and the
  484. * queue is full. The time is defined in tick periods so the constant
  485. * portTICK_PERIOD_MS should be used to convert to real time if this is required.
  486. *
  487. * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the
  488. * item at the back of the queue, or queueSEND_TO_FRONT to place the item
  489. * at the front of the queue (for high priority messages).
  490. *
  491. * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
  492. *
  493. * Example usage:
  494. * @code{c}
  495. * struct AMessage
  496. * {
  497. * char ucMessageID;
  498. * char ucData[ 20 ];
  499. * } xMessage;
  500. *
  501. * uint32_t ulVar = 10UL;
  502. *
  503. * void vATask( void *pvParameters )
  504. * {
  505. * QueueHandle_t xQueue1, xQueue2;
  506. * struct AMessage *pxMessage;
  507. *
  508. * // Create a queue capable of containing 10 uint32_t values.
  509. * xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
  510. *
  511. * // Create a queue capable of containing 10 pointers to AMessage structures.
  512. * // These should be passed by pointer as they contain a lot of data.
  513. * xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
  514. *
  515. * // ...
  516. *
  517. * if( xQueue1 != 0 )
  518. * {
  519. * // Send an uint32_t. Wait for 10 ticks for space to become
  520. * // available if necessary.
  521. * if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10, queueSEND_TO_BACK ) != pdPASS )
  522. * {
  523. * // Failed to post the message, even after 10 ticks.
  524. * }
  525. * }
  526. *
  527. * if( xQueue2 != 0 )
  528. * {
  529. * // Send a pointer to a struct AMessage object. Don't block if the
  530. * // queue is already full.
  531. * pxMessage = & xMessage;
  532. * xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0, queueSEND_TO_BACK );
  533. * }
  534. *
  535. * // ... Rest of task code.
  536. * }
  537. * @endcode
  538. * \defgroup xQueueSend xQueueSend
  539. * \ingroup QueueManagement
  540. */
  541. BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
  542. const void * const pvItemToQueue,
  543. TickType_t xTicksToWait,
  544. const BaseType_t xCopyPosition );
  545. /**
  546. * queue. h
  547. * @code{c}
  548. * BaseType_t xQueueReceive(
  549. * QueueHandle_t xQueue,
  550. * void *pvBuffer,
  551. * TickType_t xTicksToWait
  552. * );
  553. * @endcode
  554. *
  555. * Receive an item from a queue. The item is received by copy so a buffer of
  556. * adequate size must be provided. The number of bytes copied into the buffer
  557. * was defined when the queue was created.
  558. *
  559. * Successfully received items are removed from the queue.
  560. *
  561. * This function must not be used in an interrupt service routine. See
  562. * xQueueReceiveFromISR for an alternative that can.
  563. *
  564. * @param xQueue The handle to the queue from which the item is to be
  565. * received.
  566. *
  567. * @param pvBuffer Pointer to the buffer into which the received item will
  568. * be copied.
  569. *
  570. * @param xTicksToWait The maximum amount of time the task should block
  571. * waiting for an item to receive should the queue be empty at the time
  572. * of the call. xQueueReceive() will return immediately if xTicksToWait
  573. * is zero and the queue is empty. The time is defined in tick periods so the
  574. * constant portTICK_PERIOD_MS should be used to convert to real time if this is
  575. * required.
  576. *
  577. * @return pdTRUE if an item was successfully received from the queue,
  578. * otherwise pdFALSE.
  579. *
  580. * Example usage:
  581. * @code{c}
  582. * struct AMessage
  583. * {
  584. * char ucMessageID;
  585. * char ucData[ 20 ];
  586. * } xMessage;
  587. *
  588. * QueueHandle_t xQueue;
  589. *
  590. * // Task to create a queue and post a value.
  591. * void vATask( void *pvParameters )
  592. * {
  593. * struct AMessage *pxMessage;
  594. *
  595. * // Create a queue capable of containing 10 pointers to AMessage structures.
  596. * // These should be passed by pointer as they contain a lot of data.
  597. * xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
  598. * if( xQueue == 0 )
  599. * {
  600. * // Failed to create the queue.
  601. * }
  602. *
  603. * // ...
  604. *
  605. * // Send a pointer to a struct AMessage object. Don't block if the
  606. * // queue is already full.
  607. * pxMessage = & xMessage;
  608. * xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
  609. *
  610. * // ... Rest of task code.
  611. * }
  612. *
  613. * // Task to receive from the queue.
  614. * void vADifferentTask( void *pvParameters )
  615. * {
  616. * struct AMessage *pxRxedMessage;
  617. *
  618. * if( xQueue != 0 )
  619. * {
  620. * // Receive a message on the created queue. Block for 10 ticks if a
  621. * // message is not immediately available.
  622. * if( xQueueReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
  623. * {
  624. * // pcRxedMessage now points to the struct AMessage variable posted
  625. * // by vATask.
  626. * }
  627. * }
  628. *
  629. * // ... Rest of task code.
  630. * }
  631. * @endcode
  632. * \defgroup xQueueReceive xQueueReceive
  633. * \ingroup QueueManagement
  634. */
  635. BaseType_t xQueueReceive( QueueHandle_t xQueue,
  636. void * const pvBuffer,
  637. TickType_t xTicksToWait );
  638. /**
  639. * queue. h
  640. * @code{c}
  641. * UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue );
  642. * @endcode
  643. *
  644. * Return the number of messages stored in a queue.
  645. *
  646. * @param xQueue A handle to the queue being queried.
  647. *
  648. * @return The number of messages available in the queue.
  649. *
  650. * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting
  651. * \ingroup QueueManagement
  652. */
  653. UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue );
  654. /**
  655. * queue. h
  656. * @code{c}
  657. * UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue );
  658. * @endcode
  659. *
  660. * Return the number of free spaces available in a queue. This is equal to the
  661. * number of items that can be sent to the queue before the queue becomes full
  662. * if no items are removed.
  663. *
  664. * @param xQueue A handle to the queue being queried.
  665. *
  666. * @return The number of spaces available in the queue.
  667. *
  668. * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting
  669. * \ingroup QueueManagement
  670. */
  671. UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue );
  672. /**
  673. * queue. h
  674. * @code{c}
  675. * void vQueueDelete( QueueHandle_t xQueue );
  676. * @endcode
  677. *
  678. * Delete a queue - freeing all the memory allocated for storing of items
  679. * placed on the queue.
  680. *
  681. * @param xQueue A handle to the queue to be deleted.
  682. *
  683. * \defgroup vQueueDelete vQueueDelete
  684. * \ingroup QueueManagement
  685. */
  686. void vQueueDelete( QueueHandle_t xQueue );
  687. /**
  688. * queue. h
  689. * @code{c}
  690. * BaseType_t xQueueSendToFrontFromISR(
  691. * QueueHandle_t xQueue,
  692. * const void *pvItemToQueue,
  693. * BaseType_t *pxHigherPriorityTaskWoken
  694. * );
  695. * @endcode
  696. *
  697. * This is a macro that calls xQueueGenericSendFromISR().
  698. *
  699. * Post an item to the front of a queue. It is safe to use this macro from
  700. * within an interrupt service routine.
  701. *
  702. * Items are queued by copy not reference so it is preferable to only
  703. * queue small items, especially when called from an ISR. In most cases
  704. * it would be preferable to store a pointer to the item being queued.
  705. *
  706. * @param xQueue The handle to the queue on which the item is to be posted.
  707. *
  708. * @param pvItemToQueue A pointer to the item that is to be placed on the
  709. * queue. The size of the items the queue will hold was defined when the
  710. * queue was created, so this many bytes will be copied from pvItemToQueue
  711. * into the queue storage area.
  712. *
  713. * @param pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set
  714. * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
  715. * to unblock, and the unblocked task has a priority higher than the currently
  716. * running task. If xQueueSendToFromFromISR() sets this value to pdTRUE then
  717. * a context switch should be requested before the interrupt is exited.
  718. *
  719. * @return pdTRUE if the data was successfully sent to the queue, otherwise
  720. * errQUEUE_FULL.
  721. *
  722. * Example usage for buffered IO (where the ISR can obtain more than one value
  723. * per call):
  724. * @code{c}
  725. * void vBufferISR( void )
  726. * {
  727. * char cIn;
  728. * BaseType_t xHigherPrioritTaskWoken;
  729. *
  730. * // We have not woken a task at the start of the ISR.
  731. * xHigherPriorityTaskWoken = pdFALSE;
  732. *
  733. * // Loop until the buffer is empty.
  734. * do
  735. * {
  736. * // Obtain a byte from the buffer.
  737. * cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
  738. *
  739. * // Post the byte.
  740. * xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
  741. *
  742. * } while( portINPUT_BYTE( BUFFER_COUNT ) );
  743. *
  744. * // Now the buffer is empty we can switch context if necessary.
  745. * if( xHigherPriorityTaskWoken )
  746. * {
  747. * taskYIELD ();
  748. * }
  749. * }
  750. * @endcode
  751. *
  752. * \defgroup xQueueSendFromISR xQueueSendFromISR
  753. * \ingroup QueueManagement
  754. */
  755. #define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \
  756. xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT )
  757. /**
  758. * queue. h
  759. * @code{c}
  760. * BaseType_t xQueueSendToBackFromISR(
  761. * QueueHandle_t xQueue,
  762. * const void *pvItemToQueue,
  763. * BaseType_t *pxHigherPriorityTaskWoken
  764. * );
  765. * @endcode
  766. *
  767. * This is a macro that calls xQueueGenericSendFromISR().
  768. *
  769. * Post an item to the back of a queue. It is safe to use this macro from
  770. * within an interrupt service routine.
  771. *
  772. * Items are queued by copy not reference so it is preferable to only
  773. * queue small items, especially when called from an ISR. In most cases
  774. * it would be preferable to store a pointer to the item being queued.
  775. *
  776. * @param xQueue The handle to the queue on which the item is to be posted.
  777. *
  778. * @param pvItemToQueue A pointer to the item that is to be placed on the
  779. * queue. The size of the items the queue will hold was defined when the
  780. * queue was created, so this many bytes will be copied from pvItemToQueue
  781. * into the queue storage area.
  782. *
  783. * @param pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set
  784. * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
  785. * to unblock, and the unblocked task has a priority higher than the currently
  786. * running task. If xQueueSendToBackFromISR() sets this value to pdTRUE then
  787. * a context switch should be requested before the interrupt is exited.
  788. *
  789. * @return pdTRUE if the data was successfully sent to the queue, otherwise
  790. * errQUEUE_FULL.
  791. *
  792. * Example usage for buffered IO (where the ISR can obtain more than one value
  793. * per call):
  794. * @code{c}
  795. * void vBufferISR( void )
  796. * {
  797. * char cIn;
  798. * BaseType_t xHigherPriorityTaskWoken;
  799. *
  800. * // We have not woken a task at the start of the ISR.
  801. * xHigherPriorityTaskWoken = pdFALSE;
  802. *
  803. * // Loop until the buffer is empty.
  804. * do
  805. * {
  806. * // Obtain a byte from the buffer.
  807. * cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
  808. *
  809. * // Post the byte.
  810. * xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
  811. *
  812. * } while( portINPUT_BYTE( BUFFER_COUNT ) );
  813. *
  814. * // Now the buffer is empty we can switch context if necessary.
  815. * if( xHigherPriorityTaskWoken )
  816. * {
  817. * taskYIELD ();
  818. * }
  819. * }
  820. * @endcode
  821. *
  822. * \defgroup xQueueSendFromISR xQueueSendFromISR
  823. * \ingroup QueueManagement
  824. */
  825. #define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \
  826. xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )
  827. /**
  828. * queue. h
  829. * @code{c}
  830. * BaseType_t xQueueSendFromISR(
  831. * QueueHandle_t xQueue,
  832. * const void *pvItemToQueue,
  833. * BaseType_t *pxHigherPriorityTaskWoken
  834. * );
  835. * @endcode
  836. *
  837. * This is a macro that calls xQueueGenericSendFromISR(). It is included
  838. * for backward compatibility with versions of FreeRTOS.org that did not
  839. * include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR()
  840. * macros.
  841. *
  842. * Post an item to the back of a queue. It is safe to use this function from
  843. * within an interrupt service routine.
  844. *
  845. * Items are queued by copy not reference so it is preferable to only
  846. * queue small items, especially when called from an ISR. In most cases
  847. * it would be preferable to store a pointer to the item being queued.
  848. *
  849. * @param xQueue The handle to the queue on which the item is to be posted.
  850. *
  851. * @param pvItemToQueue A pointer to the item that is to be placed on the
  852. * queue. The size of the items the queue will hold was defined when the
  853. * queue was created, so this many bytes will be copied from pvItemToQueue
  854. * into the queue storage area.
  855. *
  856. * @param pxHigherPriorityTaskWoken xQueueSendFromISR() will set
  857. * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
  858. * to unblock, and the unblocked task has a priority higher than the currently
  859. * running task. If xQueueSendFromISR() sets this value to pdTRUE then
  860. * a context switch should be requested before the interrupt is exited.
  861. *
  862. * @return pdTRUE if the data was successfully sent to the queue, otherwise
  863. * errQUEUE_FULL.
  864. *
  865. * Example usage for buffered IO (where the ISR can obtain more than one value
  866. * per call):
  867. * @code{c}
  868. * void vBufferISR( void )
  869. * {
  870. * char cIn;
  871. * BaseType_t xHigherPriorityTaskWoken;
  872. *
  873. * // We have not woken a task at the start of the ISR.
  874. * xHigherPriorityTaskWoken = pdFALSE;
  875. *
  876. * // Loop until the buffer is empty.
  877. * do
  878. * {
  879. * // Obtain a byte from the buffer.
  880. * cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
  881. *
  882. * // Post the byte.
  883. * xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
  884. *
  885. * } while( portINPUT_BYTE( BUFFER_COUNT ) );
  886. *
  887. * // Now the buffer is empty we can switch context if necessary.
  888. * if( xHigherPriorityTaskWoken )
  889. * {
  890. * // Actual macro used here is port specific.
  891. * portYIELD_FROM_ISR ();
  892. * }
  893. * }
  894. * @endcode
  895. *
  896. * \defgroup xQueueSendFromISR xQueueSendFromISR
  897. * \ingroup QueueManagement
  898. */
  899. #define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \
  900. xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )
  901. /**
  902. * queue. h
  903. * @code{c}
  904. * BaseType_t xQueueGenericSendFromISR(
  905. * QueueHandle_t xQueue,
  906. * const void *pvItemToQueue,
  907. * BaseType_t *pxHigherPriorityTaskWoken,
  908. * BaseType_t xCopyPosition
  909. * );
  910. * @endcode
  911. *
  912. * It is preferred that the macros xQueueSendFromISR(),
  913. * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place
  914. * of calling this function directly. xQueueGiveFromISR() is an
  915. * equivalent for use by semaphores that don't actually copy any data.
  916. *
  917. * Post an item on a queue. It is safe to use this function from within an
  918. * interrupt service routine.
  919. *
  920. * Items are queued by copy not reference so it is preferable to only
  921. * queue small items, especially when called from an ISR. In most cases
  922. * it would be preferable to store a pointer to the item being queued.
  923. *
  924. * @param xQueue The handle to the queue on which the item is to be posted.
  925. *
  926. * @param pvItemToQueue A pointer to the item that is to be placed on the
  927. * queue. The size of the items the queue will hold was defined when the
  928. * queue was created, so this many bytes will be copied from pvItemToQueue
  929. * into the queue storage area.
  930. *
  931. * @param pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set
  932. * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
  933. * to unblock, and the unblocked task has a priority higher than the currently
  934. * running task. If xQueueGenericSendFromISR() sets this value to pdTRUE then
  935. * a context switch should be requested before the interrupt is exited.
  936. *
  937. * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the
  938. * item at the back of the queue, or queueSEND_TO_FRONT to place the item
  939. * at the front of the queue (for high priority messages).
  940. *
  941. * @return pdTRUE if the data was successfully sent to the queue, otherwise
  942. * errQUEUE_FULL.
  943. *
  944. * Example usage for buffered IO (where the ISR can obtain more than one value
  945. * per call):
  946. * @code{c}
  947. * void vBufferISR( void )
  948. * {
  949. * char cIn;
  950. * BaseType_t xHigherPriorityTaskWokenByPost;
  951. *
  952. * // We have not woken a task at the start of the ISR.
  953. * xHigherPriorityTaskWokenByPost = pdFALSE;
  954. *
  955. * // Loop until the buffer is empty.
  956. * do
  957. * {
  958. * // Obtain a byte from the buffer.
  959. * cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
  960. *
  961. * // Post each byte.
  962. * xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK );
  963. *
  964. * } while( portINPUT_BYTE( BUFFER_COUNT ) );
  965. *
  966. * // Now the buffer is empty we can switch context if necessary. Note that the
  967. * // name of the yield function required is port specific.
  968. * if( xHigherPriorityTaskWokenByPost )
  969. * {
  970. * portYIELD_FROM_ISR();
  971. * }
  972. * }
  973. * @endcode
  974. *
  975. * \defgroup xQueueSendFromISR xQueueSendFromISR
  976. * \ingroup QueueManagement
  977. */
  978. BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue,
  979. const void * const pvItemToQueue,
  980. BaseType_t * const pxHigherPriorityTaskWoken,
  981. const BaseType_t xCopyPosition );
  982. BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
  983. BaseType_t * const pxHigherPriorityTaskWoken );
  984. /**
  985. * queue. h
  986. * @code{c}
  987. * BaseType_t xQueueReceiveFromISR(
  988. * QueueHandle_t xQueue,
  989. * void *pvBuffer,
  990. * BaseType_t *pxTaskWoken
  991. * );
  992. * @endcode
  993. *
  994. * Receive an item from a queue. It is safe to use this function from within an
  995. * interrupt service routine.
  996. *
  997. * @param xQueue The handle to the queue from which the item is to be
  998. * received.
  999. *
  1000. * @param pvBuffer Pointer to the buffer into which the received item will
  1001. * be copied.
  1002. *
  1003. * @param pxTaskWoken A task may be blocked waiting for space to become
  1004. * available on the queue. If xQueueReceiveFromISR causes such a task to
  1005. * unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will
  1006. * remain unchanged.
  1007. *
  1008. * @return pdTRUE if an item was successfully received from the queue,
  1009. * otherwise pdFALSE.
  1010. *
  1011. * Example usage:
  1012. * @code{c}
  1013. *
  1014. * QueueHandle_t xQueue;
  1015. *
  1016. * // Function to create a queue and post some values.
  1017. * void vAFunction( void *pvParameters )
  1018. * {
  1019. * char cValueToPost;
  1020. * const TickType_t xTicksToWait = ( TickType_t )0xff;
  1021. *
  1022. * // Create a queue capable of containing 10 characters.
  1023. * xQueue = xQueueCreate( 10, sizeof( char ) );
  1024. * if( xQueue == 0 )
  1025. * {
  1026. * // Failed to create the queue.
  1027. * }
  1028. *
  1029. * // ...
  1030. *
  1031. * // Post some characters that will be used within an ISR. If the queue
  1032. * // is full then this task will block for xTicksToWait ticks.
  1033. * cValueToPost = 'a';
  1034. * xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
  1035. * cValueToPost = 'b';
  1036. * xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
  1037. *
  1038. * // ... keep posting characters ... this task may block when the queue
  1039. * // becomes full.
  1040. *
  1041. * cValueToPost = 'c';
  1042. * xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
  1043. * }
  1044. *
  1045. * // ISR that outputs all the characters received on the queue.
  1046. * void vISR_Routine( void )
  1047. * {
  1048. * BaseType_t xTaskWokenByReceive = pdFALSE;
  1049. * char cRxedChar;
  1050. *
  1051. * while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )
  1052. * {
  1053. * // A character was received. Output the character now.
  1054. * vOutputCharacter( cRxedChar );
  1055. *
  1056. * // If removing the character from the queue woke the task that was
  1057. * // posting onto the queue cTaskWokenByReceive will have been set to
  1058. * // pdTRUE. No matter how many times this loop iterates only one
  1059. * // task will be woken.
  1060. * }
  1061. *
  1062. * if( cTaskWokenByPost != ( char ) pdFALSE;
  1063. * {
  1064. * taskYIELD ();
  1065. * }
  1066. * }
  1067. * @endcode
  1068. * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR
  1069. * \ingroup QueueManagement
  1070. */
  1071. BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue,
  1072. void * const pvBuffer,
  1073. BaseType_t * const pxHigherPriorityTaskWoken );
  1074. /*
  1075. * Utilities to query queues that are safe to use from an ISR. These utilities
  1076. * should be used only from witin an ISR, or within a critical section.
  1077. */
  1078. BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue );
  1079. BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue );
  1080. UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue );
  1081. /*
  1082. * For internal use only. Use xSemaphoreCreateMutex(),
  1083. * xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling
  1084. * these functions directly.
  1085. */
  1086. QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType );
  1087. QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType,
  1088. StaticQueue_t * pxStaticQueue );
  1089. QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
  1090. const UBaseType_t uxInitialCount );
  1091. QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
  1092. const UBaseType_t uxInitialCount,
  1093. StaticQueue_t * pxStaticQueue );
  1094. BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue,
  1095. TickType_t xTicksToWait );
  1096. TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore );
  1097. TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore );
  1098. /*
  1099. * For internal use only. Use xSemaphoreTakeMutexRecursive() or
  1100. * xSemaphoreGiveMutexRecursive() instead of calling these functions directly.
  1101. */
  1102. BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex,
  1103. TickType_t xTicksToWait );
  1104. BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex );
  1105. /*
  1106. * Reset a queue back to its original empty state. The return value is now
  1107. * obsolete and is always set to pdPASS.
  1108. */
  1109. #define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE )
  1110. /*
  1111. * Generic version of the function used to create a queue using dynamic memory
  1112. * allocation. This is called by other functions and macros that create other
  1113. * RTOS objects that use the queue structure as their base.
  1114. */
  1115. #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  1116. QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength,
  1117. const UBaseType_t uxItemSize,
  1118. const uint8_t ucQueueType );
  1119. #endif
  1120. /*
  1121. * Generic version of the function used to create a queue using dynamic memory
  1122. * allocation. This is called by other functions and macros that create other
  1123. * RTOS objects that use the queue structure as their base.
  1124. */
  1125. #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
  1126. QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
  1127. const UBaseType_t uxItemSize,
  1128. uint8_t * pucQueueStorage,
  1129. StaticQueue_t * pxStaticQueue,
  1130. const uint8_t ucQueueType );
  1131. #endif
  1132. /* Not public API functions. */
  1133. BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
  1134. BaseType_t xNewQueue );
  1135. #ifdef ESP_PLATFORM
  1136. /* Unimplemented */
  1137. typedef struct QueueDefinition * QueueSetHandle_t;
  1138. typedef struct QueueDefinition * QueueSetMemberHandle_t;
  1139. QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength );
  1140. BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore,
  1141. QueueSetHandle_t xQueueSet );
  1142. BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
  1143. QueueSetHandle_t xQueueSet );
  1144. QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet,
  1145. const TickType_t xTicksToWait );
  1146. QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet );
  1147. BaseType_t xQueuePeek( QueueHandle_t xQueue,
  1148. void * const pvBuffer,
  1149. TickType_t xTicksToWait );
  1150. BaseType_t xQueueOverwrite(QueueHandle_t xQueue, const void * pvItemToQueue);
  1151. BaseType_t xQueueOverwriteFromISR(QueueHandle_t xQueue, const void * pvItemToQueue, BaseType_t *pxHigherPriorityTaskWoken);
  1152. #endif
  1153. /* *INDENT-OFF* */
  1154. #ifdef __cplusplus
  1155. }
  1156. #endif
  1157. /* *INDENT-ON* */
  1158. #endif /* QUEUE_H */