Fix from review.
[betaflight.git] / src / main / build / debug.h
blob43db3ee9b75a4ed8331e9ab091a19b08aaa9847e
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 #define DEBUG16_VALUE_COUNT 4
24 extern int16_t debug[DEBUG16_VALUE_COUNT];
25 extern uint8_t debugMode;
27 #define DEBUG_SET(mode, index, value) {if (debugMode == (mode)) {debug[(index)] = (value);}}
29 #define DEBUG_SECTION_TIMES
31 #ifdef DEBUG_SECTION_TIMES
32 extern uint32_t sectionTimes[2][4];
34 #define TIME_SECTION_BEGIN(index) { \
35 extern uint32_t sectionTimes[2][4]; \
36 sectionTimes[0][index] = micros(); \
39 #define TIME_SECTION_END(index) { \
40 extern uint32_t sectionTimes[2][4]; \
41 sectionTimes[1][index] = micros(); \
42 debug[index] = sectionTimes[1][index] - sectionTimes[0][index]; \
44 #else
46 #define TIME_SECTION_BEGIN(index) {}
47 #define TIME_SECTION_END(index) {}
49 #endif
51 typedef enum {
52 DEBUG_NONE,
53 DEBUG_CYCLETIME,
54 DEBUG_BATTERY,
55 DEBUG_GYRO_FILTERED,
56 DEBUG_ACCELEROMETER,
57 DEBUG_PIDLOOP,
58 DEBUG_GYRO_SCALED,
59 DEBUG_RC_INTERPOLATION,
60 DEBUG_ANGLERATE,
61 DEBUG_ESC_SENSOR,
62 DEBUG_SCHEDULER,
63 DEBUG_STACK,
64 DEBUG_ESC_SENSOR_RPM,
65 DEBUG_ESC_SENSOR_TMP,
66 DEBUG_ALTITUDE,
67 DEBUG_FFT,
68 DEBUG_FFT_TIME,
69 DEBUG_FFT_FREQ,
70 DEBUG_RX_FRSKY_SPI,
71 DEBUG_GYRO_RAW,
72 DEBUG_DUAL_GYRO,
73 DEBUG_DUAL_GYRO_RAW,
74 DEBUG_DUAL_GYRO_COMBINE,
75 DEBUG_DUAL_GYRO_DIFF,
76 DEBUG_MAX7456_SIGNAL,
77 DEBUG_MAX7456_SPICLOCK,
78 DEBUG_SBUS,
79 DEBUG_FPORT,
80 DEBUG_RANGEFINDER,
81 DEBUG_RANGEFINDER_QUALITY,
82 DEBUG_LIDAR_TF,
83 DEBUG_CORE_TEMP,
84 DEBUG_RUNAWAY_TAKEOFF,
85 DEBUG_SDIO,
86 DEBUG_CURRENT,
87 DEBUG_USB,
88 DEBUG_SMARTAUDIO,
89 DEBUG_RTH,
90 DEBUG_ITERM_RELAX,
91 DEBUG_ACRO_TRAINER,
92 DEBUG_RC_SMOOTHING,
93 DEBUG_RX_SIGNAL_LOSS,
94 DEBUG_COUNT
95 } debugType_e;
97 extern const char * const debugModeNames[DEBUG_COUNT];