From 89c5629937a63b514b9236014f4e6bbf0b16e8b0 Mon Sep 17 00:00:00 2001
From: nerdCopter <56646290+nerdCopter@users.noreply.github.com>
Date: Tue, 16 Apr 2024 15:32:16 -0500
Subject: [PATCH] [target] BETAFPVF405 dual gyro, add BMI270, ICM42688P,
motor_poles 12 (#1009)
---
src/main/target/BETAFPVF405/config.c | 34 +++++++++++++++++++++++++++
src/main/target/BETAFPVF405/target.h | 24 ++++++++++++++-----
src/main/target/BETAFPVF405/target.mk | 2 ++
3 files changed, 54 insertions(+), 6 deletions(-)
create mode 100644 src/main/target/BETAFPVF405/config.c
diff --git a/src/main/target/BETAFPVF405/config.c b/src/main/target/BETAFPVF405/config.c
new file mode 100644
index 0000000000..fb6b04d795
--- /dev/null
+++ b/src/main/target/BETAFPVF405/config.c
@@ -0,0 +1,34 @@
+/*
+ * 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
+#include
+#include
+
+#include "platform.h"
+
+#ifdef USE_TARGET_CONFIG
+
+#include "flight/mixer.h"
+
+void targetConfiguration(void) {
+ motorConfigMutable()->motorPoleCount = 12;
+}
+#endif
diff --git a/src/main/target/BETAFPVF405/target.h b/src/main/target/BETAFPVF405/target.h
index 4e6e213172..b49a1251da 100644
--- a/src/main/target/BETAFPVF405/target.h
+++ b/src/main/target/BETAFPVF405/target.h
@@ -20,8 +20,10 @@
#pragma once
-#define TARGET_BOARD_IDENTIFIER "BEFH"
-#define USBD_PRODUCT_STRING "BetaFPV f405"
+#define BOARD_NAME BETAFPVF405
+#define MANUFACTURER_ID BEFH
+#define TARGET_BOARD_IDENTIFIER "S405" // generic ID
+#define FC_TARGET_MCU STM32F405 // not used in EmuF
#define USE_BEEPER
#define BEEPER_PIN PB4
@@ -98,9 +100,10 @@
#define USE_GYRO
#define USE_ACC
#define USE_ACC_SPI_MPU6000
-#define GYRO_MPU6000_ALIGN CW270_DEG
#define USE_GYRO_SPI_MPU6000
-#define ACC_MPU6000_ALIGN CW270_DEG
+#define USE_GYRO_SPI_ICM42688P
+#define USE_ACC_SPI_ICM42688P
+#define USE_ACCGYRO_BMI270
// MPU6000 interrupts
#define USE_EXTI
@@ -108,8 +111,17 @@
#define USE_MPU_DATA_READY_SIGNAL
#define ENSURE_MPU_DATA_READY_IS_LOW
-#define MPU6000_CS_PIN PA4
-#define MPU6000_SPI_INSTANCE SPI1
+#define ACC_1_ALIGN CW270_DEG
+#define GYRO_1_ALIGN CW270_DEG
+#define GYRO_1_CS_PIN PA4
+#define GYRO_1_EXTI_PIN PC4
+#define GYRO_1_SPI_INSTANCE SPI1
+
+#define USE_DUAL_GYRO
+
+#define ACC_2_ALIGN CW0_DEG
+#define GYRO_2_ALIGN CW0_DEG
+#define GYRO_2_SPI_INSTANCE SPI1
#define USE_BARO
#define USE_BARO_BMP280
diff --git a/src/main/target/BETAFPVF405/target.mk b/src/main/target/BETAFPVF405/target.mk
index cd68232238..bb0a5ecf80 100644
--- a/src/main/target/BETAFPVF405/target.mk
+++ b/src/main/target/BETAFPVF405/target.mk
@@ -5,6 +5,8 @@ FEATURES += VCP SDCARD ONBOARDFLASH
TARGET_SRC = \
drivers/accgyro/accgyro_mpu.c \
drivers/accgyro/accgyro_spi_mpu6000.c \
+ drivers/accgyro/accgyro_spi_icm426xx.c \
+ drivers/accgyro/accgyro_spi_bmi270.c \
drivers/barometer/barometer_bmp280.c \
drivers/barometer/barometer_ms5611.c \
drivers/compass/compass_hmc5883l.c \