Commit c9107676 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Make ring buffer increment easier to read

parent 48b66f9b
...@@ -561,8 +561,8 @@ static struct { ...@@ -561,8 +561,8 @@ static struct {
void uart_buffer_push(uint8_t x) { void uart_buffer_push(uint8_t x) {
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
uart_buffer.data[uart_buffer.tail] = x; uart_buffer.data[uart_buffer.tail] = x;
uart_buffer.tail = uart_buffer.tail++;
(uart_buffer.tail + 1) % ARRAY_SIZE(uart_buffer.data); uart_buffer.tail %= ARRAY_SIZE(uart_buffer.data);
} }
} }
...@@ -573,8 +573,8 @@ uint8_t uart_buffer_pop(uint8_t *x) { ...@@ -573,8 +573,8 @@ uint8_t uart_buffer_pop(uint8_t *x) {
} }
*x = uart_buffer.data[uart_buffer.head]; *x = uart_buffer.data[uart_buffer.head];
uart_buffer.head = uart_buffer.head++;
(uart_buffer.head + 1) % ARRAY_SIZE(uart_buffer.data); uart_buffer.head %= ARRAY_SIZE(uart_buffer.data);
} }
return true; return true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment