PS_Fgen_FW  4da88f4073c1cc65ea45c3a652a2751e495e50db
Firmware for an Power Supply and Function Generator build from an ATX power supply
Loading...
Searching...
No Matches
CircularBuffer< T, MaxElements > Class Template Reference

Class that is implementing a circular buffer (for queue functionality). More...

#include <CircularBuffer.h>

Public Member Functions

uint8_t empty ()
 Check if the circular buffer is empty.
 
uint8_t full ()
 Check if the circular buffer is full.
 
void enqueue (T *data)
 Enqueue the data at the given pointer into the queue.
 
T * dequeue ()
 Dequeue data from the queue and return a pointer to the data dequeue() should never be called on an empty queue.
 

Private Attributes

queue [MaxElements]
 Array holding the circular buffer data.
 
volatile uint16_t head
 Head index of the circular buffer.
 
volatile uint16_t tail
 Tail index of the circular buffer.
 

Detailed Description

template<class T, size_t MaxElements>
class CircularBuffer< T, MaxElements >

Class that is implementing a circular buffer (for queue functionality).

Template Parameters
TType of the buffer elements
MaxElementsMaximum number of elements the buffer can hold

Member Function Documentation

◆ dequeue()

template<class T, size_t MaxElements>
T * CircularBuffer< T, MaxElements >::dequeue ( )
inline

Dequeue data from the queue and return a pointer to the data dequeue() should never be called on an empty queue.

Returns
Pointer to the data element in the queue.

◆ empty()

template<class T, size_t MaxElements>
uint8_t CircularBuffer< T, MaxElements >::empty ( )
inline

Check if the circular buffer is empty.

Returns
Returns 1 if the queue is empty, 0 otherwise

◆ enqueue()

template<class T, size_t MaxElements>
void CircularBuffer< T, MaxElements >::enqueue ( T * data)
inline

Enqueue the data at the given pointer into the queue.

enqueue() should never be called on a full queue.

Parameters
dataPointer to the data that is enqueued.

◆ full()

template<class T, size_t MaxElements>
uint8_t CircularBuffer< T, MaxElements >::full ( )
inline

Check if the circular buffer is full.

Returns
Returns 1 if the queue is full, 0 otherwise

The documentation for this class was generated from the following file: