Skip to content

File stream_buffer.c

FileList > FreeRTOS > src > stream_buffer.c

Go to the source code of this file.

  • #include <stdint.h>
  • #include <string.h>
  • #include "FreeRTOS.h"
  • #include "task.h"
  • #include "stream_buffer.h"

Classes

Type Name
struct StreamBufferDef_t

Public Types

Type Name
typedef struct StreamBufferDef_t StreamBuffer_t

Public Functions

Type Name
void vStreamBufferDelete (StreamBufferHandle_t xStreamBuffer)
size_t xStreamBufferBytesAvailable (StreamBufferHandle_t xStreamBuffer)
BaseType_t xStreamBufferIsEmpty (StreamBufferHandle_t xStreamBuffer)
BaseType_t xStreamBufferIsFull (StreamBufferHandle_t xStreamBuffer)
size_t xStreamBufferNextMessageLengthBytes (StreamBufferHandle_t xStreamBuffer)
size_t xStreamBufferReceive (StreamBufferHandle_t xStreamBuffer, void * pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait)
BaseType_t xStreamBufferReceiveCompletedFromISR (StreamBufferHandle_t xStreamBuffer, BaseType_t * pxHigherPriorityTaskWoken)
size_t xStreamBufferReceiveFromISR (StreamBufferHandle_t xStreamBuffer, void * pvRxData, size_t xBufferLengthBytes, BaseType_t *const pxHigherPriorityTaskWoken)
BaseType_t xStreamBufferReset (StreamBufferHandle_t xStreamBuffer)
size_t xStreamBufferSend (StreamBufferHandle_t xStreamBuffer, const void * pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait)
BaseType_t xStreamBufferSendCompletedFromISR (StreamBufferHandle_t xStreamBuffer, BaseType_t * pxHigherPriorityTaskWoken)
size_t xStreamBufferSendFromISR (StreamBufferHandle_t xStreamBuffer, const void * pvTxData, size_t xDataLengthBytes, BaseType_t *const pxHigherPriorityTaskWoken)
BaseType_t xStreamBufferSetTriggerLevel (StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel)
size_t xStreamBufferSpacesAvailable (StreamBufferHandle_t xStreamBuffer)

Public Static Functions

Type Name
size_t prvBytesInBuffer (const StreamBuffer_t *const pxStreamBuffer)
void prvInitialiseNewStreamBuffer (StreamBuffer_t *const pxStreamBuffer, uint8_t *const pucBuffer, size_t xBufferSizeBytes, size_t xTriggerLevelBytes, uint8_t ucFlags)
size_t prvReadBytesFromBuffer (StreamBuffer_t * pxStreamBuffer, uint8_t * pucData, size_t xMaxCount, size_t xBytesAvailable)
size_t prvReadMessageFromBuffer (StreamBuffer_t * pxStreamBuffer, void * pvRxData, size_t xBufferLengthBytes, size_t xBytesAvailable, size_t xBytesToStoreMessageLength)
size_t prvWriteBytesToBuffer (StreamBuffer_t *const pxStreamBuffer, const uint8_t * pucData, size_t xCount)
size_t prvWriteMessageToBuffer (StreamBuffer_t *const pxStreamBuffer, const void * pvTxData, size_t xDataLengthBytes, size_t xSpace, size_t xRequiredSpace)

Macros

Type Name
define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
define sbBYTES_TO_STORE_MESSAGE_LENGTH ( sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) )
define sbFLAGS_IS_MESSAGE_BUFFER ( ( uint8_t ) 1 ) /* Set if the stream buffer was created as a message buffer, in which case it holds discrete messages rather than a stream. */
define sbFLAGS_IS_STATICALLY_ALLOCATED ( ( uint8_t ) 2 ) /* Set if the stream buffer was created using statically allocated memory. */
define sbRECEIVE_COMPLETED (pxStreamBuffer)
define sbRECEIVE_COMPLETED_FROM_ISR (pxStreamBuffer, pxHigherPriorityTaskWoken)
define sbSEND_COMPLETED (pxStreamBuffer)
define sbSEND_COMPLETE_FROM_ISR (pxStreamBuffer, pxHigherPriorityTaskWoken)

Public Types Documentation

typedef StreamBuffer_t

