diff --git a/radio/src/gtests.cpp b/radio/src/gtests.cpp index 6f7158a07..ddfff10ad 100644 --- a/radio/src/gtests.cpp +++ b/radio/src/gtests.cpp @@ -48,14 +48,22 @@ void doMixerCalculations(); s_mixer_first_run_done = false; \ s_last_phase = 255; -#define MIXER_RESET() \ - memset(channelOutputs, 0, sizeof(channelOutputs)); \ - memset(ex_chans, 0, sizeof(ex_chans)); \ - memset(act, 0, sizeof(act)); \ - memset(swOn, 0, sizeof(swOn)); \ - int32_t lastAct = 0; lastAct = lastAct; /* to avoid a warning */ \ - s_current_mixer_flight_mode = s_last_phase = 0; \ +int32_t lastAct = 0; +void MIXER_RESET() +{ + memset(channelOutputs, 0, sizeof(channelOutputs)); + memset(ex_chans, 0, sizeof(ex_chans)); + memset(act, 0, sizeof(act)); + memset(swOn, 0, sizeof(swOn)); +#if !defined(CPUARM) + s_last_switch_used = 0; + s_last_switch_value = 0; +#endif + s_current_mixer_flight_mode = s_last_phase = 0; + lastAct = 0; logicalSwitchesReset(); +} + uint16_t anaInValues[NUM_STICKS+NUM_POTS] = { 0 }; uint16_t anaIn(uint8_t chan) @@ -334,18 +342,21 @@ TEST(getSwitch, recursiveSW) g_model.logicalSw[1] = { SWSRC_ELE, -SWSRC_SW1, LS_FUNC_OR }; evalLogicalSwitches(); - EXPECT_EQ(getSwitch(SWSRC_SW1), true); - EXPECT_EQ(getSwitch(SWSRC_SW2), false); + EXPECT_EQ(getSwitch(SWSRC_SW1), false); + EXPECT_EQ(getSwitch(SWSRC_SW2), true); + LS_RECURSIVE_EVALUATION_RESET(); evalLogicalSwitches(); - EXPECT_EQ(getSwitch(SWSRC_SW1), true); - EXPECT_EQ(getSwitch(SWSRC_SW2), false); + EXPECT_EQ(getSwitch(SWSRC_SW1), false); + EXPECT_EQ(getSwitch(SWSRC_SW2), true); simuSetSwitch(1, 1); + LS_RECURSIVE_EVALUATION_RESET(); evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), true); - EXPECT_EQ(getSwitch(SWSRC_SW2), false); + EXPECT_EQ(getSwitch(SWSRC_SW2), true); + LS_RECURSIVE_EVALUATION_RESET(); evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), true); EXPECT_EQ(getSwitch(SWSRC_SW2), false); diff --git a/radio/src/mixer.cpp b/radio/src/mixer.cpp index 023c696bf..fd761f8ec 100755 --- a/radio/src/mixer.cpp +++ b/radio/src/mixer.cpp @@ -525,9 +525,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms) { evalInputs(mode); -#if defined(CPUARM) evalLogicalSwitches(mode==e_perout_mode_normal); -#endif #if defined(MODULE_ALWAYS_SEND_PULSES) checkStartupWarnings(); diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 7c661dd0f..2611bd1b0 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -671,6 +671,7 @@ enum StartupWarningStates { #endif extern uint8_t s_current_mixer_flight_mode; +extern uint8_t s_last_phase; #if defined(CPUARM) #define bitfield_channels_t uint32_t @@ -698,9 +699,13 @@ void logicalSwitchesReset(); #if defined(CPUARM) void evalLogicalSwitches(bool isCurrentPhase=true); -void logicalSwitchesCopyState(); +void logicalSwitchesCopyState(uint8_t src, uint8_t dst); #define LS_RECURSIVE_EVALUATION_RESET() #else +#define evalLogicalSwitches(xxx) +#define GETSWITCH_RECURSIVE_TYPE uint16_t +extern volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_used; +extern volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_value; #define LS_RECURSIVE_EVALUATION_RESET() s_last_switch_used = 0 #endif diff --git a/radio/src/switches.cpp b/radio/src/switches.cpp index 2f40bc91a..091e01d1a 100644 --- a/radio/src/switches.cpp +++ b/radio/src/switches.cpp @@ -66,7 +66,6 @@ LogicalSwitchesFlightModeContext lswFm[MAX_FLIGHT_MODES]; int16_t lsLastValue[NUM_LOGICAL_SWITCH]; #define LS_LAST_VALUE(fm, idx) lsLastValue[idx] -#define GETSWITCH_RECURSIVE_TYPE uint16_t volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_used = 0; volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_value = 0;