|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
Circular FIFO queue for can_msg_t pointers. More...
Data Structures | |
| struct | can_fifo_t |
| Internal circular buffer for queuing can_msg_t pointers. More... | |
Functions | |
| void | CanBufferFifo_initialize (void) |
| Clears all FIFO slots and resets head and tail to zero. | |
| bool | CanBufferFifo_push (can_msg_t *new_msg) |
| Pushes a can_msg_t pointer onto the tail of the FIFO. | |
| can_msg_t * | CanBufferFifo_pop (void) |
| Removes and returns the oldest can_msg_t from the FIFO. | |
| uint8_t | CanBufferFifo_is_empty (void) |
| Returns non-zero if the FIFO is empty, zero if messages are present. | |
| uint16_t | CanBufferFifo_get_allocated_count (void) |
| Returns the number of can_msg_t pointers currently in the FIFO. | |
Circular FIFO queue for can_msg_t pointers.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Uses one extra slot (USER_DEFINED_CAN_MSG_BUFFER_DEPTH + 1) so that head == tail always means empty without needing a separate counter.
| void CanBufferFifo_initialize | ( | void | ) |
Clears all FIFO slots and resets head and tail to zero.
Algorithm:
| bool CanBufferFifo_push | ( | can_msg_t * | new_msg | ) |
Pushes a can_msg_t pointer onto the tail of the FIFO.
Algorithm:
* @param new_msg Pointer to an allocated @ref can_msg_t. *
| can_msg_t * CanBufferFifo_pop | ( | void | ) |
| uint8_t CanBufferFifo_is_empty | ( | void | ) |
Returns non-zero if the FIFO is empty, zero if messages are present.
| uint16_t CanBufferFifo_get_allocated_count | ( | void | ) |
Returns the number of can_msg_t pointers currently in the FIFO.
Handles the wraparound case where tail > head.
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License