Merge pull request #10558 from iNavFlight/MrD_Correct-comments-on-OSD-symbols
[inav.git] / src / main / blackbox / blackbox_io.h
blob76b03b5cd6a2ecfd519022860546ef05e1899820
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight 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.
9 * Cleanflight 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.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #pragma once
20 #include <stdint.h>
21 #include <stdbool.h>
23 #include "platform.h"
25 typedef enum BlackboxDevice {
26 BLACKBOX_DEVICE_SERIAL = 0,
28 #ifdef USE_FLASHFS
29 BLACKBOX_DEVICE_FLASH = 1,
30 #endif
31 #ifdef USE_SDCARD
32 BLACKBOX_DEVICE_SDCARD = 2,
33 #endif
34 #if defined(SITL_BUILD)
35 BLACKBOX_DEVICE_FILE = 3,
36 #endif
38 BLACKBOX_DEVICE_END
39 } BlackboxDevice;
41 typedef enum {
42 BLACKBOX_RESERVE_SUCCESS,
43 BLACKBOX_RESERVE_TEMPORARY_FAILURE,
44 BLACKBOX_RESERVE_PERMANENT_FAILURE
45 } blackboxBufferReserveStatus_e;
48 * We want to limit how bursty our writes to the device are. Note that this will also restrict the maximum size of a
49 * header write we can make:
51 #define BLACKBOX_MAX_ACCUMULATED_HEADER_BUDGET 256
54 * Ideally, each iteration in which we are logging headers would write a similar amount of data to the device as a
55 * regular logging iteration. This way we won't hog the CPU by making a gigantic write:
57 #define BLACKBOX_TARGET_HEADER_BUDGET_PER_ITERATION 64
59 extern int32_t blackboxHeaderBudget;
61 void blackboxOpen(void);
62 void blackboxWrite(uint8_t value);
64 void blackboxDeviceFlush(void);
65 bool blackboxDeviceFlushForce(void);
66 bool blackboxDeviceOpen(void);
67 void blackboxDeviceClose(void);
69 bool blackboxDeviceBeginLog(void);
70 bool blackboxDeviceEndLog(bool retainLog);
72 bool isBlackboxDeviceFull(void);
73 bool isBlackboxDeviceWorking(void);
74 int32_t blackboxGetLogNumber(void);
76 void blackboxReplenishHeaderBudget(void);
77 blackboxBufferReserveStatus_e blackboxDeviceReserveBufferSpace(int32_t bytes);