36 #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE 47 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE 53 #ifndef sbRECEIVE_COMPLETED 54 #define sbRECEIVE_COMPLETED( pxStreamBuffer ) \ 57 if( ( pxStreamBuffer )->xTaskWaitingToSend != NULL ) \ 59 ( void ) xTaskNotify( ( pxStreamBuffer )->xTaskWaitingToSend, \ 62 ( pxStreamBuffer )->xTaskWaitingToSend = NULL; \ 65 ( void ) xTaskResumeAll(); 68 #ifndef sbRECEIVE_COMPLETED_FROM_ISR 69 #define sbRECEIVE_COMPLETED_FROM_ISR( pxStreamBuffer, \ 70 pxHigherPriorityTaskWoken ) \ 72 UBaseType_t uxSavedInterruptStatus; \ 74 uxSavedInterruptStatus = ( UBaseType_t ) portSET_INTERRUPT_MASK_FROM_ISR(); \ 76 if( ( pxStreamBuffer )->xTaskWaitingToSend != NULL ) \ 78 ( void ) xTaskNotifyFromISR( ( pxStreamBuffer )->xTaskWaitingToSend, \ 81 pxHigherPriorityTaskWoken ); \ 82 ( pxStreamBuffer )->xTaskWaitingToSend = NULL; \ 85 portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); \ 92 #ifndef sbSEND_COMPLETED 93 #define sbSEND_COMPLETED( pxStreamBuffer ) \ 96 if( ( pxStreamBuffer )->xTaskWaitingToReceive != NULL ) \ 98 ( void ) xTaskNotify( ( pxStreamBuffer )->xTaskWaitingToReceive, \ 101 ( pxStreamBuffer )->xTaskWaitingToReceive = NULL; \ 104 ( void ) xTaskResumeAll(); 107 #ifndef sbSEND_COMPLETE_FROM_ISR 108 #define sbSEND_COMPLETE_FROM_ISR( pxStreamBuffer, pxHigherPriorityTaskWoken ) \ 110 UBaseType_t uxSavedInterruptStatus; \ 112 uxSavedInterruptStatus = ( UBaseType_t ) portSET_INTERRUPT_MASK_FROM_ISR(); \ 114 if( ( pxStreamBuffer )->xTaskWaitingToReceive != NULL ) \ 116 ( void ) xTaskNotifyFromISR( ( pxStreamBuffer )->xTaskWaitingToReceive, \ 119 pxHigherPriorityTaskWoken ); \ 120 ( pxStreamBuffer )->xTaskWaitingToReceive = NULL; \ 123 portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); \ 129 #define sbBYTES_TO_STORE_MESSAGE_LENGTH ( sizeof( size_t ) ) 132 #define sbFLAGS_IS_MESSAGE_BUFFER ( ( uint8_t ) 1 ) 133 #define sbFLAGS_IS_STATICALLY_ALLOCATED ( ( uint8_t ) 2 ) 149 #if ( configUSE_TRACE_FACILITY == 1 ) 176 size_t xBufferLengthBytes,
177 size_t xBytesAvailable,
188 const void * pvTxData,
189 size_t xDataLengthBytes,
208 size_t xBufferSizeBytes,
214 #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) 218 uint8_t *pucAllocatedMemory;
229 if( xTriggerLevelBytes == (
size_t ) 0 )
231 xTriggerLevelBytes = ( size_t ) 1;
245 if( pucAllocatedMemory !=
NULL )
266 #if( configSUPPORT_STATIC_ALLOCATION == 1 ) 269 size_t xTriggerLevelBytes,
271 uint8_t *
const pucStreamBufferStorageArea,
283 if( xTriggerLevelBytes == (
size_t ) 0 )
285 xTriggerLevelBytes = ( size_t ) 1;
294 #if( configASSERT_DEFINED == 1 ) 304 if( ( pucStreamBufferStorageArea !=
NULL ) && ( pxStaticStreamBuffer !=
NULL ) )
307 pucStreamBufferStorageArea,
342 #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) 370 #if( configUSE_TRACE_FACILITY == 1 ) 376 #if( configUSE_TRACE_FACILITY == 1 ) 380 uxStreamBufferNumber = pxStreamBuffer->uxStreamBufferNumber;
391 xIsMessageBuffer =
pdTRUE;
405 #if( configUSE_TRACE_FACILITY == 1 ) 407 pxStreamBuffer->uxStreamBufferNumber = uxStreamBufferNumber;
427 if( xTriggerLevel == (
size_t ) 0 )
429 xTriggerLevel = ( size_t ) 1;
434 if( xTriggerLevel <= pxStreamBuffer->
xLength )
455 xSpace = pxStreamBuffer->
xLength + pxStreamBuffer->
xTail;
456 xSpace -= pxStreamBuffer->
xHead;
457 xSpace -= ( size_t ) 1;
459 if( xSpace >= pxStreamBuffer->
xLength )
461 xSpace -= pxStreamBuffer->
xLength;
485 const void *pvTxData,
486 size_t xDataLengthBytes,
490 size_t xReturn, xSpace = 0;
491 size_t xRequiredSpace = xDataLengthBytes;
522 if( xSpace < xRequiredSpace )
550 if( xSpace == (
size_t ) 0 )
561 if( xReturn > (
size_t ) 0 )
586 const void *pvTxData,
587 size_t xDataLengthBytes,
588 BaseType_t *
const pxHigherPriorityTaskWoken )
591 size_t xReturn, xSpace;
592 size_t xRequiredSpace = xDataLengthBytes;
613 if( xReturn > (
size_t ) 0 )
637 const void * pvTxData,
638 size_t xDataLengthBytes,
640 size_t xRequiredSpace )
645 if( xSpace == (
size_t ) 0 )
657 xDataLengthBytes =
configMIN( xDataLengthBytes, xSpace );
659 else if( xSpace >= xRequiredSpace )
690 size_t xBufferLengthBytes,
694 size_t xReceivedLength = 0, xBytesAvailable, xBytesToStoreMessageLength;
710 xBytesToStoreMessageLength = 0;
726 if( xBytesAvailable <= xBytesToStoreMessageLength )
742 if( xBytesAvailable <= xBytesToStoreMessageLength )
767 if( xBytesAvailable > xBytesToStoreMessageLength )
769 xReceivedLength =
prvReadMessageFromBuffer( pxStreamBuffer, pvRxData, xBufferLengthBytes, xBytesAvailable, xBytesToStoreMessageLength );
772 if( xReceivedLength != (
size_t ) 0 )
788 return xReceivedLength;
794 size_t xBufferLengthBytes,
795 BaseType_t *
const pxHigherPriorityTaskWoken )
798 size_t xReceivedLength = 0, xBytesAvailable, xBytesToStoreMessageLength;
814 xBytesToStoreMessageLength = 0;
824 if( xBytesAvailable > xBytesToStoreMessageLength )
826 xReceivedLength =
prvReadMessageFromBuffer( pxStreamBuffer, pvRxData, xBufferLengthBytes, xBytesAvailable, xBytesToStoreMessageLength );
829 if( xReceivedLength != (
size_t ) 0 )
845 return xReceivedLength;
851 size_t xBufferLengthBytes,
852 size_t xBytesAvailable,
853 size_t xBytesToStoreMessageLength )
855 size_t xOriginalTail, xReceivedLength, xNextMessageLength;
857 if( xBytesToStoreMessageLength != (
size_t ) 0 )
863 xOriginalTail = pxStreamBuffer->
xTail;
864 ( void )
prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xNextMessageLength, xBytesToStoreMessageLength, xBytesAvailable );
868 xBytesAvailable -= xBytesToStoreMessageLength;
872 if( xNextMessageLength > xBufferLengthBytes )
877 pxStreamBuffer->
xTail = xOriginalTail;
878 xNextMessageLength = 0;
889 xNextMessageLength = xBufferLengthBytes;
893 xReceivedLength =
prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) pvRxData, xNextMessageLength, xBytesAvailable );
895 return xReceivedLength;
908 xTail = pxStreamBuffer->
xTail;
909 if( pxStreamBuffer->
xHead == xTail )
925 size_t xBytesToStoreMessageLength;
940 xBytesToStoreMessageLength = 0;
967 if( ( pxStreamBuffer )->xTaskWaitingToReceive !=
NULL )
972 pxHigherPriorityTaskWoken );
997 if( ( pxStreamBuffer )->xTaskWaitingToSend !=
NULL )
1002 pxHigherPriorityTaskWoken );
1019 size_t xNextHead, xFirstLength;
1023 xNextHead = pxStreamBuffer->
xHead;
1032 memcpy( (
void* ) ( &( pxStreamBuffer->
pucBuffer[ xNextHead ] ) ), (
const void * ) pucData, xFirstLength );
1036 if( xCount > xFirstLength )
1040 memcpy( (
void * ) pxStreamBuffer->
pucBuffer, (
const void * ) &( pucData[ xFirstLength ] ), xCount - xFirstLength );
1047 xNextHead += xCount;
1048 if( xNextHead >= pxStreamBuffer->
xLength )
1050 xNextHead -= pxStreamBuffer->
xLength;
1057 pxStreamBuffer->
xHead = xNextHead;
1065 size_t xCount, xFirstLength, xNextTail;
1068 xCount =
configMIN( xBytesAvailable, xMaxCount );
1070 if( xCount > (
size_t ) 0 )
1072 xNextTail = pxStreamBuffer->
xTail;
1083 memcpy( (
void * ) pucData, (
const void * ) &( pxStreamBuffer->
pucBuffer[ xNextTail ] ), xFirstLength );
1087 if( xCount > xFirstLength )
1091 memcpy( (
void * ) &( pucData[ xFirstLength ] ), (
void * ) ( pxStreamBuffer->
pucBuffer ), xCount - xFirstLength );
1100 xNextTail += xCount;
1102 if( xNextTail >= pxStreamBuffer->
xLength )
1104 xNextTail -= pxStreamBuffer->
xLength;
1107 pxStreamBuffer->
xTail = xNextTail;
1123 xCount = pxStreamBuffer->
xLength + pxStreamBuffer->
xHead;
1124 xCount -= pxStreamBuffer->
xTail;
1125 if ( xCount >= pxStreamBuffer->
xLength )
1127 xCount -= pxStreamBuffer->
xLength;
1140 size_t xBufferSizeBytes,
1141 size_t xTriggerLevelBytes,
1147 #if( configASSERT_DEFINED == 1 ) 1153 configASSERT( memset( pucBuffer, (
int ) xWriteValue, xBufferSizeBytes ) == pucBuffer );
1157 memset( (
void * ) pxStreamBuffer, 0x00,
sizeof(
StreamBuffer_t ) );
1159 pxStreamBuffer->xLength = xBufferSizeBytes;
1162 if( xIsMessageBuffer !=
pdFALSE )
1168 #if ( configUSE_TRACE_FACILITY == 1 ) 1172 return ( (
StreamBuffer_t * ) xStreamBuffer )->uxStreamBufferNumber;
1178 #if ( configUSE_TRACE_FACILITY == 1 ) 1182 ( (
StreamBuffer_t * ) xStreamBuffer )->uxStreamBufferNumber = uxStreamBufferNumber;
1188 #if ( configUSE_TRACE_FACILITY == 1 )
size_t xStreamBufferSendFromISR(StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, BaseType_t *const pxHigherPriorityTaskWoken)
volatile TaskHandle_t xTaskWaitingToReceive
void vPortFree(void *pv) PRIVILEGED_FUNCTION
size_t xStreamBufferReceive(StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait)
TaskHandle_t xTaskGetCurrentTaskHandle(void) PRIVILEGED_FUNCTION
#define traceBLOCKING_ON_STREAM_BUFFER_SEND(xStreamBuffer)
#define sbRECEIVE_COMPLETED(pxStreamBuffer)
size_t xStreamBufferSpacesAvailable(StreamBufferHandle_t xStreamBuffer)
BaseType_t xStreamBufferReceiveCompletedFromISR(StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken)
#define sbFLAGS_IS_MESSAGE_BUFFER
#define taskEXIT_CRITICAL()
BaseType_t xStreamBufferIsEmpty(StreamBufferHandle_t xStreamBuffer)
struct xSTATIC_STREAM_BUFFER StaticStreamBuffer_t
void * pvPortMalloc(size_t xSize) PRIVILEGED_FUNCTION
struct xSTREAM_BUFFER StreamBuffer_t
#define traceSTREAM_BUFFER_RECEIVE(xStreamBuffer, xReceivedLength)
size_t xStreamBufferReceiveFromISR(StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, BaseType_t *const pxHigherPriorityTaskWoken)
static PRIVILEGED_FUNCTION void prvInitialiseNewStreamBuffer(StreamBuffer_t *const pxStreamBuffer, uint8_t *const pucBuffer, size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer) PRIVILEGED_FUNCTION
#define xTaskNotifyFromISR(xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken)
unsigned long UBaseType_t
size_t xStreamBufferBytesAvailable(StreamBufferHandle_t xStreamBuffer)
#define traceSTREAM_BUFFER_RECEIVE_FAILED(xStreamBuffer)
static size_t prvReadMessageFromBuffer(StreamBuffer_t *pxStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, size_t xBytesAvailable, size_t xBytesToStoreMessageLength) PRIVILEGED_FUNCTION
#define portSET_INTERRUPT_MASK_FROM_ISR()
size_t xStreamBufferSend(StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait)
BaseType_t xTaskNotifyWait(uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait) PRIVILEGED_FUNCTION
#define traceSTREAM_BUFFER_SEND_FROM_ISR(xStreamBuffer, xBytesSent)
#define sbSEND_COMPLETE_FROM_ISR(pxStreamBuffer, pxHigherPriorityTaskWoken)
#define sbSEND_COMPLETED(pxStreamBuffer)
#define traceSTREAM_BUFFER_DELETE(xStreamBuffer)
size_t xTriggerLevelBytes
#define traceSTREAM_BUFFER_SEND(xStreamBuffer, xBytesSent)
BaseType_t xStreamBufferSetTriggerLevel(StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel)
#define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE(xStreamBuffer)
#define sbBYTES_TO_STORE_MESSAGE_LENGTH
static size_t prvReadBytesFromBuffer(StreamBuffer_t *pxStreamBuffer, uint8_t *pucData, size_t xMaxCount, size_t xBytesAvailable)
BaseType_t xStreamBufferIsFull(StreamBufferHandle_t xStreamBuffer)
#define traceSTREAM_BUFFER_CREATE(pxStreamBuffer, xIsMessageBuffer)
BaseType_t xTaskNotifyStateClear(TaskHandle_t xTask)
#define sbFLAGS_IS_STATICALLY_ALLOCATED
#define taskENTER_CRITICAL()
volatile TaskHandle_t xTaskWaitingToSend
static size_t prvWriteMessageToBuffer(StreamBuffer_t *const pxStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, size_t xSpace, size_t xRequiredSpace) PRIVILEGED_FUNCTION
BaseType_t xStreamBufferSendCompletedFromISR(StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken)
void vTaskSetTimeOutState(TimeOut_t *const pxTimeOut) PRIVILEGED_FUNCTION
BaseType_t xStreamBufferReset(StreamBufferHandle_t xStreamBuffer)
static size_t prvWriteBytesToBuffer(StreamBuffer_t *const pxStreamBuffer, const uint8_t *pucData, size_t xCount) PRIVILEGED_FUNCTION
#define traceSTREAM_BUFFER_RECEIVE_FROM_ISR(xStreamBuffer, xReceivedLength)
#define traceSTREAM_BUFFER_CREATE_STATIC_FAILED(xReturn, xIsMessageBuffer)
void * StreamBufferHandle_t
#define PRIVILEGED_FUNCTION
void vStreamBufferDelete(StreamBufferHandle_t xStreamBuffer)
StreamBufferHandle_t xStreamBufferGenericCreateStatic(size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer, uint8_t *const pucStreamBufferStorageArea, StaticStreamBuffer_t *const pxStaticStreamBuffer) PRIVILEGED_FUNCTION
#define mtCOVERAGE_TEST_MARKER()
BaseType_t xTaskCheckForTimeOut(TimeOut_t *const pxTimeOut, TickType_t *const pxTicksToWait) PRIVILEGED_FUNCTION
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(uxSavedStatusValue)
#define traceSTREAM_BUFFER_RESET(xStreamBuffer)
StreamBufferHandle_t xStreamBufferGenericCreate(size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer) PRIVILEGED_FUNCTION
#define traceSTREAM_BUFFER_SEND_FAILED(xStreamBuffer)
#define traceSTREAM_BUFFER_CREATE_FAILED(xIsMessageBuffer)
#define sbRECEIVE_COMPLETED_FROM_ISR(pxStreamBuffer, pxHigherPriorityTaskWoken)
static size_t prvBytesInBuffer(const StreamBuffer_t *const pxStreamBuffer) PRIVILEGED_FUNCTION