message_buffer.h 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  1. /*
  2. * FreeRTOS Kernel V11.1.0
  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. /*
  29. * Message buffers build functionality on top of FreeRTOS stream buffers.
  30. * Whereas stream buffers are used to send a continuous stream of data from one
  31. * task or interrupt to another, message buffers are used to send variable
  32. * length discrete messages from one task or interrupt to another. Their
  33. * implementation is light weight, making them particularly suited for interrupt
  34. * to task and core to core communication scenarios.
  35. *
  36. * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
  37. * implementation (so also the message buffer implementation, as message buffers
  38. * are built on top of stream buffers) assumes there is only one task or
  39. * interrupt that will write to the buffer (the writer), and only one task or
  40. * interrupt that will read from the buffer (the reader). It is safe for the
  41. * writer and reader to be different tasks or interrupts, but, unlike other
  42. * FreeRTOS objects, it is not safe to have multiple different writers or
  43. * multiple different readers. If there are to be multiple different writers
  44. * then the application writer must place each call to a writing API function
  45. * (such as xMessageBufferSend()) inside a critical section and set the send
  46. * block time to 0. Likewise, if there are to be multiple different readers
  47. * then the application writer must place each call to a reading API function
  48. * (such as xMessageBufferRead()) inside a critical section and set the receive
  49. * timeout to 0.
  50. *
  51. * Message buffers hold variable length messages. To enable that, when a
  52. * message is written to the message buffer an additional sizeof( size_t ) bytes
  53. * are also written to store the message's length (that happens internally, with
  54. * the API function). sizeof( size_t ) is typically 4 bytes on a 32-bit
  55. * architecture, so writing a 10 byte message to a message buffer on a 32-bit
  56. * architecture will actually reduce the available space in the message buffer
  57. * by 14 bytes (10 byte are used by the message, and 4 bytes to hold the length
  58. * of the message).
  59. */
  60. #ifndef FREERTOS_MESSAGE_BUFFER_H
  61. #define FREERTOS_MESSAGE_BUFFER_H
  62. #ifndef INC_FREERTOS_H
  63. #error "include FreeRTOS.h must appear in source files before include message_buffer.h"
  64. #endif
  65. /* Message buffers are built onto of stream buffers. */
  66. #include "stream_buffer.h"
  67. /* *INDENT-OFF* */
  68. #if defined( __cplusplus )
  69. extern "C" {
  70. #endif
  71. /* *INDENT-ON* */
  72. /**
  73. * Type by which message buffers are referenced. For example, a call to
  74. * xMessageBufferCreate() returns an MessageBufferHandle_t variable that can
  75. * then be used as a parameter to xMessageBufferSend(), xMessageBufferReceive(),
  76. * etc. Message buffer is essentially built as a stream buffer hence its handle
  77. * is also set to same type as a stream buffer handle.
  78. */
  79. typedef StreamBufferHandle_t MessageBufferHandle_t;
  80. /*-----------------------------------------------------------*/
  81. /**
  82. * message_buffer.h
  83. *
  84. * @code{c}
  85. * MessageBufferHandle_t xMessageBufferCreate( size_t xBufferSizeBytes );
  86. * @endcode
  87. *
  88. * Creates a new message buffer using dynamically allocated memory. See
  89. * xMessageBufferCreateStatic() for a version that uses statically allocated
  90. * memory (memory that is allocated at compile time).
  91. *
  92. * configSUPPORT_DYNAMIC_ALLOCATION must be set to 1 or left undefined in
  93. * FreeRTOSConfig.h for xMessageBufferCreate() to be available.
  94. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  95. * xMessageBufferCreate() to be available.
  96. *
  97. * @param xBufferSizeBytes The total number of bytes (not messages) the message
  98. * buffer will be able to hold at any one time. When a message is written to
  99. * the message buffer an additional sizeof( size_t ) bytes are also written to
  100. * store the message's length. sizeof( size_t ) is typically 4 bytes on a
  101. * 32-bit architecture, so on most 32-bit architectures a 10 byte message will
  102. * take up 14 bytes of message buffer space.
  103. *
  104. * @param pxSendCompletedCallback Callback invoked when a send operation to the
  105. * message buffer is complete. If the parameter is NULL or xMessageBufferCreate()
  106. * is called without the parameter, then it will use the default implementation
  107. * provided by sbSEND_COMPLETED macro. To enable the callback,
  108. * configUSE_SB_COMPLETED_CALLBACK must be set to 1 in FreeRTOSConfig.h.
  109. *
  110. * @param pxReceiveCompletedCallback Callback invoked when a receive operation from
  111. * the message buffer is complete. If the parameter is NULL or xMessageBufferCreate()
  112. * is called without the parameter, it will use the default implementation provided
  113. * by sbRECEIVE_COMPLETED macro. To enable the callback,
  114. * configUSE_SB_COMPLETED_CALLBACK must be set to 1 in FreeRTOSConfig.h.
  115. *
  116. * @return If NULL is returned, then the message buffer cannot be created
  117. * because there is insufficient heap memory available for FreeRTOS to allocate
  118. * the message buffer data structures and storage area. A non-NULL value being
  119. * returned indicates that the message buffer has been created successfully -
  120. * the returned value should be stored as the handle to the created message
  121. * buffer.
  122. *
  123. * Example use:
  124. * @code{c}
  125. *
  126. * void vAFunction( void )
  127. * {
  128. * MessageBufferHandle_t xMessageBuffer;
  129. * const size_t xMessageBufferSizeBytes = 100;
  130. *
  131. * // Create a message buffer that can hold 100 bytes. The memory used to hold
  132. * // both the message buffer structure and the messages themselves is allocated
  133. * // dynamically. Each message added to the buffer consumes an additional 4
  134. * // bytes which are used to hold the length of the message.
  135. * xMessageBuffer = xMessageBufferCreate( xMessageBufferSizeBytes );
  136. *
  137. * if( xMessageBuffer == NULL )
  138. * {
  139. * // There was not enough heap memory space available to create the
  140. * // message buffer.
  141. * }
  142. * else
  143. * {
  144. * // The message buffer was created successfully and can now be used.
  145. * }
  146. *
  147. * @endcode
  148. * \defgroup xMessageBufferCreate xMessageBufferCreate
  149. * \ingroup MessageBufferManagement
  150. */
  151. #define xMessageBufferCreate( xBufferSizeBytes ) \
  152. xStreamBufferGenericCreate( ( xBufferSizeBytes ), ( size_t ) 0, sbTYPE_MESSAGE_BUFFER, NULL, NULL )
  153. #if ( configUSE_SB_COMPLETED_CALLBACK == 1 )
  154. #define xMessageBufferCreateWithCallback( xBufferSizeBytes, pxSendCompletedCallback, pxReceiveCompletedCallback ) \
  155. xStreamBufferGenericCreate( ( xBufferSizeBytes ), ( size_t ) 0, sbTYPE_MESSAGE_BUFFER, ( pxSendCompletedCallback ), ( pxReceiveCompletedCallback ) )
  156. #endif
  157. /**
  158. * message_buffer.h
  159. *
  160. * @code{c}
  161. * MessageBufferHandle_t xMessageBufferCreateStatic( size_t xBufferSizeBytes,
  162. * uint8_t *pucMessageBufferStorageArea,
  163. * StaticMessageBuffer_t *pxStaticMessageBuffer );
  164. * @endcode
  165. * Creates a new message buffer using statically allocated memory. See
  166. * xMessageBufferCreate() for a version that uses dynamically allocated memory.
  167. *
  168. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  169. * xMessageBufferCreateStatic() to be available.
  170. *
  171. * @param xBufferSizeBytes The size, in bytes, of the buffer pointed to by the
  172. * pucMessageBufferStorageArea parameter. When a message is written to the
  173. * message buffer an additional sizeof( size_t ) bytes are also written to store
  174. * the message's length. sizeof( size_t ) is typically 4 bytes on a 32-bit
  175. * architecture, so on most 32-bit architecture a 10 byte message will take up
  176. * 14 bytes of message buffer space. The maximum number of bytes that can be
  177. * stored in the message buffer is actually (xBufferSizeBytes - 1).
  178. *
  179. * @param pucMessageBufferStorageArea Must point to a uint8_t array that is at
  180. * least xBufferSizeBytes big. This is the array to which messages are
  181. * copied when they are written to the message buffer.
  182. *
  183. * @param pxStaticMessageBuffer Must point to a variable of type
  184. * StaticMessageBuffer_t, which will be used to hold the message buffer's data
  185. * structure.
  186. *
  187. * @param pxSendCompletedCallback Callback invoked when a new message is sent to the message buffer.
  188. * If the parameter is NULL or xMessageBufferCreate() is called without the parameter, then it will use the default
  189. * implementation provided by sbSEND_COMPLETED macro. To enable the callback,
  190. * configUSE_SB_COMPLETED_CALLBACK must be set to 1 in FreeRTOSConfig.h.
  191. *
  192. * @param pxReceiveCompletedCallback Callback invoked when a message is read from a
  193. * message buffer. If the parameter is NULL or xMessageBufferCreate() is called without the parameter, it will
  194. * use the default implementation provided by sbRECEIVE_COMPLETED macro. To enable the callback,
  195. * configUSE_SB_COMPLETED_CALLBACK must be set to 1 in FreeRTOSConfig.h.
  196. *
  197. * @return If the message buffer is created successfully then a handle to the
  198. * created message buffer is returned. If either pucMessageBufferStorageArea or
  199. * pxStaticmessageBuffer are NULL then NULL is returned.
  200. *
  201. * Example use:
  202. * @code{c}
  203. *
  204. * // Used to dimension the array used to hold the messages. The available space
  205. * // will actually be one less than this, so 999.
  206. #define STORAGE_SIZE_BYTES 1000
  207. *
  208. * // Defines the memory that will actually hold the messages within the message
  209. * // buffer.
  210. * static uint8_t ucStorageBuffer[ STORAGE_SIZE_BYTES ];
  211. *
  212. * // The variable used to hold the message buffer structure.
  213. * StaticMessageBuffer_t xMessageBufferStruct;
  214. *
  215. * void MyFunction( void )
  216. * {
  217. * MessageBufferHandle_t xMessageBuffer;
  218. *
  219. * xMessageBuffer = xMessageBufferCreateStatic( sizeof( ucStorageBuffer ),
  220. * ucStorageBuffer,
  221. * &xMessageBufferStruct );
  222. *
  223. * // As neither the pucMessageBufferStorageArea or pxStaticMessageBuffer
  224. * // parameters were NULL, xMessageBuffer will not be NULL, and can be used to
  225. * // reference the created message buffer in other message buffer API calls.
  226. *
  227. * // Other code that uses the message buffer can go here.
  228. * }
  229. *
  230. * @endcode
  231. * \defgroup xMessageBufferCreateStatic xMessageBufferCreateStatic
  232. * \ingroup MessageBufferManagement
  233. */
  234. #define xMessageBufferCreateStatic( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer ) \
  235. xStreamBufferGenericCreateStatic( ( xBufferSizeBytes ), 0, sbTYPE_MESSAGE_BUFFER, ( pucMessageBufferStorageArea ), ( pxStaticMessageBuffer ), NULL, NULL )
  236. #if ( configUSE_SB_COMPLETED_CALLBACK == 1 )
  237. #define xMessageBufferCreateStaticWithCallback( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer, pxSendCompletedCallback, pxReceiveCompletedCallback ) \
  238. xStreamBufferGenericCreateStatic( ( xBufferSizeBytes ), 0, sbTYPE_MESSAGE_BUFFER, ( pucMessageBufferStorageArea ), ( pxStaticMessageBuffer ), ( pxSendCompletedCallback ), ( pxReceiveCompletedCallback ) )
  239. #endif
  240. /**
  241. * message_buffer.h
  242. *
  243. * @code{c}
  244. * BaseType_t xMessageBufferGetStaticBuffers( MessageBufferHandle_t xMessageBuffer,
  245. * uint8_t ** ppucMessageBufferStorageArea,
  246. * StaticMessageBuffer_t ** ppxStaticMessageBuffer );
  247. * @endcode
  248. *
  249. * Retrieve pointers to a statically created message buffer's data structure
  250. * buffer and storage area buffer. These are the same buffers that are supplied
  251. * at the time of creation.
  252. *
  253. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  254. * xMessageBufferGetStaticBuffers() to be available.
  255. *
  256. * @param xMessageBuffer The message buffer for which to retrieve the buffers.
  257. *
  258. * @param ppucMessageBufferStorageArea Used to return a pointer to the
  259. * message buffer's storage area buffer.
  260. *
  261. * @param ppxStaticMessageBuffer Used to return a pointer to the message
  262. * buffer's data structure buffer.
  263. *
  264. * @return pdTRUE if buffers were retrieved, pdFALSE otherwise..
  265. *
  266. * \defgroup xMessageBufferGetStaticBuffers xMessageBufferGetStaticBuffers
  267. * \ingroup MessageBufferManagement
  268. */
  269. #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
  270. #define xMessageBufferGetStaticBuffers( xMessageBuffer, ppucMessageBufferStorageArea, ppxStaticMessageBuffer ) \
  271. xStreamBufferGetStaticBuffers( ( xMessageBuffer ), ( ppucMessageBufferStorageArea ), ( ppxStaticMessageBuffer ) )
  272. #endif /* configSUPPORT_STATIC_ALLOCATION */
  273. /**
  274. * message_buffer.h
  275. *
  276. * @code{c}
  277. * size_t xMessageBufferSend( MessageBufferHandle_t xMessageBuffer,
  278. * const void *pvTxData,
  279. * size_t xDataLengthBytes,
  280. * TickType_t xTicksToWait );
  281. * @endcode
  282. *
  283. * Sends a discrete message to the message buffer. The message can be any
  284. * length that fits within the buffer's free space, and is copied into the
  285. * buffer.
  286. *
  287. * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
  288. * implementation (so also the message buffer implementation, as message buffers
  289. * are built on top of stream buffers) assumes there is only one task or
  290. * interrupt that will write to the buffer (the writer), and only one task or
  291. * interrupt that will read from the buffer (the reader). It is safe for the
  292. * writer and reader to be different tasks or interrupts, but, unlike other
  293. * FreeRTOS objects, it is not safe to have multiple different writers or
  294. * multiple different readers. If there are to be multiple different writers
  295. * then the application writer must place each call to a writing API function
  296. * (such as xMessageBufferSend()) inside a critical section and set the send
  297. * block time to 0. Likewise, if there are to be multiple different readers
  298. * then the application writer must place each call to a reading API function
  299. * (such as xMessageBufferRead()) inside a critical section and set the receive
  300. * block time to 0.
  301. *
  302. * Use xMessageBufferSend() to write to a message buffer from a task. Use
  303. * xMessageBufferSendFromISR() to write to a message buffer from an interrupt
  304. * service routine (ISR).
  305. *
  306. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  307. * xMessageBufferSend() to be available.
  308. *
  309. * @param xMessageBuffer The handle of the message buffer to which a message is
  310. * being sent.
  311. *
  312. * @param pvTxData A pointer to the message that is to be copied into the
  313. * message buffer.
  314. *
  315. * @param xDataLengthBytes The length of the message. That is, the number of
  316. * bytes to copy from pvTxData into the message buffer. When a message is
  317. * written to the message buffer an additional sizeof( size_t ) bytes are also
  318. * written to store the message's length. sizeof( size_t ) is typically 4 bytes
  319. * on a 32-bit architecture, so on most 32-bit architecture setting
  320. * xDataLengthBytes to 20 will reduce the free space in the message buffer by 24
  321. * bytes (20 bytes of message data and 4 bytes to hold the message length).
  322. *
  323. * @param xTicksToWait The maximum amount of time the calling task should remain
  324. * in the Blocked state to wait for enough space to become available in the
  325. * message buffer, should the message buffer have insufficient space when
  326. * xMessageBufferSend() is called. The calling task will never block if
  327. * xTicksToWait is zero. The block time is specified in tick periods, so the
  328. * absolute time it represents is dependent on the tick frequency. The macro
  329. * pdMS_TO_TICKS() can be used to convert a time specified in milliseconds into
  330. * a time specified in ticks. Setting xTicksToWait to portMAX_DELAY will cause
  331. * the task to wait indefinitely (without timing out), provided
  332. * INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h. Tasks do not use any
  333. * CPU time when they are in the Blocked state.
  334. *
  335. * @return The number of bytes written to the message buffer. If the call to
  336. * xMessageBufferSend() times out before there was enough space to write the
  337. * message into the message buffer then zero is returned. If the call did not
  338. * time out then xDataLengthBytes is returned.
  339. *
  340. * Example use:
  341. * @code{c}
  342. * void vAFunction( MessageBufferHandle_t xMessageBuffer )
  343. * {
  344. * size_t xBytesSent;
  345. * uint8_t ucArrayToSend[] = { 0, 1, 2, 3 };
  346. * char *pcStringToSend = "String to send";
  347. * const TickType_t x100ms = pdMS_TO_TICKS( 100 );
  348. *
  349. * // Send an array to the message buffer, blocking for a maximum of 100ms to
  350. * // wait for enough space to be available in the message buffer.
  351. * xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) ucArrayToSend, sizeof( ucArrayToSend ), x100ms );
  352. *
  353. * if( xBytesSent != sizeof( ucArrayToSend ) )
  354. * {
  355. * // The call to xMessageBufferSend() times out before there was enough
  356. * // space in the buffer for the data to be written.
  357. * }
  358. *
  359. * // Send the string to the message buffer. Return immediately if there is
  360. * // not enough space in the buffer.
  361. * xBytesSent = xMessageBufferSend( xMessageBuffer, ( void * ) pcStringToSend, strlen( pcStringToSend ), 0 );
  362. *
  363. * if( xBytesSent != strlen( pcStringToSend ) )
  364. * {
  365. * // The string could not be added to the message buffer because there was
  366. * // not enough free space in the buffer.
  367. * }
  368. * }
  369. * @endcode
  370. * \defgroup xMessageBufferSend xMessageBufferSend
  371. * \ingroup MessageBufferManagement
  372. */
  373. #define xMessageBufferSend( xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) \
  374. xStreamBufferSend( ( xMessageBuffer ), ( pvTxData ), ( xDataLengthBytes ), ( xTicksToWait ) )
  375. /**
  376. * message_buffer.h
  377. *
  378. * @code{c}
  379. * size_t xMessageBufferSendFromISR( MessageBufferHandle_t xMessageBuffer,
  380. * const void *pvTxData,
  381. * size_t xDataLengthBytes,
  382. * BaseType_t *pxHigherPriorityTaskWoken );
  383. * @endcode
  384. *
  385. * Interrupt safe version of the API function that sends a discrete message to
  386. * the message buffer. The message can be any length that fits within the
  387. * buffer's free space, and is copied into the buffer.
  388. *
  389. * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
  390. * implementation (so also the message buffer implementation, as message buffers
  391. * are built on top of stream buffers) assumes there is only one task or
  392. * interrupt that will write to the buffer (the writer), and only one task or
  393. * interrupt that will read from the buffer (the reader). It is safe for the
  394. * writer and reader to be different tasks or interrupts, but, unlike other
  395. * FreeRTOS objects, it is not safe to have multiple different writers or
  396. * multiple different readers. If there are to be multiple different writers
  397. * then the application writer must place each call to a writing API function
  398. * (such as xMessageBufferSend()) inside a critical section and set the send
  399. * block time to 0. Likewise, if there are to be multiple different readers
  400. * then the application writer must place each call to a reading API function
  401. * (such as xMessageBufferRead()) inside a critical section and set the receive
  402. * block time to 0.
  403. *
  404. * Use xMessageBufferSend() to write to a message buffer from a task. Use
  405. * xMessageBufferSendFromISR() to write to a message buffer from an interrupt
  406. * service routine (ISR).
  407. *
  408. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  409. * xMessageBufferSendFromISR() to be available.
  410. *
  411. * @param xMessageBuffer The handle of the message buffer to which a message is
  412. * being sent.
  413. *
  414. * @param pvTxData A pointer to the message that is to be copied into the
  415. * message buffer.
  416. *
  417. * @param xDataLengthBytes The length of the message. That is, the number of
  418. * bytes to copy from pvTxData into the message buffer. When a message is
  419. * written to the message buffer an additional sizeof( size_t ) bytes are also
  420. * written to store the message's length. sizeof( size_t ) is typically 4 bytes
  421. * on a 32-bit architecture, so on most 32-bit architecture setting
  422. * xDataLengthBytes to 20 will reduce the free space in the message buffer by 24
  423. * bytes (20 bytes of message data and 4 bytes to hold the message length).
  424. *
  425. * @param pxHigherPriorityTaskWoken It is possible that a message buffer will
  426. * have a task blocked on it waiting for data. Calling
  427. * xMessageBufferSendFromISR() can make data available, and so cause a task that
  428. * was waiting for data to leave the Blocked state. If calling
  429. * xMessageBufferSendFromISR() causes a task to leave the Blocked state, and the
  430. * unblocked task has a priority higher than the currently executing task (the
  431. * task that was interrupted), then, internally, xMessageBufferSendFromISR()
  432. * will set *pxHigherPriorityTaskWoken to pdTRUE. If
  433. * xMessageBufferSendFromISR() sets this value to pdTRUE, then normally a
  434. * context switch should be performed before the interrupt is exited. This will
  435. * ensure that the interrupt returns directly to the highest priority Ready
  436. * state task. *pxHigherPriorityTaskWoken should be set to pdFALSE before it
  437. * is passed into the function. See the code example below for an example.
  438. *
  439. * @return The number of bytes actually written to the message buffer. If the
  440. * message buffer didn't have enough free space for the message to be stored
  441. * then 0 is returned, otherwise xDataLengthBytes is returned.
  442. *
  443. * Example use:
  444. * @code{c}
  445. * // A message buffer that has already been created.
  446. * MessageBufferHandle_t xMessageBuffer;
  447. *
  448. * void vAnInterruptServiceRoutine( void )
  449. * {
  450. * size_t xBytesSent;
  451. * char *pcStringToSend = "String to send";
  452. * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE.
  453. *
  454. * // Attempt to send the string to the message buffer.
  455. * xBytesSent = xMessageBufferSendFromISR( xMessageBuffer,
  456. * ( void * ) pcStringToSend,
  457. * strlen( pcStringToSend ),
  458. * &xHigherPriorityTaskWoken );
  459. *
  460. * if( xBytesSent != strlen( pcStringToSend ) )
  461. * {
  462. * // The string could not be added to the message buffer because there was
  463. * // not enough free space in the buffer.
  464. * }
  465. *
  466. * // If xHigherPriorityTaskWoken was set to pdTRUE inside
  467. * // xMessageBufferSendFromISR() then a task that has a priority above the
  468. * // priority of the currently executing task was unblocked and a context
  469. * // switch should be performed to ensure the ISR returns to the unblocked
  470. * // task. In most FreeRTOS ports this is done by simply passing
  471. * // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the
  472. * // variables value, and perform the context switch if necessary. Check the
  473. * // documentation for the port in use for port specific instructions.
  474. * portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
  475. * }
  476. * @endcode
  477. * \defgroup xMessageBufferSendFromISR xMessageBufferSendFromISR
  478. * \ingroup MessageBufferManagement
  479. */
  480. #define xMessageBufferSendFromISR( xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) \
  481. xStreamBufferSendFromISR( ( xMessageBuffer ), ( pvTxData ), ( xDataLengthBytes ), ( pxHigherPriorityTaskWoken ) )
  482. /**
  483. * message_buffer.h
  484. *
  485. * @code{c}
  486. * size_t xMessageBufferReceive( MessageBufferHandle_t xMessageBuffer,
  487. * void *pvRxData,
  488. * size_t xBufferLengthBytes,
  489. * TickType_t xTicksToWait );
  490. * @endcode
  491. *
  492. * Receives a discrete message from a message buffer. Messages can be of
  493. * variable length and are copied out of the buffer.
  494. *
  495. * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
  496. * implementation (so also the message buffer implementation, as message buffers
  497. * are built on top of stream buffers) assumes there is only one task or
  498. * interrupt that will write to the buffer (the writer), and only one task or
  499. * interrupt that will read from the buffer (the reader). It is safe for the
  500. * writer and reader to be different tasks or interrupts, but, unlike other
  501. * FreeRTOS objects, it is not safe to have multiple different writers or
  502. * multiple different readers. If there are to be multiple different writers
  503. * then the application writer must place each call to a writing API function
  504. * (such as xMessageBufferSend()) inside a critical section and set the send
  505. * block time to 0. Likewise, if there are to be multiple different readers
  506. * then the application writer must place each call to a reading API function
  507. * (such as xMessageBufferRead()) inside a critical section and set the receive
  508. * block time to 0.
  509. *
  510. * Use xMessageBufferReceive() to read from a message buffer from a task. Use
  511. * xMessageBufferReceiveFromISR() to read from a message buffer from an
  512. * interrupt service routine (ISR).
  513. *
  514. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  515. * xMessageBufferReceive() to be available.
  516. *
  517. * @param xMessageBuffer The handle of the message buffer from which a message
  518. * is being received.
  519. *
  520. * @param pvRxData A pointer to the buffer into which the received message is
  521. * to be copied.
  522. *
  523. * @param xBufferLengthBytes The length of the buffer pointed to by the pvRxData
  524. * parameter. This sets the maximum length of the message that can be received.
  525. * If xBufferLengthBytes is too small to hold the next message then the message
  526. * will be left in the message buffer and 0 will be returned.
  527. *
  528. * @param xTicksToWait The maximum amount of time the task should remain in the
  529. * Blocked state to wait for a message, should the message buffer be empty.
  530. * xMessageBufferReceive() will return immediately if xTicksToWait is zero and
  531. * the message buffer is empty. The block time is specified in tick periods, so
  532. * the absolute time it represents is dependent on the tick frequency. The
  533. * macro pdMS_TO_TICKS() can be used to convert a time specified in milliseconds
  534. * into a time specified in ticks. Setting xTicksToWait to portMAX_DELAY will
  535. * cause the task to wait indefinitely (without timing out), provided
  536. * INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h. Tasks do not use any
  537. * CPU time when they are in the Blocked state.
  538. *
  539. * @return The length, in bytes, of the message read from the message buffer, if
  540. * any. If xMessageBufferReceive() times out before a message became available
  541. * then zero is returned. If the length of the message is greater than
  542. * xBufferLengthBytes then the message will be left in the message buffer and
  543. * zero is returned.
  544. *
  545. * Example use:
  546. * @code{c}
  547. * void vAFunction( MessageBuffer_t xMessageBuffer )
  548. * {
  549. * uint8_t ucRxData[ 20 ];
  550. * size_t xReceivedBytes;
  551. * const TickType_t xBlockTime = pdMS_TO_TICKS( 20 );
  552. *
  553. * // Receive the next message from the message buffer. Wait in the Blocked
  554. * // state (so not using any CPU processing time) for a maximum of 100ms for
  555. * // a message to become available.
  556. * xReceivedBytes = xMessageBufferReceive( xMessageBuffer,
  557. * ( void * ) ucRxData,
  558. * sizeof( ucRxData ),
  559. * xBlockTime );
  560. *
  561. * if( xReceivedBytes > 0 )
  562. * {
  563. * // A ucRxData contains a message that is xReceivedBytes long. Process
  564. * // the message here....
  565. * }
  566. * }
  567. * @endcode
  568. * \defgroup xMessageBufferReceive xMessageBufferReceive
  569. * \ingroup MessageBufferManagement
  570. */
  571. #define xMessageBufferReceive( xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) \
  572. xStreamBufferReceive( ( xMessageBuffer ), ( pvRxData ), ( xBufferLengthBytes ), ( xTicksToWait ) )
  573. /**
  574. * message_buffer.h
  575. *
  576. * @code{c}
  577. * size_t xMessageBufferReceiveFromISR( MessageBufferHandle_t xMessageBuffer,
  578. * void *pvRxData,
  579. * size_t xBufferLengthBytes,
  580. * BaseType_t *pxHigherPriorityTaskWoken );
  581. * @endcode
  582. *
  583. * An interrupt safe version of the API function that receives a discrete
  584. * message from a message buffer. Messages can be of variable length and are
  585. * copied out of the buffer.
  586. *
  587. * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
  588. * implementation (so also the message buffer implementation, as message buffers
  589. * are built on top of stream buffers) assumes there is only one task or
  590. * interrupt that will write to the buffer (the writer), and only one task or
  591. * interrupt that will read from the buffer (the reader). It is safe for the
  592. * writer and reader to be different tasks or interrupts, but, unlike other
  593. * FreeRTOS objects, it is not safe to have multiple different writers or
  594. * multiple different readers. If there are to be multiple different writers
  595. * then the application writer must place each call to a writing API function
  596. * (such as xMessageBufferSend()) inside a critical section and set the send
  597. * block time to 0. Likewise, if there are to be multiple different readers
  598. * then the application writer must place each call to a reading API function
  599. * (such as xMessageBufferRead()) inside a critical section and set the receive
  600. * block time to 0.
  601. *
  602. * Use xMessageBufferReceive() to read from a message buffer from a task. Use
  603. * xMessageBufferReceiveFromISR() to read from a message buffer from an
  604. * interrupt service routine (ISR).
  605. *
  606. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  607. * xMessageBufferReceiveFromISR() to be available.
  608. *
  609. * @param xMessageBuffer The handle of the message buffer from which a message
  610. * is being received.
  611. *
  612. * @param pvRxData A pointer to the buffer into which the received message is
  613. * to be copied.
  614. *
  615. * @param xBufferLengthBytes The length of the buffer pointed to by the pvRxData
  616. * parameter. This sets the maximum length of the message that can be received.
  617. * If xBufferLengthBytes is too small to hold the next message then the message
  618. * will be left in the message buffer and 0 will be returned.
  619. *
  620. * @param pxHigherPriorityTaskWoken It is possible that a message buffer will
  621. * have a task blocked on it waiting for space to become available. Calling
  622. * xMessageBufferReceiveFromISR() can make space available, and so cause a task
  623. * that is waiting for space to leave the Blocked state. If calling
  624. * xMessageBufferReceiveFromISR() causes a task to leave the Blocked state, and
  625. * the unblocked task has a priority higher than the currently executing task
  626. * (the task that was interrupted), then, internally,
  627. * xMessageBufferReceiveFromISR() will set *pxHigherPriorityTaskWoken to pdTRUE.
  628. * If xMessageBufferReceiveFromISR() sets this value to pdTRUE, then normally a
  629. * context switch should be performed before the interrupt is exited. That will
  630. * ensure the interrupt returns directly to the highest priority Ready state
  631. * task. *pxHigherPriorityTaskWoken should be set to pdFALSE before it is
  632. * passed into the function. See the code example below for an example.
  633. *
  634. * @return The length, in bytes, of the message read from the message buffer, if
  635. * any.
  636. *
  637. * Example use:
  638. * @code{c}
  639. * // A message buffer that has already been created.
  640. * MessageBuffer_t xMessageBuffer;
  641. *
  642. * void vAnInterruptServiceRoutine( void )
  643. * {
  644. * uint8_t ucRxData[ 20 ];
  645. * size_t xReceivedBytes;
  646. * BaseType_t xHigherPriorityTaskWoken = pdFALSE; // Initialised to pdFALSE.
  647. *
  648. * // Receive the next message from the message buffer.
  649. * xReceivedBytes = xMessageBufferReceiveFromISR( xMessageBuffer,
  650. * ( void * ) ucRxData,
  651. * sizeof( ucRxData ),
  652. * &xHigherPriorityTaskWoken );
  653. *
  654. * if( xReceivedBytes > 0 )
  655. * {
  656. * // A ucRxData contains a message that is xReceivedBytes long. Process
  657. * // the message here....
  658. * }
  659. *
  660. * // If xHigherPriorityTaskWoken was set to pdTRUE inside
  661. * // xMessageBufferReceiveFromISR() then a task that has a priority above the
  662. * // priority of the currently executing task was unblocked and a context
  663. * // switch should be performed to ensure the ISR returns to the unblocked
  664. * // task. In most FreeRTOS ports this is done by simply passing
  665. * // xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the
  666. * // variables value, and perform the context switch if necessary. Check the
  667. * // documentation for the port in use for port specific instructions.
  668. * portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
  669. * }
  670. * @endcode
  671. * \defgroup xMessageBufferReceiveFromISR xMessageBufferReceiveFromISR
  672. * \ingroup MessageBufferManagement
  673. */
  674. #define xMessageBufferReceiveFromISR( xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) \
  675. xStreamBufferReceiveFromISR( ( xMessageBuffer ), ( pvRxData ), ( xBufferLengthBytes ), ( pxHigherPriorityTaskWoken ) )
  676. /**
  677. * message_buffer.h
  678. *
  679. * @code{c}
  680. * void vMessageBufferDelete( MessageBufferHandle_t xMessageBuffer );
  681. * @endcode
  682. *
  683. * Deletes a message buffer that was previously created using a call to
  684. * xMessageBufferCreate() or xMessageBufferCreateStatic(). If the message
  685. * buffer was created using dynamic memory (that is, by xMessageBufferCreate()),
  686. * then the allocated memory is freed.
  687. *
  688. * A message buffer handle must not be used after the message buffer has been
  689. * deleted.
  690. *
  691. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  692. * vMessageBufferDelete() to be available.
  693. *
  694. * @param xMessageBuffer The handle of the message buffer to be deleted.
  695. *
  696. */
  697. #define vMessageBufferDelete( xMessageBuffer ) \
  698. vStreamBufferDelete( xMessageBuffer )
  699. /**
  700. * message_buffer.h
  701. * @code{c}
  702. * BaseType_t xMessageBufferIsFull( MessageBufferHandle_t xMessageBuffer );
  703. * @endcode
  704. *
  705. * Tests to see if a message buffer is full. A message buffer is full if it
  706. * cannot accept any more messages, of any size, until space is made available
  707. * by a message being removed from the message buffer.
  708. *
  709. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  710. * xMessageBufferIsFull() to be available.
  711. *
  712. * @param xMessageBuffer The handle of the message buffer being queried.
  713. *
  714. * @return If the message buffer referenced by xMessageBuffer is full then
  715. * pdTRUE is returned. Otherwise pdFALSE is returned.
  716. */
  717. #define xMessageBufferIsFull( xMessageBuffer ) \
  718. xStreamBufferIsFull( xMessageBuffer )
  719. /**
  720. * message_buffer.h
  721. * @code{c}
  722. * BaseType_t xMessageBufferIsEmpty( MessageBufferHandle_t xMessageBuffer );
  723. * @endcode
  724. *
  725. * Tests to see if a message buffer is empty (does not contain any messages).
  726. *
  727. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  728. * xMessageBufferIsEmpty() to be available.
  729. *
  730. * @param xMessageBuffer The handle of the message buffer being queried.
  731. *
  732. * @return If the message buffer referenced by xMessageBuffer is empty then
  733. * pdTRUE is returned. Otherwise pdFALSE is returned.
  734. *
  735. */
  736. #define xMessageBufferIsEmpty( xMessageBuffer ) \
  737. xStreamBufferIsEmpty( xMessageBuffer )
  738. /**
  739. * message_buffer.h
  740. * @code{c}
  741. * BaseType_t xMessageBufferReset( MessageBufferHandle_t xMessageBuffer );
  742. * @endcode
  743. *
  744. * Resets a message buffer to its initial empty state, discarding any message it
  745. * contained.
  746. *
  747. * A message buffer can only be reset if there are no tasks blocked on it.
  748. *
  749. * Use xMessageBufferReset() to reset a message buffer from a task.
  750. * Use xMessageBufferResetFromISR() to reset a message buffer from an
  751. * interrupt service routine (ISR).
  752. *
  753. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  754. * xMessageBufferReset() to be available.
  755. *
  756. * @param xMessageBuffer The handle of the message buffer being reset.
  757. *
  758. * @return If the message buffer was reset then pdPASS is returned. If the
  759. * message buffer could not be reset because either there was a task blocked on
  760. * the message queue to wait for space to become available, or to wait for a
  761. * a message to be available, then pdFAIL is returned.
  762. *
  763. * \defgroup xMessageBufferReset xMessageBufferReset
  764. * \ingroup MessageBufferManagement
  765. */
  766. #define xMessageBufferReset( xMessageBuffer ) \
  767. xStreamBufferReset( xMessageBuffer )
  768. /**
  769. * message_buffer.h
  770. * @code{c}
  771. * BaseType_t xMessageBufferResetFromISR( MessageBufferHandle_t xMessageBuffer );
  772. * @endcode
  773. *
  774. * An interrupt safe version of the API function that resets the message buffer.
  775. * Resets a message buffer to its initial empty state, discarding any message it
  776. * contained.
  777. *
  778. * A message buffer can only be reset if there are no tasks blocked on it.
  779. *
  780. * Use xMessageBufferReset() to reset a message buffer from a task.
  781. * Use xMessageBufferResetFromISR() to reset a message buffer from an
  782. * interrupt service routine (ISR).
  783. *
  784. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  785. * xMessageBufferResetFromISR() to be available.
  786. *
  787. * @param xMessageBuffer The handle of the message buffer being reset.
  788. *
  789. * @return If the message buffer was reset then pdPASS is returned. If the
  790. * message buffer could not be reset because either there was a task blocked on
  791. * the message queue to wait for space to become available, or to wait for a
  792. * a message to be available, then pdFAIL is returned.
  793. *
  794. * \defgroup xMessageBufferResetFromISR xMessageBufferResetFromISR
  795. * \ingroup MessageBufferManagement
  796. */
  797. #define xMessageBufferResetFromISR( xMessageBuffer ) \
  798. xStreamBufferResetFromISR( xMessageBuffer )
  799. /**
  800. * message_buffer.h
  801. * @code{c}
  802. * size_t xMessageBufferSpaceAvailable( MessageBufferHandle_t xMessageBuffer );
  803. * @endcode
  804. * Returns the number of bytes of free space in the message buffer.
  805. *
  806. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  807. * xMessageBufferSpaceAvailable() to be available.
  808. *
  809. * @param xMessageBuffer The handle of the message buffer being queried.
  810. *
  811. * @return The number of bytes that can be written to the message buffer before
  812. * the message buffer would be full. When a message is written to the message
  813. * buffer an additional sizeof( size_t ) bytes are also written to store the
  814. * message's length. sizeof( size_t ) is typically 4 bytes on a 32-bit
  815. * architecture, so if xMessageBufferSpacesAvailable() returns 10, then the size
  816. * of the largest message that can be written to the message buffer is 6 bytes.
  817. *
  818. * \defgroup xMessageBufferSpaceAvailable xMessageBufferSpaceAvailable
  819. * \ingroup MessageBufferManagement
  820. */
  821. #define xMessageBufferSpaceAvailable( xMessageBuffer ) \
  822. xStreamBufferSpacesAvailable( xMessageBuffer )
  823. #define xMessageBufferSpacesAvailable( xMessageBuffer ) \
  824. xStreamBufferSpacesAvailable( xMessageBuffer ) /* Corrects typo in original macro name. */
  825. /**
  826. * message_buffer.h
  827. * @code{c}
  828. * size_t xMessageBufferNextLengthBytes( MessageBufferHandle_t xMessageBuffer );
  829. * @endcode
  830. * Returns the length (in bytes) of the next message in a message buffer.
  831. * Useful if xMessageBufferReceive() returned 0 because the size of the buffer
  832. * passed into xMessageBufferReceive() was too small to hold the next message.
  833. *
  834. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  835. * xMessageBufferNextLengthBytes() to be available.
  836. *
  837. * @param xMessageBuffer The handle of the message buffer being queried.
  838. *
  839. * @return The length (in bytes) of the next message in the message buffer, or 0
  840. * if the message buffer is empty.
  841. *
  842. * \defgroup xMessageBufferNextLengthBytes xMessageBufferNextLengthBytes
  843. * \ingroup MessageBufferManagement
  844. */
  845. #define xMessageBufferNextLengthBytes( xMessageBuffer ) \
  846. xStreamBufferNextMessageLengthBytes( xMessageBuffer )
  847. /**
  848. * message_buffer.h
  849. *
  850. * @code{c}
  851. * BaseType_t xMessageBufferSendCompletedFromISR( MessageBufferHandle_t xMessageBuffer, BaseType_t *pxHigherPriorityTaskWoken );
  852. * @endcode
  853. *
  854. * For advanced users only.
  855. *
  856. * The sbSEND_COMPLETED() macro is called from within the FreeRTOS APIs when
  857. * data is sent to a message buffer or stream buffer. If there was a task that
  858. * was blocked on the message or stream buffer waiting for data to arrive then
  859. * the sbSEND_COMPLETED() macro sends a notification to the task to remove it
  860. * from the Blocked state. xMessageBufferSendCompletedFromISR() does the same
  861. * thing. It is provided to enable application writers to implement their own
  862. * version of sbSEND_COMPLETED(), and MUST NOT BE USED AT ANY OTHER TIME.
  863. *
  864. * See the example implemented in FreeRTOS/Demo/Minimal/MessageBufferAMP.c for
  865. * additional information.
  866. *
  867. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  868. * xMessageBufferSendCompletedFromISR() to be available.
  869. *
  870. * @param xMessageBuffer The handle of the stream buffer to which data was
  871. * written.
  872. *
  873. * @param pxHigherPriorityTaskWoken *pxHigherPriorityTaskWoken should be
  874. * initialised to pdFALSE before it is passed into
  875. * xMessageBufferSendCompletedFromISR(). If calling
  876. * xMessageBufferSendCompletedFromISR() removes a task from the Blocked state,
  877. * and the task has a priority above the priority of the currently running task,
  878. * then *pxHigherPriorityTaskWoken will get set to pdTRUE indicating that a
  879. * context switch should be performed before exiting the ISR.
  880. *
  881. * @return If a task was removed from the Blocked state then pdTRUE is returned.
  882. * Otherwise pdFALSE is returned.
  883. *
  884. * \defgroup xMessageBufferSendCompletedFromISR xMessageBufferSendCompletedFromISR
  885. * \ingroup StreamBufferManagement
  886. */
  887. #define xMessageBufferSendCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) \
  888. xStreamBufferSendCompletedFromISR( ( xMessageBuffer ), ( pxHigherPriorityTaskWoken ) )
  889. /**
  890. * message_buffer.h
  891. *
  892. * @code{c}
  893. * BaseType_t xMessageBufferReceiveCompletedFromISR( MessageBufferHandle_t xMessageBuffer, BaseType_t *pxHigherPriorityTaskWoken );
  894. * @endcode
  895. *
  896. * For advanced users only.
  897. *
  898. * The sbRECEIVE_COMPLETED() macro is called from within the FreeRTOS APIs when
  899. * data is read out of a message buffer or stream buffer. If there was a task
  900. * that was blocked on the message or stream buffer waiting for data to arrive
  901. * then the sbRECEIVE_COMPLETED() macro sends a notification to the task to
  902. * remove it from the Blocked state. xMessageBufferReceiveCompletedFromISR()
  903. * does the same thing. It is provided to enable application writers to
  904. * implement their own version of sbRECEIVE_COMPLETED(), and MUST NOT BE USED AT
  905. * ANY OTHER TIME.
  906. *
  907. * See the example implemented in FreeRTOS/Demo/Minimal/MessageBufferAMP.c for
  908. * additional information.
  909. *
  910. * configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
  911. * xMessageBufferReceiveCompletedFromISR() to be available.
  912. *
  913. * @param xMessageBuffer The handle of the stream buffer from which data was
  914. * read.
  915. *
  916. * @param pxHigherPriorityTaskWoken *pxHigherPriorityTaskWoken should be
  917. * initialised to pdFALSE before it is passed into
  918. * xMessageBufferReceiveCompletedFromISR(). If calling
  919. * xMessageBufferReceiveCompletedFromISR() removes a task from the Blocked state,
  920. * and the task has a priority above the priority of the currently running task,
  921. * then *pxHigherPriorityTaskWoken will get set to pdTRUE indicating that a
  922. * context switch should be performed before exiting the ISR.
  923. *
  924. * @return If a task was removed from the Blocked state then pdTRUE is returned.
  925. * Otherwise pdFALSE is returned.
  926. *
  927. * \defgroup xMessageBufferReceiveCompletedFromISR xMessageBufferReceiveCompletedFromISR
  928. * \ingroup StreamBufferManagement
  929. */
  930. #define xMessageBufferReceiveCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) \
  931. xStreamBufferReceiveCompletedFromISR( ( xMessageBuffer ), ( pxHigherPriorityTaskWoken ) )
  932. /* *INDENT-OFF* */
  933. #if defined( __cplusplus )
  934. } /* extern "C" */
  935. #endif
  936. /* *INDENT-ON* */
  937. #endif /* !defined( FREERTOS_MESSAGE_BUFFER_H ) */