firmware  v0.1.2
Chromation Spectrometer Dev-Kit
Data Fields
Queue_s Struct Reference

Queue uses a byte array as a circular buffer. More...

#include <Queue.h>

Data Fields

volatile uint8_t * buffer
 buffer is the address of the queue's FIFO buffer
More...
 
volatile uint8_t head
 head advances after a byte is pushed onto the queue
More...
 
volatile uint8_t tail
 tail advances after a byte is popped from the queue
More...
 
volatile uint8_t length
 length is the number of unread bytes in the queue
 
volatile uint8_t max_length
 max_length is the maximum number of bytes the queue can hold
More...
 

Detailed Description

Queue uses a byte array as a circular buffer.

A queue is a byte array with data (head, tail) and methods (push, pop) that access linear memory like circular memory. The memory is finite (the queue can fill up) but the user cannot "fall off" the end of the byte array.

Picture the byte array as a closed loop like the numbers on a clock:

Other bytes in the buffer are not in the queue, meaning they cannot be accessed by a pop. These values remain stored in the buffer until overwritten by a push.

A queue is a FIFO (first-in first-out) buffer: pop removes the oldest byte in the queue.

Definition at line 27 of file Queue.h.

Field Documentation

◆ buffer

volatile uint8_t* Queue_s::buffer

buffer is the address of the queue's FIFO buffer

  • buffer is an array of bytes
  • buffer size is set by user
  • buffer memory is allocated by user

Definition at line 33 of file Queue.h.

◆ head

volatile uint8_t Queue_s::head

head advances after a byte is pushed onto the queue

  • push indexes buffer at head

Definition at line 37 of file Queue.h.

◆ max_length

volatile uint8_t Queue_s::max_length

max_length is the maximum number of bytes the queue can hold

  • max_length is set by the user

Definition at line 47 of file Queue.h.

◆ tail

volatile uint8_t Queue_s::tail

tail advances after a byte is popped from the queue

  • pop indexes buffer at tail

Definition at line 41 of file Queue.h.


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