mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 22:35:23 +03:00
Added USB disconnect pulse for F4 / F7.
This commit is contained in:
parent
9515088a98
commit
ca67cf1990
20 changed files with 18 additions and 108 deletions
6
Makefile
6
Makefile
|
@ -786,13 +786,15 @@ VCP_SRC = \
|
||||||
vcpf4/usbd_desc.c \
|
vcpf4/usbd_desc.c \
|
||||||
vcpf4/usbd_usr.c \
|
vcpf4/usbd_usr.c \
|
||||||
vcpf4/usbd_cdc_vcp.c \
|
vcpf4/usbd_cdc_vcp.c \
|
||||||
drivers/serial_usb_vcp.c
|
drivers/serial_usb_vcp.c \
|
||||||
|
drivers/usb_io.c
|
||||||
else ifeq ($(TARGET),$(filter $(TARGET),$(F7_TARGETS)))
|
else ifeq ($(TARGET),$(filter $(TARGET),$(F7_TARGETS)))
|
||||||
VCP_SRC = \
|
VCP_SRC = \
|
||||||
vcp_hal/usbd_desc.c \
|
vcp_hal/usbd_desc.c \
|
||||||
vcp_hal/usbd_conf.c \
|
vcp_hal/usbd_conf.c \
|
||||||
vcp_hal/usbd_cdc_interface.c \
|
vcp_hal/usbd_cdc_interface.c \
|
||||||
drivers/serial_usb_vcp.c
|
drivers/serial_usb_vcp.c \
|
||||||
|
drivers/usb_io.c
|
||||||
else
|
else
|
||||||
VCP_SRC = \
|
VCP_SRC = \
|
||||||
vcp/hw_config.c \
|
vcp/hw_config.c \
|
||||||
|
|
|
@ -28,8 +28,10 @@
|
||||||
#if defined(STM32F4)
|
#if defined(STM32F4)
|
||||||
#include "usb_core.h"
|
#include "usb_core.h"
|
||||||
#include "usbd_cdc_vcp.h"
|
#include "usbd_cdc_vcp.h"
|
||||||
|
#include "usb_io.h"
|
||||||
#elif defined(STM32F7)
|
#elif defined(STM32F7)
|
||||||
#include "vcp_hal/usbd_cdc_interface.h"
|
#include "vcp_hal/usbd_cdc_interface.h"
|
||||||
|
#include "usb_io.h"
|
||||||
USBD_HandleTypeDef USBD_Device;
|
USBD_HandleTypeDef USBD_Device;
|
||||||
#else
|
#else
|
||||||
#include "usb_core.h"
|
#include "usb_core.h"
|
||||||
|
@ -184,10 +186,14 @@ serialPort_t *usbVcpOpen(void)
|
||||||
vcpPort_t *s;
|
vcpPort_t *s;
|
||||||
|
|
||||||
#if defined(STM32F4)
|
#if defined(STM32F4)
|
||||||
|
usbGenerateDisconnectPulse();
|
||||||
|
|
||||||
IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, 0);
|
IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, 0);
|
||||||
IOInit(IOGetByTag(IO_TAG(PA12)), OWNER_USB, 0);
|
IOInit(IOGetByTag(IO_TAG(PA12)), OWNER_USB, 0);
|
||||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb);
|
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb);
|
||||||
#elif defined(STM32F7)
|
#elif defined(STM32F7)
|
||||||
|
usbGenerateDisconnectPulse();
|
||||||
|
|
||||||
IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, 0);
|
IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, 0);
|
||||||
IOInit(IOGetByTag(IO_TAG(PA12)), OWNER_USB, 0);
|
IOInit(IOGetByTag(IO_TAG(PA12)), OWNER_USB, 0);
|
||||||
/* Init Device Library */
|
/* Init Device Library */
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "platform.h"
|
|
||||||
#include "io.h"
|
|
||||||
#include "system.h"
|
|
||||||
|
|
||||||
static IO_t usbDetectPin = IO_NONE;
|
|
||||||
|
|
||||||
void usbCableDetectDeinit(void)
|
|
||||||
{
|
|
||||||
#ifdef USB_DETECT_PIN
|
|
||||||
IOInit(usbDetectPin, OWNER_FREE, 0);
|
|
||||||
IOConfigGPIO(usbDetectPin, IOCFG_IN_FLOATING);
|
|
||||||
usbDetectPin = IO_NONE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void usbCableDetectInit(void)
|
|
||||||
{
|
|
||||||
#ifdef USB_DETECT_PIN
|
|
||||||
usbDetectPin = IOGetByTag(IO_TAG(USB_DETECT_PIN));
|
|
||||||
|
|
||||||
IOInit(usbDetectPin, OWNER_USB_DETECT, 0);
|
|
||||||
IOConfigGPIO(usbDetectPin, IOCFG_OUT_PP);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool usbCableIsInserted(void)
|
|
||||||
{
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
#ifdef USB_DETECT_PIN
|
|
||||||
result = IORead(usbDetectPin) != 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
void usbCableDetectDeinit(void);
|
|
||||||
void usbCableDetectInit(void);
|
|
||||||
bool usbCableIsInserted(void);
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
#ifdef USB_IO
|
#ifdef USE_VCP
|
||||||
|
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
@ -28,7 +28,6 @@
|
||||||
#include "sdcard.h"
|
#include "sdcard.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef USB_DETECT_PIN
|
#ifdef USB_DETECT_PIN
|
||||||
static IO_t usbDetectPin = IO_NONE;
|
static IO_t usbDetectPin = IO_NONE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,5 +74,4 @@ void usbGenerateDisconnectPulse(void)
|
||||||
|
|
||||||
IOLo(usbPin);
|
IOLo(usbPin);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -488,7 +488,7 @@ void init(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USB_CABLE_DETECTION
|
#ifdef USB_DETECT_PIN
|
||||||
usbCableDetectInit();
|
usbCableDetectInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,6 @@
|
||||||
#define REMAP_TIM16_DMA
|
#define REMAP_TIM16_DMA
|
||||||
#define REMAP_TIM17_DMA
|
#define REMAP_TIM17_DMA
|
||||||
|
|
||||||
#define USB_IO
|
|
||||||
|
|
||||||
#define USE_VCP
|
#define USE_VCP
|
||||||
#define USE_UART1
|
#define USE_UART1
|
||||||
#define USE_UART2
|
#define USE_UART2
|
||||||
|
|
|
@ -75,8 +75,6 @@
|
||||||
#define USE_MAG_AK8963
|
#define USE_MAG_AK8963
|
||||||
#define USE_MAG_AK8975
|
#define USE_MAG_AK8975
|
||||||
|
|
||||||
#define USB_IO
|
|
||||||
|
|
||||||
#define USE_VCP
|
#define USE_VCP
|
||||||
#define USE_UART1
|
#define USE_UART1
|
||||||
#define USE_UART2
|
#define USE_UART2
|
||||||
|
|
|
@ -91,7 +91,6 @@
|
||||||
#define USE_BARO_BMP280
|
#define USE_BARO_BMP280
|
||||||
#define USE_BARO_SPI_BMP280
|
#define USE_BARO_SPI_BMP280
|
||||||
|
|
||||||
#define USB_IO
|
|
||||||
#define USE_VCP
|
#define USE_VCP
|
||||||
#define USE_UART1
|
#define USE_UART1
|
||||||
#define USE_UART2
|
#define USE_UART2
|
||||||
|
|
|
@ -108,8 +108,6 @@
|
||||||
// Performance logging for SD card operations:
|
// Performance logging for SD card operations:
|
||||||
// #define AFATFS_USE_INTROSPECTIVE_LOGGING
|
// #define AFATFS_USE_INTROSPECTIVE_LOGGING
|
||||||
|
|
||||||
#define USB_IO
|
|
||||||
|
|
||||||
#define USE_VCP
|
#define USE_VCP
|
||||||
#define USE_UART1
|
#define USE_UART1
|
||||||
#define USE_UART2
|
#define USE_UART2
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
|
|
||||||
#define USABLE_TIMER_CHANNEL_COUNT 8
|
#define USABLE_TIMER_CHANNEL_COUNT 8
|
||||||
|
|
||||||
#define USB_IO
|
|
||||||
|
|
||||||
#define USE_EXTI
|
#define USE_EXTI
|
||||||
#define MPU_INT_EXTI PC13
|
#define MPU_INT_EXTI PC13
|
||||||
#define EXTI15_10_CALLBACK_HANDLER_COUNT 1
|
#define EXTI15_10_CALLBACK_HANDLER_COUNT 1
|
||||||
|
|
|
@ -113,8 +113,6 @@
|
||||||
#define ACC_MPU6500_ALIGN CW270_DEG
|
#define ACC_MPU6500_ALIGN CW270_DEG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define USB_IO
|
|
||||||
|
|
||||||
#define USE_VCP
|
#define USE_VCP
|
||||||
#define USE_UART1
|
#define USE_UART1
|
||||||
#define USE_UART2
|
#define USE_UART2
|
||||||
|
|
|
@ -60,8 +60,12 @@
|
||||||
|
|
||||||
#define USB_IO
|
#define USB_IO
|
||||||
#define USB_CABLE_DETECTION
|
#define USB_CABLE_DETECTION
|
||||||
|
|
||||||
#define USB_DETECT_PIN PB5
|
#define USB_DETECT_PIN PB5
|
||||||
|
|
||||||
|
#undef GPS
|
||||||
|
|
||||||
|
|
||||||
#define USE_VCP
|
#define USE_VCP
|
||||||
#define USE_UART1
|
#define USE_UART1
|
||||||
#define USE_UART2
|
#define USE_UART2
|
||||||
|
|
|
@ -58,8 +58,6 @@
|
||||||
#define SONAR_TRIGGER_PIN PA6 // RC_CH7 (PB0) - only 3.3v ( add a 1K Ohms resistor )
|
#define SONAR_TRIGGER_PIN PA6 // RC_CH7 (PB0) - only 3.3v ( add a 1K Ohms resistor )
|
||||||
#define SONAR_ECHO_PIN PB1 // RC_CH8 (PB1) - only 3.3v ( add a 1K Ohms resistor )
|
#define SONAR_ECHO_PIN PB1 // RC_CH8 (PB1) - only 3.3v ( add a 1K Ohms resistor )
|
||||||
|
|
||||||
#define USB_IO
|
|
||||||
|
|
||||||
#define USE_VCP
|
#define USE_VCP
|
||||||
#define USE_UART1
|
#define USE_UART1
|
||||||
#define USE_UART2
|
#define USE_UART2
|
||||||
|
|
|
@ -78,8 +78,6 @@
|
||||||
#define SDCARD_DMA_CHANNEL_TX_COMPLETE_FLAG DMA1_FLAG_TC3
|
#define SDCARD_DMA_CHANNEL_TX_COMPLETE_FLAG DMA1_FLAG_TC3
|
||||||
#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT
|
#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT
|
||||||
|
|
||||||
#define USB_IO
|
|
||||||
|
|
||||||
#define USE_VCP
|
#define USE_VCP
|
||||||
#define USE_UART1
|
#define USE_UART1
|
||||||
#define USE_UART2
|
#define USE_UART2
|
||||||
|
|
|
@ -53,8 +53,6 @@
|
||||||
#define MPU6500_CS_PIN PA4
|
#define MPU6500_CS_PIN PA4
|
||||||
#define MPU6500_SPI_INSTANCE SPI1
|
#define MPU6500_SPI_INSTANCE SPI1
|
||||||
|
|
||||||
#define USB_IO
|
|
||||||
|
|
||||||
#define USE_VCP
|
#define USE_VCP
|
||||||
#define USE_UART1
|
#define USE_UART1
|
||||||
#define USE_UART2
|
#define USE_UART2
|
||||||
|
|
|
@ -65,8 +65,6 @@
|
||||||
|
|
||||||
//#define SONAR
|
//#define SONAR
|
||||||
|
|
||||||
#define USB_IO
|
|
||||||
|
|
||||||
#define USE_VCP
|
#define USE_VCP
|
||||||
#define USE_UART1
|
#define USE_UART1
|
||||||
#define USE_UART2
|
#define USE_UART2
|
||||||
|
|
|
@ -78,8 +78,6 @@
|
||||||
|
|
||||||
#define BRUSHED_ESC_AUTODETECT
|
#define BRUSHED_ESC_AUTODETECT
|
||||||
|
|
||||||
#define USB_IO
|
|
||||||
|
|
||||||
#define USE_VCP
|
#define USE_VCP
|
||||||
#define USE_UART1
|
#define USE_UART1
|
||||||
#define USE_UART2
|
#define USE_UART2
|
||||||
|
@ -107,12 +105,13 @@
|
||||||
#define UART3_TX_PIN PB10 // PB10 (AF7)
|
#define UART3_TX_PIN PB10 // PB10 (AF7)
|
||||||
#define UART3_RX_PIN PB11 // PB11 (AF7)
|
#define UART3_RX_PIN PB11 // PB11 (AF7)
|
||||||
|
|
||||||
|
|
||||||
#ifndef TINYBEEF3
|
#ifndef TINYBEEF3
|
||||||
#define SOFTSERIAL1_RX_PIN PA0 // PA0 / PAD3
|
#define SOFTSERIAL1_RX_PIN PA0 // PA0 / PAD3
|
||||||
#define SOFTSERIAL1_TX_PIN PA1 // PA1 / PAD4
|
#define SOFTSERIAL1_TX_PIN PA1 // PA1 / PAD4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define USB_DETECT_PIN PB5
|
||||||
|
|
||||||
#define SONAR_SOFTSERIAL1_EXCLUSIVE
|
#define SONAR_SOFTSERIAL1_EXCLUSIVE
|
||||||
|
|
||||||
#define USE_SPI
|
#define USE_SPI
|
||||||
|
|
|
@ -53,8 +53,6 @@
|
||||||
#define USE_MAG_AK8975
|
#define USE_MAG_AK8975
|
||||||
#define USE_MAG_HMC5883
|
#define USE_MAG_HMC5883
|
||||||
|
|
||||||
#define USB_IO
|
|
||||||
|
|
||||||
#define USE_VCP
|
#define USE_VCP
|
||||||
#define USE_UART1
|
#define USE_UART1
|
||||||
#define USE_UART2
|
#define USE_UART2
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
|
|
||||||
#if USB_VCP_ENABLED
|
#if USB_VCP_ENABLED
|
||||||
#define USE_VCP
|
#define USE_VCP
|
||||||
#define USB_IO
|
|
||||||
#define USBD_PRODUCT_STRING "tinyFISH"
|
#define USBD_PRODUCT_STRING "tinyFISH"
|
||||||
#define SERIAL_PORT_COUNT 6
|
#define SERIAL_PORT_COUNT 6
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue