9 #define QUEUE_BASE_T uint8_t
10 #define QUEUE_INDEX_T uint8_t
12 typedef volatile struct {
13 QUEUE_BASE_T
*restrict buffer
; // buffer
14 QUEUE_INDEX_T first
; // position of first element
15 QUEUE_INDEX_T last
; // position of last element (should be eliminated)
17 const QUEUE_INDEX_T sz
; // size of the buffer
20 #define Q_DEF(buff) { .buffer = (buff), .first = 0, .last = 0, .ct = 0, .sz = sizeof(buff) / sizeof(QUEUE_BASE_T) }
23 int8_t q_push(queue_t
*q
, QUEUE_BASE_T x
);
24 int8_t q_push_o(queue_t
*q
, QUEUE_BASE_T x
); // overwrites old data on q full
26 QUEUE_BASE_T
q_pop(queue_t
*q
); // takes oldest element
27 QUEUE_BASE_T
q_remove(queue_t
*q
); // takes newest element
29 void q_flush(queue_t
*q
);
30 bool q_empty(queue_t
*q
);
31 bool q_full(queue_t
*q
);