1 /* 2 * FreeRTOS+TCP V2.3.1 3 * Copyright (C) 2020 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://aws.amazon.com/freertos 23 * http://www.FreeRTOS.org 24 */ 25 26 /* 27 * FreeRTOS_Stream_Buffer.h 28 * 29 * A circular character buffer 30 * An implementation of a circular buffer without a length field 31 * If LENGTH defines the size of the buffer, a maximum of (LENGTH-1) bytes can be stored 32 * In order to add or read data from the buffer, memcpy() will be called at most 2 times 33 */ 34 35 #ifndef FREERTOS_BITCONFIG_H 36 #define FREERTOS_BITCONFIG_H 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /**< @brief The struct BitConfig_t holds a character array, its length and an index. */ 43 typedef struct xBitConfig 44 { 45 uint8_t * ucContents; /**< An allocated buffer to hold the binary data stream. */ 46 size_t uxIndex; /**< Points to the next character to analyse or write. */ 47 size_t uxSize; /**< The size of the allocated buffer 'uxContents'. */ 48 BaseType_t xHasError; /**< It will be set to pdTRUE in case an error occurred, usually because the buffer is too small. */ 49 } BitConfig_t; 50 51 BaseType_t xBitConfig_init( BitConfig_t * pxConfig, 52 const uint8_t * pucData, 53 size_t uxSize ); 54 55 uint8_t ucBitConfig_read_8( BitConfig_t * pxConfig ); 56 uint16_t usBitConfig_read_16( BitConfig_t * pxConfig ); 57 uint32_t ulBitConfig_read_32( BitConfig_t * pxConfig ); 58 BaseType_t xBitConfig_read_uc( BitConfig_t * pxConfig, 59 uint8_t * pucData, 60 size_t uxSize ); 61 BaseType_t pucBitConfig_peek_last_index_uc( BitConfig_t * pxConfig, 62 uint8_t * pucData, 63 size_t uxSize ); 64 65 void vBitConfig_write_8( BitConfig_t * pxConfig, 66 uint8_t ucValue ); 67 void vBitConfig_write_16( BitConfig_t * pxConfig, 68 uint16_t usValue ); 69 void vBitConfig_write_32( BitConfig_t * pxConfig, 70 uint32_t ulValue ); 71 void vBitConfig_write_uc( BitConfig_t * pxConfig, 72 const uint8_t * pucData, 73 size_t uxSize ); 74 75 void vBitConfig_release( BitConfig_t * pxConfig ); 76 77 78 #ifdef __cplusplus 79 } /* extern "C" */ 80 #endif 81 82 #endif /* !defined( FREERTOS_STREAM_BUFFER_H ) */ 83