summaryrefslogtreecommitdiff
path: root/tests/usb-serial-rs485/ringb.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/usb-serial-rs485/ringb.c')
-rw-r--r--tests/usb-serial-rs485/ringb.c59
1 files changed, 0 insertions, 59 deletions
diff --git a/tests/usb-serial-rs485/ringb.c b/tests/usb-serial-rs485/ringb.c
deleted file mode 100644
index 245325b..0000000
--- a/tests/usb-serial-rs485/ringb.c
+++ /dev/null
@@ -1,59 +0,0 @@
-
-#include "ringb.h"
-void ringb_init(struct ringb *ring, uint8_t *buf, int len)
-{
- ring->buf_len = len;
- ring->buf = buf;
- ring->idx_r = 0;
- ring->idx_w = 0;
-}
-
-int ringb_get(struct ringb *ring) {
-#if 1
- int rval;
- if (ring->idx_r != ring->idx_w) {
- rval = ring->buf[ring->idx_r];
- ring->idx_r = (ring->idx_r + 1) % ring->buf_len;
- return rval;
- }
- return -1;
-#else
- if (((ring->idx_w - ring->idx_r) % ring->buf_len) >= 0) {
- int rval = ring->buf[ring->idx_r];
- ring->idx_r = (ring->idx_r + 1) % ring->buf_len;
- return rval;
- } else {
- return -1;
- }
-#endif
-}
-
-bool ringb_put(struct ringb *ring, uint8_t c) {
-#if 1
- unsigned int next = (ring->idx_w + 1) % ring->buf_len;
- if (next != ring->idx_r) {
- ring->buf[ring->idx_w] = c;
- ring->idx_w = next;
- return true;
- }
- return false;
-#else
- if (((ring->idx_w - ring->idx_r) % ring->buf_len) == 0) {
- return false;
- }
- ring->buf[ring->idx_w] = c;
- ring->idx_w = (ring->idx_w + 1) % ring->buf_len;
- return true;
-#endif
-
-}
-
-
-void ringb_flush(struct ringb *ring) {
- ring->idx_r = 0;
- ring->idx_w = 0;
-}
-
-int ringb_depth(struct ringb *ring) {
- return ((unsigned int)(ring->idx_w - ring->idx_r) % ring->buf_len);
-} \ No newline at end of file