Revised LPF1+LPF2 filter cutoff bandwidths from STMicro (#13239)
[betaflight.git] / src / main / common / streambuf.h
blob3eff560e9892ef366afae7850a54a21e96f811b5
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #pragma once
23 #include <stdint.h>
25 // simple buffer-based serializer/deserializer without implicit size check
27 typedef struct sbuf_s {
28 uint8_t *ptr; // data pointer must be first (sbuf_t* is equivalent to uint8_t **)
29 uint8_t *end;
30 } sbuf_t;
32 sbuf_t *sbufInit(sbuf_t *sbuf, uint8_t *ptr, uint8_t *end);
34 void sbufWriteU8(sbuf_t *dst, uint8_t val);
35 void sbufWriteU16(sbuf_t *dst, uint16_t val);
36 void sbufWriteU32(sbuf_t *dst, uint32_t val);
37 void sbufWriteU16BigEndian(sbuf_t *dst, uint16_t val);
38 void sbufWriteU32BigEndian(sbuf_t *dst, uint32_t val);
39 void sbufFill(sbuf_t *dst, uint8_t data, int len);
40 void sbufWriteData(sbuf_t *dst, const void *data, int len);
41 void sbufWriteString(sbuf_t *dst, const char *string);
42 void sbufWriteStringWithZeroTerminator(sbuf_t *dst, const char *string);
44 uint8_t sbufReadU8(sbuf_t *src);
45 uint16_t sbufReadU16(sbuf_t *src);
46 uint32_t sbufReadU32(sbuf_t *src);
47 void sbufReadData(sbuf_t *dst, void *data, int len);
49 int sbufBytesRemaining(sbuf_t *buf);
50 uint8_t* sbufPtr(sbuf_t *buf);
51 const uint8_t* sbufConstPtr(const sbuf_t *buf);
52 void sbufAdvance(sbuf_t *buf, int size);
54 void sbufSwitchToReader(sbuf_t *buf, uint8_t * base);