MCPcopy Create free account
hub / github.com/FreeRTOS/FreeRTOS-Kernel / xStreamBufferReceiveFromISR

Function xStreamBufferReceiveFromISR

stream_buffer.c:901–955  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

899/*-----------------------------------------------------------*/
900
901size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
902 void * pvRxData,
903 size_t xBufferLengthBytes,
904 BaseType_t * const pxHigherPriorityTaskWoken )
905{
906 StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
907 size_t xReceivedLength = 0, xBytesAvailable, xBytesToStoreMessageLength;
908
909 configASSERT( pvRxData );
910 configASSERT( pxStreamBuffer );
911
912 /* This receive function is used by both message buffers, which store
913 * discrete messages, and stream buffers, which store a continuous stream of
914 * bytes. Discrete messages include an additional
915 * sbBYTES_TO_STORE_MESSAGE_LENGTH bytes that hold the length of the
916 * message. */
917 if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 )
918 {
919 xBytesToStoreMessageLength = sbBYTES_TO_STORE_MESSAGE_LENGTH;
920 }
921 else
922 {
923 xBytesToStoreMessageLength = 0;
924 }
925
926 xBytesAvailable = prvBytesInBuffer( pxStreamBuffer );
927
928 /* Whether receiving a discrete message (where xBytesToStoreMessageLength
929 * holds the number of bytes used to store the message length) or a stream of
930 * bytes (where xBytesToStoreMessageLength is zero), the number of bytes
931 * available must be greater than xBytesToStoreMessageLength to be able to
932 * read bytes from the buffer. */
933 if( xBytesAvailable > xBytesToStoreMessageLength )
934 {
935 xReceivedLength = prvReadMessageFromBuffer( pxStreamBuffer, pvRxData, xBufferLengthBytes, xBytesAvailable, xBytesToStoreMessageLength );
936
937 /* Was a task waiting for space in the buffer? */
938 if( xReceivedLength != ( size_t ) 0 )
939 {
940 sbRECEIVE_COMPLETED_FROM_ISR( pxStreamBuffer, pxHigherPriorityTaskWoken );
941 }
942 else
943 {
944 mtCOVERAGE_TEST_MARKER();
945 }
946 }
947 else
948 {
949 mtCOVERAGE_TEST_MARKER();
950 }
951
952 traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength );
953
954 return xReceivedLength;
955}
956/*-----------------------------------------------------------*/
957
958static size_t prvReadMessageFromBuffer( StreamBuffer_t * pxStreamBuffer,

Callers

nothing calls this directly

Calls 2

prvBytesInBufferFunction · 0.85
prvReadMessageFromBufferFunction · 0.85

Tested by

no test coverage detected