mTower
stream_buffer.h
1 /*
2  * FreeRTOS Kernel V10.1.1
3  * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://www.FreeRTOS.org
23  * http://aws.amazon.com/freertos
24  *
25  * 1 tab == 4 spaces!
26  */
27 
28 /*
29  * Stream buffers are used to send a continuous stream of data from one task or
30  * interrupt to another. Their implementation is light weight, making them
31  * particularly suited for interrupt to task and core to core communication
32  * scenarios.
33  *
34  * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
35  * implementation (so also the message buffer implementation, as message buffers
36  * are built on top of stream buffers) assumes there is only one task or
37  * interrupt that will write to the buffer (the writer), and only one task or
38  * interrupt that will read from the buffer (the reader). It is safe for the
39  * writer and reader to be different tasks or interrupts, but, unlike other
40  * FreeRTOS objects, it is not safe to have multiple different writers or
41  * multiple different readers. If there are to be multiple different writers
42  * then the application writer must place each call to a writing API function
43  * (such as xStreamBufferSend()) inside a critical section and set the send
44  * block time to 0. Likewise, if there are to be multiple different readers
45  * then the application writer must place each call to a reading API function
46  * (such as xStreamBufferRead()) inside a critical section section and set the
47  * receive block time to 0.
48  *
49  */
50 
51 #ifndef STREAM_BUFFER_H
52 #define STREAM_BUFFER_H
53 
54 #if defined( __cplusplus )
55 extern "C" {
56 #endif
57 
64 struct StreamBufferDef_t;
66 
67 
133 #define xStreamBufferCreate( xBufferSizeBytes, xTriggerLevelBytes ) xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE )
134 
214 #define xStreamBufferCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE, pucStreamBufferStorageArea, pxStaticStreamBuffer )
215 
308 size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
309  const void *pvTxData,
310  size_t xDataLengthBytes,
311  TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
312 
409 size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
410  const void *pvTxData,
411  size_t xDataLengthBytes,
412  BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
413 
498 size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
499  void *pvRxData,
500  size_t xBufferLengthBytes,
501  TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
502 
584 size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
585  void *pvRxData,
586  size_t xBufferLengthBytes,
587  BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
588 
609 void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
610 
629 BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
630 
649 BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
650 
672 BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
673 
693 size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
694 
714 size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
715 
751 BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ) PRIVILEGED_FUNCTION;
752 
790 BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
791 
830 BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
831 
832 /* Functions below here are not part of the public API. */
833 StreamBufferHandle_t xStreamBufferGenericCreate( size_t xBufferSizeBytes,
834  size_t xTriggerLevelBytes,
835  BaseType_t xIsMessageBuffer ) PRIVILEGED_FUNCTION;
836 
837 StreamBufferHandle_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
838  size_t xTriggerLevelBytes,
839  BaseType_t xIsMessageBuffer,
840  uint8_t * const pucStreamBufferStorageArea,
841  StaticStreamBuffer_t * const pxStaticStreamBuffer ) PRIVILEGED_FUNCTION;
842 
843 size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
844 
845 #if( configUSE_TRACE_FACILITY == 1 )
846  void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer, UBaseType_t uxStreamBufferNumber ) PRIVILEGED_FUNCTION;
847  UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
848  uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
849 #endif
850 
851 #if defined( __cplusplus )
852 }
853 #endif
854 
855 #endif /* !defined( STREAM_BUFFER_H ) */
Definition: stream_buffer.c:141
Definition: FreeRTOS.h:1168