From 0d5c5ec3d58db6d227008dfcda0ff6fb1f704cdd Mon Sep 17 00:00:00 2001
From: linjieqiang <517503838@qq.com>
Date: Mon, 28 Nov 2016 11:30:02 +0800
Subject: [PATCH 1/4] Add new flight controller target files:FishDroneFC
---
src/main/target/FishDroneFC/target.c | 36 ++++++++
src/main/target/FishDroneFC/target.h | 128 ++++++++++++++++++++++++++
src/main/target/FishDroneFC/target.mk | 8 ++
3 files changed, 172 insertions(+)
create mode 100644 src/main/target/FishDroneFC/target.c
create mode 100644 src/main/target/FishDroneFC/target.h
create mode 100644 src/main/target/FishDroneFC/target.mk
diff --git a/src/main/target/FishDroneFC/target.c b/src/main/target/FishDroneFC/target.c
new file mode 100644
index 000000000..fcdde6150
--- /dev/null
+++ b/src/main/target/FishDroneFC/target.c
@@ -0,0 +1,36 @@
+/*
+ * 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 "drivers/io.h"
+
+#include "drivers/dma.h"
+#include "drivers/timer.h"
+#include "drivers/timer_def.h"
+
+const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
+ DEF_TIM(TIM3, CH3, PB0, TIM_USE_PPM, TIMER_INPUT_ENABLED, 0 ), // PPM IN
+
+ DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0 ), // S1_OUT
+ DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0 ), // S2_OUT
+ DEF_TIM(TIM2, CH1, PA15,TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0 ), // S3_OUT
+ DEF_TIM(TIM2, CH4, PA3, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 1 ), // S4_OUT
+
+ DEF_TIM(TIM5, CH1, PA0, TIM_USE_LED, TIMER_OUTPUT_ENABLED, 0 ), // LED_STRIP
+};
diff --git a/src/main/target/FishDroneFC/target.h b/src/main/target/FishDroneFC/target.h
new file mode 100644
index 000000000..552b70280
--- /dev/null
+++ b/src/main/target/FishDroneFC/target.h
@@ -0,0 +1,128 @@
+/*
+ * 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 .
+ */
+
+#pragma once
+
+#define TARGET_BOARD_IDENTIFIER "FDV2"
+#define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8)
+
+#define USBD_PRODUCT_STRING "FishDroneFC"
+
+#define LED0 PC13
+#define LED1 PC14
+
+#define BEEPER PC15
+#define BEEPER_INVERTED
+
+#define INVERTER PC8
+#define INVERTER_USART USART6
+
+#define USE_EXTI
+#define MPU_INT_EXTI PC4
+#define USE_MPU_DATA_READY_SIGNAL
+
+// *************** Gyro & ACC **********************
+#define USE_SPI
+#define USE_SPI_DEVICE_1
+
+#define MPU6500_CS_PIN PA4
+#define MPU6500_SPI_INSTANCE SPI1
+#define GYRO
+#define USE_GYRO_SPI_MPU6500
+#define GYRO_MPU6500_ALIGN CW90_DEG
+#define ACC
+#define USE_ACC_SPI_MPU6500
+#define ACC_MPU6500_ALIGN CW90_DEG
+
+// *************** UART *****************************
+#define USE_VCP
+#define VBUS_SENSING_PIN PA8
+#define VBUS_SENSING_ENABLED
+
+#define USE_UART1
+#define UART1_RX_PIN PA10
+#define UART1_TX_PIN PA9
+
+#define USE_UART3
+#define UART3_RX_PIN PB11
+#define UART3_TX_PIN PB10
+
+#define USE_UART6
+#define UART6_RX_PIN PC7
+#define UART6_TX_PIN PC6
+
+#define SERIAL_PORT_COUNT 4 // VCP, USART1, USART3, USART6
+
+// *************** OSD *****************************
+#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 OSD
+#define USE_MAX7456
+#define MAX7456_SPI_INSTANCE SPI2
+#define MAX7456_SPI_CS_PIN SPI2_NSS_PIN
+
+// *************** FLASH *****************************
+#define USE_SPI_DEVICE_3
+#define SPI3_SCK_PIN PC10
+#define SPI3_MISO_PIN PC11
+#define SPI3_MOSI_PIN PC12
+
+#define USE_FLASH_M25P16
+#define USE_FLASHFS
+#define M25P16_CS_PIN PD2
+#define M25P16_SPI_INSTANCE SPI3
+
+// *************** RTC6705 *************************
+#define USE_RTC6705
+#define RTC6705_SPILE_PIN PB3
+#define RTC6705_SPICLK_PIN PB4
+#define RTC6705_SPIDATA_PIN PB5
+
+// *************** ADC *****************************
+#define USE_ADC
+#define VBAT_ADC_PIN PC0
+#define RSSI_ADC_PIN PC1
+
+// *************** FEATURES ************************
+#define DEFAULT_FEATURES (FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX | FEATURE_LED_STRIP | FEATURE_VTX)
+#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL
+#define SERIALRX_PROVIDER SERIALRX_SBUS
+#define SERIALRX_UART SERIAL_PORT_USART3
+
+// *************** Others **************************
+#define DISPLAY
+#define LED_STRIP
+#define OSD
+
+#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT
+
+#define USE_SERIAL_4WAY_BLHELI_INTERFACE
+
+#define USE_DSHOT
+#define USE_ESC_TELEMETRY
+
+#define TARGET_IO_PORTA 0xffff
+#define TARGET_IO_PORTB 0xffff
+#define TARGET_IO_PORTC 0xffff
+#define TARGET_IO_PORTD (BIT(2))
+
+#define USABLE_TIMER_CHANNEL_COUNT 6
+#define USED_TIMERS ( TIM_N(2) | TIM_N(3) | TIM_N(4) | TIM_N(5) )
diff --git a/src/main/target/FishDroneFC/target.mk b/src/main/target/FishDroneFC/target.mk
new file mode 100644
index 000000000..3fb7f67ae
--- /dev/null
+++ b/src/main/target/FishDroneFC/target.mk
@@ -0,0 +1,8 @@
+F405_TARGETS += $(TARGET)
+FEATURES += VCP ONBOARDFLASH
+
+TARGET_SRC = \
+ drivers/accgyro_spi_mpu6500.c \
+ drivers/accgyro_mpu6500.c \
+ drivers/max7456.c \
+ drivers/vtx_soft_spi_rtc6705.c
\ No newline at end of file
From 278b97d2b8a2ce9d43ad4c9f2897979ec4c39bb5 Mon Sep 17 00:00:00 2001
From: linjieqiang <517503838@qq.com>
Date: Tue, 29 Nov 2016 14:20:31 +0800
Subject: [PATCH 2/4] [Change]change target to "FishDroneF4" from
"FishDroneFC". [Fix]some code format.
---
src/main/target/{FishDroneFC => FishDroneF4}/target.c | 10 +++++-----
src/main/target/{FishDroneFC => FishDroneF4}/target.h | 6 ++++--
src/main/target/{FishDroneFC => FishDroneF4}/target.mk | 0
3 files changed, 9 insertions(+), 7 deletions(-)
rename src/main/target/{FishDroneFC => FishDroneF4}/target.c (86%)
rename src/main/target/{FishDroneFC => FishDroneF4}/target.h (97%)
rename src/main/target/{FishDroneFC => FishDroneF4}/target.mk (100%)
diff --git a/src/main/target/FishDroneFC/target.c b/src/main/target/FishDroneF4/target.c
similarity index 86%
rename from src/main/target/FishDroneFC/target.c
rename to src/main/target/FishDroneF4/target.c
index fcdde6150..299ecdc2e 100644
--- a/src/main/target/FishDroneFC/target.c
+++ b/src/main/target/FishDroneF4/target.c
@@ -27,10 +27,10 @@
const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
DEF_TIM(TIM3, CH3, PB0, TIM_USE_PPM, TIMER_INPUT_ENABLED, 0 ), // PPM IN
- DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0 ), // S1_OUT
- DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0 ), // S2_OUT
- DEF_TIM(TIM2, CH1, PA15,TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0 ), // S3_OUT
- DEF_TIM(TIM2, CH4, PA3, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 1 ), // S4_OUT
+ DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0 ), // S1_OUT - DMA1_ST7
+ DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0 ), // S2_OUT - DMA1_ST1
+ DEF_TIM(TIM2, CH1, PA15,TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0 ), // S3_OUT - DMA1_ST5
+ DEF_TIM(TIM2, CH4, PA3, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 1 ), // S4_OUT - DMA1_ST6
- DEF_TIM(TIM5, CH1, PA0, TIM_USE_LED, TIMER_OUTPUT_ENABLED, 0 ), // LED_STRIP
+ DEF_TIM(TIM5, CH1, PA0, TIM_USE_LED, TIMER_OUTPUT_ENABLED, 0 ), // LED_STRIP - DMA1_ST2
};
diff --git a/src/main/target/FishDroneFC/target.h b/src/main/target/FishDroneF4/target.h
similarity index 97%
rename from src/main/target/FishDroneFC/target.h
rename to src/main/target/FishDroneF4/target.h
index 552b70280..46a6a7152 100644
--- a/src/main/target/FishDroneFC/target.h
+++ b/src/main/target/FishDroneF4/target.h
@@ -17,10 +17,10 @@
#pragma once
-#define TARGET_BOARD_IDENTIFIER "FDV2"
+#define TARGET_BOARD_IDENTIFIER "FDF4"
#define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8)
-#define USBD_PRODUCT_STRING "FishDroneFC"
+#define USBD_PRODUCT_STRING "FishDroneF4"
#define LED0 PC13
#define LED1 PC14
@@ -41,9 +41,11 @@
#define MPU6500_CS_PIN PA4
#define MPU6500_SPI_INSTANCE SPI1
+
#define GYRO
#define USE_GYRO_SPI_MPU6500
#define GYRO_MPU6500_ALIGN CW90_DEG
+
#define ACC
#define USE_ACC_SPI_MPU6500
#define ACC_MPU6500_ALIGN CW90_DEG
diff --git a/src/main/target/FishDroneFC/target.mk b/src/main/target/FishDroneF4/target.mk
similarity index 100%
rename from src/main/target/FishDroneFC/target.mk
rename to src/main/target/FishDroneF4/target.mk
From e53e829b7ad430500bae4a972876685bb0eb76c1 Mon Sep 17 00:00:00 2001
From: linjieqiang <517503838@qq.com>
Date: Tue, 13 Dec 2016 13:39:08 +0800
Subject: [PATCH 3/4] Add support for SDCard
---
src/main/target/FishDroneF4/target.h | 19 +++++++++++++++++++
src/main/target/FishDroneF4/target.mk | 2 +-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/main/target/FishDroneF4/target.h b/src/main/target/FishDroneF4/target.h
index 46a6a7152..1be82892d 100644
--- a/src/main/target/FishDroneF4/target.h
+++ b/src/main/target/FishDroneF4/target.h
@@ -92,6 +92,25 @@
#define M25P16_CS_PIN PD2
#define M25P16_SPI_INSTANCE SPI3
+// *************** SDCARD *****************************
+#define USE_SDCARD
+
+#define SDCARD_DETECT_INVERTED
+
+#define SDCARD_DETECT_PIN PB7
+#define SDCARD_SPI_INSTANCE SPI3
+#define SDCARD_SPI_CS_PIN PB9
+
+// SPI2 is on the APB1 bus whose clock runs at 84MHz. Divide to under 400kHz for init:
+#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 328kHz
+// Divide to under 25MHz for normal operation:
+#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4 // 21MHz
+
+#define SDCARD_DMA_CHANNEL_TX DMA1_Stream5
+#define SDCARD_DMA_CHANNEL_TX_COMPLETE_FLAG DMA_FLAG_TCIF5
+#define SDCARD_DMA_CLK RCC_AHB1Periph_DMA1
+#define SDCARD_DMA_CHANNEL DMA_Channel_0
+
// *************** RTC6705 *************************
#define USE_RTC6705
#define RTC6705_SPILE_PIN PB3
diff --git a/src/main/target/FishDroneF4/target.mk b/src/main/target/FishDroneF4/target.mk
index 3fb7f67ae..0fd79b1f8 100644
--- a/src/main/target/FishDroneF4/target.mk
+++ b/src/main/target/FishDroneF4/target.mk
@@ -1,5 +1,5 @@
F405_TARGETS += $(TARGET)
-FEATURES += VCP ONBOARDFLASH
+FEATURES += SDCARD VCP ONBOARDFLASH
TARGET_SRC = \
drivers/accgyro_spi_mpu6500.c \
From b9d8bbab100f0ca6c29cf77d8e973b6d34b7f662 Mon Sep 17 00:00:00 2001
From: linjieqiang <517503838@qq.com>
Date: Tue, 13 Dec 2016 13:44:50 +0800
Subject: [PATCH 4/4] fix code format.
---
src/main/target/FishDroneF4/target.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/main/target/FishDroneF4/target.h b/src/main/target/FishDroneF4/target.h
index 1be82892d..5da604c13 100644
--- a/src/main/target/FishDroneF4/target.h
+++ b/src/main/target/FishDroneF4/target.h
@@ -73,8 +73,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 OSD
#define USE_MAX7456
@@ -101,10 +101,10 @@
#define SDCARD_SPI_INSTANCE SPI3
#define SDCARD_SPI_CS_PIN PB9
-// SPI2 is on the APB1 bus whose clock runs at 84MHz. Divide to under 400kHz for init:
+// SPI3 is on the APB1 bus whose clock runs at 84MHz. Divide to under 400kHz for init:
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 328kHz
// Divide to under 25MHz for normal operation:
-#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4 // 21MHz
+#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4 // 21MHz
#define SDCARD_DMA_CHANNEL_TX DMA1_Stream5
#define SDCARD_DMA_CHANNEL_TX_COMPLETE_FLAG DMA_FLAG_TCIF5
@@ -123,7 +123,7 @@
#define RSSI_ADC_PIN PC1
// *************** FEATURES ************************
-#define DEFAULT_FEATURES (FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX | FEATURE_LED_STRIP | FEATURE_VTX)
+#define DEFAULT_FEATURES (FEATURE_VBAT | FEATURE_OSD | FEATURE_BLACKBOX | FEATURE_VTX)
#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL
#define SERIALRX_PROVIDER SERIALRX_SBUS
#define SERIALRX_UART SERIAL_PORT_USART3
@@ -133,7 +133,7 @@
#define LED_STRIP
#define OSD
-#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT
+#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT
#define USE_SERIAL_4WAY_BLHELI_INTERFACE