From 1f4644557d88c197e7bccbc95dedc30839526bba Mon Sep 17 00:00:00 2001 From: Hydra Date: Sun, 2 Apr 2017 17:46:11 +0100 Subject: [PATCH 1/6] CF/BF - Ensure that ESC voltage/current meters do not read random memory when reading data from unconfigured motors. --- src/main/sensors/current.c | 5 +++-- src/main/sensors/voltage.c | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/sensors/current.c b/src/main/sensors/current.c index 9e3c83424..403166fd6 100644 --- a/src/main/sensors/current.c +++ b/src/main/sensors/current.c @@ -220,11 +220,12 @@ void currentMeterESCReadMotor(uint8_t motorNumber, currentMeter_t *meter) currentMeterReset(meter); #else escSensorData_t *escData = getEscSensorData(motorNumber); - if (escData->dataAge <= ESC_BATTERY_AGE_MAX) { + if (escData && escData->dataAge <= ESC_BATTERY_AGE_MAX) { meter->amperage = escData->current; meter->amperageLatest = escData->current; meter->mAhDrawn = escData->consumption; - return; + } else { + currentMeterReset(meter); } #endif } diff --git a/src/main/sensors/voltage.c b/src/main/sensors/voltage.c index 22cc1105b..aa9db9dfe 100644 --- a/src/main/sensors/voltage.c +++ b/src/main/sensors/voltage.c @@ -221,9 +221,13 @@ void voltageMeterESCReadMotor(uint8_t motorNumber, voltageMeter_t *voltageMeter) voltageMeterReset(voltageMeter); #else escSensorData_t *escData = getEscSensorData(motorNumber); + if (escData) { + voltageMeter->unfiltered = escData->dataAge <= ESC_BATTERY_AGE_MAX ? escData->voltage / 10 : 0; + voltageMeter->filtered = voltageMeter->unfiltered; // no filtering for ESC motors currently. + } else { + voltageMeterReset(voltageMeter); + } - voltageMeter->unfiltered = escData->dataAge <= ESC_BATTERY_AGE_MAX ? escData->voltage / 10 : 0; - voltageMeter->filtered = voltageMeter->unfiltered; // no filtering for ESC motors currently. #endif } From 2fb950b54327cb60973e420d7ba648701c7b8d59 Mon Sep 17 00:00:00 2001 From: Hydra Date: Sun, 2 Apr 2017 18:49:31 +0100 Subject: [PATCH 2/6] CF/BF - Fix GPS lat/lon symbols to use symbols that are actually in the default CF/BF fonts. --- src/main/io/osd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 995fea8c3..43e45dd30 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -234,10 +234,10 @@ static void osdDrawSingleElement(uint8_t item) { int32_t val; if (item == OSD_GPS_LAT) { - buff[0] = 0xA6; + buff[0] = 0x64; // right arrow val = GPS_coord[LAT]; } else { - buff[0] = 0xA7; + buff[0] = 0x60; // down arrow val = GPS_coord[LON]; } if (val >= 0) { From 10205731b91b28d7f4fc0e5c7a49991e75f46eeb Mon Sep 17 00:00:00 2001 From: Hydra Date: Sun, 2 Apr 2017 19:38:05 +0100 Subject: [PATCH 3/6] CF/BF - SPRACINGF3NEO - Add target specific config. --- src/main/target/SPRACINGF3NEO/config.c | 62 ++++++++++++++++++++++++++ src/main/target/SPRACINGF3NEO/target.h | 9 +++- 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 src/main/target/SPRACINGF3NEO/config.c diff --git a/src/main/target/SPRACINGF3NEO/config.c b/src/main/target/SPRACINGF3NEO/config.c new file mode 100644 index 000000000..f7d6bcd2b --- /dev/null +++ b/src/main/target/SPRACINGF3NEO/config.c @@ -0,0 +1,62 @@ +/* + * This file is part of Cleanflight. + * + * 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. + * + * Cleanflight 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 Cleanflight. If not, see . + */ + +#include +#include + +#include + +#include "common/axis.h" + +#include "drivers/sensor.h" +#include "drivers/compass.h" +#include "drivers/serial.h" + +#include "fc/rc_controls.h" + +#include "flight/failsafe.h" +#include "flight/mixer.h" +#include "flight/pid.h" + +#include "rx/rx.h" + +#include "io/serial.h" + +#include "telemetry/telemetry.h" + +#include "sensors/sensors.h" +#include "sensors/compass.h" +#include "sensors/barometer.h" + +#include "config/feature.h" + +#include "fc/config.h" + +#ifdef TARGET_CONFIG +void targetConfiguration(void) +{ + barometerConfigMutable()->baro_hardware = BARO_DEFAULT; + compassConfigMutable()->mag_hardware = MAG_DEFAULT; + rxConfigMutable()->sbus_inversion = 1; + serialConfigMutable()->portConfigs[1].functionMask = FUNCTION_MSP; // So Bluetooth users don't have to change anything. + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIALRX_UART)].functionMask = FUNCTION_RX_SERIAL; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(TELEMETRY_UART)].functionMask = FUNCTION_TELEMETRY_SMARTPORT; + serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(GPS_UART)].functionMask = FUNCTION_GPS; + telemetryConfigMutable()->telemetry_inversion = 0; + telemetryConfigMutable()->sportHalfDuplex = 0; +} +#endif diff --git a/src/main/target/SPRACINGF3NEO/target.h b/src/main/target/SPRACINGF3NEO/target.h index 3aa363b92..ecfc8b282 100755 --- a/src/main/target/SPRACINGF3NEO/target.h +++ b/src/main/target/SPRACINGF3NEO/target.h @@ -18,6 +18,7 @@ #pragma once #define TARGET_BOARD_IDENTIFIER "SP3N" +#define TARGET_CONFIG #define CONFIG_FASTLOOP_PREFERRED_ACC ACC_DEFAULT @@ -159,8 +160,12 @@ #define OSD -#define DEFAULT_RX_FEATURE FEATURE_RX_PPM -#define DEFAULT_FEATURES (FEATURE_TRANSPONDER | FEATURE_RSSI_ADC | FEATURE_TELEMETRY) +#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL +#define DEFAULT_FEATURES (FEATURE_TRANSPONDER | FEATURE_RSSI_ADC | FEATURE_TELEMETRY | FEATURE_OSD | FEATURE_LED_STRIP) +#define SERIALRX_UART SERIAL_PORT_USART2 +#define GPS_UART SERIAL_PORT_USART3 +#define TELEMETRY_UART SERIAL_PORT_UART5 +#define SERIALRX_PROVIDER SERIALRX_SBUS #define BUTTONS #define BUTTON_A_PIN PD2 From 4f743a0b40e69339f65b711bd770de7fdd431c03 Mon Sep 17 00:00:00 2001 From: Hydra Date: Sun, 2 Apr 2017 19:38:28 +0100 Subject: [PATCH 4/6] CF/BF - Update MSP_GPS_CONFIG --- src/main/fc/fc_msp.c | 12 ++++++++---- src/main/msp/msp_protocol.h | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 232a00c1d..c3d27342c 100755 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -812,8 +812,10 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn #ifdef GPS case MSP_GPS_CONFIG: - sbufWriteU8(dst, gpsConfig()->provider); // gps_type - sbufWriteU8(dst, gpsConfig()->sbasMode); // gps_ubx_sbas + sbufWriteU8(dst, gpsConfig()->provider); + sbufWriteU8(dst, gpsConfig()->sbasMode); + sbufWriteU8(dst, gpsConfig()->autoConfig); + sbufWriteU8(dst, gpsConfig()->autoBaud); break; case MSP_RAW_GPS: @@ -1435,8 +1437,10 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src) #ifdef GPS case MSP_SET_GPS_CONFIG: - gpsConfigMutable()->provider = sbufReadU8(src); // gps_type - gpsConfigMutable()->sbasMode = sbufReadU8(src); // gps_ubx_sbas + gpsConfigMutable()->provider = sbufReadU8(src); + gpsConfigMutable()->sbasMode = sbufReadU8(src); + gpsConfigMutable()->autoConfig = sbufReadU8(src); + gpsConfigMutable()->autoBaud = sbufReadU8(src); break; #endif diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index badc00299..843dba0fc 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -58,8 +58,8 @@ #define MSP_PROTOCOL_VERSION 0 -#define API_VERSION_MAJOR 1 // increment when major changes are made -#define API_VERSION_MINOR 33 // increment after a release, to set the version for all changes to go into the following release (if no changes to MSP are made between the releases, this can be reverted before the release) +#define API_VERSION_MAJOR 1 // increment when major changes are made +#define API_VERSION_MINOR 34 // increment after a release, to set the version for all changes to go into the following release (if no changes to MSP are made between the releases, this can be reverted before the release) #define API_VERSION_LENGTH 2 From efac0ee6a9ba62b3d390ab1cf4b54510425e4ca9 Mon Sep 17 00:00:00 2001 From: Hydra Date: Sun, 2 Apr 2017 00:25:18 +0100 Subject: [PATCH 5/6] CF/BF - Fix Naze32 missing second softserial port. The NAZE32_SP can only have one port because it the pins are not available for use as soft serial. The NAZE32_SP should only configure the I2C pins if USART3 is not used. --- src/main/target/NAZE/initialisation.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/target/NAZE/initialisation.c b/src/main/target/NAZE/initialisation.c index 9b121e4b1..0d75c2c69 100644 --- a/src/main/target/NAZE/initialisation.c +++ b/src/main/target/NAZE/initialisation.c @@ -32,13 +32,14 @@ void targetBusInit(void) #endif #endif - if (hardwareRevision != NAZE32_SP) { - i2cInit(I2C_DEVICE); + if (hardwareRevision == NAZE32_SP) { serialRemovePort(SERIAL_PORT_SOFTSERIAL2); - } else { + if (!doesConfigurationUsePort(SERIAL_PORT_USART3)) { serialRemovePort(SERIAL_PORT_USART3); i2cInit(I2C_DEVICE); } + } else { + i2cInit(I2C_DEVICE); } -} \ No newline at end of file +} From a2841d783b4091eb6ad7145baad5be19ba0f6391 Mon Sep 17 00:00:00 2001 From: Miguel Date: Fri, 31 Mar 2017 15:47:15 +0200 Subject: [PATCH 6/6] Fix compile linking issues when USE_PWM is disabled --- src/main/fc/fc_init.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/fc/fc_init.c b/src/main/fc/fc_init.c index f435677fa..d35f671bc 100644 --- a/src/main/fc/fc_init.c +++ b/src/main/fc/fc_init.c @@ -294,11 +294,15 @@ void init(void) } #endif -#if defined(USE_PWM) || defined(USE_PPM) - if (feature(FEATURE_RX_PPM)) { - ppmRxInit(ppmConfig(), motorConfig()->dev.motorPwmProtocol); - } else if (feature(FEATURE_RX_PARALLEL_PWM)) { - pwmRxInit(pwmConfig()); + if (0) {} +#if defined(USE_PPM) + else if (feature(FEATURE_RX_PPM)) { + ppmRxInit(ppmConfig(), motorConfig()->dev.motorPwmProtocol); + } +#endif +#if defined(USE_PWM) + else if (feature(FEATURE_RX_PARALLEL_PWM)) { + pwmRxInit(pwmConfig()); } #endif