Ring Buffer
This is the ring or circular buffer implementation with fixed size of user initialization.
The main buffer structure variable and the internal data buffer both should be declared on the application side and the pointers of the variables are used in the module.
Usage
All API functions have the first argument as the buffer structure.
Internal data buffer size and pointer are initialized with module init function.
Module read and module write functions are used to read/write data bytes.
Other API functions to return the status of buffer whether empty or full.
Return codes of API functions are defined in header file.
Function |
Description |
|---|---|
rs_ring_buf_init |
Function to initialize the ring buffer |
rs_ring_buf_push |
Function to push the data into the ring buffer |
rs_ring_buf_pop |
Function to pop the data from the ring buffer |
rs_ring_buf_peek |
Function to get top of the data |
rs_ring_buf_get_used_space |
Function to get buffer count |
rs_ring_buf_get_free_space |
Function to get remaining bytes |
rs_ring_buf_is_full |
Function to know the buffer is full or not |
rs_ring_buf_is_empty |
Function to know the buffer is empty or not |
rs_ring_buf_flush |
Function to reset the elements of the ring buffer structure |
Using these ‘rs’ calls to initialize the ring buffer, push and pop from the structure via ring buffer, data is obtained from the structure, and all filter structure elements are flushed.
Error Code
Every API’s for the ring buffer module returns some success or failure values. Please refer below section,
Example Demo
Please refer below section,
Ring Buffer Header Details
Documentation from the relevant header as follows:
Warning
doxygenfile: Cannot find file “rs_ring_buf.h