EasyGUI  Version v1.0
Ring buffer

Generic cyclic buffer library. More...

Data Structures

struct  GUI_BUFFER_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_BUFFER_t *Buffer, uint32_t Size, void *BufferPtr)
 Initializes buffer structure for work. More...
 
void gui_buffer_free (GUI_BUFFER_t *Buffer)
 Free memory for buffer allocated using dynamic memory allocation. More...
 
uint32_t gui_buffer_write (GUI_BUFFER_t *Buffer, const void *Data, uint32_t count)
 Writes data to buffer. More...
 
uint32_t gui_buffer_read (GUI_BUFFER_t *Buffer, void *Data, uint32_t count)
 Reads data from buffer. More...
 
uint32_t gui_buffer_getfree (GUI_BUFFER_t *Buffer)
 Gets number of free elements in buffer. More...
 
uint32_t gui_buffer_getfull (GUI_BUFFER_t *Buffer)
 Gets number of elements in buffer. More...
 
void gui_buffer_reset (GUI_BUFFER_t *Buffer)
 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_BUFFER_t Buffer)

Free memory for buffer allocated using dynamic memory allocation.

Note
This function has sense only if dynamic allocation was used for memory buffer
Parameters
*BufferPointer to GUI_BUFFER_t structure
Return values
None

◆ gui_buffer_getfree()

uint32_t gui_buffer_getfree ( GUI_BUFFER_t Buffer)

Gets number of free elements in buffer.

Parameters
*BufferPointer to GUI_BUFFER_t structure
Return values
Numberof free elements in buffer

◆ gui_buffer_getfull()

uint32_t gui_buffer_getfull ( GUI_BUFFER_t Buffer)

Gets number of elements in buffer.

Parameters
*BufferPointer to GUI_BUFFER_t structure
Return values
Numberof elements in buffer

◆ gui_buffer_init()

uint8_t gui_buffer_init ( GUI_BUFFER_t Buffer,
uint32_t  Size,
void *  BufferPtr 
)

Initializes buffer structure for work.

Parameters
*BufferPointer to GUI_BUFFER_t structure to initialize
SizeSize of buffer in units of bytes
*BufferPtrPointer 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
Return values
Bufferinitialization status:
  • 0: Buffer initialized OK
  • > 0: Buffer initialization error. Malloc has failed with allocation

◆ gui_buffer_read()

uint32_t gui_buffer_read ( GUI_BUFFER_t Buffer,
void *  Data,
uint32_t  count 
)

Reads data from buffer.

Parameters
*BufferPointer to GUI_BUFFER_t structure
*DataPointer to data where read values will be stored
countNumber of elements of type unsigned char to read
Return values
Numberof elements read from buffer

◆ gui_buffer_reset()

void gui_buffer_reset ( GUI_BUFFER_t Buffer)

Resets (clears) buffer pointers.

Parameters
*BufferPointer to GUI_BUFFER_t structure
Return values
None

◆ gui_buffer_write()

uint32_t gui_buffer_write ( GUI_BUFFER_t Buffer,
const void *  Data,
uint32_t  count 
)

Writes data to buffer.

Parameters
*BufferPointer to GUI_BUFFER_t structure
*DataPointer to data to be written
countNumber of elements of type unsigned char to write
Return values
Numberof elements written in buffer