From e7ade114d656bef6ab214c5859db29eaf5f78e04 Mon Sep 17 00:00:00 2001 From: Richard Osborne Date: Mon, 9 Dec 2013 18:21:50 +0000 Subject: [PATCH] Add functions for working with queues of bytes. This is used by the IAP code. --- module_queue/src/queue.h | 11 +++++++++++ module_queue/src/queue.xc | 2 ++ 2 files changed, 13 insertions(+) diff --git a/module_queue/src/queue.h b/module_queue/src/queue.h index 23e4cea5..39b57728 100644 --- a/module_queue/src/queue.h +++ b/module_queue/src/queue.h @@ -43,6 +43,17 @@ inline unsigned queue_pop_word(queue_t &q, unsigned array[]) { return array[q.rdptr++ & q.mask]; } +inline void queue_push_byte(queue_t &q, unsigned char array[], unsigned data) +{ + assert(!queue_is_full(q)); + array[q.wrptr++ & q.mask] = data; +} + +inline unsigned queue_pop_byte(queue_t &q, unsigned char array[]) { + assert(!queue_is_empty(q)); + return array[q.rdptr++ & q.mask]; +} + inline unsigned queue_items(const queue_t &q) { return q.wrptr - q.rdptr; } diff --git a/module_queue/src/queue.xc b/module_queue/src/queue.xc index 58c78248..c78f2b0f 100644 --- a/module_queue/src/queue.xc +++ b/module_queue/src/queue.xc @@ -7,5 +7,7 @@ extern inline int queue_is_empty(const queue_t &q); extern inline int queue_is_full(const queue_t &q); extern inline void queue_push_word(queue_t &q, unsigned array[], unsigned data); extern inline unsigned queue_pop_word(queue_t &q, unsigned array[]); +extern inline void queue_push_byte(queue_t &q, unsigned char array[], unsigned data); +extern inline unsigned queue_pop_byte(queue_t &q, unsigned char array[]); extern inline unsigned queue_space(const queue_t &q); extern inline unsigned queue_items(const queue_t &q);