From 44abc8f2e468fa0979bb0d223daaf7163eb047d8 Mon Sep 17 00:00:00 2001 From: Anders Hoglund Date: Sat, 1 Oct 2016 18:30:58 +0200 Subject: [PATCH 1/3] Clean up vtx.c includes, move all not directly used to where they belong. --- src/main/config/config.h | 2 ++ src/main/config/config_master.h | 39 ++++++++++++-------------------- src/main/config/config_profile.h | 5 ++++ src/main/drivers/accgyro.h | 2 ++ src/main/drivers/pwm_rx.h | 2 ++ src/main/fc/rc_controls.h | 2 ++ src/main/flight/imu.h | 5 ++++ src/main/flight/pid.h | 2 ++ src/main/io/ledstrip.h | 3 +++ src/main/io/serial.h | 2 ++ src/main/io/vtx.c | 20 ++++++---------- src/main/io/vtx.h | 2 ++ src/main/sensors/acceleration.h | 3 +++ src/main/sensors/gyro.h | 3 +++ 14 files changed, 54 insertions(+), 38 deletions(-) diff --git a/src/main/config/config.h b/src/main/config/config.h index 56f66645a..1432b6882 100644 --- a/src/main/config/config.h +++ b/src/main/config/config.h @@ -17,6 +17,8 @@ #pragma once +#include + #if FLASH_SIZE <= 128 #define MAX_PROFILE_COUNT 2 #else diff --git a/src/main/config/config_master.h b/src/main/config/config_master.h index 87a527e41..59d5a39fe 100644 --- a/src/main/config/config_master.h +++ b/src/main/config/config_master.h @@ -17,49 +17,38 @@ #pragma once -#include -#include #include -#include "common/color.h" -#include "common/axis.h" +#include "config/config_profile.h" -#include "drivers/sensor.h" -#include "drivers/accgyro.h" #include "drivers/pwm_rx.h" -#include "drivers/serial.h" -#include "sensors/sensors.h" -#include "sensors/gyro.h" -#include "sensors/acceleration.h" -#include "sensors/barometer.h" -#include "sensors/boardalignment.h" -#include "sensors/battery.h" +#include "fc/rc_controls.h" + +#include "flight/failsafe.h" +#include "flight/mixer.h" +#include "flight/imu.h" +#include "flight/navigation.h" #include "io/serial.h" #include "io/gimbal.h" #include "io/motors.h" #include "io/servos.h" -#include "fc/rc_controls.h" -#include "io/ledstrip.h" #include "io/gps.h" #include "io/osd.h" +#include "io/ledstrip.h" #include "io/vtx.h" #include "rx/rx.h" #include "telemetry/telemetry.h" -#include "flight/mixer.h" -#include "flight/pid.h" -#include "flight/imu.h" -#include "flight/failsafe.h" -#include "flight/altitudehold.h" -#include "flight/navigation.h" - -#include "config/config.h" -#include "config/config_profile.h" -#include "config/config_master.h" +#include "sensors/sensors.h" +#include "sensors/gyro.h" +#include "sensors/acceleration.h" +#include "sensors/boardalignment.h" +#include "sensors/barometer.h" +#include "sensors/battery.h" // System-wide diff --git a/src/main/config/config_profile.h b/src/main/config/config_profile.h index 1ecbc29fc..b66233df0 100644 --- a/src/main/config/config_profile.h +++ b/src/main/config/config_profile.h @@ -17,6 +17,11 @@ #pragma once +#include "config/config.h" +#include "common/axis.h" +#include "fc/rc_controls.h" +#include "flight/pid.h" + typedef struct profile_s { pidProfile_t pidProfile; uint8_t activeRateProfile; diff --git a/src/main/drivers/accgyro.h b/src/main/drivers/accgyro.h index 3d90de1bc..0020d770f 100644 --- a/src/main/drivers/accgyro.h +++ b/src/main/drivers/accgyro.h @@ -17,6 +17,8 @@ #pragma once +#include "drivers/sensor.h" + #ifndef MPU_I2C_INSTANCE #define MPU_I2C_INSTANCE I2C_DEVICE #endif diff --git a/src/main/drivers/pwm_rx.h b/src/main/drivers/pwm_rx.h index 5158a2465..b59c5c484 100644 --- a/src/main/drivers/pwm_rx.h +++ b/src/main/drivers/pwm_rx.h @@ -17,6 +17,8 @@ #pragma once +#include "drivers/timer.h" + typedef enum { INPUT_FILTERING_DISABLED = 0, INPUT_FILTERING_ENABLED diff --git a/src/main/fc/rc_controls.h b/src/main/fc/rc_controls.h index 87008c129..6c84dee56 100644 --- a/src/main/fc/rc_controls.h +++ b/src/main/fc/rc_controls.h @@ -17,6 +17,8 @@ #pragma once +#include + typedef enum { BOXARM = 0, BOXANGLE, diff --git a/src/main/flight/imu.h b/src/main/flight/imu.h index 43a629ce3..5fac3452c 100644 --- a/src/main/flight/imu.h +++ b/src/main/flight/imu.h @@ -17,6 +17,11 @@ #pragma once +#include "common/axis.h" +#include "common/maths.h" + +#include "sensors/acceleration.h" + extern int16_t throttleAngleCorrection; extern uint32_t accTimeSum; extern int accSumCount; diff --git a/src/main/flight/pid.h b/src/main/flight/pid.h index 464989b8d..38b7a81f1 100644 --- a/src/main/flight/pid.h +++ b/src/main/flight/pid.h @@ -17,6 +17,8 @@ #pragma once +#include + #define GYRO_I_MAX 256 // Gyro I limiter #define YAW_P_LIMIT_MIN 100 // Maximum value for yaw P limiter #define YAW_P_LIMIT_MAX 500 // Maximum value for yaw P limiter diff --git a/src/main/io/ledstrip.h b/src/main/io/ledstrip.h index b7497d6a5..a60b040b4 100644 --- a/src/main/io/ledstrip.h +++ b/src/main/io/ledstrip.h @@ -17,6 +17,9 @@ #pragma once +#include +#include "common/color.h" + #define LED_MAX_STRIP_LENGTH 32 #define LED_CONFIGURABLE_COLOR_COUNT 16 #define LED_MODE_COUNT 6 diff --git a/src/main/io/serial.h b/src/main/io/serial.h index 0448d3e59..38d6851d2 100644 --- a/src/main/io/serial.h +++ b/src/main/io/serial.h @@ -17,6 +17,8 @@ #pragma once +#include "drivers/serial.h" + typedef enum { PORTSHARING_UNUSED = 0, PORTSHARING_NOT_SHARED, diff --git a/src/main/io/vtx.c b/src/main/io/vtx.c index c4c859a17..0b4e72791 100644 --- a/src/main/io/vtx.c +++ b/src/main/io/vtx.c @@ -15,27 +15,21 @@ * along with Cleanflight. If not, see . */ -#include -#include +// Get target build configuration #include "platform.h" #ifdef VTX -#include "drivers/vtx_rtc6705.h" - -#include "fc/rc_controls.h" -#include "fc/runtime_config.h" - -#include "flight/pid.h" - -#include "io/beeper.h" +// Own interfaces #include "io/vtx.h" -#include "config/config.h" -#include "config/config_eeprom.h" -#include "config/config_profile.h" +//External dependencies #include "config/config_master.h" +#include "config/config_eeprom.h" +#include "drivers/vtx_rtc6705.h" +#include "fc/runtime_config.h" +#include "io/beeper.h" static uint8_t locked = 0; diff --git a/src/main/io/vtx.h b/src/main/io/vtx.h index fdd5e506f..939c84d70 100644 --- a/src/main/io/vtx.h +++ b/src/main/io/vtx.h @@ -17,6 +17,8 @@ #pragma once +#include "fc/rc_controls.h" + #define VTX_BAND_MIN 1 #define VTX_BAND_MAX 5 #define VTX_CHANNEL_MIN 1 diff --git a/src/main/sensors/acceleration.h b/src/main/sensors/acceleration.h index b7a63ecbc..c4050fc9d 100644 --- a/src/main/sensors/acceleration.h +++ b/src/main/sensors/acceleration.h @@ -17,6 +17,9 @@ #pragma once +#include "drivers/accgyro.h" +#include "sensors/sensors.h" + // Type of accelerometer used/detected typedef enum { ACC_DEFAULT = 0, diff --git a/src/main/sensors/gyro.h b/src/main/sensors/gyro.h index 32d53b126..2946a4602 100644 --- a/src/main/sensors/gyro.h +++ b/src/main/sensors/gyro.h @@ -17,6 +17,9 @@ #pragma once +#include "drivers/accgyro.h" +#include "common/axis.h" + typedef enum { GYRO_NONE = 0, GYRO_DEFAULT, From 15e24e20159392ec1192a871933b03ab352f5693 Mon Sep 17 00:00:00 2001 From: Anders Hoglund Date: Sun, 2 Oct 2016 13:49:00 +0200 Subject: [PATCH 2/3] Removed not needed fwd declaraions and includes. --- src/main/drivers/pwm_rx.h | 1 - src/main/flight/imu.h | 6 ------ src/main/io/ledstrip.h | 1 - 3 files changed, 8 deletions(-) diff --git a/src/main/drivers/pwm_rx.h b/src/main/drivers/pwm_rx.h index b59c5c484..b30279617 100644 --- a/src/main/drivers/pwm_rx.h +++ b/src/main/drivers/pwm_rx.h @@ -26,7 +26,6 @@ typedef enum { #define PPM_RCVR_TIMEOUT 0 -struct timerHardware_s; void ppmInConfig(const struct timerHardware_s *timerHardwarePtr); void ppmAvoidPWMTimerClash(const struct timerHardware_s *timerHardwarePtr, TIM_TypeDef *sharedPwmTimer, uint8_t pwmProtocol); diff --git a/src/main/flight/imu.h b/src/main/flight/imu.h index 5fac3452c..3d43658e7 100644 --- a/src/main/flight/imu.h +++ b/src/main/flight/imu.h @@ -22,12 +22,6 @@ #include "sensors/acceleration.h" -extern int16_t throttleAngleCorrection; -extern uint32_t accTimeSum; -extern int accSumCount; -extern float accVelScale; -extern int32_t accSum[XYZ_AXIS_COUNT]; - #define DEGREES_TO_DECIDEGREES(angle) (angle * 10) #define DECIDEGREES_TO_DEGREES(angle) (angle / 10) #define DECIDEGREES_TO_RADIANS(angle) ((angle / 10.0f) * 0.0174532925f) diff --git a/src/main/io/ledstrip.h b/src/main/io/ledstrip.h index a60b040b4..eff11d7cf 100644 --- a/src/main/io/ledstrip.h +++ b/src/main/io/ledstrip.h @@ -17,7 +17,6 @@ #pragma once -#include #include "common/color.h" #define LED_MAX_STRIP_LENGTH 32 From a1599d0c18f36bd879454b3bb870a722cfbfa4fc Mon Sep 17 00:00:00 2001 From: Anders Hoglund Date: Sun, 2 Oct 2016 14:04:28 +0200 Subject: [PATCH 3/3] Re-add some of the prev removed export symbols in imu.h --- src/main/flight/imu.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/flight/imu.h b/src/main/flight/imu.h index 3d43658e7..28751a86f 100644 --- a/src/main/flight/imu.h +++ b/src/main/flight/imu.h @@ -22,6 +22,13 @@ #include "sensors/acceleration.h" +// Exported symbols +extern uint32_t accTimeSum; +extern int accSumCount; +extern float accVelScale; +extern int32_t accSum[XYZ_AXIS_COUNT]; + + #define DEGREES_TO_DECIDEGREES(angle) (angle * 10) #define DECIDEGREES_TO_DEGREES(angle) (angle / 10) #define DECIDEGREES_TO_RADIANS(angle) ((angle / 10.0f) * 0.0174532925f)