Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F122315647
circular_buffer.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jul 17, 04:33
Size
1 KB
Mime Type
text/x-c
Expires
Sat, Jul 19, 04:33 (2 d)
Engine
blob
Format
Raw Data
Handle
27465239
Attached To
R2671 HHRI-software
circular_buffer.h
View Options
#ifndef __CIRCULAR_BUFFER_H
#define __CIRCULAR_BUFFER_H
#include "../main.h"
/** @defgroup CircularBuffer Circular buffer
* @brief Bytes queue (FIFO) implemented with a circular buffer.
*
* This bytes container works as a queue, which means "first in, first out".
* Create a cb_CircularBuffer structure, and initialize it with cb_Init().
* Then, add bytes using cb_Push(), and extract them with cb_Pull().
*
* @ingroup Lib
* @addtogroup CircularBuffer
* @{
*/
/**
* @brief Circular buffer structure.
*/
typedef struct
{
uint8_t *buffer; ///< Pointer to the byte buffer.
uint16_t bufferSize; ///< Size of buffer.
volatile uint16_t readIndex, ///< Index of the element at the front of the queue.
writeIndex; ///< Index of the next free location at the end of the queue.
} cb_CircularBuffer;
void cb_Init(cb_CircularBuffer* cb, uint8_t *buffer, uint16_t bufferSize);
uint16_t cb_ItemsCount(cb_CircularBuffer* cb);
bool cb_IsEmpty(cb_CircularBuffer* cb);
bool cb_IsFull(cb_CircularBuffer* cb);
void cb_Push(cb_CircularBuffer* cb, uint8_t newElem);
uint8_t cb_Pull(cb_CircularBuffer* cb);
/**
* @}
*/
#endif
Event Timeline
Log In to Comment