NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
blackbox_io.h
Go to the documentation of this file.
1 /*
2  * This file is part of Ninjaflight.
3  *
4  * Ninjaflight is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Ninjaflight is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Ninjaflight. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 typedef enum {
25 
26 /*
27  * We want to limit how bursty our writes to the device are. Note that this will also restrict the maximum size of a
28  * header write we can make:
29  */
30 #define BLACKBOX_MAX_ACCUMULATED_HEADER_BUDGET 256
31 
32 /*
33  * Ideally, each iteration in which we are logging headers would write a similar amount of data to the device as a
34  * regular logging iteration. This way we won't hog the CPU by making a gigantic write:
35  */
36 #define BLACKBOX_TARGET_HEADER_BUDGET_PER_ITERATION 64
37 
38 extern int32_t blackboxHeaderBudget;
39 
40 void blackboxWrite(struct blackbox *self, uint8_t value);
41 
42 int blackboxPrintf(const char *fmt, ...);
43 void blackboxPrintfHeaderLine(const char *fmt, ...);
44 int blackboxPrint(const char *s);
45 
46 void blackboxWriteUnsignedVB(uint32_t value);
47 void blackboxWriteSignedVB(int32_t value);
48 void blackboxWriteSignedVBArray(int32_t *array, int count);
49 void blackboxWriteSigned16VBArray(int16_t *array, int count);
50 void blackboxWriteS16(int16_t value);
51 void blackboxWriteTag2_3S32(int32_t *values);
52 void blackboxWriteTag8_4S16(int32_t *values);
53 void blackboxWriteTag8_8SVB(int32_t *values, int valueCount);
54 void blackboxWriteU32(int32_t value);
55 void blackboxWriteFloat(float value);
56 
57 void blackboxDeviceFlush(void);
58 bool blackboxDeviceFlushForce(void);
59 bool blackboxDeviceOpen(void);
60 void blackboxDeviceClose(void);
61 
62 bool blackboxDeviceBeginLog(void);
63 bool blackboxDeviceEndLog(bool retainLog);
64 
65 bool isBlackboxDeviceFull(void);
66 
int blackboxPrintf(const char *fmt,...)
Definition: blackbox_io.h:21
void blackboxWriteSigned16VBArray(int16_t *array, int count)
bool blackboxDeviceOpen(void)
void blackboxWrite(struct blackbox *self, uint8_t value)
void blackboxWriteTag8_8SVB(int32_t *values, int valueCount)
void blackboxDeviceClose(void)
void blackboxWriteTag8_4S16(int32_t *values)
void blackboxWriteU32(int32_t value)
uint8_t bytes[UBLOX_BUFFER_SIZE]
Definition: gps.c:833
Definition: blackbox_io.h:23
bool blackboxDeviceEndLog(bool retainLog)
blackboxBufferReserveStatus_e
Definition: blackbox_io.h:20
void blackboxWriteUnsignedVB(uint32_t value)
void blackboxPrintfHeaderLine(const char *fmt,...)
void blackboxWriteS16(int16_t value)
rollAndPitchTrims_t_def values
Definition: accelerometer.h:52
void blackboxWriteSignedVBArray(int32_t *array, int count)
bool blackboxDeviceBeginLog(void)
void blackboxWriteFloat(float value)
void blackboxWriteSignedVB(int32_t value)
int32_t blackboxHeaderBudget
Definition: blackbox.h:90
void blackboxReplenishHeaderBudget(void)
Definition: blackbox_io.h:22
blackboxBufferReserveStatus_e blackboxDeviceReserveBufferSpace(int32_t bytes)
void blackboxWriteTag2_3S32(int32_t *values)
bool isBlackboxDeviceFull(void)
int blackboxPrint(const char *s)
void blackboxDeviceFlush(void)
bool blackboxDeviceFlushForce(void)