From 380399208650990bb16ce42647159a86b4d1cda3 Mon Sep 17 00:00:00 2001 From: Moto Moto Date: Mon, 7 Aug 2017 22:10:48 -0500 Subject: [PATCH] Add MOTOLABF4 targets MLTEMPF4 and MLTYPHF4 --- make/targets.mk | 2 + src/main/target/MOTOLABF4/MLTEMPF4.mk | 0 src/main/target/MOTOLABF4/MLTYPHF4.mk | 0 src/main/target/MOTOLABF4/target.c | 36 ++++++ src/main/target/MOTOLABF4/target.h | 174 ++++++++++++++++++++++++++ src/main/target/MOTOLABF4/target.mk | 14 +++ 6 files changed, 226 insertions(+) create mode 100644 src/main/target/MOTOLABF4/MLTEMPF4.mk create mode 100644 src/main/target/MOTOLABF4/MLTYPHF4.mk create mode 100644 src/main/target/MOTOLABF4/target.c create mode 100644 src/main/target/MOTOLABF4/target.h create mode 100644 src/main/target/MOTOLABF4/target.mk diff --git a/make/targets.mk b/make/targets.mk index c92255015..6a251f97b 100644 --- a/make/targets.mk +++ b/make/targets.mk @@ -70,6 +70,8 @@ GROUP_3_TARGETS := \ LUX_RACE \ LUXV2_RACE \ MICROSCISKY \ + MLTEMPF4 \ + MLTYPHF4 \ MOTOLAB \ MULTIFLITEPICO \ NAZE \ diff --git a/src/main/target/MOTOLABF4/MLTEMPF4.mk b/src/main/target/MOTOLABF4/MLTEMPF4.mk new file mode 100644 index 000000000..e69de29bb diff --git a/src/main/target/MOTOLABF4/MLTYPHF4.mk b/src/main/target/MOTOLABF4/MLTYPHF4.mk new file mode 100644 index 000000000..e69de29bb diff --git a/src/main/target/MOTOLABF4/target.c b/src/main/target/MOTOLABF4/target.c new file mode 100644 index 000000000..acb722ce4 --- /dev/null +++ b/src/main/target/MOTOLABF4/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/timer.h" +#include "drivers/timer_def.h" +#include "drivers/dma.h" + +const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { + DEF_TIM( TIM3, CH2, PB5, TIM_USE_MOTOR, TIMER_OUTPUT_STANDARD, 0 ), // PWM1 + DEF_TIM( TIM3, CH3, PB0, TIM_USE_MOTOR, TIMER_OUTPUT_STANDARD, 0 ), // PWM2 + DEF_TIM( TIM2, CH2, PB3, TIM_USE_MOTOR, TIMER_OUTPUT_STANDARD, 0 ), // PWM3 + DEF_TIM( TIM3, CH4, PB1, TIM_USE_MOTOR, TIMER_OUTPUT_STANDARD, 0 ), // PWM4 +#ifdef ML_PWM_6 + DEF_TIM( TIM5, CH3, PA2, TIM_USE_MOTOR, TIMER_OUTPUT_STANDARD, 0 ), // PWM5 + DEF_TIM( TIM5, CH4, PA3, TIM_USE_MOTOR, TIMER_OUTPUT_STANDARD, 0 ), // PWM6 +#endif + DEF_TIM( TIM1, CH1, PA8, TIM_USE_LED, TIMER_OUTPUT_STANDARD, 0 ), // Serial LED +}; diff --git a/src/main/target/MOTOLABF4/target.h b/src/main/target/MOTOLABF4/target.h new file mode 100644 index 000000000..4c0a6de42 --- /dev/null +++ b/src/main/target/MOTOLABF4/target.h @@ -0,0 +1,174 @@ +/* + * 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 + +#undef USE_MSP_DISPLAYPORT + +#ifdef MLTEMPF4 +#define TARGET_BOARD_IDENTIFIER "MLTE" +#else +#define TARGET_BOARD_IDENTIFIER "MLTY" +#endif + +#define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8) + +#define USBD_PRODUCT_STRING "MotoLabF4" + +#define LED0 PC3 +#define LED1 PC4 + +#define BEEPER PB4 +#define BEEPER_INVERTED + +//#define INVERTER PC0 // PC0 used as inverter select GPIO +//#define INVERTER_USART USART1 + +#define MPU6000_CS_PIN PA4 +#define MPU6000_SPI_INSTANCE SPI1 + +#define ACC +#define USE_ACC_SPI_MPU6000 +#define GYRO_MPU6000_ALIGN CW180_DEG + +#define GYRO +#define USE_GYRO_SPI_MPU6000 +#define ACC_MPU6000_ALIGN CW180_DEG + +// MPU6000 interrupts +#define USE_EXTI +#define MPU_INT_EXTI PC5 +#define USE_MPU_DATA_READY_SIGNAL +//#define ENSURE_MPU_DATA_READY_IS_LOW +//#define EXTI_CALLBACK_HANDLER_COUNT 1 // MPU data ready + +#define USE_SPI_DEVICE_3 // MAX7456 on V1.2 +#define SPI3_NSS_PIN PA15 +#define SPI3_SCK_PIN PC10 +#define SPI3_MISO_PIN PC11 +#define SPI3_MOSI_PIN PC12 +#define OSD +#define USE_MAX7456 +#define MAX7456_SPI_INSTANCE SPI3 +#define MAX7456_SPI_CS_PIN SPI3_NSS_PIN +#define MAX7456_SPI_CLK (SPI_CLOCK_STANDARD*2) +#define MAX7456_RESTORE_CLK (SPI_CLOCK_FAST) + +#define USE_VCP +//#define VBUS_SENSING_PIN PC15 +//#define VBUS_SENSING_ENABLED + +#define USE_UART1 +#define UART1_RX_PIN PA10 +#define UART1_TX_PIN PA9 +#define UART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2 + +#define USE_UART2 +#define UART2_RX_PIN PA3 +#define UART2_TX_PIN PA2 + +// Pins are available, not connected +//#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_UART5 +#define UART5_RX_PIN PD2 +#define UART5_TX_PIN PC12 // not connected + +#ifdef MLTEMPF4 +#define USE_UART6 +#define UART6_RX_PIN PC7 +#define UART6_TX_PIN PC6 +#define SERIAL_PORT_COUNT 6 //VCP, USART1, USART2, UART4, UART5, USART6 +#else +#define SERIAL_PORT_COUNT 5 //VCP, USART1, USART2, UART4, UART5 +#define VTX_RTC6705 +#define VTX_RTC6705SOFTSPI +#define RTC6705_SPIDATA_PIN PC6 +#define RTC6705_SPILE_PIN PC7 +#define RTC6705_SPICLK_PIN PC2 +#endif + +#define USE_SPI +#define USE_SPI_DEVICE_1 // MPU6000 +#define USE_SPI_DEVICE_2 // SDcard + +#define USE_SDCARD +#define SDCARD_DETECT_INVERTED +#define SDCARD_DETECT_PIN PC13 +#define SDCARD_SPI_INSTANCE SPI2 +#define SDCARD_SPI_CS_PIN PB12 +#define SDCARD_SPI_CS_CFG IOCFG_OUT_OD +// 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_Stream4 +#define SDCARD_DMA_CHANNEL_TX_COMPLETE_FLAG DMA_FLAG_TCIF4 +#define SDCARD_DMA_CLK RCC_AHB1Periph_DMA1 +#define SDCARD_DMA_CHANNEL DMA_Channel_0 + +// Pins are available unless USART3 is connected, not connected +//#define USE_I2C +//#define I2C_DEVICE (I2CDEV_2) + +#define USE_ADC +#define BOARD_HAS_VOLTAGE_DIVIDER +#define VBAT_ADC_PIN PC0 +#define CURRENT_METER_ADC_PIN PC1 +// Reserved pins, not connected +//#define RSSI_ADC_GPIO_PIN PC2 + +#define USE_DSHOT +#define USE_ESC_TELEMETRY +#define SENSORS_SET (SENSOR_ACC) +#define LED_STRIP +#define USE_SERIAL_4WAY_BLHELI_INTERFACE + +#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT +#define DEFAULT_FEATURES (FEATURE_TELEMETRY | FEATURE_OSD) +// | FEATURE_VTX | +// FEATURE_VBAT | FEATURE_CURRENT_METER | +// FEATURE_SDCARD) +#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT +#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL +#define SERIALRX_PROVIDER SERIALRX_SBUS +#define SERIALRX_UART SERIAL_PORT_UART5 +#define SBUS_TELEMETRY_UART SERIAL_PORT_UART4 + +// USART5 Rx, PD2 +#define SPEKTRUM_BIND +#define BIND_PIN UART5_RX_PIN + +#define TARGET_IO_PORTA 0xffff +#define TARGET_IO_PORTB 0xffff +#define TARGET_IO_PORTC 0xffff +#define TARGET_IO_PORTD (BIT(2)) + +#ifndef ML_PWM_6 +#define USABLE_TIMER_CHANNEL_COUNT 5 +#define USED_TIMERS ( TIM_N(1) | TIM_N(2) | TIM_N(3) ) +#else +#define USABLE_TIMER_CHANNEL_COUNT 7 +#define USED_TIMERS ( TIM_N(1) | TIM_N(2) | TIM_N(3) | TIM_N(5) ) +#endif diff --git a/src/main/target/MOTOLABF4/target.mk b/src/main/target/MOTOLABF4/target.mk new file mode 100644 index 000000000..a65c46ace --- /dev/null +++ b/src/main/target/MOTOLABF4/target.mk @@ -0,0 +1,14 @@ +F405_TARGETS += $(TARGET) +FEATURES += SDCARD VCP + +ifeq ($(TARGET), MLTEMPF4) +TARGET_SRC = \ + drivers/accgyro/accgyro_spi_mpu6000.c \ + drivers/max7456.c +else +TARGET_SRC = \ + drivers/accgyro/accgyro_spi_mpu6000.c \ + drivers/max7456.c \ + drivers/vtx_rtc6705_soft_spi.c +endif +