From 72f622afbe987a762024cb7bf7a4eae12cc04b58 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 6 Apr 2024 20:46:54 +0200 Subject: [PATCH 01/13] Drop MSP_PID_ADVANCED and MSP_SET_PID_ADVANCED from MSP protocol --- src/main/fc/fc_msp.c | 42 ------------------------------------- src/main/msp/msp_protocol.h | 3 --- 2 files changed, 45 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index c1360fcce6..2bf9ea7051 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1236,25 +1236,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU16(dst, 0); //Was gyroConfig()->gyro_stage2_lowpass_hz break; - case MSP_PID_ADVANCED: - sbufWriteU16(dst, 0); // pidProfile()->rollPitchItermIgnoreRate - sbufWriteU16(dst, 0); // pidProfile()->yawItermIgnoreRate - sbufWriteU16(dst, 0); //pidProfile()->yaw_p_limit - sbufWriteU8(dst, 0); //BF: pidProfile()->deltaMethod - sbufWriteU8(dst, 0); //BF: pidProfile()->vbatPidCompensation - sbufWriteU8(dst, 0); //BF: pidProfile()->setpointRelaxRatio - sbufWriteU8(dst, 0); - sbufWriteU16(dst, pidProfile()->pidSumLimit); - sbufWriteU8(dst, 0); //BF: pidProfile()->itermThrottleGain - - /* - * To keep compatibility on MSP frame length level with Betaflight, axis axisAccelerationLimitYaw - * limit will be sent and received in [dps / 10] - */ - sbufWriteU16(dst, constrain(pidProfile()->axisAccelerationLimitRollPitch / 10, 0, 65535)); - sbufWriteU16(dst, constrain(pidProfile()->axisAccelerationLimitYaw / 10, 0, 65535)); - break; - case MSP_INAV_PID: sbufWriteU8(dst, 0); //Legacy, no longer in use async processing value sbufWriteU16(dst, 0); //Legacy, no longer in use async processing value @@ -2241,29 +2222,6 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; - case MSP_SET_PID_ADVANCED: - if (dataSize == 17) { - sbufReadU16(src); // pidProfileMutable()->rollPitchItermIgnoreRate - sbufReadU16(src); // pidProfileMutable()->yawItermIgnoreRate - sbufReadU16(src); //pidProfile()->yaw_p_limit - - sbufReadU8(src); //BF: pidProfileMutable()->deltaMethod - sbufReadU8(src); //BF: pidProfileMutable()->vbatPidCompensation - sbufReadU8(src); //BF: pidProfileMutable()->setpointRelaxRatio - sbufReadU8(src); - pidProfileMutable()->pidSumLimit = sbufReadU16(src); - sbufReadU8(src); //BF: pidProfileMutable()->itermThrottleGain - - /* - * To keep compatibility on MSP frame length level with Betaflight, axis axisAccelerationLimitYaw - * limit will be sent and received in [dps / 10] - */ - pidProfileMutable()->axisAccelerationLimitRollPitch = sbufReadU16(src) * 10; - pidProfileMutable()->axisAccelerationLimitYaw = sbufReadU16(src) * 10; - } else - return MSP_RESULT_ERROR; - break; - case MSP_SET_INAV_PID: if (dataSize == 15) { sbufReadU8(src); //Legacy, no longer in use async processing value diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index ea7902fccb..245b24a3ad 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -199,9 +199,6 @@ #define MSP_FILTER_CONFIG 92 #define MSP_SET_FILTER_CONFIG 93 -#define MSP_PID_ADVANCED 94 -#define MSP_SET_PID_ADVANCED 95 - #define MSP_SENSOR_CONFIG 96 #define MSP_SET_SENSOR_CONFIG 97 From 78ef85ace5854839cbec77968d60975f44328b7b Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Sat, 6 Apr 2024 20:58:44 +0200 Subject: [PATCH 02/13] Drop MSP_FILTER_CONFIG and MSP_SET_FILTER_CONFIG commands --- src/main/fc/fc_msp.c | 59 ------------------------------------- src/main/msp/msp_protocol.h | 3 -- 2 files changed, 62 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index c1360fcce6..8244922e20 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1218,24 +1218,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU8(dst, 0); break; - case MSP_FILTER_CONFIG : - sbufWriteU8(dst, gyroConfig()->gyro_main_lpf_hz); - sbufWriteU16(dst, pidProfile()->dterm_lpf_hz); - sbufWriteU16(dst, pidProfile()->yaw_lpf_hz); - sbufWriteU16(dst, 0); //Was gyroConfig()->gyro_notch_hz - sbufWriteU16(dst, 1); //Was gyroConfig()->gyro_notch_cutoff - sbufWriteU16(dst, 0); //BF: pidProfile()->dterm_notch_hz - sbufWriteU16(dst, 1); //pidProfile()->dterm_notch_cutoff - - sbufWriteU16(dst, 0); //BF: masterConfig.gyro_soft_notch_hz_2 - sbufWriteU16(dst, 1); //BF: masterConfig.gyro_soft_notch_cutoff_2 - - sbufWriteU16(dst, accelerometerConfig()->acc_notch_hz); - sbufWriteU16(dst, accelerometerConfig()->acc_notch_cutoff); - - sbufWriteU16(dst, 0); //Was gyroConfig()->gyro_stage2_lowpass_hz - break; - case MSP_PID_ADVANCED: sbufWriteU16(dst, 0); // pidProfile()->rollPitchItermIgnoreRate sbufWriteU16(dst, 0); // pidProfile()->yawItermIgnoreRate @@ -2200,47 +2182,6 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; - case MSP_SET_FILTER_CONFIG : - if (dataSize >= 5) { - gyroConfigMutable()->gyro_main_lpf_hz = sbufReadU8(src); - pidProfileMutable()->dterm_lpf_hz = constrain(sbufReadU16(src), 0, 500); - pidProfileMutable()->yaw_lpf_hz = constrain(sbufReadU16(src), 0, 255); - if (dataSize >= 9) { - sbufReadU16(src); //Was gyroConfigMutable()->gyro_notch_hz - sbufReadU16(src); //Was gyroConfigMutable()->gyro_notch_cutoff - } else { - return MSP_RESULT_ERROR; - } - if (dataSize >= 13) { - sbufReadU16(src); - sbufReadU16(src); - pidInitFilters(); - } else { - return MSP_RESULT_ERROR; - } - if (dataSize >= 17) { - sbufReadU16(src); // Was gyroConfigMutable()->gyro_soft_notch_hz_2 - sbufReadU16(src); // Was gyroConfigMutable()->gyro_soft_notch_cutoff_2 - } else { - return MSP_RESULT_ERROR; - } - - if (dataSize >= 21) { - accelerometerConfigMutable()->acc_notch_hz = constrain(sbufReadU16(src), 0, 255); - accelerometerConfigMutable()->acc_notch_cutoff = constrain(sbufReadU16(src), 1, 255); - } else { - return MSP_RESULT_ERROR; - } - - if (dataSize >= 22) { - sbufReadU16(src); //Was gyro_stage2_lowpass_hz - } else { - return MSP_RESULT_ERROR; - } - } else - return MSP_RESULT_ERROR; - break; - case MSP_SET_PID_ADVANCED: if (dataSize == 17) { sbufReadU16(src); // pidProfileMutable()->rollPitchItermIgnoreRate diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index ea7902fccb..d8b84c5f8e 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -196,9 +196,6 @@ #define MSP_ADVANCED_CONFIG 90 #define MSP_SET_ADVANCED_CONFIG 91 -#define MSP_FILTER_CONFIG 92 -#define MSP_SET_FILTER_CONFIG 93 - #define MSP_PID_ADVANCED 94 #define MSP_SET_PID_ADVANCED 95 From 7f831ce8fc1b5529ab85813fcf329731e10a30e1 Mon Sep 17 00:00:00 2001 From: 0crap <31951195+0crap@users.noreply.github.com> Date: Mon, 8 Apr 2024 12:54:16 +0200 Subject: [PATCH 03/13] Update Fixed Wing Landing.md Simple typo fix. --- docs/Fixed Wing Landing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Fixed Wing Landing.md b/docs/Fixed Wing Landing.md index 8e1a3ef6fc..9a4c3a5b4a 100644 --- a/docs/Fixed Wing Landing.md +++ b/docs/Fixed Wing Landing.md @@ -54,7 +54,7 @@ This means that practically 4 landing directions can be saved. > [!CAUTION] > The Configuator automatically determines the ground altitude based on databases on the Internet, which may be inaccurate. Please always compare with the measured GPS altitude at the landing site to avoid crashes. -### Global paramters +### Global parameters All settings are available via “Advanced Tuning” in the Configurator. @@ -104,7 +104,7 @@ If the altitude of the waypoint and the "Approach Altitude" are different, the a ## Logic Conditions -The current landing state can be retrieved via ID 41 in "Flight" (FW Land State). This allows additional actions to be executed according to the landing phases, e.g. deplyoment of the landing flaps. +The current landing state can be retrieved via ID 41 in "Flight" (FW Land State). This allows additional actions to be executed according to the landing phases, e.g. deployment of the landing flaps. | Returned value | State | | --- | --- | From c2c03b99f4d47cfbee916813f88caa985acb17eb Mon Sep 17 00:00:00 2001 From: Roman Lut <11955117+RomanLut@users.noreply.github.com> Date: Tue, 9 Apr 2024 13:40:48 +0200 Subject: [PATCH 04/13] do not remove nav modes in connected by usb --- src/main/fc/fc_msp_box.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/fc/fc_msp_box.c b/src/main/fc/fc_msp_box.c index 0cb2ab1b32..2745f7e041 100644 --- a/src/main/fc/fc_msp_box.c +++ b/src/main/fc/fc_msp_box.c @@ -213,7 +213,7 @@ void initActiveBoxIds(void) ADD_ACTIVE_BOX(BOXFPVANGLEMIX); } - bool navReadyAltControl = sensors(SENSOR_BARO); + bool navReadyAltControl = getHwBarometerStatus() != HW_SENSOR_NONE; #ifdef USE_GPS navReadyAltControl = navReadyAltControl || (feature(FEATURE_GPS) && (STATE(AIRPLANE) || positionEstimationConfig()->use_gps_no_baro)); From 755b312dabfafbed5a5df029f65e7c2f7ba6cf81 Mon Sep 17 00:00:00 2001 From: YI-BOYANG <46438966+YI-BOYANG@users.noreply.github.com> Date: Wed, 10 Apr 2024 10:45:02 +0800 Subject: [PATCH 05/13] Add TAKERF722SE target --- src/main/target/TAKERF722SE/CMakeLists.txt | 1 + src/main/target/TAKERF722SE/target.c | 48 ++++++ src/main/target/TAKERF722SE/target.h | 186 +++++++++++++++++++++ 3 files changed, 235 insertions(+) create mode 100644 src/main/target/TAKERF722SE/CMakeLists.txt create mode 100644 src/main/target/TAKERF722SE/target.c create mode 100644 src/main/target/TAKERF722SE/target.h diff --git a/src/main/target/TAKERF722SE/CMakeLists.txt b/src/main/target/TAKERF722SE/CMakeLists.txt new file mode 100644 index 0000000000..c4716f616e --- /dev/null +++ b/src/main/target/TAKERF722SE/CMakeLists.txt @@ -0,0 +1 @@ +target_stm32f722xe(TAKERF722SE) \ No newline at end of file diff --git a/src/main/target/TAKERF722SE/target.c b/src/main/target/TAKERF722SE/target.c new file mode 100644 index 0000000000..247efb84e5 --- /dev/null +++ b/src/main/target/TAKERF722SE/target.c @@ -0,0 +1,48 @@ +/* +* This file is part of INAV Project. +* +* INAV 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. +* +* INAV 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 INAV. If not, see . +*/ + +#include + +#include "platform.h" +#include "drivers/io.h" + +#include "drivers/dma.h" +#include "drivers/timer.h" +#include "drivers/timer_def.h" + + + + + +timerHardware_t timerHardware[] = { + + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); + + diff --git a/src/main/target/TAKERF722SE/target.h b/src/main/target/TAKERF722SE/target.h new file mode 100644 index 0000000000..61ab442653 --- /dev/null +++ b/src/main/target/TAKERF722SE/target.h @@ -0,0 +1,186 @@ +/* + * This file is part of INAV Project. + * + * 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "GEPR" + +#define USBD_PRODUCT_STRING "TAKERF722SE" + +#define LED0 PC14 + + +// *************** BEEPER ************************ + +#define BEEPER PC13 +#define BEEPER_INVERTED + + +// *************** LEDSTRIP ************************ +#define USE_LED_STRIP +#define WS2811_PIN PA8 + + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_UART3 +#define UART3_TX_PIN PB10 +#define UART3_RX_PIN PB11 + +#define USE_UART4 +#define UART4_TX_PIN PA0 +#define UART4_RX_PIN PA1 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + +#define USE_UART6 +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 + + +#define SERIAL_PORT_COUNT 7 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_SBUS +#define SERIALRX_UART SERIAL_PORT_USART2 + + +// *************** SPI Bus ********************** + +#define USE_SPI + +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PC10 +#define SPI3_MISO_PIN PC11 +#define SPI3_MOSI_PIN PB2 +#define SPI3_SCK_AF GPIO_AF6_SPI3 +#define SPI3_MISO_AF GPIO_AF6_SPI3 +#define SPI3_MOSI_AF GPIO_AF7_SPI3 + + +// *************** Gyro & ACC ********************** + +#define USE_IMU_MPU6000 +#define IMU_MPU6000_ALIGN CW0_DEG +#define MPU6000_CS_PIN PA4 +#define MPU6000_SPI_BUS BUS_SPI1 + + +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW0_DEG +#define ICM42605_CS_PIN PA4 +#define ICM42605_SPI_BUS BUS_SPI1 + +// *************** I2C/Baro/Mag ********************* +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 + + +//*************************************************** +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_BMP280 +#define USE_BARO_DPS310 +#define USE_BARO_MS5611 + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_HMC5883 +#define USE_MAG_QMC5883 +#define USE_MAG_IST8310 +#define USE_MAG_IST8308 + +#define TEMPERATURE_I2C_BUS BUS_I2C1 + +#define PITOT_I2C_BUS BUS_I2C1 + +#define USE_RANGEFINDER +#define RANGEFINDER_I2C_BUS BUS_I2C1 +#define BNO055_I2C_BUS BUS_I2C1 + +// *************** FLASH ************************** + +#define USE_FLASHFS + +#define USE_FLASH_M25P16 +#define M25P16_CS_PIN PA15 +#define M25P16_SPI_BUS BUS_SPI3 + +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +// *************** OSD ***************************** + +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN PB12 + +// *************** ADC ***************************** + +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC1_DMA_STREAM DMA2_Stream0 +#define ADC_CHANNEL_1_PIN PC3 +#define ADC_CHANNEL_2_PIN PC0 +#define ADC_CHANNEL_3_PIN PC2 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define RSSI_ADC_CHANNEL ADC_CHN_2 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_3 + + +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX) + + + + +//************************************************** + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD (BIT(2)) + + +#define MAX_PWM_OUTPUT_PORTS 8 + +#define USE_DSHOT +#define USE_ESC_SENSOR From b79dea677c9e83f115ff5f2b59793799ba6624c1 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 14:20:11 +0200 Subject: [PATCH 06/13] fix formatting --- src/main/target/TAKERF722SE/target.c | 96 +++---- src/main/target/TAKERF722SE/target.h | 372 +++++++++++++-------------- 2 files changed, 234 insertions(+), 234 deletions(-) diff --git a/src/main/target/TAKERF722SE/target.c b/src/main/target/TAKERF722SE/target.c index 247efb84e5..d67062a9fb 100644 --- a/src/main/target/TAKERF722SE/target.c +++ b/src/main/target/TAKERF722SE/target.c @@ -1,48 +1,48 @@ -/* -* This file is part of INAV Project. -* -* INAV 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. -* -* INAV 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 INAV. If not, see . -*/ - -#include - -#include "platform.h" -#include "drivers/io.h" - -#include "drivers/dma.h" -#include "drivers/timer.h" -#include "drivers/timer_def.h" - - - - - -timerHardware_t timerHardware[] = { - - DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), - - DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), - DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), - - DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), -}; - -const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); - - +/* +* This file is part of INAV Project. +* +* INAV 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. +* +* INAV 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 INAV. If not, see . +*/ + +#include + +#include "platform.h" +#include "drivers/io.h" + +#include "drivers/dma.h" +#include "drivers/timer.h" +#include "drivers/timer_def.h" + + + + + +timerHardware_t timerHardware[] = { + + DEF_TIM(TIM3, CH1, PB4, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH2, PB5, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM4, CH1, PB6, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM4, CH2, PB7, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0), + DEF_TIM(TIM8, CH4, PC9, TIM_USE_OUTPUT_AUTO, 0, 0), + + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0), +}; + +const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]); + + diff --git a/src/main/target/TAKERF722SE/target.h b/src/main/target/TAKERF722SE/target.h index 61ab442653..817dc535f0 100644 --- a/src/main/target/TAKERF722SE/target.h +++ b/src/main/target/TAKERF722SE/target.h @@ -1,186 +1,186 @@ -/* - * This file is part of INAV Project. - * - * 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. - * - * INAV 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 INAV. If not, see . - */ - -#pragma once - -#define TARGET_BOARD_IDENTIFIER "GEPR" - -#define USBD_PRODUCT_STRING "TAKERF722SE" - -#define LED0 PC14 - - -// *************** BEEPER ************************ - -#define BEEPER PC13 -#define BEEPER_INVERTED - - -// *************** LEDSTRIP ************************ -#define USE_LED_STRIP -#define WS2811_PIN PA8 - - -// *************** UART ***************************** -#define USE_VCP - -#define USE_UART1 -#define UART1_TX_PIN PA9 -#define UART1_RX_PIN PA10 - -#define USE_UART2 -#define UART2_TX_PIN PA2 -#define UART2_RX_PIN PA3 - -#define USE_UART3 -#define UART3_TX_PIN PB10 -#define UART3_RX_PIN PB11 - -#define USE_UART4 -#define UART4_TX_PIN PA0 -#define UART4_RX_PIN PA1 - -#define USE_UART5 -#define UART5_TX_PIN PC12 -#define UART5_RX_PIN PD2 - -#define USE_UART6 -#define UART6_TX_PIN PC6 -#define UART6_RX_PIN PC7 - - -#define SERIAL_PORT_COUNT 7 - -#define DEFAULT_RX_TYPE RX_TYPE_SERIAL -#define SERIALRX_PROVIDER SERIALRX_SBUS -#define SERIALRX_UART SERIAL_PORT_USART2 - - -// *************** SPI Bus ********************** - -#define USE_SPI - -#define USE_SPI_DEVICE_1 -#define SPI1_SCK_PIN PA5 -#define SPI1_MISO_PIN PA6 -#define SPI1_MOSI_PIN PA7 - -#define USE_SPI_DEVICE_2 -#define SPI2_SCK_PIN PB13 -#define SPI2_MISO_PIN PB14 -#define SPI2_MOSI_PIN PB15 - -#define USE_SPI_DEVICE_3 -#define SPI3_SCK_PIN PC10 -#define SPI3_MISO_PIN PC11 -#define SPI3_MOSI_PIN PB2 -#define SPI3_SCK_AF GPIO_AF6_SPI3 -#define SPI3_MISO_AF GPIO_AF6_SPI3 -#define SPI3_MOSI_AF GPIO_AF7_SPI3 - - -// *************** Gyro & ACC ********************** - -#define USE_IMU_MPU6000 -#define IMU_MPU6000_ALIGN CW0_DEG -#define MPU6000_CS_PIN PA4 -#define MPU6000_SPI_BUS BUS_SPI1 - - -#define USE_IMU_ICM42605 -#define IMU_ICM42605_ALIGN CW0_DEG -#define ICM42605_CS_PIN PA4 -#define ICM42605_SPI_BUS BUS_SPI1 - -// *************** I2C/Baro/Mag ********************* -#define USE_I2C -#define USE_I2C_DEVICE_1 -#define I2C1_SCL PB8 -#define I2C1_SDA PB9 - - -//*************************************************** -#define USE_BARO -#define BARO_I2C_BUS BUS_I2C1 -#define USE_BARO_BMP280 -#define USE_BARO_DPS310 -#define USE_BARO_MS5611 - -#define USE_MAG -#define MAG_I2C_BUS BUS_I2C1 -#define USE_MAG_HMC5883 -#define USE_MAG_QMC5883 -#define USE_MAG_IST8310 -#define USE_MAG_IST8308 - -#define TEMPERATURE_I2C_BUS BUS_I2C1 - -#define PITOT_I2C_BUS BUS_I2C1 - -#define USE_RANGEFINDER -#define RANGEFINDER_I2C_BUS BUS_I2C1 -#define BNO055_I2C_BUS BUS_I2C1 - -// *************** FLASH ************************** - -#define USE_FLASHFS - -#define USE_FLASH_M25P16 -#define M25P16_CS_PIN PA15 -#define M25P16_SPI_BUS BUS_SPI3 - -#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT - -// *************** OSD ***************************** - -#define USE_MAX7456 -#define MAX7456_SPI_BUS BUS_SPI2 -#define MAX7456_CS_PIN PB12 - -// *************** ADC ***************************** - -#define USE_ADC -#define ADC_INSTANCE ADC1 -#define ADC1_DMA_STREAM DMA2_Stream0 -#define ADC_CHANNEL_1_PIN PC3 -#define ADC_CHANNEL_2_PIN PC0 -#define ADC_CHANNEL_3_PIN PC2 - -#define VBAT_ADC_CHANNEL ADC_CHN_1 -#define RSSI_ADC_CHANNEL ADC_CHN_2 -#define CURRENT_METER_ADC_CHANNEL ADC_CHN_3 - - -#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX) - - - - -//************************************************** - -#define USE_SERIAL_4WAY_BLHELI_INTERFACE - -#define TARGET_IO_PORTA 0xffff -#define TARGET_IO_PORTB 0xffff -#define TARGET_IO_PORTC 0xffff -#define TARGET_IO_PORTD (BIT(2)) - - -#define MAX_PWM_OUTPUT_PORTS 8 - -#define USE_DSHOT -#define USE_ESC_SENSOR +/* + * This file is part of INAV Project. + * + * 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. + * + * INAV 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 INAV. If not, see . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "GEPR" + +#define USBD_PRODUCT_STRING "TAKERF722SE" + +#define LED0 PC14 + + +// *************** BEEPER ************************ + +#define BEEPER PC13 +#define BEEPER_INVERTED + + +// *************** LEDSTRIP ************************ +#define USE_LED_STRIP +#define WS2811_PIN PA8 + + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_UART3 +#define UART3_TX_PIN PB10 +#define UART3_RX_PIN PB11 + +#define USE_UART4 +#define UART4_TX_PIN PA0 +#define UART4_RX_PIN PA1 + +#define USE_UART5 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + +#define USE_UART6 +#define UART6_TX_PIN PC6 +#define UART6_RX_PIN PC7 + + +#define SERIAL_PORT_COUNT 7 + +#define DEFAULT_RX_TYPE RX_TYPE_SERIAL +#define SERIALRX_PROVIDER SERIALRX_SBUS +#define SERIALRX_UART SERIAL_PORT_USART2 + + +// *************** SPI Bus ********************** + +#define USE_SPI + +#define USE_SPI_DEVICE_1 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_SPI_DEVICE_3 +#define SPI3_SCK_PIN PC10 +#define SPI3_MISO_PIN PC11 +#define SPI3_MOSI_PIN PB2 +#define SPI3_SCK_AF GPIO_AF6_SPI3 +#define SPI3_MISO_AF GPIO_AF6_SPI3 +#define SPI3_MOSI_AF GPIO_AF7_SPI3 + + +// *************** Gyro & ACC ********************** + +#define USE_IMU_MPU6000 +#define IMU_MPU6000_ALIGN CW0_DEG +#define MPU6000_CS_PIN PA4 +#define MPU6000_SPI_BUS BUS_SPI1 + + +#define USE_IMU_ICM42605 +#define IMU_ICM42605_ALIGN CW0_DEG +#define ICM42605_CS_PIN PA4 +#define ICM42605_SPI_BUS BUS_SPI1 + +// *************** I2C/Baro/Mag ********************* +#define USE_I2C +#define USE_I2C_DEVICE_1 +#define I2C1_SCL PB8 +#define I2C1_SDA PB9 + + +//*************************************************** +#define USE_BARO +#define BARO_I2C_BUS BUS_I2C1 +#define USE_BARO_BMP280 +#define USE_BARO_DPS310 +#define USE_BARO_MS5611 + +#define USE_MAG +#define MAG_I2C_BUS BUS_I2C1 +#define USE_MAG_HMC5883 +#define USE_MAG_QMC5883 +#define USE_MAG_IST8310 +#define USE_MAG_IST8308 + +#define TEMPERATURE_I2C_BUS BUS_I2C1 + +#define PITOT_I2C_BUS BUS_I2C1 + +#define USE_RANGEFINDER +#define RANGEFINDER_I2C_BUS BUS_I2C1 +#define BNO055_I2C_BUS BUS_I2C1 + +// *************** FLASH ************************** + +#define USE_FLASHFS + +#define USE_FLASH_M25P16 +#define M25P16_CS_PIN PA15 +#define M25P16_SPI_BUS BUS_SPI3 + +#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT + +// *************** OSD ***************************** + +#define USE_MAX7456 +#define MAX7456_SPI_BUS BUS_SPI2 +#define MAX7456_CS_PIN PB12 + +// *************** ADC ***************************** + +#define USE_ADC +#define ADC_INSTANCE ADC1 +#define ADC1_DMA_STREAM DMA2_Stream0 +#define ADC_CHANNEL_1_PIN PC3 +#define ADC_CHANNEL_2_PIN PC0 +#define ADC_CHANNEL_3_PIN PC2 + +#define VBAT_ADC_CHANNEL ADC_CHN_1 +#define RSSI_ADC_CHANNEL ADC_CHN_2 +#define CURRENT_METER_ADC_CHANNEL ADC_CHN_3 + + +#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_CURRENT_METER | FEATURE_TELEMETRY | FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX) + + + + +//************************************************** + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD (BIT(2)) + + +#define MAX_PWM_OUTPUT_PORTS 8 + +#define USE_DSHOT +#define USE_ESC_SENSOR From 25c545220926c6b09a6c62471a72a0b451295893 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 16:25:02 +0200 Subject: [PATCH 07/13] Drop MSP_MOTOR_PINS --- src/main/fc/fc_msp.c | 7 ------- src/main/msp/msp_protocol.h | 1 - 2 files changed, 8 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index cba93fb59c..f53523b24e 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -859,13 +859,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU8(dst, currentBatteryProfile->capacity.unit); break; - case MSP_MOTOR_PINS: - // FIXME This is hardcoded and should not be. - for (int i = 0; i < 8; i++) { - sbufWriteU8(dst, i + 1); - } - break; - #ifdef USE_GPS case MSP_RAW_GPS: sbufWriteU8(dst, gpsSol.fixType); diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 692f8fbffa..f8eb7ef01b 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -233,7 +233,6 @@ #define MSP_RC_TUNING 111 //out message rc rate, rc expo, rollpitch rate, yaw rate, dyn throttle PID #define MSP_ACTIVEBOXES 113 //out message Active box flags (full width, more than 32 bits) #define MSP_MISC 114 //out message powermeter trig -#define MSP_MOTOR_PINS 115 //out message which pins are in use for motors & servos, for GUI #define MSP_BOXNAMES 116 //out message the aux switch names #define MSP_WP 118 //out message get a WP, WP# is in the payload, returns (WP#, lat, lon, alt, flags) WP#0-home, WP#16-poshold #define MSP_BOXIDS 119 //out message get the permanent IDs associated to BOXes From 77fac1a3c1ad3a223c629b0235b6d65cd40b3f03 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 20:30:56 +0200 Subject: [PATCH 08/13] Revert "Merge pull request #9903 from iNavFlight/dzikuvx-drop-MSP_FILTER_CONFIG" This reverts commit 0d21b3d71daf17221ced2b8e8ef078ec9cbc1b86, reversing changes made to b5d5f4ca6e3909a58d5dd8ffdf8774d55380044b. --- src/main/fc/fc_msp.c | 59 +++++++++++++++++++++++++++++++++++++ src/main/msp/msp_protocol.h | 3 ++ 2 files changed, 62 insertions(+) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index f53523b24e..893e057645 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1193,6 +1193,24 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU8(dst, 0); break; + case MSP_FILTER_CONFIG : + sbufWriteU8(dst, gyroConfig()->gyro_main_lpf_hz); + sbufWriteU16(dst, pidProfile()->dterm_lpf_hz); + sbufWriteU16(dst, pidProfile()->yaw_lpf_hz); + sbufWriteU16(dst, 0); //Was gyroConfig()->gyro_notch_hz + sbufWriteU16(dst, 1); //Was gyroConfig()->gyro_notch_cutoff + sbufWriteU16(dst, 0); //BF: pidProfile()->dterm_notch_hz + sbufWriteU16(dst, 1); //pidProfile()->dterm_notch_cutoff + + sbufWriteU16(dst, 0); //BF: masterConfig.gyro_soft_notch_hz_2 + sbufWriteU16(dst, 1); //BF: masterConfig.gyro_soft_notch_cutoff_2 + + sbufWriteU16(dst, accelerometerConfig()->acc_notch_hz); + sbufWriteU16(dst, accelerometerConfig()->acc_notch_cutoff); + + sbufWriteU16(dst, 0); //Was gyroConfig()->gyro_stage2_lowpass_hz + break; + case MSP_INAV_PID: sbufWriteU8(dst, 0); //Legacy, no longer in use async processing value sbufWriteU16(dst, 0); //Legacy, no longer in use async processing value @@ -2138,6 +2156,47 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; + case MSP_SET_FILTER_CONFIG : + if (dataSize >= 5) { + gyroConfigMutable()->gyro_main_lpf_hz = sbufReadU8(src); + pidProfileMutable()->dterm_lpf_hz = constrain(sbufReadU16(src), 0, 500); + pidProfileMutable()->yaw_lpf_hz = constrain(sbufReadU16(src), 0, 255); + if (dataSize >= 9) { + sbufReadU16(src); //Was gyroConfigMutable()->gyro_notch_hz + sbufReadU16(src); //Was gyroConfigMutable()->gyro_notch_cutoff + } else { + return MSP_RESULT_ERROR; + } + if (dataSize >= 13) { + sbufReadU16(src); + sbufReadU16(src); + pidInitFilters(); + } else { + return MSP_RESULT_ERROR; + } + if (dataSize >= 17) { + sbufReadU16(src); // Was gyroConfigMutable()->gyro_soft_notch_hz_2 + sbufReadU16(src); // Was gyroConfigMutable()->gyro_soft_notch_cutoff_2 + } else { + return MSP_RESULT_ERROR; + } + + if (dataSize >= 21) { + accelerometerConfigMutable()->acc_notch_hz = constrain(sbufReadU16(src), 0, 255); + accelerometerConfigMutable()->acc_notch_cutoff = constrain(sbufReadU16(src), 1, 255); + } else { + return MSP_RESULT_ERROR; + } + + if (dataSize >= 22) { + sbufReadU16(src); //Was gyro_stage2_lowpass_hz + } else { + return MSP_RESULT_ERROR; + } + } else + return MSP_RESULT_ERROR; + break; + case MSP_SET_INAV_PID: if (dataSize == 15) { sbufReadU8(src); //Legacy, no longer in use async processing value diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index f8eb7ef01b..a983d0bc46 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -196,6 +196,9 @@ #define MSP_ADVANCED_CONFIG 90 #define MSP_SET_ADVANCED_CONFIG 91 +#define MSP_FILTER_CONFIG 92 +#define MSP_SET_FILTER_CONFIG 93 + #define MSP_SENSOR_CONFIG 96 #define MSP_SET_SENSOR_CONFIG 97 From 7204413a291e3eebb09b7573fd6fc0ccd1441159 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 20:36:11 +0200 Subject: [PATCH 09/13] Revert "Merge pull request #9865 from iNavFlight/dzikuvx-drop-msp-osd-config" This reverts commit a8de611b1a30917ac61023bfb11169f7c57c232f, reversing changes made to 05e7a31f562839c553bdc68de81e0a1e4312633c. --- src/main/fc/fc_msp.c | 50 +++++++++++++++++++++++++++++++++++++ src/main/msp/msp_protocol.h | 3 +++ 2 files changed, 53 insertions(+) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 893e057645..9dccbf0925 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1155,6 +1155,26 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF break; #endif + case MSP_OSD_CONFIG: +#ifdef USE_OSD + sbufWriteU8(dst, OSD_DRIVER_MAX7456); // OSD supported + // send video system (AUTO/PAL/NTSC) + sbufWriteU8(dst, osdConfig()->video_system); + sbufWriteU8(dst, osdConfig()->units); + sbufWriteU8(dst, osdConfig()->rssi_alarm); + sbufWriteU16(dst, currentBatteryProfile->capacity.warning); + sbufWriteU16(dst, osdConfig()->time_alarm); + sbufWriteU16(dst, osdConfig()->alt_alarm); + sbufWriteU16(dst, osdConfig()->dist_alarm); + sbufWriteU16(dst, osdConfig()->neg_alt_alarm); + for (int i = 0; i < OSD_ITEM_COUNT; i++) { + sbufWriteU16(dst, osdLayoutsConfig()->item_pos[0][i]); + } +#else + sbufWriteU8(dst, OSD_DRIVER_NONE); // OSD not supported +#endif + break; + case MSP_3D: sbufWriteU16(dst, reversibleMotorsConfig()->deadband_low); sbufWriteU16(dst, reversibleMotorsConfig()->deadband_high); @@ -2396,6 +2416,36 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) #endif #ifdef USE_OSD + case MSP_SET_OSD_CONFIG: + sbufReadU8Safe(&tmp_u8, src); + // set all the other settings + if ((int8_t)tmp_u8 == -1) { + if (dataSize >= 10) { + osdConfigMutable()->video_system = sbufReadU8(src); + osdConfigMutable()->units = sbufReadU8(src); + osdConfigMutable()->rssi_alarm = sbufReadU8(src); + currentBatteryProfileMutable->capacity.warning = sbufReadU16(src); + osdConfigMutable()->time_alarm = sbufReadU16(src); + osdConfigMutable()->alt_alarm = sbufReadU16(src); + // Won't be read if they weren't provided + sbufReadU16Safe(&osdConfigMutable()->dist_alarm, src); + sbufReadU16Safe(&osdConfigMutable()->neg_alt_alarm, src); + } else + return MSP_RESULT_ERROR; + } else { + // set a position setting + if ((dataSize >= 3) && (tmp_u8 < OSD_ITEM_COUNT)) // tmp_u8 == addr + osdLayoutsConfigMutable()->item_pos[0][tmp_u8] = sbufReadU16(src); + else + return MSP_RESULT_ERROR; + } + // Either a element position change or a units change needs + // a full redraw, since an element can change size significantly + // and the old position or the now unused space due to the + // size change need to be erased. + osdStartFullRedraw(); + break; + case MSP_OSD_CHAR_WRITE: if (dataSize >= 55) { osdCharacter_t chr; diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index a983d0bc46..2ee996dc38 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -186,6 +186,9 @@ #define MSP_TRANSPONDER_CONFIG 82 //out message Get transponder settings #define MSP_SET_TRANSPONDER_CONFIG 83 //in message Set transponder settings +#define MSP_OSD_CONFIG 84 //out message Get osd settings - betaflight +#define MSP_SET_OSD_CONFIG 85 //in message Set osd settings - betaflight + #define MSP_OSD_CHAR_READ 86 //out message Get osd settings - betaflight #define MSP_OSD_CHAR_WRITE 87 //in message Set osd settings - betaflight From 225a8efe323096498f818caa3849e02bc0ba3483 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 20:39:47 +0200 Subject: [PATCH 10/13] Revert "Merge pull request #9900 from iNavFlight/dzikuvx-drop-MSP_PIDNAMES" This reverts commit e5ab1e16bae1077d34aaf64904ea2bc9890e33ad, reversing changes made to 2bd253393a7458b8d072c31ccda588e4502fc950. --- src/main/fc/fc_msp.c | 18 ++++++++++++++++++ src/main/msp/msp_protocol.h | 1 + 2 files changed, 19 insertions(+) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 9dccbf0925..e8697cae34 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -140,6 +140,18 @@ static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER; // from mixer.c extern int16_t motor_disarmed[MAX_SUPPORTED_MOTORS]; +static const char pidnames[] = + "ROLL;" + "PITCH;" + "YAW;" + "ALT;" + "Pos;" + "PosR;" + "NavR;" + "LEVEL;" + "MAG;" + "VEL;"; + typedef enum { MSP_SDCARD_STATE_NOT_PRESENT = 0, MSP_SDCARD_STATE_FATAL = 1, @@ -696,6 +708,12 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF #endif break; + case MSP_PIDNAMES: + for (const char *c = pidnames; *c; c++) { + sbufWriteU8(dst, *c); + } + break; + case MSP_MODE_RANGES: for (int i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) { const modeActivationCondition_t *mac = modeActivationConditions(i); diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 2ee996dc38..5d7a0fbd8b 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -240,6 +240,7 @@ #define MSP_ACTIVEBOXES 113 //out message Active box flags (full width, more than 32 bits) #define MSP_MISC 114 //out message powermeter trig #define MSP_BOXNAMES 116 //out message the aux switch names +#define MSP_PIDNAMES 117 //out message the PID names #define MSP_WP 118 //out message get a WP, WP# is in the payload, returns (WP#, lat, lon, alt, flags) WP#0-home, WP#16-poshold #define MSP_BOXIDS 119 //out message get the permanent IDs associated to BOXes #define MSP_NAV_STATUS 121 //out message Returns navigation status From 2d20132ecbe118315935d09fe6d78814159b7a83 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 20:44:01 +0200 Subject: [PATCH 11/13] Revert "Merge pull request #9873 from iNavFlight/dzikuvx-new-msp-frames-for-servos" This reverts commit f7bda375d2ea89316b171758d60679073328de68, reversing changes made to a8de611b1a30917ac61023bfb11169f7c57c232f. --- src/main/fc/fc_msp.c | 41 +++++++++++++++++++++++---- src/main/msp/msp_protocol.h | 4 +++ src/main/msp/msp_protocol_v2_common.h | 1 + src/main/msp/msp_protocol_v2_inav.h | 2 -- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index e8697cae34..75af8dabbb 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -492,16 +492,29 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF case MSP_SERVO: sbufWriteData(dst, &servo, MAX_SUPPORTED_SERVOS * 2); break; - - case MSP2_INAV_SERVO_CONFIG: + case MSP_SERVO_CONFIGURATIONS: for (int i = 0; i < MAX_SUPPORTED_SERVOS; i++) { sbufWriteU16(dst, servoParams(i)->min); sbufWriteU16(dst, servoParams(i)->max); sbufWriteU16(dst, servoParams(i)->middle); sbufWriteU8(dst, servoParams(i)->rate); + sbufWriteU8(dst, 0); + sbufWriteU8(dst, 0); + sbufWriteU8(dst, 255); // used to be forwardFromChannel, not used anymore, send 0xff for compatibility reasons + sbufWriteU32(dst, 0); //Input reversing is not required since it can be done on mixer level + } + break; + case MSP_SERVO_MIX_RULES: + for (int i = 0; i < MAX_SERVO_RULES; i++) { + sbufWriteU8(dst, customServoMixers(i)->targetChannel); + sbufWriteU8(dst, customServoMixers(i)->inputSource); + sbufWriteU16(dst, customServoMixers(i)->rate); + sbufWriteU8(dst, customServoMixers(i)->speed); + sbufWriteU8(dst, 0); + sbufWriteU8(dst, 100); + sbufWriteU8(dst, 0); } break; - case MSP2_INAV_SERVO_MIXER: for (int i = 0; i < MAX_SERVO_RULES; i++) { sbufWriteU8(dst, customServoMixers(i)->targetChannel); @@ -2065,8 +2078,8 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; - case MSP2_INAV_SET_SERVO_CONFIG: - if (dataSize != 8) { + case MSP_SET_SERVO_CONFIGURATION: + if (dataSize != (1 + 14)) { return MSP_RESULT_ERROR; } tmp_u8 = sbufReadU8(src); @@ -2077,10 +2090,28 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) servoParamsMutable(tmp_u8)->max = sbufReadU16(src); servoParamsMutable(tmp_u8)->middle = sbufReadU16(src); servoParamsMutable(tmp_u8)->rate = sbufReadU8(src); + sbufReadU8(src); + sbufReadU8(src); + sbufReadU8(src); // used to be forwardFromChannel, ignored + sbufReadU32(src); // used to be reversedSources servoComputeScalingFactors(tmp_u8); } break; + case MSP_SET_SERVO_MIX_RULE: + sbufReadU8Safe(&tmp_u8, src); + if ((dataSize == 9) && (tmp_u8 < MAX_SERVO_RULES)) { + customServoMixersMutable(tmp_u8)->targetChannel = sbufReadU8(src); + customServoMixersMutable(tmp_u8)->inputSource = sbufReadU8(src); + customServoMixersMutable(tmp_u8)->rate = sbufReadU16(src); + customServoMixersMutable(tmp_u8)->speed = sbufReadU8(src); + sbufReadU16(src); //Read 2bytes for min/max and ignore it + sbufReadU8(src); //Read 1 byte for `box` and ignore it + loadCustomServoMixer(); + } else + return MSP_RESULT_ERROR; + break; + case MSP2_INAV_SET_SERVO_MIXER: sbufReadU8Safe(&tmp_u8, src); if ((dataSize == 7) && (tmp_u8 < MAX_SERVO_RULES)) { diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 5d7a0fbd8b..9840b39aa3 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -243,6 +243,7 @@ #define MSP_PIDNAMES 117 //out message the PID names #define MSP_WP 118 //out message get a WP, WP# is in the payload, returns (WP#, lat, lon, alt, flags) WP#0-home, WP#16-poshold #define MSP_BOXIDS 119 //out message get the permanent IDs associated to BOXes +#define MSP_SERVO_CONFIGURATIONS 120 //out message All servo configurations. #define MSP_NAV_STATUS 121 //out message Returns navigation status #define MSP_NAV_CONFIG 122 //out message Returns navigation parameters #define MSP_3D 124 //out message Settings needed for reversible ESCs @@ -262,6 +263,7 @@ #define MSP_SET_WP 209 //in message sets a given WP (WP#,lat, lon, alt, flags) #define MSP_SELECT_SETTING 210 //in message Select Setting Number (0-2) #define MSP_SET_HEAD 211 //in message define a new heading hold direction +#define MSP_SET_SERVO_CONFIGURATION 212 //in message Servo settings #define MSP_SET_MOTOR 214 //in message PropBalance function #define MSP_SET_NAV_CONFIG 215 //in message Sets nav config parameters - write to the eeprom #define MSP_SET_3D 217 //in message Settings needed for reversible ESCs @@ -288,6 +290,8 @@ #define MSP_GPSSTATISTICS 166 //out message get GPS debugging data #define MSP_ACC_TRIM 240 //out message get acc angle trim values #define MSP_SET_ACC_TRIM 239 //in message set acc angle trim values +#define MSP_SERVO_MIX_RULES 241 //out message Returns servo mixer configuration +#define MSP_SET_SERVO_MIX_RULE 242 //in message Sets servo mixer configuration #define MSP_SET_PASSTHROUGH 245 //in message Sets up passthrough to different peripherals (4way interface, uart, etc...) #define MSP_RTC 246 //out message Gets the RTC clock (returns: secs(i32) millis(u16) - (0,0) if time is not known) #define MSP_SET_RTC 247 //in message Sets the RTC clock (args: secs(i32) millis(u16)) diff --git a/src/main/msp/msp_protocol_v2_common.h b/src/main/msp/msp_protocol_v2_common.h index 2d87219ac6..82b7f75407 100644 --- a/src/main/msp/msp_protocol_v2_common.h +++ b/src/main/msp/msp_protocol_v2_common.h @@ -32,3 +32,4 @@ // radar commands #define MSP2_COMMON_SET_RADAR_POS 0x100B //SET radar position information #define MSP2_COMMON_SET_RADAR_ITD 0x100C //SET radar information to display + diff --git a/src/main/msp/msp_protocol_v2_inav.h b/src/main/msp/msp_protocol_v2_inav.h index 3312e5bc25..66e883ab8c 100755 --- a/src/main/msp/msp_protocol_v2_inav.h +++ b/src/main/msp/msp_protocol_v2_inav.h @@ -108,5 +108,3 @@ #define MSP2_INAV_CUSTOM_OSD_ELEMENTS 0x2100 #define MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS 0x2101 -#define MSP2_INAV_SERVO_CONFIG 0x2200 -#define MSP2_INAV_SET_SERVO_CONFIG 0x2201 \ No newline at end of file From f7334495dce55abe7ee637069d7a54617b120437 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 20:57:19 +0200 Subject: [PATCH 12/13] Revert "Merge pull request #9866 from iNavFlight/dzikuvx-drop-MSP_POSITION_ESTIMATION_CONFIG" This reverts commit 05e7a31f562839c553bdc68de81e0a1e4312633c, reversing changes made to b29b8f1d9434c7d563dbb7ae993d2b86df1aba58. --- src/main/fc/fc_msp.c | 25 +++++++++++++++++++++++++ src/main/msp/msp_protocol.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 75af8dabbb..ee97a9f1e6 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1381,6 +1381,18 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF break; + case MSP_POSITION_ESTIMATION_CONFIG: + + sbufWriteU16(dst, positionEstimationConfig()->w_z_baro_p * 100); // inav_w_z_baro_p float as value * 100 + sbufWriteU16(dst, positionEstimationConfig()->w_z_gps_p * 100); // 2 inav_w_z_gps_p float as value * 100 + sbufWriteU16(dst, positionEstimationConfig()->w_z_gps_v * 100); // 2 inav_w_z_gps_v float as value * 100 + sbufWriteU16(dst, positionEstimationConfig()->w_xy_gps_p * 100); // 2 inav_w_xy_gps_p float as value * 100 + sbufWriteU16(dst, positionEstimationConfig()->w_xy_gps_v * 100); // 2 inav_w_xy_gps_v float as value * 100 + sbufWriteU8(dst, gpsConfigMutable()->gpsMinSats); // 1 + sbufWriteU8(dst, 1); // 1 inav_use_gps_velned ON/OFF + + break; + case MSP_REBOOT: if (!ARMING_FLAG(ARMED)) { if (mspPostProcessFn) { @@ -2407,6 +2419,19 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; + case MSP_SET_POSITION_ESTIMATION_CONFIG: + if (dataSize == 12) { + positionEstimationConfigMutable()->w_z_baro_p = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); + positionEstimationConfigMutable()->w_z_gps_p = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); + positionEstimationConfigMutable()->w_z_gps_v = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); + positionEstimationConfigMutable()->w_xy_gps_p = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); + positionEstimationConfigMutable()->w_xy_gps_v = constrainf(sbufReadU16(src) / 100.0f, 0.0f, 10.0f); + gpsConfigMutable()->gpsMinSats = constrain(sbufReadU8(src), 5, 10); + sbufReadU8(src); // was positionEstimationConfigMutable()->use_gps_velned + } else + return MSP_RESULT_ERROR; + break; + case MSP_RESET_CONF: if (!ARMING_FLAG(ARMED)) { suspendRxSignal(); diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 9840b39aa3..62e3c0d1a3 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -110,6 +110,9 @@ #define MSP_CALIBRATION_DATA 14 #define MSP_SET_CALIBRATION_DATA 15 +#define MSP_POSITION_ESTIMATION_CONFIG 16 +#define MSP_SET_POSITION_ESTIMATION_CONFIG 17 + #define MSP_WP_MISSION_LOAD 18 // Load mission from NVRAM #define MSP_WP_MISSION_SAVE 19 // Save mission to NVRAM #define MSP_WP_GETINFO 20 From 6481f1ef25dc146aff6b4e20d2f213dfc17d895a Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Wed, 10 Apr 2024 21:06:47 +0200 Subject: [PATCH 13/13] Revert "Merge pull request #9901 from iNavFlight/dzikuvx-drop-MSP_PID_ADVANCED" This reverts commit cea4397f7b3695b84a2550b63cd85a1ed9e10abb, reversing changes made to 8fac3549b43acc4cb3439ddcb63f9a641f0b4f00. --- src/main/fc/fc_msp.c | 42 +++++++++++++++++++++++++++++++++++++ src/main/msp/msp_protocol.h | 2 ++ 2 files changed, 44 insertions(+) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index ee97a9f1e6..63c7468ea6 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1260,6 +1260,25 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF sbufWriteU16(dst, accelerometerConfig()->acc_notch_cutoff); sbufWriteU16(dst, 0); //Was gyroConfig()->gyro_stage2_lowpass_hz + break; + + case MSP_PID_ADVANCED: + sbufWriteU16(dst, 0); // pidProfile()->rollPitchItermIgnoreRate + sbufWriteU16(dst, 0); // pidProfile()->yawItermIgnoreRate + sbufWriteU16(dst, 0); //pidProfile()->yaw_p_limit + sbufWriteU8(dst, 0); //BF: pidProfile()->deltaMethod + sbufWriteU8(dst, 0); //BF: pidProfile()->vbatPidCompensation + sbufWriteU8(dst, 0); //BF: pidProfile()->setpointRelaxRatio + sbufWriteU8(dst, 0); + sbufWriteU16(dst, pidProfile()->pidSumLimit); + sbufWriteU8(dst, 0); //BF: pidProfile()->itermThrottleGain + + /* + * To keep compatibility on MSP frame length level with Betaflight, axis axisAccelerationLimitYaw + * limit will be sent and received in [dps / 10] + */ + sbufWriteU16(dst, constrain(pidProfile()->axisAccelerationLimitRollPitch / 10, 0, 65535)); + sbufWriteU16(dst, constrain(pidProfile()->axisAccelerationLimitYaw / 10, 0, 65535)); break; case MSP_INAV_PID: @@ -2278,6 +2297,29 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) return MSP_RESULT_ERROR; break; + case MSP_SET_PID_ADVANCED: + if (dataSize == 17) { + sbufReadU16(src); // pidProfileMutable()->rollPitchItermIgnoreRate + sbufReadU16(src); // pidProfileMutable()->yawItermIgnoreRate + sbufReadU16(src); //pidProfile()->yaw_p_limit + + sbufReadU8(src); //BF: pidProfileMutable()->deltaMethod + sbufReadU8(src); //BF: pidProfileMutable()->vbatPidCompensation + sbufReadU8(src); //BF: pidProfileMutable()->setpointRelaxRatio + sbufReadU8(src); + pidProfileMutable()->pidSumLimit = sbufReadU16(src); + sbufReadU8(src); //BF: pidProfileMutable()->itermThrottleGain + + /* + * To keep compatibility on MSP frame length level with Betaflight, axis axisAccelerationLimitYaw + * limit will be sent and received in [dps / 10] + */ + pidProfileMutable()->axisAccelerationLimitRollPitch = sbufReadU16(src) * 10; + pidProfileMutable()->axisAccelerationLimitYaw = sbufReadU16(src) * 10; + } else + return MSP_RESULT_ERROR; + break; + case MSP_SET_INAV_PID: if (dataSize == 15) { sbufReadU8(src); //Legacy, no longer in use async processing value diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 62e3c0d1a3..ac847afeae 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -204,6 +204,8 @@ #define MSP_FILTER_CONFIG 92 #define MSP_SET_FILTER_CONFIG 93 +#define MSP_PID_ADVANCED 94 +#define MSP_SET_PID_ADVANCED 95 #define MSP_SENSOR_CONFIG 96 #define MSP_SET_SENSOR_CONFIG 97