Skip to content

Commit 1947dd2

Browse files
glemcoactions-userAniruddhaKanhereaggarg
authored
Added ability to change task notification index for streambuffers (#939)
* Added possibility to change notification index for streambuffers * Uncrustify: triggered by comment. * Minor code review suggestions. Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> --------- Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
1 parent 4568507 commit 1947dd2

File tree

3 files changed

+183
-70
lines changed

3 files changed

+183
-70
lines changed

include/FreeRTOS.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,6 +2509,22 @@
25092509
#define traceRETURN_xStreamBufferReceiveCompletedFromISR( xReturn )
25102510
#endif
25112511

2512+
#ifndef traceENTER_uxStreamBufferGetStreamBufferNotificationIndex
2513+
#define traceENTER_uxStreamBufferGetStreamBufferNotificationIndex( xStreamBuffer )
2514+
#endif
2515+
2516+
#ifndef traceRETURN_uxStreamBufferGetStreamBufferNotificationIndex
2517+
#define traceRETURN_uxStreamBufferGetStreamBufferNotificationIndex( uxNotificationIndex )
2518+
#endif
2519+
2520+
#ifndef traceENTER_vStreamBufferSetStreamBufferNotificationIndex
2521+
#define traceENTER_vStreamBufferSetStreamBufferNotificationIndex( xStreamBuffer, uxNotificationIndex )
2522+
#endif
2523+
2524+
#ifndef traceRETURN_vStreamBufferSetStreamBufferNotificationIndex
2525+
#define traceRETURN_vStreamBufferSetStreamBufferNotificationIndex()
2526+
#endif
2527+
25122528
#ifndef traceENTER_uxStreamBufferGetStreamBufferNumber
25132529
#define traceENTER_uxStreamBufferGetStreamBufferNumber( xStreamBuffer )
25142530
#endif
@@ -3271,6 +3287,7 @@ typedef struct xSTATIC_STREAM_BUFFER
32713287
#if ( configUSE_SB_COMPLETED_CALLBACK == 1 )
32723288
void * pvDummy5[ 2 ];
32733289
#endif
3290+
UBaseType_t uxDummy6;
32743291
} StaticStreamBuffer_t;
32753292

32763293
/* Message buffers are built on stream buffers. */

include/stream_buffer.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,57 @@ BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer
911911
BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer,
912912
BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
913913

914+
/**
915+
* stream_buffer.h
916+
*
917+
* @code{c}
918+
* UBaseType_t uxStreamBufferGetStreamBufferNotificationIndex( StreamBufferHandle_t xStreamBuffer );
919+
* @endcode
920+
*
921+
* Get the task notification index used for the supplied stream buffer which can
922+
* be set using vStreamBufferSetStreamBufferNotificationIndex. If the task
923+
* notification index for the stream buffer is not changed using
924+
* vStreamBufferSetStreamBufferNotificationIndex, this function returns the
925+
* default value (tskDEFAULT_INDEX_TO_NOTIFY).
926+
*
927+
* @param xStreamBuffer The handle of the stream buffer for which the task
928+
* notification index is retrieved.
929+
*
930+
* @return The task notification index for the stream buffer.
931+
*
932+
* \defgroup uxStreamBufferGetStreamBufferNotificationIndex uxStreamBufferGetStreamBufferNotificationIndex
933+
* \ingroup StreamBufferManagement
934+
*/
935+
UBaseType_t uxStreamBufferGetStreamBufferNotificationIndex( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
936+
937+
/**
938+
* stream_buffer.h
939+
*
940+
* @code{c}
941+
* void vStreamBufferSetStreamBufferNotificationIndex ( StreamBuffer_t xStreamBuffer, UBaseType_t uxNotificationIndex );
942+
* @endcode
943+
*
944+
* Set the task notification index used for the supplied stream buffer.
945+
* Successive calls to stream buffer APIs (like xStreamBufferSend or
946+
* xStreamBufferReceive) for this stream buffer will use this new index for
947+
* their task notifications.
948+
*
949+
* If this function is not called, the default index (tskDEFAULT_INDEX_TO_NOTIFY)
950+
* is used for task notifications. It is recommended to call this function
951+
* before attempting to send or receive data from the stream buffer to avoid
952+
* inconsistencies.
953+
*
954+
* @param xStreamBuffer The handle of the stream buffer for which the task
955+
* notification index is set.
956+
*
957+
* @param uxNotificationIndex The task notification index to set.
958+
*
959+
* \defgroup vStreamBufferSetStreamBufferNotificationIndex vStreamBufferSetStreamBufferNotificationIndex
960+
* \ingroup StreamBufferManagement
961+
*/
962+
void vStreamBufferSetStreamBufferNotificationIndex( StreamBufferHandle_t xStreamBuffer,
963+
UBaseType_t uxNotificationIndex ) PRIVILEGED_FUNCTION;
964+
914965
/* Functions below here are not part of the public API. */
915966
StreamBufferHandle_t xStreamBufferGenericCreate( size_t xBufferSizeBytes,
916967
size_t xTriggerLevelBytes,

0 commit comments

Comments
 (0)