// Copyright (C) 2026 Hector van der Aa // Copyright (C) 2026 Association Exergie // SPDX-License-Identifier: GPL-3.0-or-later #include #include #include inline void ringBufferPush(ring_buffer_t *rb, uint32_t value) { rb->buffer[rb->w_head] = value; rb->w_head++; if (rb->w_head == rb->r_head) { // if write head catches up to read head, crash program as consumer task // should keep up with write head assert(false); } return; } inline int ringBufferPop(ring_buffer_t *rb, uint32_t *output) { if (rb->w_head == rb->r_head) { // if read head is at write head, buffer is empty so nothing to pop return 1; } *output = rb->buffer[rb->r_head]; rb->r_head++; return 0; }