aboutsummaryrefslogtreecommitdiffstats
path: root/app/ring.c
diff options
context:
space:
mode:
authorroot <root@ka-ata-killa.ourano.james.local>2021-03-03 15:24:13 +0000
committerroot <root@ka-ata-killa.ourano.james.local>2021-03-03 16:03:28 +0000
commit49148e76706e5e24c2ba7f6ccc1d7ec4736ab2f3 (patch)
treef65cb7440711ea1708c25fe78819e9986b2d8566 /app/ring.c
parent129a103238d69bd90b4fe9a44bbed943b9488fc2 (diff)
downloadserial_over_dp-49148e76706e5e24c2ba7f6ccc1d7ec4736ab2f3.tar.gz
serial_over_dp-49148e76706e5e24c2ba7f6ccc1d7ec4736ab2f3.tar.bz2
serial_over_dp-49148e76706e5e24c2ba7f6ccc1d7ec4736ab2f3.zip
support cheap chinese blue pill boards, make usb dfu compatible with dfuse
Diffstat (limited to 'app/ring.c')
-rw-r--r--app/ring.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/app/ring.c b/app/ring.c
index e3a6209..26bba3a 100644
--- a/app/ring.c
+++ b/app/ring.c
@@ -6,9 +6,8 @@ ring_next (ring_t *r, size_t p)
{
p++;
- if (p >= r->size) {
+ if (p >= r->size)
p -= r->size;
- }
return p;
}
@@ -27,9 +26,8 @@ ring_write_byte (ring_t *r, uint8_t c)
{
size_t n = ring_next (r, r->write);
- if (n == r->read) {
+ if (n == r->read)
return -1;
- }
r->data[r->write] = c;
r->write = n;
@@ -46,9 +44,8 @@ ring_read_byte (ring_t *r, uint8_t *c)
{
size_t n = ring_next (r, r->read);
- if (r->read == r->write) {
+ if (r->read == r->write)
return -1;
- }
*c = r->data[r->read];
r->read = n;
@@ -59,9 +56,8 @@ int
ring_write (ring_t *r, uint8_t *buf, size_t len)
{
while (len--) {
- if (ring_write_byte (r, * (buf++))) {
+ if (ring_write_byte (r, * (buf++)))
return -1;
- }
}
return 0;