diff --git a/src/main/blackbox/blackbox.c b/src/main/blackbox/blackbox.c index 406ce05d3..d2fcb40a5 100644 --- a/src/main/blackbox/blackbox.c +++ b/src/main/blackbox/blackbox.c @@ -72,6 +72,7 @@ #include "flight/altitudehold.h" #include "flight/failsafe.h" #include "flight/imu.h" +#include "flight/pid.h" #include "flight/navigation.h" #include "config/runtime_config.h" diff --git a/src/main/blackbox/blackbox_io.c b/src/main/blackbox/blackbox_io.c index cd4f05d98..88306767c 100644 --- a/src/main/blackbox/blackbox_io.c +++ b/src/main/blackbox/blackbox_io.c @@ -53,6 +53,7 @@ #include "flight/altitudehold.h" #include "flight/failsafe.h" #include "flight/imu.h" +#include "flight/pid.h" #include "flight/navigation.h" #include "config/runtime_config.h" diff --git a/src/main/common/printf.h b/src/main/common/printf.h index ac5493590..467b054d5 100644 --- a/src/main/common/printf.h +++ b/src/main/common/printf.h @@ -102,13 +102,10 @@ For further details see source code. regs Kusti, 23.10.2004 */ -#ifndef __TFP_PRINTF__ -#define __TFP_PRINTF__ +#pragma once #include -#include "drivers/serial.h" - void init_printf(void *putp, void (*putf) (void *, char)); int tfp_printf(const char *fmt, ...); @@ -119,8 +116,6 @@ int tfp_format(void *putp, void (*putf) (void *, char), const char *fmt, va_list #define printf tfp_printf #define sprintf tfp_sprintf -void setPrintfSerialPort(serialPort_t *serialPort); +struct serialPort_s; +void setPrintfSerialPort(struct serialPort_s *serialPort); void printfSupportInit(void); - - -#endif diff --git a/src/main/flight/altitudehold.h b/src/main/flight/altitudehold.h index 3677fbb28..da1697881 100644 --- a/src/main/flight/altitudehold.h +++ b/src/main/flight/altitudehold.h @@ -15,19 +15,21 @@ * along with Cleanflight. If not, see . */ -#include "io/escservo.h" -#include "io/rc_controls.h" -#include "flight/pid.h" - -#include "sensors/barometer.h" +#pragma once extern int32_t AltHold; extern int32_t vario; void calculateEstimatedAltitude(uint32_t currentTime); -void configureAltitudeHold(pidProfile_t *initialPidProfile, barometerConfig_t *intialBarometerConfig, rcControlsConfig_t *initialRcControlsConfig, escAndServoConfig_t *initialEscAndServoConfig); -void applyAltHold(airplaneConfig_t *airplaneConfig); +struct pidProfile_s; +struct barometerConfig_s; +struct rcControlsConfig_s; +struct escAndServoConfig_s; +void configureAltitudeHold(struct pidProfile_s *initialPidProfile, struct barometerConfig_s *intialBarometerConfig, struct rcControlsConfig_s *initialRcControlsConfig, struct escAndServoConfig_s *initialEscAndServoConfig); + +struct airplaneConfig_t; +void applyAltHold(struct airplaneConfig_s *airplaneConfig); void updateAltHoldState(void); void updateSonarAltHoldState(void); diff --git a/src/main/flight/imu.h b/src/main/flight/imu.h index 94b361fcf..e5229a2ea 100644 --- a/src/main/flight/imu.h +++ b/src/main/flight/imu.h @@ -69,9 +69,10 @@ typedef struct accProcessor_s { accProcessorState_e state; } accProcessor_t; +struct pidProfile_s; void imuConfigure( imuRuntimeConfig_t *initialImuRuntimeConfig, - pidProfile_t *initialPidProfile, + struct pidProfile_s *initialPidProfile, accDeadband_t *initialAccDeadband, uint16_t throttle_correction_angle ); diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 068012ad5..be1bcf203 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -51,6 +51,8 @@ uint32_t targetPidLooptime; bool pidStabilisationEnabled; +uint8_t PIDweight[3]; + int16_t axisPID[3]; // PIDweight is a scale factor for PIDs which is derived from the throttle and TPA setting, and 100 = 100% scale means no PID reduction diff --git a/src/main/flight/pid.h b/src/main/flight/pid.h index 60efb88a5..c4509887d 100644 --- a/src/main/flight/pid.h +++ b/src/main/flight/pid.h @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with Cleanflight. If not, see . */ -#include "rx/rx.h" #pragma once diff --git a/src/main/io/display.c b/src/main/io/display.c index 1e5eee974..a22ca8802 100644 --- a/src/main/io/display.c +++ b/src/main/io/display.c @@ -63,6 +63,8 @@ #include "io/display.h" +#include "rx/rx.h" + #include "scheduler/scheduler.h" extern profile_t *currentProfile; diff --git a/src/main/io/rc_controls.h b/src/main/io/rc_controls.h index aace839d9..a3622aaca 100644 --- a/src/main/io/rc_controls.h +++ b/src/main/io/rc_controls.h @@ -17,8 +17,6 @@ #pragma once -#include "rx/rx.h" - typedef enum { BOXARM = 0, BOXANGLE, @@ -167,8 +165,9 @@ typedef struct rcControlsConfig_s { bool areUsingSticksToArm(void); bool areSticksInApModePosition(uint16_t ap_mode); -throttleStatus_e calculateThrottleStatus(rxConfig_t *rxConfig, uint16_t deadband3d_throttle); -void processRcStickPositions(rxConfig_t *rxConfig, throttleStatus_e throttleStatus, bool disarm_kill_switch); +struct rxConfig_s; +throttleStatus_e calculateThrottleStatus(struct rxConfig_s *rxConfig, uint16_t deadband3d_throttle); +void processRcStickPositions(struct rxConfig_s *rxConfig, throttleStatus_e throttleStatus, bool disarm_kill_switch); bool isRangeActive(uint8_t auxChannelIndex, channelRange_t *range); void updateActivatedModes(modeActivationCondition_t *modeActivationConditions); @@ -257,7 +256,7 @@ bool isAirmodeActive(void); bool isSuperExpoActive(void); void resetAdjustmentStates(void); void updateAdjustmentStates(adjustmentRange_t *adjustmentRanges); -void processRcAdjustments(controlRateConfig_t *controlRateConfig, rxConfig_t *rxConfig); +void processRcAdjustments(controlRateConfig_t *controlRateConfig, struct rxConfig_s *rxConfig); bool isUsingSticksForArming(void); diff --git a/src/main/io/rc_curves.c b/src/main/io/rc_curves.c index 89b46522f..f96426bfd 100644 --- a/src/main/io/rc_curves.c +++ b/src/main/io/rc_curves.c @@ -18,13 +18,15 @@ #include #include -#include "io/rc_controls.h" -#include "io/escservo.h" - -#include "io/rc_curves.h" - #include "config/config.h" +#include "io/escservo.h" +#include "io/rc_curves.h" +#include "io/rc_controls.h" + +#include "rx/rx.h" + + #define THROTTLE_LOOKUP_LENGTH 12 static int16_t lookupThrottleRC[THROTTLE_LOOKUP_LENGTH]; // lookup table for expo & mid THROTTLE diff --git a/src/main/io/rc_curves.h b/src/main/io/rc_curves.h index 747a934df..406218d03 100644 --- a/src/main/io/rc_curves.h +++ b/src/main/io/rc_curves.h @@ -17,7 +17,9 @@ #pragma once -void generateThrottleCurve(controlRateConfig_t *controlRateConfig, escAndServoConfig_t *escAndServoConfig); +struct controlRateConfig_s; +struct escAndServoConfig_s; +void generateThrottleCurve(struct controlRateConfig_s *controlRateConfig, struct escAndServoConfig_s *escAndServoConfig); int16_t rcLookup(int32_t tmp, uint8_t expo, uint8_t rate); int16_t rcLookupThrottle(int32_t tmp); diff --git a/src/main/io/serial_4way.c b/src/main/io/serial_4way.c index 9bd2ba69e..0065cff89 100644 --- a/src/main/io/serial_4way.c +++ b/src/main/io/serial_4way.c @@ -23,21 +23,23 @@ #include #include "platform.h" + #ifdef USE_SERIAL_4WAY_BLHELI_INTERFACE -#include "drivers/serial.h" + #include "drivers/buf_writer.h" -#include "drivers/gpio.h" +#include "drivers/io.h" +#include "drivers/serial.h" #include "drivers/timer.h" #include "drivers/pwm_mapping.h" #include "drivers/pwm_output.h" #include "drivers/light_led.h" #include "drivers/system.h" + #include "flight/mixer.h" + #include "io/beeper.h" #include "io/serial_msp.h" -#include "io/serial_msp.h" #include "io/serial_4way.h" -#include "io/serial_4way_impl.h" #ifdef USE_SERIAL_4WAY_BLHELI_BOOTLOADER #include "io/serial_4way_avrootloader.h" diff --git a/src/main/io/serial_4way.h b/src/main/io/serial_4way.h index b1bba5ff6..8e0c934a9 100644 --- a/src/main/io/serial_4way.h +++ b/src/main/io/serial_4way.h @@ -17,7 +17,8 @@ */ #pragma once -#include "serial_4way_impl.h" +#include "drivers/io_types.h" +#include "io/serial_4way_impl.h" #define USE_SERIAL_4WAY_BLHELI_BOOTLOADER #define USE_SERIAL_4WAY_SK_BOOTLOADER @@ -46,5 +47,6 @@ typedef union __attribute__ ((packed)) { bool isMcuConnected(void); uint8_t esc4wayInit(void); -void esc4wayProcess(serialPort_t *mspPort); +struct serialPort_s; +void esc4wayProcess(struct serialPort_s *mspPort); void esc4wayRelease(void); diff --git a/src/main/io/serial_4way_avrootloader.c b/src/main/io/serial_4way_avrootloader.c index 223d3e10c..f3eeba532 100644 --- a/src/main/io/serial_4way_avrootloader.c +++ b/src/main/io/serial_4way_avrootloader.c @@ -25,7 +25,8 @@ #include "platform.h" #ifdef USE_SERIAL_4WAY_BLHELI_INTERFACE -#include "drivers/io_types.h" + +#include "drivers/io.h" #include "drivers/system.h" #include "drivers/serial.h" #include "drivers/timer.h" diff --git a/src/main/io/serial_4way_impl.h b/src/main/io/serial_4way_impl.h index a8f83bfae..351aba0b6 100644 --- a/src/main/io/serial_4way_impl.h +++ b/src/main/io/serial_4way_impl.h @@ -17,7 +17,7 @@ */ #pragma once -#include "drivers/io.h" +#include "drivers/io_types.h" typedef struct { IO_t io; diff --git a/src/main/io/serial_4way_stk500v2.c b/src/main/io/serial_4way_stk500v2.c index 342a0c8b0..0b406531f 100644 --- a/src/main/io/serial_4way_stk500v2.c +++ b/src/main/io/serial_4way_stk500v2.c @@ -23,7 +23,10 @@ #include #include "platform.h" + #ifdef USE_SERIAL_4WAY_BLHELI_INTERFACE + +#include "drivers/io.h" #include "drivers/serial.h" #include "config/config.h" #include "io/serial.h" diff --git a/src/main/io/serial_msp.c b/src/main/io/serial_msp.c index a2f472f45..031d0ddf6 100644 --- a/src/main/io/serial_msp.c +++ b/src/main/io/serial_msp.c @@ -37,6 +37,7 @@ #include "drivers/serial.h" #include "drivers/bus_i2c.h" +#include "drivers/io.h" #include "drivers/gpio.h" #include "drivers/timer.h" #include "drivers/pwm_rx.h" diff --git a/src/main/io/serial_msp.h b/src/main/io/serial_msp.h index 2778da7e2..114e94ab8 100644 --- a/src/main/io/serial_msp.h +++ b/src/main/io/serial_msp.h @@ -17,9 +17,6 @@ #pragma once -#include "io/serial.h" -#include "drivers/serial.h" - // Each MSP port requires state and a receive buffer, revisit this default if someone needs more than 2 MSP ports. #define MAX_MSP_PORT_COUNT 2 @@ -46,7 +43,9 @@ typedef struct mspPort_s { uint8_t cmdMSP; } mspPort_t; -void mspInit(serialConfig_t *serialConfig); +struct serialConfig_s; +void mspInit(struct serialConfig_s *serialConfig); void mspProcess(void); -void mspAllocateSerialPorts(serialConfig_t *serialConfig); -void mspReleasePortIfAllocated(serialPort_t *serialPort); +void mspAllocateSerialPorts(struct serialConfig_s *serialConfig); +struct serialPort_s; +void mspReleasePortIfAllocated(struct serialPort_s *serialPort); diff --git a/src/main/rx/rx.c b/src/main/rx/rx.c index a7a09a44b..bcba5bb86 100644 --- a/src/main/rx/rx.c +++ b/src/main/rx/rx.c @@ -32,15 +32,16 @@ #include "drivers/serial.h" #include "drivers/adc.h" -#include "io/serial.h" -#include "io/rc_controls.h" - -#include "flight/failsafe.h" - -#include "drivers/gpio.h" #include "drivers/timer.h" #include "drivers/pwm_rx.h" #include "drivers/system.h" + +#include "flight/failsafe.h" + +#include "io/serial.h" +#include "io/rc_controls.h" + +#include "rx/rx.h" #include "rx/pwm.h" #include "rx/sbus.h" #include "rx/spektrum.h" @@ -51,8 +52,6 @@ #include "rx/ibus.h" #include "rx/jetiexbus.h" -#include "rx/rx.h" - //#define DEBUG_RX_SIGNAL_LOSS diff --git a/src/main/rx/xbus.h b/src/main/rx/xbus.h index bc76f5678..cfaa920ff 100644 --- a/src/main/rx/xbus.h +++ b/src/main/rx/xbus.h @@ -17,7 +17,7 @@ #pragma once -#include "rx/rx.h" - -bool xBusInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadRawDataPtr *callback); +struct rxConfig_s; +struct rxRuntimeConfig_s; +bool xBusInit(struct rxConfig_s *rxConfig, struct rxRuntimeConfig_s *rxRuntimeConfig, rcReadRawDataPtr *callback); uint8_t xBusFrameStatus(void); diff --git a/src/main/sensors/battery.c b/src/main/sensors/battery.c index 75aac6cf0..6d165cbc5 100644 --- a/src/main/sensors/battery.c +++ b/src/main/sensors/battery.c @@ -35,6 +35,8 @@ #include "io/rc_controls.h" #include "io/beeper.h" +#include "rx/rx.h" + #define VBATT_PRESENT_THRESHOLD_MV 10 #define VBATT_LPF_FREQ 0.4f diff --git a/src/main/telemetry/frsky.h b/src/main/telemetry/frsky.h index 555eb43e8..89ba617c8 100644 --- a/src/main/telemetry/frsky.h +++ b/src/main/telemetry/frsky.h @@ -17,17 +17,17 @@ #pragma once -#include "rx/rx.h" - typedef enum { FRSKY_VFAS_PRECISION_LOW = 0, FRSKY_VFAS_PRECISION_HIGH } frskyVFasPrecision_e; -void handleFrSkyTelemetry(rxConfig_t *rxConfig, uint16_t deadband3d_throttle); +struct rxConfig_s; +void handleFrSkyTelemetry(struct rxConfig_s *rxConfig, uint16_t deadband3d_throttle); void checkFrSkyTelemetryState(void); -void initFrSkyTelemetry(telemetryConfig_t *telemetryConfig); +struct telemetryConfig_s; +void initFrSkyTelemetry(struct telemetryConfig_s *telemetryConfig); void configureFrSkyTelemetryPort(void); void freeFrSkyTelemetryPort(void);