circular_buffer: block multi* fully
#include "drv_interrupt.h"
uint32_t circular_buffer_free(circular_buffer_t *c) {
- ATOMIC_BLOCK(MAX_PRIORITY) {
+ ATOMIC_BLOCK_ALL {
if (c->head >= c->tail) {
return (c->size - c->head) + c->tail;
}
@@ -13,7 +13,7 @@ uint32_t circular_buffer_free(circular_buffer_t *c) {
}
uint8_t circular_buffer_write(circular_buffer_t *c, uint8_t data) {
- ATOMIC_BLOCK(MAX_PRIORITY) {
+ ATOMIC_BLOCK_ALL {
const uint32_t next = (c->head + 1) % c->size;
if (next == c->tail)
return 0;
@@ -26,11 +26,12 @@ uint8_t circular_buffer_write(circular_buffer_t *c, uint8_t data) {
}
uint32_t circular_buffer_write_multi(circular_buffer_t *c, const uint8_t *data, const uint32_t len) {
+ ATOMIC_BLOCK_ALL {
for (uint32_t i = 0; i < len; i++) {
- ATOMIC_BLOCK(MAX_PRIORITY) {
const uint32_t next = (c->head + 1) % c->size;
- if (next == c->tail)
+ if (next == c->tail) {
return i;
+ }
c->buffer[c->head] = data[i];
c->head = next;
@@ -40,7 +41,7 @@ uint32_t circular_buffer_write_multi(circular_buffer_t *c, const uint8_t *data,
}
uint32_t circular_buffer_available(circular_buffer_t *c) {
- ATOMIC_BLOCK(MAX_PRIORITY) {
+ ATOMIC_BLOCK_ALL {
if (c->head >= c->tail) {
return c->head - c->tail;
}
@@ -50,7 +51,7 @@ uint32_t circular_buffer_available(circular_buffer_t *c) {
}
uint8_t circular_buffer_read(circular_buffer_t *c, uint8_t *data) {
- ATOMIC_BLOCK(MAX_PRIORITY) {
+ ATOMIC_BLOCK_ALL {
if (c->head == c->tail)
return 0;
@@ -62,8 +63,8 @@ uint8_t circular_buffer_read(circular_buffer_t *c, uint8_t *data) {
}
uint32_t circular_buffer_read_multi(circular_buffer_t *c, uint8_t *data, const uint32_t len) {
+ ATOMIC_BLOCK_ALL {
for (uint32_t i = 0; i < len; i++) {
- ATOMIC_BLOCK(MAX_PRIORITY) {
if (c->head == c->tail)
return i;
