diff --git a/src/main/config/parameter_group_ids.h b/src/main/config/parameter_group_ids.h index 754b7dbada..384fa79ba4 100644 --- a/src/main/config/parameter_group_ids.h +++ b/src/main/config/parameter_group_ids.h @@ -37,7 +37,7 @@ #define PG_SYSTEM_CONFIG 18 #define PG_FEATURE_CONFIG 19 #define PG_MIXER_PROFILE 20 -#define PG_SERVO_MIXER 21 +// #define PG_SERVO_MIXER 21 #define PG_IMU_CONFIG 22 //#define PG_PROFILE_SELECTION 23 #define PG_RX_CONFIG 24 diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c index 778889c11a..34932c58c3 100644 --- a/src/main/fc/cli.c +++ b/src/main/fc/cli.c @@ -1864,7 +1864,8 @@ static void cliServoMix(char *cmdline) printServoMix(DUMP_MASTER, customServoMixers(0), NULL); } else if (sl_strncasecmp(cmdline, "reset", 5) == 0) { // erase custom mixer - pgResetCopy(customServoMixersMutable(0), PG_SERVO_MIXER); + // pgResetCopy(customServoMixersMutable(0), PG_SERVO_MIXER); + Reset_servoMixers(customServoMixersMutable(0)); } else { enum {RULE = 0, TARGET, INPUT, RATE, SPEED, CONDITION, ARGS_COUNT}; char *ptr = strtok_r(cmdline, " ", &saveptr); @@ -3589,12 +3590,14 @@ static void printConfig(const char *cmdline, bool doDiff) const int currentProfileIndexSave = getConfigProfile(); const int currentBatteryProfileIndexSave = getConfigBatteryProfile(); + const int currentMixerProfileIndexSave = getConfigMixerProfile(); backupConfigs(); // reset all configs to defaults to do differencing resetConfigs(); // restore the profile indices, since they should not be reset for proper comparison setConfigProfile(currentProfileIndexSave); setConfigBatteryProfile(currentBatteryProfileIndexSave); + setConfigMixerProfile(currentMixerProfileIndexSave); if (checkCommand(options, "showdefaults")) { dumpMask = dumpMask | SHOW_DEFAULTS; // add default values as comments for changed values @@ -3622,8 +3625,8 @@ static void printConfig(const char *cmdline, bool doDiff) #endif } - // cliPrintHashLine("resources"); - //printResource(dumpMask, &defaultConfig); + cliPrintHashLine("resources"); + // printResource(dumpMask, &defaultConfig); // cliPrintHashLine("mixer"); // cliDumpPrintLinef(dumpMask, primaryMotorMixer_CopyArray[0].throttle == 0.0f, "\r\nmmix reset\r\n"); @@ -3716,6 +3719,7 @@ static void printConfig(const char *cmdline, bool doDiff) // dump all profiles const int currentProfileIndexSave = getConfigProfile(); const int currentBatteryProfileIndexSave = getConfigBatteryProfile(); + const int currentMixerProfileIndexSave = getConfigMixerProfile(); for (int ii = 0; ii < MAX_PROFILE_COUNT; ++ii) { cliDumpProfile(ii, dumpMask); } @@ -3727,10 +3731,11 @@ static void printConfig(const char *cmdline, bool doDiff) } setConfigProfile(currentProfileIndexSave); setConfigBatteryProfile(currentBatteryProfileIndexSave); + setConfigMixerProfile(currentMixerProfileIndexSave); cliPrintHashLine("restore original profile selection"); cliPrintLinef("profile %d", currentProfileIndexSave + 1); - cliPrintLinef("battery_profile %d", currentBatteryProfileIndexSave + 1); + cliPrintLinef("mixer_profile %d", currentMixerProfileIndexSave + 1); #ifdef USE_CLI_BATCH batchModeEnabled = false; diff --git a/src/main/fc/config.c b/src/main/fc/config.c index 1a7ced8515..e0f21442db 100755 --- a/src/main/fc/config.c +++ b/src/main/fc/config.c @@ -321,6 +321,7 @@ void readEEPROM(void) setConfigProfile(getConfigProfile()); setConfigBatteryProfile(getConfigBatteryProfile()); + setConfigMixerProfile(getConfigMixerProfile()); validateAndFixConfig(); activateConfig(); diff --git a/src/main/flight/mixer_profile.c b/src/main/flight/mixer_profile.c index 204d54a2b4..04974eb22d 100644 --- a/src/main/flight/mixer_profile.c +++ b/src/main/flight/mixer_profile.c @@ -62,12 +62,12 @@ void pgResetFn_mixerProfiles(mixerProfile_t *instance) // PG_REGISTER_ARRAY(motorMixer_t, MAX_SUPPORTED_MOTORS, primaryMotorMixer, PG_MOTOR_MIXER, 0); bool OutputProfileHotSwitch(int profile_index) -{ +{ // does not work with timerHardwareOverride LOG_INFO(PWM, "OutputProfileHotSwitch"); //do not allow switching between multi rotor and non multi rotor -#ifdef ENABLE_MCFW_MIXER_PROFILE_HOTSWAP +#ifdef ENABLE_MIXER_PROFILE_MCFW_HOTSWAP bool MCFW_hotswap_unavailable = false; #else bool MCFW_hotswap_unavailable = true; @@ -88,6 +88,7 @@ bool OutputProfileHotSwitch(int profile_index) LOG_INFO(PWM, "navModesEnabled"); return false; } + //TODO add check of each motor/servo is mapped before and after the switch if (!setConfigMixerProfile(profile_index)){ LOG_INFO(PWM, "failed to set config"); @@ -104,7 +105,7 @@ bool OutputProfileHotSwitch(int profile_index) pidInit(); pidInitFilters(); schedulePidGainsUpdate(); - navigationInit(); + // navigationInit(); //may need to initilize FW_HEADING_USE_YAW on rover or boat } return true; } diff --git a/src/main/flight/mixer_profile.h b/src/main/flight/mixer_profile.h index 97d5296abd..4eee2a0415 100644 --- a/src/main/flight/mixer_profile.h +++ b/src/main/flight/mixer_profile.h @@ -30,5 +30,7 @@ static inline const mixerProfile_t* mixerProfiles_CopyArray_by_index(int _index) #define customServoMixers_CopyArray() (mixerProfiles_CopyArray_by_index(systemConfig()->current_mixer_profile_index)->ServoMixers) #define mixerConfigByIndex(index) (&(mixerProfiles(index)->mixer_config)) +#define mixerMotorMixersByIndex(index) (&(mixerProfiles(index)->MotorMixers)) +#define mixerServoMixersByIndex(index) (&(mixerProfiles(index)->ServoMixers)) bool OutputProfileHotSwitch(int profile_index); diff --git a/src/main/flight/servos.c b/src/main/flight/servos.c index 93ebeb9991..674a7ab355 100755 --- a/src/main/flight/servos.c +++ b/src/main/flight/servos.c @@ -87,6 +87,22 @@ PG_RESET_TEMPLATE(servoConfig_t, servoConfig, // } // } +void Reset_servoMixers(servoMixer_t *instance) +{ + for (int i = 0; i < MAX_SERVO_RULES; i++) + { + RESET_CONFIG(servoMixer_t, &instance[i], + .targetChannel = 0, + .inputSource = 0, + .rate = 0, + .speed = 0 +#ifdef USE_PROGRAMMING_FRAMEWORK + ,.conditionId = -1 +#endif + ); + } +} + PG_REGISTER_ARRAY_WITH_RESET_FN(servoParam_t, MAX_SUPPORTED_SERVOS, servoParams, PG_SERVO_PARAMS, 3); void pgResetFn_servoParams(servoParam_t *instance) diff --git a/src/main/flight/servos.h b/src/main/flight/servos.h index 841415ea23..cf303db6a4 100644 --- a/src/main/flight/servos.h +++ b/src/main/flight/servos.h @@ -151,6 +151,7 @@ typedef struct servoMetadata_s { extern int16_t servo[MAX_SUPPORTED_SERVOS]; +void Reset_servoMixers(servoMixer_t* instance); bool isServoOutputEnabled(void); void setServoOutputEnabled(bool flag); bool isMixerUsingServos(void); diff --git a/src/main/target/MATEKF405/target.c b/src/main/target/MATEKF405/target.c index 34387de6c8..3f4d761834 100644 --- a/src/main/target/MATEKF405/target.c +++ b/src/main/target/MATEKF405/target.c @@ -23,7 +23,7 @@ timerHardware_t timerHardware[] = { DEF_TIM(TIM9, CH2, PA3, TIM_USE_PPM, 0, 0), // PPM -#ifdef MATEKF405VTOL +#ifdef MATEKF405VTOL//development purpose, TODO: remove it in the release DEF_TIM(TIM3, CH1, PC6, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 0), // S1 DEF_TIM(TIM8, CH2, PC7, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 1), // S2 UP(2,1) DEF_TIM(TIM8, CH3, PC8, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 1), // S3 UP(2,1) diff --git a/src/main/target/MATEKF405/target.h b/src/main/target/MATEKF405/target.h index f0f1c8bc87..e9aff02df4 100644 --- a/src/main/target/MATEKF405/target.h +++ b/src/main/target/MATEKF405/target.h @@ -197,5 +197,5 @@ #define MAX_PWM_OUTPUT_PORTS 6 #ifdef MATEKF405VTOL -#define ENABLE_MCFW_MIXER_PROFILE_HOTSWAP +#define ENABLE_MIXER_PROFILE_MCFW_HOTSWAP #endif \ No newline at end of file diff --git a/src/main/target/MATEKF405TE/CMakeLists.txt b/src/main/target/MATEKF405TE/CMakeLists.txt index ce0150c7d3..d8fc13c77b 100644 --- a/src/main/target/MATEKF405TE/CMakeLists.txt +++ b/src/main/target/MATEKF405TE/CMakeLists.txt @@ -1,2 +1,3 @@ target_stm32f405xg(MATEKF405TE) target_stm32f405xg(MATEKF405TE_SD) +target_stm32f405xg(MATEKF405TE_SD_VTOL) diff --git a/src/main/target/MATEKF405TE/target.c b/src/main/target/MATEKF405TE/target.c index 70561e001f..54e485b3c9 100644 --- a/src/main/target/MATEKF405TE/target.c +++ b/src/main/target/MATEKF405TE/target.c @@ -25,6 +25,18 @@ #include "drivers/timer_def_stm32f4xx.h" timerHardware_t timerHardware[] = { +#ifdef MATEKF405TE_SD_VTOL +//using d-shot on motors seems to have problems on s3,maybe dma related,maybe my board problem + DEF_TIM(TIM8, CH4, PC9, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 0), // S1 D(2,7,7) UP217 + DEF_TIM(TIM8, CH3, PC8, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 0), // S2 D(2,2,0) UP217 + DEF_TIM(TIM1, CH3N, PB15, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 0), // S3 D(2,6,0) UP256 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 1), // S4 D(2,1,6) UP256 + + DEF_TIM(TIM2, CH4, PB11, TIM_USE_MC_SERVO | TIM_USE_FW_SERVO, 0, 0), // S5 D(1,7,3) UP173 + DEF_TIM(TIM2, CH3, PB10, TIM_USE_MC_SERVO | TIM_USE_FW_SERVO, 0, 0), // S6 D(1,1,3) UP173 + DEF_TIM(TIM2, CH2, PB3, TIM_USE_MC_SERVO | TIM_USE_FW_SERVO, 0, 0), // S7 D(1,6,3) UP173 + DEF_TIM(TIM2, CH1, PA15, TIM_USE_MC_SERVO | TIM_USE_FW_SERVO, 0, 0), // S8 D(1,5,3) UP173 +#else DEF_TIM(TIM8, CH4, PC9, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 0), // S1 D(2,7,7) UP217 DEF_TIM(TIM8, CH3, PC8, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 0), // S2 D(2,2,0) UP217 DEF_TIM(TIM1, CH3N, PB15, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO, 0, 0), // S3 D(2,6,0) UP256 @@ -34,7 +46,7 @@ timerHardware_t timerHardware[] = { DEF_TIM(TIM2, CH3, PB10, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO, 0, 0), // S6 D(1,1,3) UP173 DEF_TIM(TIM2, CH2, PB3, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO, 0, 0), // S7 D(1,6,3) UP173 DEF_TIM(TIM2, CH1, PA15, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO, 0, 0), // S8 D(1,5,3) UP173 - +#endif DEF_TIM(TIM12, CH1, PB14, TIM_USE_MC_SERVO | TIM_USE_FW_SERVO, 0, 0), // S9 DMA NONE DEF_TIM(TIM13, CH1, PA6, TIM_USE_MC_SERVO | TIM_USE_FW_SERVO, 0, 0), // S10 DMA NONE DEF_TIM(TIM4, CH1, PB6, TIM_USE_MC_SERVO | TIM_USE_FW_SERVO, 0, 0), // S11 D(1,0,2) diff --git a/src/main/target/MATEKF405TE/target.h b/src/main/target/MATEKF405TE/target.h index 93ab3345de..e51a6d9a20 100644 --- a/src/main/target/MATEKF405TE/target.h +++ b/src/main/target/MATEKF405TE/target.h @@ -180,3 +180,6 @@ #define USE_DSHOT #define USE_ESC_SENSOR +#ifdef MATEKF405TE_SD_VTOL +#define ENABLE_MIXER_PROFILE_MCFW_HOTSWAP +#endif \ No newline at end of file