Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
circular_buffer.h
Go to the documentation of this file.
1/*
2 * General purpose circular buffer
3 *
4 * Copyright (C) 2021 Fabien-B <fabien-b@github.com>
5 *
6 * This file is part of paparazzi. See LICENCE file.
7 */
8
9#pragma once
10
11#include <stdint.h>
12#include <stddef.h>
13
29
35
42void circular_buffer_init(struct circular_buffer *cb, uint8_t *buffer, size_t len);
43
44
52int circular_buffer_get(struct circular_buffer *cb, uint8_t *buf, size_t len);
53
61int circular_buffer_put(struct circular_buffer *cb, uint8_t *buf, size_t len);
void circular_buffer_init(struct circular_buffer *cb, uint8_t *buffer, size_t len)
initialize a circular buffer.
cir_error
@ CIR_ERROR_NO_MSG
circular buffer is empty
@ CIR_ERROR_NO_SPACE_AVAILABLE
no space available in the circular buffer
@ CIR_ERROR_BUFFER_TOO_SMALL
destination buffer is too small
int circular_buffer_put(struct circular_buffer *cb, uint8_t *buf, size_t len)
Copy buf in the circular buffer.
int circular_buffer_get(struct circular_buffer *cb, uint8_t *buf, size_t len)
copy the next buffer available in cb to buf.
This is a general purpose circular buffer for storing buffers in a FIFO order.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.