From 452e694306fb5bb524c41db798f316e909c8d039 Mon Sep 17 00:00:00 2001 From: blckmn Date: Tue, 26 Jan 2016 07:45:05 +1100 Subject: [PATCH 1/2] Added max_rx_channels configuration option --- src/main/config/config.c | 10 +++++++++- src/main/flight/mixer.c | 3 ++- src/main/io/serial_cli.c | 1 + src/main/rx/rx.c | 15 +++------------ src/main/rx/rx.h | 1 + 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/config/config.c b/src/main/config/config.c index e3fd47597..7a0e1912f 100755 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -472,7 +472,15 @@ static void resetConf(void) #if defined(CC3D) masterConfig.acc_hardware = 1; // default/autodetect #endif - + +#if defined(STM32F40_41xxx) || defined (STM32F411xE) + masterConfig.rxConfig.max_rx_channels = 16; +#elif defined(STM32F303xC) + masterConfig.rxConfig.max_rx_channels = 10; +#else + masterConfig.rxConfig.max_rx_channels = 8; +#endif + masterConfig.rxConfig.spektrum_sat_bind = 0; masterConfig.rxConfig.midrc = 1500; masterConfig.rxConfig.mincheck = 1100; diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index 036e76d04..9e67f2933 100755 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -753,7 +753,7 @@ STATIC_UNIT_TESTED void servoMixer(void) void mixTable(void) { uint32_t i; - + bool isFailsafeActive = failsafeIsActive(); // TODO - Find out if failsafe checks are really needed here in mixer code if (motorCount >= 4 && mixerConfig->yaw_jump_prevention_limit < YAW_JUMP_PREVENTION_LIMIT_HIGH) { @@ -793,6 +793,7 @@ void mixTable(void) int16_t throttleMin, throttleMax; static bool flightDirection3dReversed; + throttleMin = 0; throttle = rcData[THROTTLE]; // Find min and max throttle based on condition diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index 856a481be..08c1487f7 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -605,6 +605,7 @@ const clivalue_t valueTable[] = { { "rx_min_usec", VAR_UINT16 | MASTER_VALUE, &masterConfig.rxConfig.rx_min_usec, .config.minmax = { PWM_PULSE_MIN, PWM_PULSE_MAX } }, { "rx_max_usec", VAR_UINT16 | MASTER_VALUE, &masterConfig.rxConfig.rx_max_usec, .config.minmax = { PWM_PULSE_MIN, PWM_PULSE_MAX } }, + { "max_rx_channels", VAR_UINT8 | MASTER_VALUE, &masterConfig.rxConfig.max_rx_channels, .config.minmax = { 4, 16 } }, #ifdef USE_SERVOS { "gimbal_mode", VAR_UINT8 | PROFILE_VALUE | MODE_LOOKUP, &masterConfig.profile[0].gimbalConfig.mode, .config.lookup = { TABLE_GIMBAL_MODE } }, diff --git a/src/main/rx/rx.c b/src/main/rx/rx.c index e2789f6d2..54e08d2ea 100644 --- a/src/main/rx/rx.c +++ b/src/main/rx/rx.c @@ -94,11 +94,6 @@ uint32_t rcInvalidPulsPeriod[MAX_SUPPORTED_RC_CHANNEL_COUNT]; #define DELAY_5_HZ (1000000 / 5) #define SKIP_RC_ON_SUSPEND_PERIOD 1500000 // 1.5 second period in usec (call frequency independent) #define SKIP_RC_SAMPLES_ON_RESUME 2 // flush 2 samples to drop wrong measurements (timing independent) -#ifdef STM32F303xC -#define MAX_RC_CHANNELS_HIGH_PERFORMANCE 10 // Maximum channels allowed during fast refresh rates for more performance -#else -#define MAX_RC_CHANNELS_HIGH_PERFORMANCE 8 // Maximum channels allowed during fast refresh rates for more performance -#endif rxRuntimeConfig_t rxRuntimeConfig; static rxConfig_t *rxConfig; @@ -457,14 +452,10 @@ static uint8_t getRxChannelCount(void) { static uint8_t maxChannelsAllowed; if (!maxChannelsAllowed) { - if (targetLooptime < 1000) { - if (MAX_RC_CHANNELS_HIGH_PERFORMANCE > rxRuntimeConfig.channelCount) { - maxChannelsAllowed = rxRuntimeConfig.channelCount; - } else { - maxChannelsAllowed = MAX_RC_CHANNELS_HIGH_PERFORMANCE; - } - } else { + if (rxConfig->max_rx_channels > rxRuntimeConfig.channelCount) { maxChannelsAllowed = rxRuntimeConfig.channelCount; + } else { + maxChannelsAllowed = rxConfig->max_rx_channels; } } return maxChannelsAllowed; diff --git a/src/main/rx/rx.h b/src/main/rx/rx.h index 6ac43194c..b172a74ce 100644 --- a/src/main/rx/rx.h +++ b/src/main/rx/rx.h @@ -123,6 +123,7 @@ typedef struct rxConfig_s { uint16_t rx_min_usec; uint16_t rx_max_usec; + uint8_t max_rx_channels; rxFailsafeChannelConfiguration_t failsafe_channel_configurations[MAX_SUPPORTED_RC_CHANNEL_COUNT]; rxChannelRangeConfiguration_t channelRanges[NON_AUX_CHANNEL_COUNT]; From 3f201d7e6b150eec63132ce82b186267285e10f8 Mon Sep 17 00:00:00 2001 From: blckmn Date: Tue, 26 Jan 2016 08:13:24 +1100 Subject: [PATCH 2/2] Tabs to spaces --- src/main/rx/rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/rx/rx.c b/src/main/rx/rx.c index 54e08d2ea..e9dd68524 100644 --- a/src/main/rx/rx.c +++ b/src/main/rx/rx.c @@ -455,7 +455,7 @@ static uint8_t getRxChannelCount(void) { if (rxConfig->max_rx_channels > rxRuntimeConfig.channelCount) { maxChannelsAllowed = rxRuntimeConfig.channelCount; } else { - maxChannelsAllowed = rxConfig->max_rx_channels; + maxChannelsAllowed = rxConfig->max_rx_channels; } } return maxChannelsAllowed;