XDK API  3.6.0
Documentation
Files | Data Structures | Typedefs | Functions
Ring Buffer

Ring Buffer Interface. More...

+ Collaboration diagram for Ring Buffer:

Files

file  BCDS_RingBuffer.h
 

Data Structures

struct  RingBuffer_S
 Describes a circular buffer - this implementation expects a single consumer and a single producer. More...
 

Typedefs

typedef struct RingBuffer_S RingBuffer_T
 Describes a circular buffer - this implementation expects a single consumer and a single producer. More...
 

Functions

void RingBuffer_Initialize (RingBuffer_T *ringBuffer, uint8_t *bufferSpace, uint32_t size)
 Initializes a ring-buffer to empty state with a given buffer and buffer size. More...
 
uint32_t RingBuffer_Read (RingBuffer_T *ringBuffer, uint8_t *data, uint32_t length)
 Removes the specified number of bytes from the circular buffer and stores them in the user supplied buffer. More...
 
void RingBuffer_Reset (RingBuffer_T *ringBuffer)
 Resets the ring-buffer. All the saved / available data will be lost, if any at the time of trigger. More...
 
uint32_t RingBuffer_Write (RingBuffer_T *ringBuffer, uint8_t *data, uint32_t length)
 Copies specified number of bytes into the circular buffer. More...
 

Detailed Description


Data Structure Documentation

struct RingBuffer_S

Reading and writing to the buffer can be done independently. The read function only returns data unless the buffer is empty The write function only writes data when the buffer is not full.

Definition:

  • WriteIndex: the location where data is stored to
  • ReadIndex: the location from where to read from

Data Fields

uint8_t * Base
 
uint32_t ReadIndex
 
uint32_t Size
 
uint32_t WriteIndex
 

Field Documentation

uint8_t* Base

Pointer to the base of the user-supplied buffer

uint32_t ReadIndex

Read index. NOT to be changed by hand

uint32_t Size

Maximum number of bytes in the user-supplied buffer. Must be set during initialization

uint32_t WriteIndex

Write index. NOT to be changed by hand

Typedef Documentation

typedef struct RingBuffer_S RingBuffer_T

Reading and writing to the buffer can be done independently. The read function only returns data unless the buffer is empty The write function only writes data when the buffer is not full.

Definition:

  • WriteIndex: the location where data is stored to
  • ReadIndex: the location from where to read from

Function Documentation

void RingBuffer_Initialize ( RingBuffer_T ringBuffer,
uint8_t *  bufferSpace,
uint32_t  size 
)
Parameters
[in]ringBufferPointer to the ring-buffer descriptor. MUST NOT be NULL
[in]bufferSpacePointer to the circular buffer. This buffer must be created and maintained by the caller. The reason the buffer is separate from the descriptor is to allow for buffers of different sizes while using the same descriptor to manage any buffer MUST NOT be NULL
[in]sizeSize of the circular buffer. Must be known to the caller and will get stored inside the descriptor. MUST BE > 1 NOTE: the actual number of bytes that can be stored is size -1
uint32_t RingBuffer_Read ( RingBuffer_T ringBuffer,
uint8_t *  data,
uint32_t  length 
)
Note
The number of bytes may be different depending on the actual fill-level of the buffer.
Parameters
[in]ringBufferPointer to the ring-buffer descriptor MUST NOT be NULL
[out]dataPointer to the user supplied buffer into which the data has to be copied. Must be large enough to hold the specific number of bytes MUST NOT be NULL
[in]lengthThe number of bytes to copy
Returns
Actual number of bytes read
void RingBuffer_Reset ( RingBuffer_T ringBuffer)
Note
We do not guard the buffer. Application is expected to take care of this if needed.
Parameters
[in]ringBufferPointer to the ring-buffer descriptor MUST NOT be NULL
uint32_t RingBuffer_Write ( RingBuffer_T ringBuffer,
uint8_t *  data,
uint32_t  length 
)
Note
The actual number of bytes written may be different depending on the fill-level of the buffer.
It is the responsibility of the interface user to provide valid input parameters. Since this API is often used in ISR context, we minimize the internal validations.
Parameters
[in]ringBufferPointer to the ring-buffer descriptor

MUST NOT be NULL

Parameters
[in]dataPointer to the user data that is to be copied into the circular buffer MUST NOT be NULL
[in]lengthNumber of bytes to copy
Returns
actual number of bytes written

All rights reserved. The use is subject to the XDK SDK EULA by Bosch Connected Devices and Solutions GmbH.
This documentation file has been automatically generated on Thu Mar 14 2019 19:12:52 by doxygen 1.8.8