mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Cleanup debug code.
This commit is contained in:
parent
c11c25514b
commit
f28158a5a7
22 changed files with 107 additions and 68 deletions
1
Makefile
1
Makefile
|
@ -212,6 +212,7 @@ INCLUDE_DIRS := $(INCLUDE_DIRS) \
|
|||
VPATH := $(VPATH):$(TARGET_DIR)
|
||||
|
||||
COMMON_SRC = build_config.c \
|
||||
debug.c \
|
||||
version.c \
|
||||
$(TARGET_SRC) \
|
||||
config/config.c \
|
||||
|
|
|
@ -35,27 +35,3 @@
|
|||
#define REQUIRE_PRINTF_LONG_SUPPORT
|
||||
#endif
|
||||
|
||||
extern int16_t debug[4];
|
||||
|
||||
#define DEBUG_SECTION_TIMES
|
||||
|
||||
#ifdef DEBUG_SECTION_TIMES
|
||||
extern uint32_t sectionTimes[2][4];
|
||||
|
||||
#define TIME_SECTION_BEGIN(index) { \
|
||||
extern uint32_t sectionTimes[2][4]; \
|
||||
sectionTimes[0][index] = micros(); \
|
||||
}
|
||||
|
||||
#define TIME_SECTION_END(index) { \
|
||||
extern uint32_t sectionTimes[2][4]; \
|
||||
sectionTimes[1][index] = micros(); \
|
||||
debug[index] = sectionTimes[1][index] - sectionTimes[0][index]; \
|
||||
}
|
||||
#else
|
||||
|
||||
#define TIME_SECTION_BEGIN(index) {}
|
||||
#define TIME_SECTION_END(index) {}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
27
src/main/debug.c
Normal file
27
src/main/debug.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
int16_t debug[DEBUG16_VALUE_COUNT];
|
||||
|
||||
#ifdef DEBUG_SECTION_TIMES
|
||||
uint32_t sectionTimes[2][4];
|
||||
#endif
|
41
src/main/debug.h
Normal file
41
src/main/debug.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define DEBUG16_VALUE_COUNT 4
|
||||
extern int16_t debug[DEBUG16_VALUE_COUNT];
|
||||
|
||||
#define DEBUG_SECTION_TIMES
|
||||
|
||||
#ifdef DEBUG_SECTION_TIMES
|
||||
extern uint32_t sectionTimes[2][4];
|
||||
|
||||
#define TIME_SECTION_BEGIN(index) { \
|
||||
extern uint32_t sectionTimes[2][4]; \
|
||||
sectionTimes[0][index] = micros(); \
|
||||
}
|
||||
|
||||
#define TIME_SECTION_END(index) { \
|
||||
extern uint32_t sectionTimes[2][4]; \
|
||||
sectionTimes[1][index] = micros(); \
|
||||
debug[index] = sectionTimes[1][index] - sectionTimes[0][index]; \
|
||||
}
|
||||
#else
|
||||
|
||||
#define TIME_SECTION_BEGIN(index) {}
|
||||
#define TIME_SECTION_END(index) {}
|
||||
|
||||
#endif
|
|
@ -19,8 +19,8 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "build_config.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "common/maths.h"
|
||||
|
||||
|
@ -32,8 +32,6 @@
|
|||
#include "accgyro.h"
|
||||
#include "accgyro_l3gd20.h"
|
||||
|
||||
extern int16_t debug[4];
|
||||
|
||||
#define READ_CMD ((uint8_t)0x80)
|
||||
#define MULTIPLEBYTE_CMD ((uint8_t)0x40)
|
||||
#define DUMMY_BYTE ((uint8_t)0x00)
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "build_config.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "common/maths.h"
|
||||
#include "common/axis.h"
|
||||
|
@ -31,8 +33,6 @@
|
|||
#include "accgyro.h"
|
||||
#include "accgyro_lsm303dlhc.h"
|
||||
|
||||
extern int16_t debug[4];
|
||||
|
||||
// Addresses (7 bit address format)
|
||||
|
||||
#define LSM303DLHC_ACCEL_ADDRESS 0x19
|
||||
|
|
|
@ -18,9 +18,10 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "build_config.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "build_config.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include "adc.h"
|
||||
|
@ -32,7 +33,6 @@
|
|||
adc_config_t adcConfig[ADC_CHANNEL_COUNT];
|
||||
volatile uint16_t adcValues[ADC_CHANNEL_COUNT];
|
||||
|
||||
extern int16_t debug[4];
|
||||
|
||||
uint16_t adcGetChannel(uint8_t channel)
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
|
||||
#include "platform.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "common/maths.h"
|
||||
#include "common/axis.h"
|
||||
|
@ -46,8 +47,6 @@
|
|||
|
||||
#include "config/runtime_config.h"
|
||||
|
||||
extern int16_t debug[4];
|
||||
|
||||
int32_t setVelocity = 0;
|
||||
uint8_t velocityControl = 0;
|
||||
int32_t errorVelocityI = 0;
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "build_config.h"
|
||||
#include "debug.h"
|
||||
|
||||
#ifdef AUTOTUNE
|
||||
|
||||
|
@ -40,8 +42,6 @@
|
|||
#include "config/config.h"
|
||||
#include "blackbox/blackbox.h"
|
||||
|
||||
extern int16_t debug[4];
|
||||
|
||||
/*
|
||||
* Authors
|
||||
* Brad Quick - initial implementation in BradWii
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
|
||||
#include "common/maths.h"
|
||||
|
||||
#include <platform.h>
|
||||
#include "platform.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "common/axis.h"
|
||||
|
||||
|
@ -45,9 +46,6 @@
|
|||
|
||||
#include "config/runtime_config.h"
|
||||
|
||||
|
||||
extern int16_t debug[4];
|
||||
|
||||
int16_t accSmooth[XYZ_AXIS_COUNT];
|
||||
int32_t accSum[XYZ_AXIS_COUNT];
|
||||
int16_t gyroData[FLIGHT_DYNAMICS_INDEX_COUNT] = { 0, 0, 0 };
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "build_config.h"
|
||||
|
||||
|
@ -57,8 +58,6 @@
|
|||
|
||||
//#define MIXER_DEBUG
|
||||
|
||||
extern int16_t debug[4];
|
||||
|
||||
uint8_t motorCount = 0;
|
||||
int16_t motor[MAX_SUPPORTED_MOTORS];
|
||||
int16_t motor_disarmed[MAX_SUPPORTED_MOTORS];
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "common/maths.h"
|
||||
#include "common/axis.h"
|
||||
|
@ -53,8 +54,6 @@ extern int16_t magHold;
|
|||
|
||||
#ifdef GPS
|
||||
|
||||
extern int16_t debug[4];
|
||||
|
||||
bool areSticksInApModePosition(uint16_t ap_mode);
|
||||
|
||||
// **********************
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "build_config.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "common/maths.h"
|
||||
#include "common/axis.h"
|
||||
|
@ -51,9 +51,6 @@
|
|||
|
||||
#ifdef GPS
|
||||
|
||||
extern int16_t debug[4];
|
||||
|
||||
|
||||
#define LOG_ERROR '?'
|
||||
#define LOG_IGNORED '!'
|
||||
#define LOG_SKIPPED '>'
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "build_config.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
|
@ -88,7 +89,6 @@ static serialPort_t *mspSerialPort;
|
|||
|
||||
extern uint16_t cycleTime; // FIXME dependency on mw.c
|
||||
extern uint16_t rssi; // FIXME dependency on mw.c
|
||||
extern int16_t debug[4]; // FIXME dependency on mw.c
|
||||
|
||||
void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions, escAndServoConfig_t *escAndServoConfigToUse, pidProfile_t *pidProfileToUse);
|
||||
|
||||
|
@ -1077,10 +1077,12 @@ static bool processOutCommand(uint8_t cmdMSP)
|
|||
break;
|
||||
#endif
|
||||
case MSP_DEBUG:
|
||||
headSerialReply(8);
|
||||
// make use of this crap, output some useful QA statistics
|
||||
//debug[3] = ((hse_value / 1000000) * 1000) + (SystemCoreClock / 1000000); // XX0YY [crystal clock : core clock]
|
||||
for (i = 0; i < 4; i++)
|
||||
headSerialReply(DEBUG16_VALUE_COUNT * sizeof(debug[0]));
|
||||
|
||||
// output some useful QA statistics
|
||||
// debug[x] = ((hse_value / 1000000) * 1000) + (SystemCoreClock / 1000000); // XX0YY [crystal clock : core clock]
|
||||
|
||||
for (i = 0; i < DEBUG16_VALUE_COUNT; i++)
|
||||
serialize16(debug[i]); // 4 variables are here for general monitoring purpose
|
||||
break;
|
||||
|
||||
|
|
|
@ -87,10 +87,8 @@
|
|||
#endif
|
||||
|
||||
#include "build_config.h"
|
||||
#include "debug.h"
|
||||
|
||||
#ifdef DEBUG_SECTION_TIMES
|
||||
uint32_t sectionTimes[2][4];
|
||||
#endif
|
||||
extern uint32_t previousTime;
|
||||
|
||||
#ifdef SOFTSERIAL_LOOPBACK
|
||||
|
|
|
@ -90,7 +90,6 @@ enum {
|
|||
/* for VBAT monitoring frequency */
|
||||
#define VBATFREQ 6 // to read battery voltage - nth number of loop iterations
|
||||
|
||||
int16_t debug[4];
|
||||
uint32_t currentTime = 0;
|
||||
uint32_t previousTime = 0;
|
||||
uint16_t cycleTime = 0; // this is the number in micro second to achieve a full loop, it can differ a little and is taken into account in the PID loop
|
||||
|
|
|
@ -21,9 +21,10 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "build_config.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "build_config.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
#include "common/maths.h"
|
||||
|
||||
|
@ -48,8 +49,6 @@
|
|||
|
||||
#include "rx/rx.h"
|
||||
|
||||
extern int16_t debug[4];
|
||||
|
||||
void rxPwmInit(rxRuntimeConfig_t *rxRuntimeConfig, rcReadRawDataPtr *callback);
|
||||
|
||||
bool sbusInit(rxConfig_t *initialRxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadRawDataPtr *callback);
|
||||
|
|
|
@ -57,8 +57,8 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "build_config.h"
|
||||
#include "debug.h"
|
||||
|
||||
#ifdef TELEMETRY
|
||||
|
||||
|
@ -81,8 +81,6 @@
|
|||
#include "telemetry/telemetry.h"
|
||||
#include "telemetry/hott.h"
|
||||
|
||||
extern int16_t debug[4];
|
||||
|
||||
//#define HOTT_DEBUG
|
||||
|
||||
#define HOTT_MESSAGE_PREPARATION_FREQUENCY_5_HZ ((1000 * 1000) / 5)
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#define BARO
|
||||
|
||||
extern "C" {
|
||||
#include "debug.h"
|
||||
|
||||
#include "common/axis.h"
|
||||
#include "common/maths.h"
|
||||
|
||||
|
@ -145,7 +147,7 @@ rollAndPitchInclination_t inclination;
|
|||
int32_t accSum[XYZ_AXIS_COUNT];
|
||||
//int16_t magADC[XYZ_AXIS_COUNT];
|
||||
int32_t BaroAlt;
|
||||
int16_t debug[4];
|
||||
int16_t debug[DEBUG16_VALUE_COUNT];
|
||||
|
||||
uint8_t stateFlags;
|
||||
uint16_t flightModeFlags;
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#define BARO
|
||||
|
||||
extern "C" {
|
||||
#include "debug.h"
|
||||
|
||||
#include "common/axis.h"
|
||||
#include "common/maths.h"
|
||||
|
||||
|
@ -79,7 +81,7 @@ int16_t heading;
|
|||
gyro_t gyro;
|
||||
int16_t magADC[XYZ_AXIS_COUNT];
|
||||
int32_t BaroAlt;
|
||||
int16_t debug[4];
|
||||
int16_t debug[DEBUG16_VALUE_COUNT];
|
||||
|
||||
uint8_t stateFlags;
|
||||
uint16_t flightModeFlags;
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include <limits.h>
|
||||
|
||||
extern "C" {
|
||||
#include "debug.h"
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "common/axis.h"
|
||||
|
@ -293,7 +295,7 @@ int16_t rcCommand[4];
|
|||
int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT];
|
||||
|
||||
uint32_t rcModeActivationMask;
|
||||
int16_t debug[4];
|
||||
int16_t debug[DEBUG16_VALUE_COUNT];
|
||||
|
||||
uint8_t stateFlags;
|
||||
uint16_t flightModeFlags;
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include <limits.h>
|
||||
|
||||
extern "C" {
|
||||
#include "debug.h"
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "common/axis.h"
|
||||
|
@ -148,7 +150,7 @@ TEST(TelemetryHottTest, PrepareGPSMessage_Altitude1m)
|
|||
|
||||
extern "C" {
|
||||
|
||||
int16_t debug[4];
|
||||
int16_t debug[DEBUG16_VALUE_COUNT];
|
||||
|
||||
uint8_t stateFlags;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue