mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-20 14:55:21 +03:00
CC3D - Adding USB Virtual COM port suport.
You can now connect the configurator via the USB port.
This commit is contained in:
parent
3916e5f2b5
commit
5760519a03
5 changed files with 54 additions and 21 deletions
45
Makefile
45
Makefile
|
@ -53,13 +53,13 @@ LINKER_DIR = $(ROOT)/src/main/target
|
||||||
|
|
||||||
# Search path for sources
|
# Search path for sources
|
||||||
VPATH := $(SRC_DIR):$(SRC_DIR)/startup
|
VPATH := $(SRC_DIR):$(SRC_DIR)/startup
|
||||||
|
USBFS_DIR = $(ROOT)/lib/main/STM32_USB-FS-Device_Driver
|
||||||
|
USBPERIPH_SRC = $(notdir $(wildcard $(USBFS_DIR)/src/*.c))
|
||||||
|
|
||||||
ifeq ($(TARGET),$(filter $(TARGET),STM32F3DISCOVERY CHEBUZZF3 NAZE32PRO SPRACINGF3 SPARKY))
|
ifeq ($(TARGET),$(filter $(TARGET),STM32F3DISCOVERY CHEBUZZF3 NAZE32PRO SPRACINGF3 SPARKY))
|
||||||
|
|
||||||
STDPERIPH_DIR = $(ROOT)/lib/main/STM32F30x_StdPeriph_Driver
|
STDPERIPH_DIR = $(ROOT)/lib/main/STM32F30x_StdPeriph_Driver
|
||||||
USBFS_DIR = $(ROOT)/lib/main/STM32_USB-FS-Device_Driver
|
|
||||||
|
|
||||||
USBPERIPH_SRC = $(notdir $(wildcard $(USBFS_DIR)/src/*.c))
|
|
||||||
STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c))
|
STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c))
|
||||||
|
|
||||||
EXCLUDES = stm32f30x_crc.c \
|
EXCLUDES = stm32f30x_crc.c \
|
||||||
|
@ -155,14 +155,26 @@ INCLUDE_DIRS := $(INCLUDE_DIRS) \
|
||||||
$(CMSIS_DIR)/CM3/CoreSupport \
|
$(CMSIS_DIR)/CM3/CoreSupport \
|
||||||
$(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x \
|
$(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x \
|
||||||
|
|
||||||
|
DEVICE_STDPERIPH_SRC = $(STDPERIPH_SRC)
|
||||||
|
|
||||||
|
ifeq ($(TARGET),CC3D)
|
||||||
|
INCLUDE_DIRS := $(INCLUDE_DIRS) \
|
||||||
|
$(USBFS_DIR)/inc \
|
||||||
|
$(ROOT)/src/main/vcp
|
||||||
|
|
||||||
|
VPATH := $(VPATH):$(USBFS_DIR)/src
|
||||||
|
|
||||||
|
DEVICE_STDPERIPH_SRC := $(DEVICE_STDPERIPH_SRC) \
|
||||||
|
$(USBPERIPH_SRC)
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f103_128k.ld
|
LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f103_128k.ld
|
||||||
|
|
||||||
ARCH_FLAGS = -mthumb -mcpu=cortex-m3
|
ARCH_FLAGS = -mthumb -mcpu=cortex-m3
|
||||||
TARGET_FLAGS = -D$(TARGET) -pedantic
|
TARGET_FLAGS = -D$(TARGET) -pedantic
|
||||||
DEVICE_FLAGS = -DSTM32F10X_MD -DSTM32F10X
|
DEVICE_FLAGS = -DSTM32F10X_MD -DSTM32F10X
|
||||||
|
|
||||||
DEVICE_STDPERIPH_SRC = $(STDPERIPH_SRC)
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
TARGET_DIR = $(ROOT)/src/main/target/$(TARGET)
|
TARGET_DIR = $(ROOT)/src/main/target/$(TARGET)
|
||||||
|
@ -233,11 +245,21 @@ HIGHEND_SRC = flight/autotune.c \
|
||||||
telemetry/frsky.c \
|
telemetry/frsky.c \
|
||||||
telemetry/hott.c \
|
telemetry/hott.c \
|
||||||
telemetry/msp.c \
|
telemetry/msp.c \
|
||||||
telemetry/smartport.c \
|
telemetry/smartport.c \
|
||||||
sensors/sonar.c \
|
sensors/sonar.c \
|
||||||
sensors/barometer.c \
|
sensors/barometer.c \
|
||||||
blackbox/blackbox.c
|
blackbox/blackbox.c
|
||||||
|
|
||||||
|
VCP_SRC = \
|
||||||
|
vcp/hw_config.c \
|
||||||
|
vcp/stm32_it.c \
|
||||||
|
vcp/usb_desc.c \
|
||||||
|
vcp/usb_endp.c \
|
||||||
|
vcp/usb_istr.c \
|
||||||
|
vcp/usb_prop.c \
|
||||||
|
vcp/usb_pwr.c \
|
||||||
|
drivers/serial_usb_vcp.c
|
||||||
|
|
||||||
NAZE_SRC = startup_stm32f10x_md_gcc.S \
|
NAZE_SRC = startup_stm32f10x_md_gcc.S \
|
||||||
drivers/accgyro_adxl345.c \
|
drivers/accgyro_adxl345.c \
|
||||||
drivers/accgyro_bma280.c \
|
drivers/accgyro_bma280.c \
|
||||||
|
@ -403,7 +425,8 @@ CC3D_SRC = \
|
||||||
drivers/timer.c \
|
drivers/timer.c \
|
||||||
drivers/timer_stm32f10x.c \
|
drivers/timer_stm32f10x.c \
|
||||||
$(HIGHEND_SRC) \
|
$(HIGHEND_SRC) \
|
||||||
$(COMMON_SRC)
|
$(COMMON_SRC) \
|
||||||
|
$(VCP_SRC)
|
||||||
|
|
||||||
STM32F30x_COMMON_SRC = \
|
STM32F30x_COMMON_SRC = \
|
||||||
startup_stm32f30x_md_gcc.S \
|
startup_stm32f30x_md_gcc.S \
|
||||||
|
@ -425,16 +448,6 @@ STM32F30x_COMMON_SRC = \
|
||||||
drivers/timer.c \
|
drivers/timer.c \
|
||||||
drivers/timer_stm32f30x.c
|
drivers/timer_stm32f30x.c
|
||||||
|
|
||||||
VCP_SRC = \
|
|
||||||
vcp/hw_config.c \
|
|
||||||
vcp/stm32_it.c \
|
|
||||||
vcp/usb_desc.c \
|
|
||||||
vcp/usb_endp.c \
|
|
||||||
vcp/usb_istr.c \
|
|
||||||
vcp/usb_prop.c \
|
|
||||||
vcp/usb_pwr.c \
|
|
||||||
drivers/serial_usb_vcp.c
|
|
||||||
|
|
||||||
NAZE32PRO_SRC = \
|
NAZE32PRO_SRC = \
|
||||||
$(STM32F30x_COMMON_SRC) \
|
$(STM32F30x_COMMON_SRC) \
|
||||||
$(HIGHEND_SRC) \
|
$(HIGHEND_SRC) \
|
||||||
|
|
|
@ -106,12 +106,18 @@ const serialPortConstraint_t serialPortConstraints[SERIAL_PORT_COUNT] = {
|
||||||
|
|
||||||
#ifdef CC3D
|
#ifdef CC3D
|
||||||
static serialPortFunction_t serialPortFunctions[SERIAL_PORT_COUNT] = {
|
static serialPortFunction_t serialPortFunctions[SERIAL_PORT_COUNT] = {
|
||||||
|
#ifdef USE_VCP
|
||||||
|
{SERIAL_PORT_USB_VCP, NULL, SCENARIO_UNUSED, FUNCTION_NONE},
|
||||||
|
#endif
|
||||||
{SERIAL_PORT_USART1, NULL, SCENARIO_UNUSED, FUNCTION_NONE},
|
{SERIAL_PORT_USART1, NULL, SCENARIO_UNUSED, FUNCTION_NONE},
|
||||||
{SERIAL_PORT_USART3, NULL, SCENARIO_UNUSED, FUNCTION_NONE},
|
{SERIAL_PORT_USART3, NULL, SCENARIO_UNUSED, FUNCTION_NONE},
|
||||||
{SERIAL_PORT_SOFTSERIAL1, NULL, SCENARIO_UNUSED, FUNCTION_NONE}
|
{SERIAL_PORT_SOFTSERIAL1, NULL, SCENARIO_UNUSED, FUNCTION_NONE}
|
||||||
};
|
};
|
||||||
|
|
||||||
const serialPortConstraint_t serialPortConstraints[SERIAL_PORT_COUNT] = {
|
const serialPortConstraint_t serialPortConstraints[SERIAL_PORT_COUNT] = {
|
||||||
|
#ifdef USE_VCP
|
||||||
|
{SERIAL_PORT_USB_VCP, 9600, 115200, SPF_NONE },
|
||||||
|
#endif
|
||||||
{SERIAL_PORT_USART1, 9600, 115200, SPF_NONE | SPF_SUPPORTS_SBUS_MODE | SPF_SUPPORTS_BIDIR_MODE},
|
{SERIAL_PORT_USART1, 9600, 115200, SPF_NONE | SPF_SUPPORTS_SBUS_MODE | SPF_SUPPORTS_BIDIR_MODE},
|
||||||
{SERIAL_PORT_USART3, 9600, 115200, SPF_SUPPORTS_CALLBACK | SPF_SUPPORTS_SBUS_MODE | SPF_SUPPORTS_BIDIR_MODE},
|
{SERIAL_PORT_USART3, 9600, 115200, SPF_SUPPORTS_CALLBACK | SPF_SUPPORTS_SBUS_MODE | SPF_SUPPORTS_BIDIR_MODE},
|
||||||
{SERIAL_PORT_SOFTSERIAL1, 9600, 19200, SPF_SUPPORTS_CALLBACK | SPF_IS_SOFTWARE_INVERTABLE}
|
{SERIAL_PORT_SOFTSERIAL1, 9600, 19200, SPF_SUPPORTS_CALLBACK | SPF_IS_SOFTWARE_INVERTABLE}
|
||||||
|
|
|
@ -60,10 +60,11 @@
|
||||||
#define BEEPER
|
#define BEEPER
|
||||||
#define DISPLAY
|
#define DISPLAY
|
||||||
|
|
||||||
|
#define USE_VCP
|
||||||
#define USE_USART1
|
#define USE_USART1
|
||||||
#define USE_USART3
|
#define USE_USART3
|
||||||
#define USE_SOFTSERIAL1
|
#define USE_SOFTSERIAL1
|
||||||
#define SERIAL_PORT_COUNT 3
|
#define SERIAL_PORT_COUNT 4
|
||||||
|
|
||||||
#define SOFTSERIAL_1_TIMER TIM3
|
#define SOFTSERIAL_1_TIMER TIM3
|
||||||
#define SOFTSERIAL_1_TIMER_TX_HARDWARE 1 // PWM 2
|
#define SOFTSERIAL_1_TIMER_TX_HARDWARE 1 // PWM 2
|
||||||
|
|
|
@ -92,11 +92,11 @@ void Set_System(void)
|
||||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; // HJI
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; // HJI
|
||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; // HJI
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; // HJI
|
||||||
#else
|
#else
|
||||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); // HJI
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); // HJI
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;// HJI
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;// HJI
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;// HJI
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;// HJI
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;// HJI
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;// HJI
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GPIO_Init(GPIOA, &GPIO_InitStructure); // HJI
|
GPIO_Init(GPIOA, &GPIO_InitStructure); // HJI
|
||||||
|
@ -123,6 +123,13 @@ void Set_System(void)
|
||||||
GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_14);
|
GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_14);
|
||||||
|
|
||||||
#endif /* STM32F37X && STM32F303xC)*/
|
#endif /* STM32F37X && STM32F303xC)*/
|
||||||
|
#if defined(STM32F10X)
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
|
||||||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Configure the EXTI line 18 connected internally to the USB IP */
|
/* Configure the EXTI line 18 connected internally to the USB IP */
|
||||||
EXTI_ClearITPendingBit(EXTI_Line18);
|
EXTI_ClearITPendingBit(EXTI_Line18);
|
||||||
|
|
|
@ -32,7 +32,13 @@
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
//#include "platform_config.h"
|
//#include "platform_config.h"
|
||||||
#include "usb_type.h"
|
#include "usb_type.h"
|
||||||
|
#ifdef STM32F303
|
||||||
#include "stm32f30x.h"
|
#include "stm32f30x.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef STM32F10X
|
||||||
|
#include "stm32f10x.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
/* Exported types ------------------------------------------------------------*/
|
||||||
/* Exported constants --------------------------------------------------------*/
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue