Skip to content

Commit e8289df

Browse files
kar-rahul-awsjoshzarraggargSkptak
authored
Add config option for event groups and stream buffers (#994)
* Add configUSE_EVENT_GROUPS in source files * Add configUSE_EVENT_GROUPS macro in MPU wrapper files * Add configUSE_EVENT_GROUPS macro in MPU port files for GCC and RVDS compilers * Fix Formatting * Add configUSE_STREAM_BUFFERS in source files * Add configUSE_STREAM_BUFFERS macro in MPU wrapper files * Add configUSE_STREAM_BUFFERS macro in MPU port files for GCC and RVDS compilers * Update FreeRTOS.h post latest commit * Update the ARM_CRx_MPU Port to account for the new configuration changes * Formatting suggestions Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> * Code review suggestions --------- Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> Co-authored-by: joshzarr <joshzarr@amazon.com> Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com> Co-authored-by: Soren Ptak <ptaksoren@gmail.com> Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 parent 39dbff7 commit e8289df

File tree

26 files changed

+7131
-5978
lines changed

26 files changed

+7131
-5978
lines changed

event_groups.c

Lines changed: 608 additions & 597 deletions
Large diffs are not rendered by default.

include/FreeRTOS.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,14 @@
318318
#define configUSE_TIMERS 0
319319
#endif
320320

321+
#ifndef configUSE_EVENT_GROUPS
322+
#define configUSE_EVENT_GROUPS 1
323+
#endif
324+
325+
#ifndef configUSE_STREAM_BUFFERS
326+
#define configUSE_STREAM_BUFFERS 1
327+
#endif
328+
321329
#ifndef configUSE_DAEMON_TASK_STARTUP_HOOK
322330
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
323331
#endif

include/event_groups.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ typedef TickType_t EventBits_t;
139139
* each event group has 56 usable bits (bit 0 to bit 53). The EventBits_t type
140140
* is used to store event bits within an event group.
141141
*
142+
* The configUSE_EVENT_GROUPS configuration constant must be set to 1 for xEventGroupCreate()
143+
* to be available.
144+
*
142145
* @return If the event group was created then a handle to the event group is
143146
* returned. If there was insufficient FreeRTOS heap available to create the
144147
* event group then NULL is returned. See https://www.FreeRTOS.org/a00111.html
@@ -196,6 +199,9 @@ typedef TickType_t EventBits_t;
196199
* each event group has 56 usable bits (bit 0 to bit 53). The EventBits_t type
197200
* is used to store event bits within an event group.
198201
*
202+
* The configUSE_EVENT_GROUPS configuration constant must be set to 1 for xEventGroupCreateStatic()
203+
* to be available.
204+
*
199205
* @param pxEventGroupBuffer pxEventGroupBuffer must point to a variable of type
200206
* StaticEventGroup_t, which will be then be used to hold the event group's data
201207
* structures, removing the need for the memory to be allocated dynamically.
@@ -238,6 +244,9 @@ typedef TickType_t EventBits_t;
238244
*
239245
* This function cannot be called from an interrupt.
240246
*
247+
* The configUSE_EVENT_GROUPS configuration constant must be set to 1 for xEventGroupWaitBits()
248+
* to be available.
249+
*
241250
* @param xEventGroup The event group in which the bits are being tested. The
242251
* event group must have previously been created using a call to
243252
* xEventGroupCreate().
@@ -331,6 +340,9 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
331340
* Clear bits within an event group. This function cannot be called from an
332341
* interrupt.
333342
*
343+
* The configUSE_EVENT_GROUPS configuration constant must be set to 1 for xEventGroupClearBits()
344+
* to be available.
345+
*
334346
* @param xEventGroup The event group in which the bits are to be cleared.
335347
*
336348
* @param uxBitsToClear A bitwise value that indicates the bit or bits to clear
@@ -461,6 +473,9 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup,
461473
* Setting bits in an event group will automatically unblock tasks that are
462474
* blocked waiting for the bits.
463475
*
476+
* The configUSE_EVENT_GROUPS configuration constant must be set to 1 for xEventGroupSetBits()
477+
* to be available.
478+
*
464479
* @param xEventGroup The event group in which the bits are to be set.
465480
*
466481
* @param uxBitsToSet A bitwise value that indicates the bit or bits to set.
@@ -625,6 +640,9 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup,
625640
* this case all the bits specified by uxBitsToWait will be automatically
626641
* cleared before the function returns.
627642
*
643+
* The configUSE_EVENT_GROUPS configuration constant must be set to 1 for xEventGroupSync()
644+
* to be available.
645+
*
628646
* @param xEventGroup The event group in which the bits are being tested. The
629647
* event group must have previously been created using a call to
630648
* xEventGroupCreate().
@@ -743,6 +761,9 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
743761
* Returns the current value of the bits in an event group. This function
744762
* cannot be used from an interrupt.
745763
*
764+
* The configUSE_EVENT_GROUPS configuration constant must be set to 1 for xEventGroupGetBits()
765+
* to be available.
766+
*
746767
* @param xEventGroup The event group being queried.
747768
*
748769
* @return The event group bits at the time xEventGroupGetBits() was called.
@@ -760,6 +781,9 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
760781
*
761782
* A version of xEventGroupGetBits() that can be called from an ISR.
762783
*
784+
* The configUSE_EVENT_GROUPS configuration constant must be set to 1 for xEventGroupGetBitsFromISR()
785+
* to be available.
786+
*
763787
* @param xEventGroup The event group being queried.
764788
*
765789
* @return The event group bits at the time xEventGroupGetBitsFromISR() was called.
@@ -779,6 +803,9 @@ EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) PRIVILEG
779803
* xEventGroupCreate(). Tasks that are blocked on the event group will be
780804
* unblocked and obtain 0 as the event group's value.
781805
*
806+
* The configUSE_EVENT_GROUPS configuration constant must be set to 1 for vEventGroupDelete()
807+
* to be available.
808+
*
782809
* @param xEventGroup The event group being deleted.
783810
*/
784811
void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
@@ -793,6 +820,9 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
793820
* Retrieve a pointer to a statically created event groups's data structure
794821
* buffer. It is the same buffer that is supplied at the time of creation.
795822
*
823+
* The configUSE_EVENT_GROUPS configuration constant must be set to 1 for xEventGroupGetStaticBuffer()
824+
* to be available.
825+
*
796826
* @param xEventGroup The event group for which to retrieve the buffer.
797827
*
798828
* @param ppxEventGroupBuffer Used to return a pointer to the event groups's