typedef struct StreamBufferDef_t StreamBuffer_t;

Public Functions Documentation

function vStreamBufferDelete

void vStreamBufferDelete (
    StreamBufferHandle_t xStreamBuffer
) 

function xStreamBufferBytesAvailable

size_t xStreamBufferBytesAvailable (
    StreamBufferHandle_t xStreamBuffer
) 

function xStreamBufferIsEmpty

BaseType_t xStreamBufferIsEmpty (
    StreamBufferHandle_t xStreamBuffer
) 

function xStreamBufferIsFull

BaseType_t xStreamBufferIsFull (
    StreamBufferHandle_t xStreamBuffer
) 

function xStreamBufferNextMessageLengthBytes

size_t xStreamBufferNextMessageLengthBytes (
    StreamBufferHandle_t xStreamBuffer
) 

function xStreamBufferReceive

size_t xStreamBufferReceive (
    StreamBufferHandle_t xStreamBuffer,
    void * pvRxData,
    size_t xBufferLengthBytes,
    TickType_t xTicksToWait
) 

function xStreamBufferReceiveCompletedFromISR

BaseType_t xStreamBufferReceiveCompletedFromISR (
    StreamBufferHandle_t xStreamBuffer,
    BaseType_t * pxHigherPriorityTaskWoken
) 

function xStreamBufferReceiveFromISR

size_t xStreamBufferReceiveFromISR (
    StreamBufferHandle_t xStreamBuffer,
    void * pvRxData,
    size_t xBufferLengthBytes,
    BaseType_t *const pxHigherPriorityTaskWoken
) 

function xStreamBufferReset

BaseType_t xStreamBufferReset (
    StreamBufferHandle_t xStreamBuffer
) 

function xStreamBufferSend

size_t xStreamBufferSend (
    StreamBufferHandle_t xStreamBuffer,
    const void * pvTxData,
    size_t xDataLengthBytes,
    TickType_t xTicksToWait
) 

function xStreamBufferSendCompletedFromISR

BaseType_t xStreamBufferSendCompletedFromISR (
    StreamBufferHandle_t xStreamBuffer,
    BaseType_t * pxHigherPriorityTaskWoken
) 

function xStreamBufferSendFromISR

size_t xStreamBufferSendFromISR (
    StreamBufferHandle_t xStreamBuffer,
    const void * pvTxData,
    size_t xDataLengthBytes,
    BaseType_t *const pxHigherPriorityTaskWoken
) 

function xStreamBufferSetTriggerLevel

BaseType_t xStreamBufferSetTriggerLevel (
    StreamBufferHandle_t xStreamBuffer,
    size_t xTriggerLevel
) 

function xStreamBufferSpacesAvailable

size_t xStreamBufferSpacesAvailable (
    StreamBufferHandle_t xStreamBuffer
) 

Public Static Functions Documentation

function prvBytesInBuffer

static size_t prvBytesInBuffer (
    const StreamBuffer_t *const pxStreamBuffer
) 

function prvInitialiseNewStreamBuffer

static void prvInitialiseNewStreamBuffer (
    StreamBuffer_t *const pxStreamBuffer,
    uint8_t *const pucBuffer,
    size_t xBufferSizeBytes,
    size_t xTriggerLevelBytes,
    uint8_t ucFlags
) 

function prvReadBytesFromBuffer

static size_t prvReadBytesFromBuffer (
    StreamBuffer_t * pxStreamBuffer,
    uint8_t * pucData,
    size_t xMaxCount,
    size_t xBytesAvailable
) 

function prvReadMessageFromBuffer

static size_t prvReadMessageFromBuffer (
    StreamBuffer_t * pxStreamBuffer,
    void * pvRxData,
    size_t xBufferLengthBytes,
    size_t xBytesAvailable,
    size_t xBytesToStoreMessageLength
) 

function prvWriteBytesToBuffer

static size_t prvWriteBytesToBuffer (
    StreamBuffer_t *const pxStreamBuffer,
    const uint8_t * pucData,
    size_t xCount
) 

function prvWriteMessageToBuffer

static size_t prvWriteMessageToBuffer (
    StreamBuffer_t *const pxStreamBuffer,
    const void * pvTxData,
    size_t xDataLengthBytes,
    size_t xSpace,
    size_t xRequiredSpace
) 

