Espressif ESP32-S2 Programming Manual page 963

Table of Contents

Advertisement

Chapter 2. API Reference
in tick periods, so the absolute time it represents is dependent on the tick frequency. The macro
pdMS_TO_TICKS() can be used to convert a time specified in milliseconds into a time specified in
ticks. Setting xTicksToWait to portMAX_DELAY will cause the task to wait indefinitely (without
timing out), provided INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h. Tasks do not use
any CPU time when they are in the Blocked state.
xMessageBufferReceiveFromISR(xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPri-
An interrupt safe version of the API function that receives a discrete message from a message buffer. Messages
can be of variable length and are copied out of the buffer.
***NOTE***: Uniquely among FreeRTOS objects, the stream buffer implementation (so also the message
buffer implementation, as message buffers are built on top of stream buffers) assumes there is only one task
or interrupt that will write to the buffer (the writer), and only one task or interrupt that will read from the
buffer (the reader). It is safe for the writer and reader to be different tasks or interrupts, but, unlike other
FreeRTOS objects, it is not safe to have multiple different writers or multiple different readers. If there are to
be multiple different writers then the application writer must place each call to a writing API function (such as
xMessageBufferSend()) inside a critical section and set the send block time to 0. Likewise, if there are to be
multiple different readers then the application writer must place each call to a reading API function (such as
xMessageBufferRead()) inside a critical section and set the receive block time to 0.
Use xMessageBufferReceive() to read from a message buffer from a task. Use xMessageBufferReceive-
FromISR() to read from a message buffer from an interrupt service routine (ISR).
Example use:
//
A message buffer that has already been
MessageBuffer_t xMessageBuffer;
void vAnInterruptServiceRoutine( void )
{
uint8_t ucRxData[
size_t xReceivedBytes;
BaseType_t xHigherPriorityTaskWoken
//
Receive the
xReceivedBytes
if( xReceivedBytes
{
//
A ucRxData contains a message that
//
the message
}
//
If xHigherPriorityTaskWoken was
//
xMessageBufferReceiveFromISR() then a task that has a priority above the
//
priority of the currently executing task was unblocked
//
switch should be performed to ensure the ISR returns to the unblocked
// task.
In most FreeRTOS ports this
//
xHigherPriorityTaskWoken into portYIELD_FROM_ISR(), which will test the
//
variables value,
//
documentation
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}
Return The length, in bytes, of the message read from the message buffer, if any.
Parameters
• xMessageBuffer: The handle of the message buffer from which a message is being received.
• pvRxData: A pointer to the buffer into which the received message is to be copied.
• xBufferLengthBytes: The length of the buffer pointed to by the pvRxData parameter. This
Espressif Systems
orityTaskWoken)
20
];
next
message
from
the
=
xMessageBufferReceiveFromISR( xMessageBuffer,
>
0
)
here....
and
perform the context switch
for
the port
in
use
Submit Document Feedback
created.
=
pdFALSE;
//
Initialised to
message
buffer.
( void
*
sizeof( ucRxData ),
&xHigherPriorityTaskWoken );
is
xReceivedBytes
set
to pdTRUE inside
is
done by simply passing
if
for
port specific
952
pdFALSE.
) ucRxData,
long.
Process
and
a context
necessary.
Check the
instructions.
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?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents

Save PDF