ZestCode
 
Loading...
Searching...
No Matches
stream_buffer.h
1/*
2 * FreeRTOS Kernel V10.0.1
3 * Copyright (C) 2017 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 stream_buf_send()) 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 )
55extern "C" {
56#endif
57
64typedef void * stream_buf_t;
65
66
132#define stream_buf_create( xBufferSizeBytes, xTriggerLevelBytes ) xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE )
133
213#define stream_buf_create_static( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE, pucStreamBufferStorageArea, pxStaticStreamBuffer )
214
307size_t stream_buf_send( stream_buf_t xStreamBuffer,
308 const void *pvTxData,
309 size_t xDataLengthBytes,
310 uint32_t xTicksToWait ) ;
311
408size_t xStreamBufferSendFromISR( stream_buf_t xStreamBuffer,
409 const void *pvTxData,
410 size_t xDataLengthBytes,
411 int32_t * const pxHigherPriorityTaskWoken ) ;
412
497size_t stream_buf_recv( stream_buf_t xStreamBuffer,
498 void *pvRxData,
499 size_t xBufferLengthBytes,
500 uint32_t xTicksToWait ) ;
501
583size_t xStreamBufferReceiveFromISR( stream_buf_t xStreamBuffer,
584 void *pvRxData,
585 size_t xBufferLengthBytes,
586 int32_t * const pxHigherPriorityTaskWoken ) ;
587
608void vStreamBufferDelete( stream_buf_t xStreamBuffer ) ;
609
628int32_t stream_buf_is_full( stream_buf_t xStreamBuffer ) ;
629
648int32_t stream_buf_is_empty( stream_buf_t xStreamBuffer ) ;
649
671int32_t stream_buf_reset( stream_buf_t xStreamBuffer ) ;
672
692size_t stream_buf_get_unused( stream_buf_t xStreamBuffer ) ;
693
713size_t stream_buf_get_used( stream_buf_t xStreamBuffer ) ;
714
750int32_t stream_buf_set_trigger( stream_buf_t xStreamBuffer, size_t xTriggerLevel ) ;
751
789int32_t xStreamBufferSendCompletedFromISR( stream_buf_t xStreamBuffer, int32_t *pxHigherPriorityTaskWoken ) ;
790
829int32_t xStreamBufferReceiveCompletedFromISR( stream_buf_t xStreamBuffer, int32_t *pxHigherPriorityTaskWoken ) ;
830
831/* Functions below here are not part of the public API. */
832stream_buf_t xStreamBufferGenericCreate( size_t xBufferSizeBytes,
833 size_t xTriggerLevelBytes,
834 int32_t xIsMessageBuffer ) ;
835
836stream_buf_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
837 size_t xTriggerLevelBytes,
838 int32_t xIsMessageBuffer,
839 uint8_t * const pucStreamBufferStorageArea,
840 static_stream_buf_s_t * const pxStaticStreamBuffer ) ;
841
842#if( configUSE_TRACE_FACILITY == 1 )
843 void vStreamBufferSetStreamBufferNumber( stream_buf_t xStreamBuffer, uint32_t uxStreamBufferNumber ) ;
844 uint32_t uxStreamBufferGetStreamBufferNumber( stream_buf_t xStreamBuffer ) ;
845 uint8_t ucStreamBufferGetStreamBufferType( stream_buf_t xStreamBuffer ) ;
846#endif
847
848#if defined( __cplusplus )
849}
850#endif
851
852#endif /* !defined( STREAM_BUFFER_H ) */