Macro Definition Documentation

define MPU_WRAPPERS_INCLUDED_FROM_API_FILE

#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE 

define sbBYTES_TO_STORE_MESSAGE_LENGTH

#define sbBYTES_TO_STORE_MESSAGE_LENGTH ( sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) )

define sbFLAGS_IS_MESSAGE_BUFFER

#define sbFLAGS_IS_MESSAGE_BUFFER ( ( uint8_t ) 1 ) /* Set if the stream buffer was created as a message buffer, in which case it holds discrete messages rather than a stream. */

define sbFLAGS_IS_STATICALLY_ALLOCATED

#define sbFLAGS_IS_STATICALLY_ALLOCATED ( ( uint8_t ) 2 ) /* Set if the stream buffer was created using statically allocated memory. */

define sbRECEIVE_COMPLETED

#define sbRECEIVE_COMPLETED (
    pxStreamBuffer
) vTaskSuspendAll();                                                                \
        {                                                                               \
            if( ( pxStreamBuffer )->xTaskWaitingToSend != NULL )                        \
            {                                                                           \
                ( void ) xTaskNotify( ( pxStreamBuffer )->xTaskWaitingToSend,           \
                                      ( uint32_t ) 0,                                   \
                                      eNoAction );                                      \
                ( pxStreamBuffer )->xTaskWaitingToSend = NULL;                          \
            }                                                                           \
        }                                                                               \
        ( void ) xTaskResumeAll();

define sbRECEIVE_COMPLETED_FROM_ISR

#define sbRECEIVE_COMPLETED_FROM_ISR (
    pxStreamBuffer,
    pxHigherPriorityTaskWoken
) {                                                                                 \
    UBaseType_t uxSavedInterruptStatus;                                                 \
                                                                                        \
        uxSavedInterruptStatus = ( UBaseType_t ) portSET_INTERRUPT_MASK_FROM_ISR();     \
        {                                                                               \
            if( ( pxStreamBuffer )->xTaskWaitingToSend != NULL )                        \
            {                                                                           \
                ( void ) xTaskNotifyFromISR( ( pxStreamBuffer )->xTaskWaitingToSend,    \
                                             ( uint32_t ) 0,                            \
                                             eNoAction,                                 \
                                             pxHigherPriorityTaskWoken );               \
                ( pxStreamBuffer )->xTaskWaitingToSend = NULL;                          \
            }                                                                           \
        }                                                                               \
        portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );                    \
    }

define sbSEND_COMPLETED

#define sbSEND_COMPLETED (
    pxStreamBuffer
) vTaskSuspendAll();                                                                \
        {                                                                               \
            if( ( pxStreamBuffer )->xTaskWaitingToReceive != NULL )                     \
            {                                                                           \
                ( void ) xTaskNotify( ( pxStreamBuffer )->xTaskWaitingToReceive,        \
                                      ( uint32_t ) 0,                                   \
                                      eNoAction );                                      \
                ( pxStreamBuffer )->xTaskWaitingToReceive = NULL;                       \
            }                                                                           \
        }                                                                               \
        ( void ) xTaskResumeAll();

define sbSEND_COMPLETE_FROM_ISR

#define sbSEND_COMPLETE_FROM_ISR (
    pxStreamBuffer,
    pxHigherPriorityTaskWoken
) {                                                                                 \
    UBaseType_t uxSavedInterruptStatus;                                                 \
                                                                                        \
        uxSavedInterruptStatus = ( UBaseType_t ) portSET_INTERRUPT_MASK_FROM_ISR();     \
        {                                                                               \
            if( ( pxStreamBuffer )->xTaskWaitingToReceive != NULL )                     \
            {                                                                           \
                ( void ) xTaskNotifyFromISR( ( pxStreamBuffer )->xTaskWaitingToReceive, \
                                             ( uint32_t ) 0,                            \
                                             eNoAction,                                 \
                                             pxHigherPriorityTaskWoken );               \
                ( pxStreamBuffer )->xTaskWaitingToReceive = NULL;                       \
            }                                                                           \
        }                                                                               \
        portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );                    \
    }

The documentation for this class was generated from the following file fw/rbcx-coprocessor/lib/FreeRTOS/src/stream_buffer.c