include/message_buffer.h

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
100100
*
101101
* configSUPPORT_DYNAMIC_ALLOCATION must be set to 1 or left undefined in
102102
* FreeRTOSConfig.h for xMessageBufferCreate() to be available.
103+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
104+
* xMessageBufferCreate() to be available.
103105
*
104106
* @param xBufferSizeBytes The total number of bytes (not messages) the message
105107
* buffer will be able to hold at any one time. When a message is written to
@@ -168,12 +170,15 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
168170
*
169171
* @code{c}
170172
* MessageBufferHandle_t xMessageBufferCreateStatic( size_t xBufferSizeBytes,
171-
* uint8_t *pucMessageBufferStorageArea,
172-
* StaticMessageBuffer_t *pxStaticMessageBuffer );
173+
* uint8_t *pucMessageBufferStorageArea,
174+
* StaticMessageBuffer_t *pxStaticMessageBuffer );
173175
* @endcode
174176
* Creates a new message buffer using statically allocated memory. See
175177
* xMessageBufferCreate() for a version that uses dynamically allocated memory.
176178
*
179+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
180+
* xMessageBufferCreateStatic() to be available.
181+
*
177182
* @param xBufferSizeBytes The size, in bytes, of the buffer pointed to by the
178183
* pucMessageBufferStorageArea parameter. When a message is written to the
179184
* message buffer an additional sizeof( size_t ) bytes are also written to store
@@ -258,6 +263,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
258263
* buffer and storage area buffer. These are the same buffers that are supplied
259264
* at the time of creation.
260265
*
266+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
267+
* xMessageBufferGetStaticBuffers() to be available.
268+
*
261269
* @param xMessageBuffer The message buffer for which to retrieve the buffers.
262270
*
263271
* @param ppucMessageBufferStorageArea Used to return a pointer to the
@@ -281,9 +289,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
281289
*
282290
* @code{c}
283291
* size_t xMessageBufferSend( MessageBufferHandle_t xMessageBuffer,
284-
* const void *pvTxData,
285-
* size_t xDataLengthBytes,
286-
* TickType_t xTicksToWait );
292+
* const void *pvTxData,
293+
* size_t xDataLengthBytes,
294+
* TickType_t xTicksToWait );
287295
* @endcode
288296
*
289297
* Sends a discrete message to the message buffer. The message can be any
@@ -309,6 +317,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
309317
* xMessageBufferSendFromISR() to write to a message buffer from an interrupt
310318
* service routine (ISR).
311319
*
320+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
321+
* xMessageBufferSend() to be available.
322+
*
312323
* @param xMessageBuffer The handle of the message buffer to which a message is
313324
* being sent.
314325
*
@@ -381,9 +392,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
381392
*
382393
* @code{c}
383394
* size_t xMessageBufferSendFromISR( MessageBufferHandle_t xMessageBuffer,
384-
* const void *pvTxData,
385-
* size_t xDataLengthBytes,
386-
* BaseType_t *pxHigherPriorityTaskWoken );
395+
* const void *pvTxData,
396+
* size_t xDataLengthBytes,
397+
* BaseType_t *pxHigherPriorityTaskWoken );
387398
* @endcode
388399
*
389400
* Interrupt safe version of the API function that sends a discrete message to
@@ -409,6 +420,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
409420
* xMessageBufferSendFromISR() to write to a message buffer from an interrupt
410421
* service routine (ISR).
411422
*
423+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
424+
* xMessageBufferSendFromISR() to be available.
425+
*
412426
* @param xMessageBuffer The handle of the message buffer to which a message is
413427
* being sent.
414428
*
@@ -486,9 +500,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
486500
*
487501
* @code{c}
488502
* size_t xMessageBufferReceive( MessageBufferHandle_t xMessageBuffer,
489-
* void *pvRxData,
490-
* size_t xBufferLengthBytes,
491-
* TickType_t xTicksToWait );
503+
* void *pvRxData,
504+
* size_t xBufferLengthBytes,
505+
* TickType_t xTicksToWait );
492506
* @endcode
493507
*
494508
* Receives a discrete message from a message buffer. Messages can be of
@@ -513,6 +527,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
513527
* xMessageBufferReceiveFromISR() to read from a message buffer from an
514528
* interrupt service routine (ISR).
515529
*
530+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
531+
* xMessageBufferReceive() to be available.
532+
*
516533
* @param xMessageBuffer The handle of the message buffer from which a message
517534
* is being received.
518535
*
@@ -576,9 +593,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
576593
*
577594
* @code{c}
578595
* size_t xMessageBufferReceiveFromISR( MessageBufferHandle_t xMessageBuffer,
579-
* void *pvRxData,
580-
* size_t xBufferLengthBytes,
581-
* BaseType_t *pxHigherPriorityTaskWoken );
596+
* void *pvRxData,
597+
* size_t xBufferLengthBytes,
598+
* BaseType_t *pxHigherPriorityTaskWoken );
582599
* @endcode
583600
*
584601
* An interrupt safe version of the API function that receives a discrete
@@ -604,6 +621,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
604621
* xMessageBufferReceiveFromISR() to read from a message buffer from an
605622
* interrupt service routine (ISR).
606623
*
624+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
625+
* xMessageBufferReceiveFromISR() to be available.
626+
*
607627
* @param xMessageBuffer The handle of the message buffer from which a message
608628
* is being received.
609629
*
@@ -687,6 +707,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
687707
* A message buffer handle must not be used after the message buffer has been
688708
* deleted.
689709
*
710+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
711+
* vMessageBufferDelete() to be available.
712+
*
690713
* @param xMessageBuffer The handle of the message buffer to be deleted.
691714
*
692715
*/
@@ -703,6 +726,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
703726
* cannot accept any more messages, of any size, until space is made available
704727
* by a message being removed from the message buffer.
705728
*
729+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
730+
* xMessageBufferIsFull() to be available.
731+
*
706732
* @param xMessageBuffer The handle of the message buffer being queried.
707733
*
708734
* @return If the message buffer referenced by xMessageBuffer is full then
@@ -719,6 +745,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
719745
*
720746
* Tests to see if a message buffer is empty (does not contain any messages).
721747
*
748+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
749+
* xMessageBufferIsEmpty() to be available.
750+
*
722751
* @param xMessageBuffer The handle of the message buffer being queried.
723752
*
724753
* @return If the message buffer referenced by xMessageBuffer is empty then
@@ -739,6 +768,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
739768
*
740769
* A message buffer can only be reset if there are no tasks blocked on it.
741770
*
771+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
772+
* xMessageBufferReset() to be available.
773+
*
742774
* @param xMessageBuffer The handle of the message buffer being reset.
743775
*
744776
* @return If the message buffer was reset then pdPASS is returned. If the
@@ -760,6 +792,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
760792
* @endcode
761793
* Returns the number of bytes of free space in the message buffer.
762794
*
795+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
796+
* xMessageBufferSpaceAvailable() to be available.
797+
*
763798
* @param xMessageBuffer The handle of the message buffer being queried.
764799
*
765800
* @return The number of bytes that can be written to the message buffer before
@@ -786,6 +821,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
786821
* Useful if xMessageBufferReceive() returned 0 because the size of the buffer
787822
* passed into xMessageBufferReceive() was too small to hold the next message.
788823
*
824+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
825+
* xMessageBufferNextLengthBytes() to be available.
826+
*
789827
* @param xMessageBuffer The handle of the message buffer being queried.
790828
*
791829
* @return The length (in bytes) of the next message in the message buffer, or 0
@@ -817,6 +855,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
817855
* See the example implemented in FreeRTOS/Demo/Minimal/MessageBufferAMP.c for
818856
* additional information.
819857
*
858+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
859+
* xMessageBufferSendCompletedFromISR() to be available.
860+
*
820861
* @param xMessageBuffer The handle of the stream buffer to which data was
821862
* written.
822863
*
@@ -858,6 +899,9 @@ typedef StreamBufferHandle_t MessageBufferHandle_t;
858899
* See the example implemented in FreeRTOS/Demo/Minimal/MessageBufferAMP.c for
859900
* additional information.
860901
*
902+
* configUSE_STREAM_BUFFERS must be set to 1 in for FreeRTOSConfig.h for
903+
* xMessageBufferReceiveCompletedFromISR() to be available.
904+
*
861905
* @param xMessageBuffer The handle of the stream buffer from which data was
862906
* read.
863907
*

0 commit comments

Comments
 (0)