From 09d054ad7a105af87d7745af762d148d0c920e7a Mon Sep 17 00:00:00 2001 From: EmaxModel Date: Tue, 19 Apr 2022 14:48:30 +0800 Subject: [PATCH] add EmaxModel STM32F411 SX1280 target --- src/main/target/EMAXF4SX1280/target.c | 43 ++++++++ src/main/target/EMAXF4SX1280/target.h | 131 +++++++++++++++++++++++++ src/main/target/EMAXF4SX1280/target.mk | 17 ++++ 3 files changed, 191 insertions(+) create mode 100644 src/main/target/EMAXF4SX1280/target.c create mode 100644 src/main/target/EMAXF4SX1280/target.h create mode 100644 src/main/target/EMAXF4SX1280/target.mk diff --git a/src/main/target/EMAXF4SX1280/target.c b/src/main/target/EMAXF4SX1280/target.c new file mode 100644 index 0000000000..eea19600ae --- /dev/null +++ b/src/main/target/EMAXF4SX1280/target.c @@ -0,0 +1,43 @@ +/* + * 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 "platform.h" + +#include "drivers/dma.h" +#include "drivers/io.h" +#include "drivers/timer.h" +#include "drivers/timer_def.h" + +const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { + DEF_TIM(TIM9, CH2, PA3, TIM_USE_PPM, 0, 0), // PPM/RX2 + + DEF_TIM(TIM2, CH3, PB10, TIM_USE_MOTOR, 0, 0), // S1_OUT - DMA1_ST1 + DEF_TIM(TIM4, CH1, PB6, TIM_USE_MOTOR, 0, 0), // S2_OUT - DMA1_ST0 + DEF_TIM(TIM4, CH2, PB7, TIM_USE_MOTOR, 0, 0), // S3_OUT - DMA1_ST3 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 0, 0), // S4_OUT - DMA1_ST7 + + DEF_TIM(TIM5, CH1, PA0, TIM_USE_LED, 0, 0), // 2812LED - DMA1_ST2 + + DEF_TIM(TIM9, CH1, PA2, TIM_USE_PWM, 0, 0 ), // TX2 + DEF_TIM(TIM1, CH2, PA9, TIM_USE_PWM, 0, 0 ), // TX1 + DEF_TIM(TIM1, CH3, PA10, TIM_USE_PWM, 0, 0 ), // RX1 +}; diff --git a/src/main/target/EMAXF4SX1280/target.h b/src/main/target/EMAXF4SX1280/target.h new file mode 100644 index 0000000000..2cbb73c20c --- /dev/null +++ b/src/main/target/EMAXF4SX1280/target.h @@ -0,0 +1,131 @@ +/* + * 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 . + */ + +#pragma once + +#define TARGET_BOARD_IDENTIFIER "EMAX" +#define USBD_PRODUCT_STRING "EMAXF4SX1280" + + +#define LED0_PIN PC13 + +#define USE_BEEPER +#define BEEPER_PIN PC15 +#define BEEPER_INVERTED + +#define ENABLE_DSHOT_DMAR DSHOT_DMAR_AUTO +#define DSHOT_BITBANG_DEFAULT DSHOT_BITBANG_OFF + +// *************** SPI1 Gyro & ACC ********************** +#define USE_SPI +#define USE_SPI_DEVICE_1 + +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define GYRO_1_CS_PIN PA4 +#define GYRO_1_SPI_INSTANCE SPI1 + +#define USE_EXTI +#define USE_GYRO_EXTI +#define GYRO_1_EXTI_PIN PA1 +#define USE_MPU_DATA_READY_SIGNAL + +#define USE_GYRO +#define USE_GYRO_SPI_MPU6000 +#define USE_GYRO_SPI_ICM20689 +#define GYRO_1_ALIGN CW180_DEG + +#define USE_ACC +#define USE_ACC_SPI_MPU6000 +#define USE_ACC_SPI_ICM20689 +#define USE_ACCGYRO_BMI270 + +// *************** SPI2 OSD ***************************** +#define USE_SPI_DEVICE_2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define USE_MAX7456 +#define MAX7456_SPI_INSTANCE SPI2 +#define MAX7456_SPI_CS_PIN PB12 + +// *************** SPI3 RX *************************** +#define USE_SPI_DEVICE_3 +#define RX_SPI_INSTANCE SPI3 +#define SPI3_SCK_PIN PB3 +#define SPI3_MISO_PIN PB4 +#define SPI3_MOSI_PIN PB5 +#define RX_NSS_PIN PA15 + +#define USE_RX_SPI +#define USE_RX_EXPRESSLRS +#define USE_RX_SX1280 + +#define RX_SPI_LED_INVERTED +#define RX_SPI_BIND_PIN PB2 +#define RX_SPI_EXTI_PIN PC14 +#define RX_SPI_LED_PIN PB9 +#define RX_EXPRESSLRS_SPI_RESET_PIN PA8 +#define RX_EXPRESSLRS_SPI_BUSY_PIN PA13 +#define RX_EXPRESSLRS_TIMER_INSTANCE TIM3 + +#define DEFAULT_RX_FEATURE FEATURE_RX_SPI +#define RX_SPI_DEFAULT_PROTOCOL RX_SPI_EXPRESSLRS + +// *************** UART ***************************** +#define USE_VCP + +#define USE_UART1 +#define UART1_TX_PIN PA9 +#define UART1_RX_PIN PA10 + +#define USE_UART2 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 + +#define USE_SOFTSERIAL1 + +#define SERIAL_PORT_COUNT 4 + +// *************** ADC ***************************** +#define USE_ADC +#define ADC_INSTANCE ADC1 // Default added +#define ADC1_DMA_OPT 0 // DMA 2 Stream 0 Channel 0 + +#define VBAT_ADC_PIN PB0 +#define CURRENT_METER_ADC_PIN PB1 + +#define USE_ESCSERIAL + +#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_TELEMETRY ) +#define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC +#define DEFAULT_CURRENT_METER_SOURCE CURRENT_METER_ADC +#define CURRENT_METER_SCALE_DEFAULT 179 + +#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 9 +#define USED_TIMERS ( TIM_N(1)|TIM_N(2)|TIM_N(4)|TIM_N(5)|TIM_N(9)) diff --git a/src/main/target/EMAXF4SX1280/target.mk b/src/main/target/EMAXF4SX1280/target.mk new file mode 100644 index 0000000000..c8fc2df866 --- /dev/null +++ b/src/main/target/EMAXF4SX1280/target.mk @@ -0,0 +1,17 @@ +F411_TARGETS += $(TARGET) + +FEATURES += VCP SDCARD_SPI + +TARGET_SRC = \ + drivers/accgyro/accgyro_spi_mpu6000.c \ + drivers/accgyro/accgyro_spi_icm20689.c \ + $(ROOT)/lib/main/BoschSensortec/BMI270-Sensor-API/bmi270_maximum_fifo.c \ + drivers/accgyro/accgyro_spi_bmi270.c \ + drivers/max7456.c \ + drivers/rx/expresslrs_driver.c \ + drivers/rx/rx_sx1280.c \ + rx/expresslrs_telemetry.c \ + rx/expresslrs_common.c \ + rx/expresslrs.c + +