EasyGUI  Version v1.0
Ring buffer

Generic cyclic buffer library. More...

Data Structures

struct  gui_buff_t
 Buffer structure. More...
 

Macros

#define GUI_BUFFER_INITIALIZED   0x01
 
#define GUI_BUFFER_MALLOC   0x02
 
#define GUI_BUFFER_FAST   1
 

Functions

uint8_t gui_buffer_init (gui_buff_t *buff, uint32_t size, void *buff_ptr)
 Initializes buffer structure for work. More...
 
void gui_buffer_free (gui_buff_t *buff)
 Free memory for buffer allocated using dynamic memory allocation. More...
 
uint32_t gui_buffer_write (gui_buff_t *buff, const void *data, uint32_t count)
 Writes data to buffer. More...
 
uint32_t gui_buffer_read (gui_buff_t *buff, void *data, uint32_t count)
 Reads data from buffer. More...
 
uint32_t gui_buffer_getfree (gui_buff_t *buff)
 Gets number of free elements in buffer. More...
 
uint32_t gui_buffer_getfull (gui_buff_t *buff)
 Gets number of elements in buffer. More...
 
void gui_buffer_reset (gui_buff_t *buff)
 Resets (clears) buffer pointers. More...
 

Detailed Description

Generic cyclic buffer library.

Macro Definition Documentation

◆ GUI_BUFFER_INITIALIZED

#define GUI_BUFFER_INITIALIZED   0x01

Buffer initialized flag

◆ GUI_BUFFER_MALLOC

#define GUI_BUFFER_MALLOC   0x02

Buffer uses malloc for memory

Function Documentation

◆ gui_buffer_free()

void gui_buffer_free ( gui_buff_t buff)

Free memory for buffer allocated using dynamic memory allocation.

Note
This function has sense only if dynamic allocation was used for memory buffer
Parameters
*buffPointer to gui_buff_t structure
Returns
None

◆ gui_buffer_getfree()

uint32_t gui_buffer_getfree ( gui_buff_t buff)

Gets number of free elements in buffer.

Parameters
*buffPointer to gui_buff_t structure
Returns
Number of free elements in buffer

◆ gui_buffer_getfull()

uint32_t gui_buffer_getfull ( gui_buff_t buff)

Gets number of elements in buffer.

Parameters
*buffPointer to gui_buff_t structure
Returns
Number of elements in buffer

◆ gui_buffer_init()

uint8_t gui_buffer_init ( gui_buff_t buff,
uint32_t  size,
void *  buff_ptr 
)

Initializes buffer structure for work.

Parameters
*buffPointer to gui_buff_t structure to initialize
sizeSize of buffer in units of bytes
*buff_ptrPointer to array for buffer storage. Its length should be equal to
Sizeparameter. If NULL is passed as parameter, internal memory management will be used to allocate memory
Returns
buff initialization status:
  • 0: buff initialized OK
  • > 0: buff initialization error. Malloc has failed with allocation

◆ gui_buffer_read()

uint32_t gui_buffer_read ( gui_buff_t buff,
void *  data,
uint32_t  count 
)

Reads data from buffer.

Parameters
*buffPointer to gui_buff_t structure
*DataPointer to data where read values will be stored
countNumber of elements of type unsigned char to read
Returns
Number of elements read from buffer

◆ gui_buffer_reset()

void gui_buffer_reset ( gui_buff_t buff)

Resets (clears) buffer pointers.

Parameters
*buffPointer to gui_buff_t structure
Returns
None

◆ gui_buffer_write()

uint32_t gui_buffer_write ( gui_buff_t buff,
const void *  Data,
uint32_t  count 
)

Writes data to buffer.

Parameters
*buffPointer to gui_buff_t structure
*DataPointer to data to be written
countNumber of elements of type unsigned char to write
Returns
Number of elements written in buffer