firmware
IEM Firmware Documentation
Loading...
Searching...
No Matches
stream_buffer.h
Go to the documentation of this file.
1/*
2 * FreeRTOS Kernel V11.1.0
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of
8 * this software and associated documentation files (the "Software"), to deal in
9 * the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11 * the Software, and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * https://www.FreeRTOS.org
25 * https://github.com/FreeRTOS
26 *
27 */
28
29/*
30 * Stream buffers are used to send a continuous stream of data from one task or
31 * interrupt to another. Their implementation is light weight, making them
32 * particularly suited for interrupt to task and core to core communication
33 * scenarios.
34 *
35 * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
36 * implementation (so also the message buffer implementation, as message buffers
37 * are built on top of stream buffers) assumes there is only one task or
38 * interrupt that will write to the buffer (the writer), and only one task or
39 * interrupt that will read from the buffer (the reader). It is safe for the
40 * writer and reader to be different tasks or interrupts, but, unlike other
41 * FreeRTOS objects, it is not safe to have multiple different writers or
42 * multiple different readers. If there are to be multiple different writers
43 * then the application writer must place each call to a writing API function
44 * (such as xStreamBufferSend()) inside a critical section and set the send
45 * block time to 0. Likewise, if there are to be multiple different readers
46 * then the application writer must place each call to a reading API function
47 * (such as xStreamBufferReceive()) inside a critical section section and set the
48 * receive block time to 0.
49 *
50 */
51
52#ifndef STREAM_BUFFER_H
53#define STREAM_BUFFER_H
54
55#ifndef INC_FREERTOS_H
56 #error "include FreeRTOS.h must appear in source files before include stream_buffer.h"
57#endif
58
59/* *INDENT-OFF* */
60#if defined( __cplusplus )
61 extern "C" {
62#endif
63/* *INDENT-ON* */
64
68#define sbTYPE_STREAM_BUFFER ( ( BaseType_t ) 0 )
69#define sbTYPE_MESSAGE_BUFFER ( ( BaseType_t ) 1 )
70#define sbTYPE_STREAM_BATCHING_BUFFER ( ( BaseType_t ) 2 )
71
78struct StreamBufferDef_t;
79typedef struct StreamBufferDef_t * StreamBufferHandle_t;
80
85 BaseType_t xIsInsideISR,
86 BaseType_t * const pxHigherPriorityTaskWoken );
87
165
166#define xStreamBufferCreate( xBufferSizeBytes, xTriggerLevelBytes ) \
167 xStreamBufferGenericCreate( ( xBufferSizeBytes ), ( xTriggerLevelBytes ), sbTYPE_STREAM_BUFFER, NULL, NULL )
168
169#if ( configUSE_SB_COMPLETED_CALLBACK == 1 )
170 #define xStreamBufferCreateWithCallback( xBufferSizeBytes, xTriggerLevelBytes, pxSendCompletedCallback, pxReceiveCompletedCallback ) \
171 xStreamBufferGenericCreate( ( xBufferSizeBytes ), ( xTriggerLevelBytes ), sbTYPE_STREAM_BUFFER, ( pxSendCompletedCallback ), ( pxReceiveCompletedCallback ) )
172#endif
173
265
266#define xStreamBufferCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer ) \
267 xStreamBufferGenericCreateStatic( ( xBufferSizeBytes ), ( xTriggerLevelBytes ), sbTYPE_STREAM_BUFFER, ( pucStreamBufferStorageArea ), ( pxStaticStreamBuffer ), NULL, NULL )
268
269#if ( configUSE_SB_COMPLETED_CALLBACK == 1 )
270 #define xStreamBufferCreateStaticWithCallback( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer, pxSendCompletedCallback, pxReceiveCompletedCallback ) \
271 xStreamBufferGenericCreateStatic( ( xBufferSizeBytes ), ( xTriggerLevelBytes ), sbTYPE_STREAM_BUFFER, ( pucStreamBufferStorageArea ), ( pxStaticStreamBuffer ), ( pxSendCompletedCallback ), ( pxReceiveCompletedCallback ) )
272#endif
273
351
352#define xStreamBatchingBufferCreate( xBufferSizeBytes, xTriggerLevelBytes ) \
353 xStreamBufferGenericCreate( ( xBufferSizeBytes ), ( xTriggerLevelBytes ), sbTYPE_STREAM_BATCHING_BUFFER, NULL, NULL )
354
355#if ( configUSE_SB_COMPLETED_CALLBACK == 1 )
356 #define xStreamBatchingBufferCreateWithCallback( xBufferSizeBytes, xTriggerLevelBytes, pxSendCompletedCallback, pxReceiveCompletedCallback ) \
357 xStreamBufferGenericCreate( ( xBufferSizeBytes ), ( xTriggerLevelBytes ), sbTYPE_STREAM_BATCHING_BUFFER, ( pxSendCompletedCallback ), ( pxReceiveCompletedCallback ) )
358#endif
359
453
454#define xStreamBatchingBufferCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer ) \
455 xStreamBufferGenericCreateStatic( ( xBufferSizeBytes ), ( xTriggerLevelBytes ), sbTYPE_STREAM_BATCHING_BUFFER, ( pucStreamBufferStorageArea ), ( pxStaticStreamBuffer ), NULL, NULL )
456
457#if ( configUSE_SB_COMPLETED_CALLBACK == 1 )
458 #define xStreamBatchingBufferCreateStaticWithCallback( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer, pxSendCompletedCallback, pxReceiveCompletedCallback ) \
459 xStreamBufferGenericCreateStatic( ( xBufferSizeBytes ), ( xTriggerLevelBytes ), sbTYPE_STREAM_BATCHING_BUFFER, ( pucStreamBufferStorageArea ), ( pxStaticStreamBuffer ), ( pxSendCompletedCallback ), ( pxReceiveCompletedCallback ) )
460#endif
461
491#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
492 BaseType_t xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffer,
493 uint8_t ** ppucStreamBufferStorageArea,
494 StaticStreamBuffer_t ** ppxStaticStreamBuffer ) PRIVILEGED_FUNCTION;
495#endif /* configSUPPORT_STATIC_ALLOCATION */
496
593 const void * pvTxData,
594 size_t xDataLengthBytes,
595 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
596
697 const void * pvTxData,
698 size_t xDataLengthBytes,
699 BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
700
789 void * pvRxData,
790 size_t xBufferLengthBytes,
791 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
792
878 void * pvRxData,
879 size_t xBufferLengthBytes,
880 BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
881
906
929
952
982
1014
1038
1062
1102 size_t xTriggerLevel ) PRIVILEGED_FUNCTION;
1103
1145 BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
1146
1189 BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
1190
1216
1246 UBaseType_t uxNotificationIndex ) PRIVILEGED_FUNCTION;
1247
1248/* Functions below here are not part of the public API. */
1250 size_t xTriggerLevelBytes,
1251 BaseType_t xStreamBufferType,
1252 StreamBufferCallbackFunction_t pxSendCompletedCallback,
1253 StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
1254
1255#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1256 StreamBufferHandle_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
1257 size_t xTriggerLevelBytes,
1258 BaseType_t xStreamBufferType,
1259 uint8_t * const pucStreamBufferStorageArea,
1260 StaticStreamBuffer_t * const pxStaticStreamBuffer,
1261 StreamBufferCallbackFunction_t pxSendCompletedCallback,
1262 StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
1263#endif
1264
1266
1267#if ( configUSE_TRACE_FACILITY == 1 )
1268 void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer,
1269 UBaseType_t uxStreamBufferNumber ) PRIVILEGED_FUNCTION;
1270 UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
1271 uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
1272#endif
1273
1274/* *INDENT-OFF* */
1275#if defined( __cplusplus )
1276 }
1277#endif
1278/* *INDENT-ON* */
1279
1280#endif /* !defined( STREAM_BUFFER_H ) */
struct xSTATIC_STREAM_BUFFER StaticStreamBuffer_t
#define PRIVILEGED_FUNCTION
Definition mpu_wrappers.h:269
long BaseType_t
Definition portmacro.h:59
unsigned long UBaseType_t
Definition portmacro.h:60
uint16_t TickType_t
Definition portmacro.h:63
void vStreamBufferDelete(StreamBufferHandle_t xStreamBuffer) PRIVILEGED_FUNCTION
void vStreamBufferSetStreamBufferNotificationIndex(StreamBufferHandle_t xStreamBuffer, UBaseType_t uxNotificationIndex) PRIVILEGED_FUNCTION
size_t xStreamBufferSendFromISR(StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, BaseType_t *const pxHigherPriorityTaskWoken) PRIVILEGED_FUNCTION
StreamBufferHandle_t xStreamBufferGenericCreate(size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xStreamBufferType, StreamBufferCallbackFunction_t pxSendCompletedCallback, StreamBufferCallbackFunction_t pxReceiveCompletedCallback) PRIVILEGED_FUNCTION
BaseType_t xStreamBufferSetTriggerLevel(StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel) PRIVILEGED_FUNCTION
size_t xStreamBufferSend(StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait) PRIVILEGED_FUNCTION
void(* StreamBufferCallbackFunction_t)(StreamBufferHandle_t xStreamBuffer, BaseType_t xIsInsideISR, BaseType_t *const pxHigherPriorityTaskWoken)
Definition stream_buffer.h:84
BaseType_t xStreamBufferReset(StreamBufferHandle_t xStreamBuffer) PRIVILEGED_FUNCTION
size_t xStreamBufferReceive(StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait) PRIVILEGED_FUNCTION
size_t xStreamBufferReceiveFromISR(StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, BaseType_t *const pxHigherPriorityTaskWoken) PRIVILEGED_FUNCTION
BaseType_t xStreamBufferResetFromISR(StreamBufferHandle_t xStreamBuffer) PRIVILEGED_FUNCTION
struct StreamBufferDef_t * StreamBufferHandle_t
Definition stream_buffer.h:79
size_t xStreamBufferSpacesAvailable(StreamBufferHandle_t xStreamBuffer) PRIVILEGED_FUNCTION
size_t xStreamBufferNextMessageLengthBytes(StreamBufferHandle_t xStreamBuffer) PRIVILEGED_FUNCTION
BaseType_t xStreamBufferSendCompletedFromISR(StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken) PRIVILEGED_FUNCTION
BaseType_t xStreamBufferReceiveCompletedFromISR(StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken) PRIVILEGED_FUNCTION
BaseType_t xStreamBufferIsFull(StreamBufferHandle_t xStreamBuffer) PRIVILEGED_FUNCTION
UBaseType_t uxStreamBufferGetStreamBufferNotificationIndex(StreamBufferHandle_t xStreamBuffer) PRIVILEGED_FUNCTION
size_t xStreamBufferBytesAvailable(StreamBufferHandle_t xStreamBuffer) PRIVILEGED_FUNCTION
BaseType_t xStreamBufferIsEmpty(StreamBufferHandle_t xStreamBuffer) PRIVILEGED_FUNCTION