From 6c27482f4ca1e16c8d45fde9c7f7528d95c9b262 Mon Sep 17 00:00:00 2001 From: githubDLG Date: Fri, 4 May 2018 10:34:02 +0800 Subject: [PATCH 1/4] Add new target Stack-X Add new target Stack-X --- src/main/target/FISHDRONEF4/STACKX.mk | 0 src/main/target/FISHDRONEF4/target.h | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 src/main/target/FISHDRONEF4/STACKX.mk diff --git a/src/main/target/FISHDRONEF4/STACKX.mk b/src/main/target/FISHDRONEF4/STACKX.mk new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/main/target/FISHDRONEF4/target.h b/src/main/target/FISHDRONEF4/target.h index 6627c0a8bd..b965b789e0 100644 --- a/src/main/target/FISHDRONEF4/target.h +++ b/src/main/target/FISHDRONEF4/target.h @@ -20,9 +20,14 @@ #pragma once +#if defined(STACKX) +#define TARGET_BOARD_IDENTIFIER "SXF4" +#define USBD_PRODUCT_STRING "Stack-X F4" +#define SETVTX_ULTRALOWPOWER_DISARMED +#else #define TARGET_BOARD_IDENTIFIER "FDF4" - -#define USBD_PRODUCT_STRING "FishDroneF4" +#define USBD_PRODUCT_STRING "FishDroneF4" +#endif #define LED0_PIN PC13 #define LED1_PIN PC14 @@ -81,8 +86,8 @@ #define USE_SPI_DEVICE_2 #define SPI2_NSS_PIN PB12 #define SPI2_SCK_PIN PB13 -#define SPI2_MISO_PIN PC2 -#define SPI2_MOSI_PIN PC3 +#define SPI2_MISO_PIN PC2 +#define SPI2_MOSI_PIN PC3 #define USE_MAX7456 #define MAX7456_SPI_INSTANCE SPI2 @@ -127,6 +132,11 @@ #define USE_ADC #define VBAT_ADC_PIN PC0 #define RSSI_ADC_PIN PC1 +#if defined(STACKX) +#define CURRENT_METER_ADC_PIN PA1 +#define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC +#define DEFAULT_CURRENT_METER_SOURCE CURRENT_METER_ADC +#endif // *************** FEATURES ************************ #define DEFAULT_FEATURES (FEATURE_OSD) From 5d716a43973d10e909b208a8639bbc61edd47a91 Mon Sep 17 00:00:00 2001 From: githubDLG Date: Fri, 4 May 2018 15:28:44 +0800 Subject: [PATCH 2/4] Update target file Update target file --- src/main/drivers/vtx_rtc6705_soft_spi.c | 11 ++++++++- src/main/target/FISHDRONEF4/config.c | 31 +++++++++++++++++++++++++ src/main/target/FISHDRONEF4/target.h | 2 +- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 src/main/target/FISHDRONEF4/config.c diff --git a/src/main/drivers/vtx_rtc6705_soft_spi.c b/src/main/drivers/vtx_rtc6705_soft_spi.c index 0b67c25142..1ecf9c7964 100644 --- a/src/main/drivers/vtx_rtc6705_soft_spi.c +++ b/src/main/drivers/vtx_rtc6705_soft_spi.c @@ -30,6 +30,11 @@ #include "drivers/light_led.h" #include "drivers/time.h" #include "drivers/vtx_rtc6705.h" +#if defined(STACKX) +#include "fc/runtime_config.h" +#include "flight/failsafe.h" +#include "io/vtx.h" +#endif #define DP_5G_MASK 0x7000 #define PA5G_BS_MASK 0x0E00 @@ -136,7 +141,11 @@ void rtc6705SetFrequency(uint16_t channel_freq) void rtc6705SetRFPower(uint8_t rf_power) { - rtc6705_write_register(7, (rf_power > 1 ? PA_CONTROL_DEFAULT : (PA_CONTROL_DEFAULT | PD_Q5G_MASK) & (~(PA5G_PW_MASK | PA5G_BS_MASK)))); + if (!ARMING_FLAG(ARMED) && (vtxSettingsConfig()->lowPowerDisarm == 0xFF) && !failsafeIsActive()) { + rtc6705_write_register(7, ((PA_CONTROL_DEFAULT | PD_Q5G_MASK) & (~(PA5G_PW_MASK | PA5G_BS_MASK | DP_5G_MASK)))); + } else { + rtc6705_write_register(7, (rf_power > 1 ? PA_CONTROL_DEFAULT : (PA_CONTROL_DEFAULT | PD_Q5G_MASK) & (~(PA5G_PW_MASK | PA5G_BS_MASK)))); + } } void rtc6705Disable(void) diff --git a/src/main/target/FISHDRONEF4/config.c b/src/main/target/FISHDRONEF4/config.c new file mode 100644 index 0000000000..50c51ee180 --- /dev/null +++ b/src/main/target/FISHDRONEF4/config.c @@ -0,0 +1,31 @@ +/* + * This file is part of Cleanflight and Betaflight. + * + * Cleanflight and Betaflight are free software. You can redistribute + * this software and/or modify this software 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 and Betaflight are distributed in the hope that they + * 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 this software. + * + * If not, see . + */ + +#include "io/vtx.h" + +#ifdef USE_TARGET_CONFIG +#if defined(STACKX) +#define VTX_SETTINGS_ULTRA_LOW_POWER 0xff +void targetConfiguration(void) +{ + vtxSettingsConfigMutable()->lowPowerDisarm = VTX_SETTINGS_ULTRA_LOW_POWER; +} +#endif +#endif \ No newline at end of file diff --git a/src/main/target/FISHDRONEF4/target.h b/src/main/target/FISHDRONEF4/target.h index b965b789e0..21a97123ac 100644 --- a/src/main/target/FISHDRONEF4/target.h +++ b/src/main/target/FISHDRONEF4/target.h @@ -23,7 +23,7 @@ #if defined(STACKX) #define TARGET_BOARD_IDENTIFIER "SXF4" #define USBD_PRODUCT_STRING "Stack-X F4" -#define SETVTX_ULTRALOWPOWER_DISARMED +#define USE_TARGET_CONFIG #else #define TARGET_BOARD_IDENTIFIER "FDF4" #define USBD_PRODUCT_STRING "FishDroneF4" From 6b65cce9ae76e1e772f2d2b64f591509bac2746c Mon Sep 17 00:00:00 2001 From: githubDLG Date: Fri, 4 May 2018 15:42:27 +0800 Subject: [PATCH 3/4] update update --- src/main/drivers/vtx_rtc6705_soft_spi.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/drivers/vtx_rtc6705_soft_spi.c b/src/main/drivers/vtx_rtc6705_soft_spi.c index 1ecf9c7964..7c331cdf57 100644 --- a/src/main/drivers/vtx_rtc6705_soft_spi.c +++ b/src/main/drivers/vtx_rtc6705_soft_spi.c @@ -30,11 +30,9 @@ #include "drivers/light_led.h" #include "drivers/time.h" #include "drivers/vtx_rtc6705.h" -#if defined(STACKX) #include "fc/runtime_config.h" #include "flight/failsafe.h" #include "io/vtx.h" -#endif #define DP_5G_MASK 0x7000 #define PA5G_BS_MASK 0x0E00 From 874b4a0118921bb7207eb4137077838c7750d304 Mon Sep 17 00:00:00 2001 From: githubDLG Date: Sat, 5 May 2018 16:05:28 +0800 Subject: [PATCH 4/4] update update according to comments, this PR will only add new target. VTX power setting will opened in another PR~ --- src/main/drivers/vtx_rtc6705_soft_spi.c | 9 +------ src/main/target/FISHDRONEF4/config.c | 31 ------------------------- src/main/target/FISHDRONEF4/target.h | 1 - 3 files changed, 1 insertion(+), 40 deletions(-) delete mode 100644 src/main/target/FISHDRONEF4/config.c diff --git a/src/main/drivers/vtx_rtc6705_soft_spi.c b/src/main/drivers/vtx_rtc6705_soft_spi.c index 7c331cdf57..0b67c25142 100644 --- a/src/main/drivers/vtx_rtc6705_soft_spi.c +++ b/src/main/drivers/vtx_rtc6705_soft_spi.c @@ -30,9 +30,6 @@ #include "drivers/light_led.h" #include "drivers/time.h" #include "drivers/vtx_rtc6705.h" -#include "fc/runtime_config.h" -#include "flight/failsafe.h" -#include "io/vtx.h" #define DP_5G_MASK 0x7000 #define PA5G_BS_MASK 0x0E00 @@ -139,11 +136,7 @@ void rtc6705SetFrequency(uint16_t channel_freq) void rtc6705SetRFPower(uint8_t rf_power) { - if (!ARMING_FLAG(ARMED) && (vtxSettingsConfig()->lowPowerDisarm == 0xFF) && !failsafeIsActive()) { - rtc6705_write_register(7, ((PA_CONTROL_DEFAULT | PD_Q5G_MASK) & (~(PA5G_PW_MASK | PA5G_BS_MASK | DP_5G_MASK)))); - } else { - rtc6705_write_register(7, (rf_power > 1 ? PA_CONTROL_DEFAULT : (PA_CONTROL_DEFAULT | PD_Q5G_MASK) & (~(PA5G_PW_MASK | PA5G_BS_MASK)))); - } + rtc6705_write_register(7, (rf_power > 1 ? PA_CONTROL_DEFAULT : (PA_CONTROL_DEFAULT | PD_Q5G_MASK) & (~(PA5G_PW_MASK | PA5G_BS_MASK)))); } void rtc6705Disable(void) diff --git a/src/main/target/FISHDRONEF4/config.c b/src/main/target/FISHDRONEF4/config.c deleted file mode 100644 index 50c51ee180..0000000000 --- a/src/main/target/FISHDRONEF4/config.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of Cleanflight and Betaflight. - * - * Cleanflight and Betaflight are free software. You can redistribute - * this software and/or modify this software 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 and Betaflight are distributed in the hope that they - * 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 this software. - * - * If not, see . - */ - -#include "io/vtx.h" - -#ifdef USE_TARGET_CONFIG -#if defined(STACKX) -#define VTX_SETTINGS_ULTRA_LOW_POWER 0xff -void targetConfiguration(void) -{ - vtxSettingsConfigMutable()->lowPowerDisarm = VTX_SETTINGS_ULTRA_LOW_POWER; -} -#endif -#endif \ No newline at end of file diff --git a/src/main/target/FISHDRONEF4/target.h b/src/main/target/FISHDRONEF4/target.h index 21a97123ac..6135985c8e 100644 --- a/src/main/target/FISHDRONEF4/target.h +++ b/src/main/target/FISHDRONEF4/target.h @@ -23,7 +23,6 @@ #if defined(STACKX) #define TARGET_BOARD_IDENTIFIER "SXF4" #define USBD_PRODUCT_STRING "Stack-X F4" -#define USE_TARGET_CONFIG #else #define TARGET_BOARD_IDENTIFIER "FDF4" #define USBD_PRODUCT_STRING "FishDroneF4"