Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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 
24  size_t read_offset;
25  size_t write_offset;
26  size_t _buf_len;
28 };
29 
30 enum cir_error {
34 };
35 
42 void circular_buffer_init(struct circular_buffer *cb, uint8_t *buffer, size_t len);
43 
44 
52 int circular_buffer_get(struct circular_buffer *cb, uint8_t *buf, size_t len);
53 
61 int 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.
Definition: vl53l1_types.h:98