Initial public release.
This commit is contained in:
parent
7b169e8116
commit
dac4af8d25
255 changed files with 68595 additions and 2 deletions
41
2020TPCAppNoDFU.cydsn/UTIL/UTIL_CircularBuffer.h
Normal file
41
2020TPCAppNoDFU.cydsn/UTIL/UTIL_CircularBuffer.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/** \file
|
||||
* \brief This file contains definitions for a circular buffer.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef UTIL_CIRCULARBUFFER_H
|
||||
#define UTIL_CIRCULARBUFFER_H
|
||||
|
||||
/* Definitions */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
//! The result could not be determined.
|
||||
UTIL_CIRCULARBUFFERRESULT_UNKNOWN = 0,
|
||||
//! The requested action completed successfully.
|
||||
UTIL_CIRCULARBUFFERRESULT_SUCCESS,
|
||||
//! There is no more room in the buffer.
|
||||
UTIL_CIRCULARBUFFERRESULT_ERROR_OVERFLOW,
|
||||
//! There is no data left in the buffer.
|
||||
UTIL_CIRCULARBUFFERRESULT_ERROR_UNDERFLOW
|
||||
} UTIL_CircularBufferResult_T;
|
||||
|
||||
//! Circular buffer data structure.
|
||||
typedef struct
|
||||
{
|
||||
uint8_t * buffer;
|
||||
uint16_t size;
|
||||
volatile uint16_t head;
|
||||
volatile uint16_t tail;
|
||||
volatile uint16_t count;
|
||||
} UTIL_CircularBuffer_T;
|
||||
|
||||
/* Function Declarations */
|
||||
|
||||
void UTIL_InitCircularBuffer(UTIL_CircularBuffer_T * const this, uint8_t * buffer, uint16_t size);
|
||||
UTIL_CircularBufferResult_T UTIL_PushToCircularBuffer(UTIL_CircularBuffer_T * const this, uint8_t value);
|
||||
UTIL_CircularBufferResult_T UTIL_PopFromCircularBuffer(UTIL_CircularBuffer_T * const this, uint8_t * const value);
|
||||
bool UTIL_IsCircularBufferEmpty(UTIL_CircularBuffer_T * const this);
|
||||
bool UTIL_IsCircularBufferFull(UTIL_CircularBuffer_T * const this);
|
||||
|
||||
#endif // UTIL_CIRCULARBUFFER_H
|
Loading…
Add table
Add a link
Reference in a new issue