From afef3b09b0e7cc23b522430cb3f6cc87c115000a Mon Sep 17 00:00:00 2001 From: Vlad Adamenko Date: Fri, 13 Jan 2017 18:16:03 -0500 Subject: [PATCH] Making production target rg_SSD_F3 Clean ups on mikeller and martinbudden requests. Plus, added default VBat scale configuration. --- Makefile | 4 +- src/main/target/RG_SSD_F3/config.c | 27 +++++ src/main/target/RG_SSD_F3/target.c | 23 ++++ src/main/target/RG_SSD_F3/target.h | 168 ++++++++++++++++++++++++++++ src/main/target/RG_SSD_F3/target.mk | 16 +++ 5 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 src/main/target/RG_SSD_F3/config.c create mode 100644 src/main/target/RG_SSD_F3/target.c create mode 100644 src/main/target/RG_SSD_F3/target.h create mode 100644 src/main/target/RG_SSD_F3/target.mk diff --git a/Makefile b/Makefile index dcd122ec83..1c8fa50377 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,9 @@ include $(ROOT)/make/system-id.mk -include $(ROOT)/make/local.mk # configure some directories that are relative to wherever ROOT_DIR is located +ifndef TOOLS_DIR TOOLS_DIR := $(ROOT)/tools +endif BUILD_DIR := $(ROOT)/build DL_DIR := $(ROOT)/downloads @@ -94,7 +96,7 @@ include $(ROOT)/make/$(OSFAMILY).mk include $(ROOT)/make/tools.mk # default xtal value for F4 targets -HSE_VALUE = 8000000 +HSE_VALUE ?= 8000000 # used for turning on features like VCP and SDCARD FEATURES = diff --git a/src/main/target/RG_SSD_F3/config.c b/src/main/target/RG_SSD_F3/config.c new file mode 100644 index 0000000000..ae0ee4d6fc --- /dev/null +++ b/src/main/target/RG_SSD_F3/config.c @@ -0,0 +1,27 @@ +/* + * 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 "config/config_master.h" + +void targetConfiguration(master_t *config) { + config->batteryConfig.vbatmaxcellvoltage = 45; + config->batteryConfig.currentMeterScale = 119; +} diff --git a/src/main/target/RG_SSD_F3/target.c b/src/main/target/RG_SSD_F3/target.c new file mode 100644 index 0000000000..477472a8dd --- /dev/null +++ b/src/main/target/RG_SSD_F3/target.c @@ -0,0 +1,23 @@ +#include + +#include +#include "drivers/io.h" + +#include "drivers/timer.h" +#include "drivers/timer_def.h" +#include "drivers/dma.h" + + +const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { + DEF_TIM(TIM2, CH4, PA3, TIM_USE_PPM, TIMER_INPUT_ENABLED) , + // Main outputs 6 PWM + DEF_TIM(TIM4, CH1, PB6, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED), + DEF_TIM(TIM4, CH2, PB7, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED), + DEF_TIM(TIM8, CH2, PB8, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED), + DEF_TIM(TIM8, CH3, PB9, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED), + DEF_TIM(TIM3, CH1, PC6, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED), + DEF_TIM(TIM3, CH2, PC7, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED), + // Additional outputs + DEF_TIM(TIM16,CH1, PA6, TIM_USE_TRANSPONDER, TIMER_OUTPUT_ENABLED), + DEF_TIM(TIM1 ,CH1N,PA7, TIM_USE_LED, TIMER_OUTPUT_ENABLED), +}; diff --git a/src/main/target/RG_SSD_F3/target.h b/src/main/target/RG_SSD_F3/target.h new file mode 100644 index 0000000000..017e5ceeed --- /dev/null +++ b/src/main/target/RG_SSD_F3/target.h @@ -0,0 +1,168 @@ +/* + * 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 "RGF3" // rgSSD_F3 + +#define LED0 PC1 +#define LED1 PC0 + +#define BEEPER PA8 +#define BEEPER_INVERTED + +#define MPU6000_CS_PIN PB2 +#define MPU6000_SPI_INSTANCE SPI2 + +#define USE_SPI +#define USE_SPI_DEVICE_1 +#define USE_SPI_DEVICE_2 + +#define SPI1_NSS_PIN PB12 +#define SPI1_SCK_PIN PB3 +#define SPI1_MISO_PIN PB4 +#define SPI1_MOSI_PIN PB5 + +#define SPI2_NSS_PIN PB2 +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 + +#define EXTI15_10_CALLBACK_HANDLER_COUNT 2 // MPU_INT, SDCardDetect + +#define GYRO +#define USE_GYRO_SPI_MPU6000 +#define GYRO_MPU6000_ALIGN CW180_DEG + +#define ACC +#define USE_ACC_SPI_MPU6000 +#define ACC_MPU6000_ALIGN CW180_DEG +#define CONFIG_FASTLOOP_PREFERRED_ACC ACC_DEFAULT + +#define USE_EXTI +#define MPU_INT_EXTI PC13 +#define USE_MPU_DATA_READY_SIGNAL +#define ENSURE_MPU_DATA_READY_IS_LOW + +#define USE_SDCARD +#define USE_SDCARD_SPI1 + +#define SDCARD_DETECT_INVERTED + +#define SDCARD_DETECT_PIN PC14 +#define SDCARD_SPI_INSTANCE SPI1 +#define SDCARD_SPI_CS_GPIO GPIOB +#define SDCARD_SPI_CS_PIN SPI1_NSS_PIN + +// SPI2 is on the APB1 bus whose clock runs at 36MHz. Divide to under 400kHz for init: +#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 128 +// Divide to under 25MHz for normal operation: +#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 2 + +#define SDCARD_DMA_CHANNEL_TX DMA1_Channel3 +#define SDCARD_DMA_CHANNEL_TX_COMPLETE_FLAG DMA1_FLAG_TC3 +#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT + +#define USB_IO + +#define USE_VCP +#define USE_UART1 +#define USE_UART2 +#define USE_UART3 +#define USE_UART4 +#define USE_UART5 +#define SERIAL_PORT_COUNT 6 + +#define UART1_TX_PIN PC4 +#define UART1_RX_PIN PC5 +#define UART2_TX_PIN PA2 +#define UART2_RX_PIN PA3 +#define UART3_TX_PIN PB10 +#define UART3_RX_PIN PB11 +#define UART4_TX_PIN PC10 +#define UART4_RX_PIN PC11 +#define UART5_TX_PIN PC12 +#define UART5_RX_PIN PD2 + +#define USE_I2C +#define I2C_DEVICE (I2CDEV_2) // SDA (PA14/AF4), SCL (PA15/AF4) + +#define I2C2_SCL_GPIO GPIOA +#define I2C2_SCL_GPIO_AF GPIO_AF_4 +#define I2C2_SCL_PIN GPIO_Pin_9 +#define I2C2_SCL_PIN_SOURCE GPIO_PinSource9 +#define I2C2_SCL_CLK_SOURCE RCC_AHBPeriph_GPIOA +#define I2C2_SDA_GPIO GPIOA +#define I2C2_SDA_GPIO_AF GPIO_AF_4 +#define I2C2_SDA_PIN GPIO_Pin_10 +#define I2C2_SDA_PIN_SOURCE GPIO_PinSource10 +#define I2C2_SDA_CLK_SOURCE RCC_AHBPeriph_GPIOA + +#define USE_ADC +#define BOARD_HAS_VOLTAGE_DIVIDER + +#define ADC_INSTANCE ADC2 + +#define VBAT_ADC_PIN PA4 +#define CURRENT_METER_ADC_PIN PA5 + +#define LED_STRIP + +#define TRANSPONDER +#define TRANSPONDER_GPIO GPIOA +#define TRANSPONDER_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA +#define TRANSPONDER_GPIO_AF GPIO_AF_1 +#define TRANSPONDER_PIN GPIO_Pin_6 +#define TRANSPONDER_PIN_SOURCE GPIO_PinSource6 +#define TRANSPONDER_TIMER TIM16 +#define TRANSPONDER_TIMER_APB2_PERIPHERAL RCC_APB2Periph_TIM16 +#define TRANSPONDER_DMA_CHANNEL DMA1_Channel6 +#define TRANSPONDER_IRQ DMA1_Channel6_IRQn +#define TRANSPONDER_DMA_TC_FLAG DMA1_FLAG_TC6 +#define TRANSPONDER_DMA_HANDLER_IDENTIFER DMA1_CH6_HANDLER +#define BLACKBOX +#define GPS +#define SERIAL_RX +#define TELEMETRY +#define USE_SERVOS +#define USE_CLI + +#define DEFAULT_RX_FEATURE FEATURE_RX_PPM + +#define USE_DSHOT +#define USE_ESC_TELEMETRY +#define REMAP_TIM16_DMA +#define REMAP_TIM17_DMA +#define ADC24_DMA_REMAP + +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define SPEKTRUM_BIND + +#define BIND_PIN PB11 + +// IO - stm32f303rc in 64pin package +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD (BIT(2)) +#define TARGET_IO_PORTF (BIT(0)|BIT(1)|BIT(4)) + +#define USED_TIMERS (TIM_N(2) | TIM_N(3) | TIM_N(4) | TIM_N(8) | TIM_N(16) | TIM_N(17)) + +#define USABLE_TIMER_CHANNEL_COUNT 9 + diff --git a/src/main/target/RG_SSD_F3/target.mk b/src/main/target/RG_SSD_F3/target.mk new file mode 100644 index 0000000000..06d9d1dfa3 --- /dev/null +++ b/src/main/target/RG_SSD_F3/target.mk @@ -0,0 +1,16 @@ +F3_TARGETS += $(TARGET) +FEATURES = VCP SDCARD + +TARGET_SRC = \ + drivers/accgyro_mpu.c \ + drivers/accgyro_spi_mpu6000.c \ + drivers/light_ws2811strip.c \ + drivers/light_ws2811strip_stm32f30x.c \ + drivers/serial_usb_vcp.c \ + drivers/transponder_ir.c \ + drivers/transponder_ir_stm32f30x.c \ + io/transponder_ir.c + +HSE_VALUE = 12000000 + +