summaryrefslogtreecommitdiffstats
path: root/src/ring.c
diff options
context:
space:
mode:
authorroot <root@lab2.panaceas.james.local>2014-11-02 18:17:44 +0000
committerroot <root@lab2.panaceas.james.local>2014-11-02 18:17:44 +0000
commit12287ff0a55f929bf840dcb4780d3f77b862c434 (patch)
tree46632674f393249e7cd74eacd7a4da00ccec540f /src/ring.c
parent479e719a64d75374f00438498cf91ba2601a63f1 (diff)
downloadstm32_usb_kvm-12287ff0a55f929bf840dcb4780d3f77b862c434.tar.gz
stm32_usb_kvm-12287ff0a55f929bf840dcb4780d3f77b862c434.tar.bz2
stm32_usb_kvm-12287ff0a55f929bf840dcb4780d3f77b862c434.zip
fish
Diffstat (limited to 'src/ring.c')
-rw-r--r--src/ring.c61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/ring.c b/src/ring.c
deleted file mode 100644
index 4f38e44..0000000
--- a/src/ring.c
+++ /dev/null
@@ -1,61 +0,0 @@
-#include "project.h"
-
-
-static inline size_t
-ring_next (ring_t * r, size_t p)
-{
- p++;
- if (p >= r->size)
- p -= r->size;
- return p;
-}
-
-void
-ring_init (ring_t * r, uint8_t * buf, size_t len)
-{
- r->data = buf;
- r->size = len;
- r->write = 0;
- r->read = 0;
-}
-
-int
-ring_write_byte (ring_t * r, uint8_t c)
-{
- size_t n = ring_next (r, r->write);
-
- if (n == r->read)
- return -1;
-
- r->data[r->write] = c;
- r->write = n;
-
- return 0;
-}
-
-
-int
-ring_read_byte (ring_t * r, uint8_t * c)
-{
- size_t n = ring_next (r, r->read);
-
- if (r->read == r->write)
- return -1;
-
- *c = r->data[r->read];
- r->read = n;
-
- return 0;
-}
-
-int
-ring_write (ring_t * r, uint8_t * buf, size_t len)
-{
- while (len--)
- {
- if (ring_write_byte (r, *(buf++)))
- return -1;
- }
-
- return 0;
-}