Espressif ESP32-S2 Programming Manual page 958

Table of Contents

Advertisement

Chapter 2. API Reference
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.
• 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 buffer's 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
//
Create a message buffer that can hold
//
both the message buffer structure
// dynamically.
//
bytes
which are used to hold the lengh of the
xMessageBuffer
if( xMessageBuffer
{
//
There was
//
message
}
else
{
//
The message buffer was created successfully
}
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
Each message added to the buffer consumes an additional
=
xMessageBufferCreate( xMessageBufferSizeBytes );
==
NULL )
not
enough heap memory space available to create the
buffer.
Submit Document Feedback
=
100;
100
bytes.
The memory used to hold
and
the messages themselves
message.
and
947
is
allocated
4
can now be
used.
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents

Save PDF