Chapter 2. API Reference
BaseType_t xHigherPriorityTaskWoken
//
Attempt to send the string to the stream
xBytesSent
=
xStreamBufferSendFromISR( xStreamBuffer,
if( xBytesSent
{
//
There was
//
string to be written, ut xBytesSent
}
//
If xHigherPriorityTaskWoken was
//
xStreamBufferSendFromISR() 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 taskYIELD_FROM_ISR(), which will test the
//
variables value,
//
documentation
taskYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}
Return The number of bytes actually written to the stream buffer, which will be less than xDataLengthBytes
if the stream buffer didn't have enough free space for all the bytes to be written.
Parameters
• xStreamBuffer: The handle of the stream buffer to which a stream is being sent.
• pvTxData: A pointer to the data that is to be copied into the stream buffer.
• xDataLengthBytes: The maximum number of bytes to copy from pvTxData into the stream
buffer.
• pxHigherPriorityTaskWoken: It is possible that a stream buffer will have a task blocked
on it waiting for data. Calling xStreamBufferSendFromISR() can make data available, and so cause
a task that was waiting for data to leave the Blocked state. If calling xStreamBufferSendFromISR()
causes a task to leave the Blocked state, and the unblocked task has a priority higher than the cur-
rently executing task (the task that was interrupted), then, internally, xStreamBufferSendFromISR()
will set *pxHigherPriorityTaskWoken to pdTRUE. If xStreamBufferSendFromISR() sets this value
to pdTRUE, then normally a context switch should be performed before the interrupt is exited. This
will ensure that the interrupt returns directly to the highest priority Ready state task. *pxHigherPri-
orityTaskWoken should be set to pdFALSE before it is passed into the function. See the example
code below for an example.
size_t
xStreamBufferReceive(StreamBufferHandle_t
Receives bytes from a stream 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 xStreamBufferSend()) 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
xStreamBufferReceive()) inside a critical section and set the receive block time to 0.
Use xStreamBufferReceive() to read from a stream buffer from a task. Use xStreamBufferReceiveFromISR()
to read from a stream buffer from an interrupt service routine (ISR).
Example use:
Espressif Systems
!=
strlen( pcStringToSend ) )
not
enough free space
and
perform the context switch
for
the port
in
use
LengthBytes, TickType_t xTicksToWait)
Submit Document Feedback
=
pdFALSE;
//
Initialised to
buffer.
( void
*
) pcStringToSend,
strlen( pcStringToSend ),
&xHigherPriorityTaskWoken );
in
the stream buffer
bytes
were
set
to pdTRUE inside
is
done by simply passing
if
for
port specific
xStreamBuffer, void *pvRxData, size_t xBuffer-
941
(continued from previous page)
pdFALSE.
for
the entire
written.
and
a context
necessary.
Check the
instructions.
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?