LP-89 - Port OP_15.05.01 fixes. Release notes:
[librepilot.git] / flight / libraries / inc / fifo_buffer.h
blobd653529d7b8ce2285ec8c0eb6362aff08bf64a7a
1 /**
2 ******************************************************************************
4 * @file fifo_buffer.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @brief GPIO functions header.
7 * @see The GNU Public License (GPL) Version 3
9 *****************************************************************************/
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #ifndef _FIFO_BUFFER_H_
27 #define _FIFO_BUFFER_H_
29 #include "stdint.h"
31 // *********************
33 typedef struct {
34 uint8_t *buf_ptr;
35 volatile uint16_t rd;
36 volatile uint16_t wr;
37 uint16_t buf_size;
38 } t_fifo_buffer;
40 // *********************
42 uint16_t fifoBuf_getSize(t_fifo_buffer *buf);
44 uint16_t fifoBuf_getUsed(t_fifo_buffer *buf);
45 uint16_t fifoBuf_getFree(t_fifo_buffer *buf);
47 void fifoBuf_clearData(t_fifo_buffer *buf);
48 void fifoBuf_removeData(t_fifo_buffer *buf, uint16_t len);
50 int16_t fifoBuf_getBytePeek(t_fifo_buffer *buf);
51 int16_t fifoBuf_getByte(t_fifo_buffer *buf);
53 uint16_t fifoBuf_getDataPeek(t_fifo_buffer *buf, void *data, uint16_t len);
54 uint16_t fifoBuf_getData(t_fifo_buffer *buf, void *data, uint16_t len);
56 uint16_t fifoBuf_putByte(t_fifo_buffer *buf, const uint8_t b);
58 uint16_t fifoBuf_putData(t_fifo_buffer *buf, const void *data, uint16_t len);
60 void fifoBuf_init(t_fifo_buffer *buf, const void *buffer, const uint16_t buffer_size);
62 // *********************
64 #endif // ifndef _FIFO_BUFFER_H_