EasyManua.ls Logo

Espressif ESP32-S2 - Page 958

Espressif ESP32-S2
1695 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2. API Reference
will be unblocked when a single byte is written to the buffer or the tasks 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 tasks 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.
pucStreamBufferStorageArea: Must point to a uint8_t array that is at least xBufferSize-
Bytes + 1 big. This is the array to which streams are copied when they are written to the stream
buffer.
pxStaticStreamBuffer: Must point to a variable of type StaticStreamBuffer_t, which will
be used to hold the stream buffers data structure.
Type Definitions
typedef struct StreamBufferDef_t *StreamBufferHandle_t
Message Buffer API
Header File
components/freertos/include/freertos/message_buffer.h
Macros
xMessageBufferCreate(xBufferSizeBytes)
Creates a new message buffer using dynamically allocated memory. See xMessageBufferCreateStatic() for a
version that uses statically allocated memory (memory that is allocated at compile time).
configSUPPORT_DYNAMIC_ALLOCATION must be set to 1 or left undefined in FreeRTOSConfig.h for
xMessageBufferCreate() to be available.
Example use:
void vAFunction( void )
{
MessageBufferHandle_t xMessageBuffer;
const size_t xMessageBufferSizeBytes = 100;
// Create a message buffer that can hold 100 bytes. The memory used to hold
// both the message buffer structure and the messages themselves is allocated
// dynamically. Each message added to the buffer consumes an additional 4
// bytes which are used to hold the lengh of the message.
xMessageBuffer = xMessageBufferCreate( xMessageBufferSizeBytes );
if( xMessageBuffer == NULL )
{
// There was not enough heap memory space available to create the
// message buffer.
}
else
{
// The message buffer was created successfully and can now be used.
}
Return If NULL is returned, then the message buffer cannot be created because there is insufficient heap
memory available for FreeRTOS to allocate the message buffer data structures and storage area. A non-
NULL value being returned indicates that the message buffer has been created successfully - the returned
value should be stored as the handle to the created message buffer.
Parameters
Espressif Systems 947
Submit Document Feedback
Release v4.4

Table of Contents