From 119048246969e0d82d56cca2c62a914afe14509b Mon Sep 17 00:00:00 2001 From: Cheng Lin Date: Sat, 6 May 2017 00:04:13 -0400 Subject: [PATCH] ADD CLRACINGF7 --- src/main/target/CLRACINGF7/CL_RACINGF7.md | 14 +++ src/main/target/CLRACINGF7/target.c | 42 +++++++ src/main/target/CLRACINGF7/target.h | 135 ++++++++++++++++++++++ src/main/target/CLRACINGF7/target.mk | 6 + 4 files changed, 197 insertions(+) create mode 100644 src/main/target/CLRACINGF7/CL_RACINGF7.md create mode 100644 src/main/target/CLRACINGF7/target.c create mode 100644 src/main/target/CLRACINGF7/target.h create mode 100644 src/main/target/CLRACINGF7/target.mk diff --git a/src/main/target/CLRACINGF7/CL_RACINGF7.md b/src/main/target/CLRACINGF7/CL_RACINGF7.md new file mode 100644 index 000000000..7c2e8195a --- /dev/null +++ b/src/main/target/CLRACINGF7/CL_RACINGF7.md @@ -0,0 +1,14 @@ +MCU: STM32F722RE +IMU: MPU-6000 +IMU Interrupt: yes +BARO: NO +VCP: YES +Hardware UARTS: +OSD: uses a AB7456 chip +Blackbox: SD Card +PPM/UART NOT Shared: YES +Battery Voltage Sensor: 10:1 +Current sensor: 0.5 mOhm, 250 Current scale in the setting +Integrated Voltage Regulator: 1.2A 5v +Integrated Volrage Regulator: 1.2A 7.8V for clean vtx and camera power +120A Current sensing PDB and 150A burst current for 10S on the current sensing Resistor diff --git a/src/main/target/CLRACINGF7/target.c b/src/main/target/CLRACINGF7/target.c new file mode 100644 index 000000000..a811d5663 --- /dev/null +++ b/src/main/target/CLRACINGF7/target.c @@ -0,0 +1,42 @@ +/* + * 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" + +// DSHOT will work for motor 1-6. + +const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { + + DEF_TIM(TIM4, CH3, PB8, TIM_USE_PPM | TIM_USE_LED, TIMER_INPUT_ENABLED, 0), // PPM -DMA1_ST7 + + DEF_TIM(TIM2, CH4, PA3, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 1), // PWM1 - DMA1_ST6 + DEF_TIM(TIM8, CH3, PC8, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 1), // PWM2 - DMA2_ST2 + DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0), // PWM3 - DMA1_ST1 + DEF_TIM(TIM3, CH4, PC9, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0), // PWM4 - DMA1_ST2 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 2), // PWM5 - DMA2_ST3 + DEF_TIM(TIM4, CH1, PB6, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED, 0), // PWM6 - DMA1_ST0 + + DEF_TIM(TIM1, CH3N, PB1, TIM_USE_MOTOR | TIM_USE_LED, TIMER_OUTPUT_ENABLED | TIMER_OUTPUT_INVERTED, 0), // S5_OUT - DMA2_ST6 + +}; diff --git a/src/main/target/CLRACINGF7/target.h b/src/main/target/CLRACINGF7/target.h new file mode 100644 index 000000000..3ffc917ef --- /dev/null +++ b/src/main/target/CLRACINGF7/target.h @@ -0,0 +1,135 @@ +/* + * 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 "CLR7" + +#define USBD_PRODUCT_STRING "CL_RACING F7" + +#define LED0 PB0 +#define BEEPER PB4 +#define BEEPER_INVERTED + +#define MPU6000_CS_PIN PA4 +#define MPU6000_SPI_INSTANCE SPI1 +#define ACC +#define USE_ACC_SPI_MPU6000 +#define GYRO +#define USE_GYRO_SPI_MPU6000 + +// MPU6000 interrupts +#define USE_EXTI +#define MPU_INT_EXTI PC4 +#define USE_MPU_DATA_READY_SIGNAL +#define GYRO_MPU6000_ALIGN CW0_DEG +#define ACC_MPU6000_ALIGN CW0_DEG + +#define OSD +#define USE_MAX7456 +#define MAX7456_SPI_INSTANCE SPI3 +#define MAX7456_SPI_CS_PIN PA15 +#define MAX7456_SPI_CLK (SPI_CLOCK_STANDARD*2) +#define MAX7456_RESTORE_CLK (SPI_CLOCK_FAST) + +#define USE_SDCARD +#define SDCARD_DETECT_PIN PB7 +#define SDCARD_SPI_INSTANCE SPI2 +#define SDCARD_SPI_CS_PIN SPI2_NSS_PIN + +#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 422kHz +// Divide to under 25MHz for normal operation: +#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 8 // 27MHz + +#define SDCARD_DMA_CHANNEL_TX DMA1_Stream4 +#define SDCARD_DMA_CHANNEL_TX_COMPLETE_FLAG DMA_FLAG_TCIF1_5 +#define SDCARD_DMA_CLK RCC_AHB1Periph_DMA2 +#define SDCARD_DMA_CHANNEL DMA_CHANNEL_0 + + +#define USE_VCP +#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_UART4 +#define UART4_RX_PIN PA1 +#define UART4_TX_PIN PA0 + +#define USE_UART6 +#define UART6_RX_PIN PC7 +#define UART6_TX_PIN PC6 + +#define SERIAL_PORT_COUNT 5 + +#define USE_I2C + +#define USE_SPI +#define USE_SPI_DEVICE_1 +#define USE_SPI_DEVICE_2 +#define USE_SPI_DEVICE_3 + +#define SPI1_NSS_PIN PA4 +#define SPI1_SCK_PIN PA5 +#define SPI1_MISO_PIN PA6 +#define SPI1_MOSI_PIN PA7 + +#define SPI2_NSS_PIN PB12 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define SPI3_NSS_PIN PA15 +#define SPI3_SCK_PIN PC10 +#define SPI3_MISO_PIN PC11 +#define SPI3_MOSI_PIN PC12 + + +#define USE_ADC +#define BOARD_HAS_VOLTAGE_DIVIDER +#define BOARD_HAS_CURRENT_SENSOR +#define CURRENT_METER_ADC_PIN PC1 +#define VBAT_ADC_PIN PC2 +#define RSSI_ADC_PIN PC3 + +#define CURRENT_METER_SCALE_DEFAULT 250 // 3/120A = 25mv/A + +// LED strip configuration. +#define LED_STRIP +#define SPEKTRUM_BIND_PIN UART6_RX_PIN +#define BINDPLUG_PIN PB2 + +#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT + +#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL +#define SERIALRX_UART SERIAL_PORT_USART6 + +#define TELEMETRY_UART SERIAL_PORT_USART1 + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#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(3) | TIM_N(4) | TIM_N(8) ) + diff --git a/src/main/target/CLRACINGF7/target.mk b/src/main/target/CLRACINGF7/target.mk new file mode 100644 index 000000000..980fad005 --- /dev/null +++ b/src/main/target/CLRACINGF7/target.mk @@ -0,0 +1,6 @@ +F7X2RE_TARGETS += $(TARGET) +FEATURES += SDCARD VCP + +TARGET_SRC = \ + drivers/accgyro/accgyro_spi_mpu6000.c\ + drivers/max7456.c