Chapter 2. API Reference
memory available for FreeRTOS to allocate the stream buffer data structures and storage area. A non-
NULL value being returned indicates that the stream buffer has been created successfully - the returned
value should be stored as the handle to the created stream buffer.
Parameters
• xBufferSizeBytes: The total number of bytes the stream buffer will be able to hold at any one
time.
• xTriggerLevelBytes: The number of bytes that must be in the stream buffer before a task
that is blocked on the stream buffer to wait for data is moved out of the blocked state. For example,
if a task is blocked on a read of an empty stream buffer that has a trigger level of 1 then the task
will be unblocked when a single byte is written to the buffer or the task's block time expires. As
another example, if a task is blocked on a read of an empty stream buffer that has a trigger level of
10 then the task will not be unblocked until the stream buffer contains at least 10 bytes or the task'
s block time expires. If a reading task's block time expires before the trigger level is reached then
the task will still receive however many bytes are actually available. Setting a trigger level of 0 will
result in a trigger level of 1 being used. It is not valid to specify a trigger level that is greater than
the buffer size.
xStreamBufferCreateStatic(xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea,
Creates a new stream buffer using statically allocated memory. See xStreamBufferCreate() for a version that
uses dynamically allocated memory.
configSUPPORT_STATIC_ALLOCATION must be set to 1 in FreeRTOSConfig.h for xStreamBufferCreat-
eStatic() to be available.
Example use:
//
Used to dimension the array used to hold the
//
will actually be one less than this, so
#define STORAGE_SIZE_BYTES 1000
//
Defines the memory that will actually hold the streams within the stream
// buffer.
static uint8_t ucStorageBuffer[ STORAGE_SIZE_BYTES ];
//
The variable used to hold the stream buffer
StaticStreamBuffer_t xStreamBufferStruct;
void MyFunction( void )
{
StreamBufferHandle_t xStreamBuffer;
const size_t xTriggerLevel
xStreamBuffer
//
As neither the pucStreamBufferStorageArea
//
parameters were NULL, xStreamBuffer will
//
reference the created stream buffer
//
Other code that uses the stream buffer can go
}
Return If the stream buffer is created successfully then a handle to the created stream buffer is returned. If
either pucStreamBufferStorageArea or pxStaticstreamBuffer are NULL then NULL is returned.
Parameters
• xBufferSizeBytes: The size, in bytes, of the buffer pointed to by the pucStreamBufferStor-
ageArea parameter.
• xTriggerLevelBytes: The number of bytes that must be in the stream buffer before a task
that is blocked on the stream buffer to wait for data is moved out of the blocked state. For example,
if a task is blocked on a read of an empty stream buffer that has a trigger level of 1 then the task
Espressif Systems
pxStaticStreamBuffer)
=
1;
=
xStreamBufferCreateStatic( sizeof( ucBufferStorage ),
Submit Document Feedback
streams.
999.
structure.
xTriggerLevel,
ucBufferStorage,
&xStreamBufferStruct );
or
pxStaticStreamBuffer
not
be NULL,
in
other stream buffer API
here.
946
The available space
and
can be used to
calls.
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?
Questions and answers