diff --git a/Makefile b/Makefile
index 06c039d592..8b46c0dd81 100644
--- a/Makefile
+++ b/Makefile
@@ -786,13 +786,15 @@ VCP_SRC = \
vcpf4/usbd_desc.c \
vcpf4/usbd_usr.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)))
VCP_SRC = \
vcp_hal/usbd_desc.c \
vcp_hal/usbd_conf.c \
vcp_hal/usbd_cdc_interface.c \
- drivers/serial_usb_vcp.c
+ drivers/serial_usb_vcp.c \
+ drivers/usb_io.c
else
VCP_SRC = \
vcp/hw_config.c \
diff --git a/src/main/drivers/serial_usb_vcp.c b/src/main/drivers/serial_usb_vcp.c
index 6014553cb4..97fdfe03c4 100644
--- a/src/main/drivers/serial_usb_vcp.c
+++ b/src/main/drivers/serial_usb_vcp.c
@@ -28,8 +28,10 @@
#if defined(STM32F4)
#include "usb_core.h"
#include "usbd_cdc_vcp.h"
+#include "usb_io.h"
#elif defined(STM32F7)
#include "vcp_hal/usbd_cdc_interface.h"
+#include "usb_io.h"
USBD_HandleTypeDef USBD_Device;
#else
#include "usb_core.h"
@@ -184,10 +186,14 @@ serialPort_t *usbVcpOpen(void)
vcpPort_t *s;
#if defined(STM32F4)
+ usbGenerateDisconnectPulse();
+
IOInit(IOGetByTag(IO_TAG(PA11)), 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);
#elif defined(STM32F7)
+ usbGenerateDisconnectPulse();
+
IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, 0);
IOInit(IOGetByTag(IO_TAG(PA12)), OWNER_USB, 0);
/* Init Device Library */
diff --git a/src/main/drivers/usb_detection.c b/src/main/drivers/usb_detection.c
deleted file mode 100644
index d1c0088c9e..0000000000
--- a/src/main/drivers/usb_detection.c
+++ /dev/null
@@ -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 .
- */
-
-#include
-#include
-
-#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;
-}
diff --git a/src/main/drivers/usb_detection.h b/src/main/drivers/usb_detection.h
deleted file mode 100644
index 5a3c53d6b4..0000000000
--- a/src/main/drivers/usb_detection.h
+++ /dev/null
@@ -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 .
- */
-
-#pragma once
-
-void usbCableDetectDeinit(void);
-void usbCableDetectInit(void);
-bool usbCableIsInserted(void);
diff --git a/src/main/drivers/usb_io.c b/src/main/drivers/usb_io.c
index 7d2c99fc89..8166dca4bf 100644
--- a/src/main/drivers/usb_io.c
+++ b/src/main/drivers/usb_io.c
@@ -20,7 +20,7 @@
#include "platform.h"
-#ifdef USB_IO
+#ifdef USE_VCP
#include "io.h"
#include "system.h"
@@ -28,7 +28,6 @@
#include "sdcard.h"
-
#ifdef USB_DETECT_PIN
static IO_t usbDetectPin = IO_NONE;
#endif
@@ -75,5 +74,4 @@ void usbGenerateDisconnectPulse(void)
IOLo(usbPin);
}
-
#endif
diff --git a/src/main/fc/fc_init.c b/src/main/fc/fc_init.c
index 9846d9bbdb..8b0acf1bb7 100644
--- a/src/main/fc/fc_init.c
+++ b/src/main/fc/fc_init.c
@@ -475,7 +475,7 @@ void init(void)
}
#endif
-#ifdef USB_CABLE_DETECTION
+#ifdef USB_DETECT_PIN
usbCableDetectInit();
#endif
diff --git a/src/main/target/BETAFLIGHTF3/target.h b/src/main/target/BETAFLIGHTF3/target.h
index 04c906052f..6c27ce17b3 100755
--- a/src/main/target/BETAFLIGHTF3/target.h
+++ b/src/main/target/BETAFLIGHTF3/target.h
@@ -49,8 +49,6 @@
#define REMAP_TIM16_DMA
#define REMAP_TIM17_DMA
-#define USB_IO
-
#define USE_VCP
#define USE_UART1
#define USE_UART2
diff --git a/src/main/target/COLIBRI_RACE/target.h b/src/main/target/COLIBRI_RACE/target.h
index cb7f26331e..de74fc6fa4 100755
--- a/src/main/target/COLIBRI_RACE/target.h
+++ b/src/main/target/COLIBRI_RACE/target.h
@@ -75,8 +75,6 @@
#define USE_MAG_AK8963
#define USE_MAG_AK8975
-#define USB_IO
-
#define USE_VCP
#define USE_UART1
#define USE_UART2
diff --git a/src/main/target/DOGE/target.h b/src/main/target/DOGE/target.h
index 51e6d6ae0e..0dae0773f8 100644
--- a/src/main/target/DOGE/target.h
+++ b/src/main/target/DOGE/target.h
@@ -91,7 +91,6 @@
#define USE_BARO_BMP280
#define USE_BARO_SPI_BMP280
-#define USB_IO
#define USE_VCP
#define USE_UART1
#define USE_UART2
diff --git a/src/main/target/FURYF3/target.h b/src/main/target/FURYF3/target.h
index 4c95f8959b..de1790a4fc 100644
--- a/src/main/target/FURYF3/target.h
+++ b/src/main/target/FURYF3/target.h
@@ -108,8 +108,6 @@
// Performance logging for SD card operations:
// #define AFATFS_USE_INTROSPECTIVE_LOGGING
-#define USB_IO
-
#define USE_VCP
#define USE_UART1
#define USE_UART2
diff --git a/src/main/target/IMPULSERCF3/target.h b/src/main/target/IMPULSERCF3/target.h
index 19858114af..468fec4f3d 100644
--- a/src/main/target/IMPULSERCF3/target.h
+++ b/src/main/target/IMPULSERCF3/target.h
@@ -27,8 +27,6 @@
#define USABLE_TIMER_CHANNEL_COUNT 8
-#define USB_IO
-
#define USE_EXTI
#define MPU_INT_EXTI PC13
#define EXTI15_10_CALLBACK_HANDLER_COUNT 1
diff --git a/src/main/target/LUX_RACE/target.h b/src/main/target/LUX_RACE/target.h
index 3ea53966cc..03ef073164 100644
--- a/src/main/target/LUX_RACE/target.h
+++ b/src/main/target/LUX_RACE/target.h
@@ -113,8 +113,6 @@
#define ACC_MPU6500_ALIGN CW270_DEG
#endif
-#define USB_IO
-
#define USE_VCP
#define USE_UART1
#define USE_UART2
diff --git a/src/main/target/OMNIBUS/target.h b/src/main/target/OMNIBUS/target.h
index d88c343d55..98fa9048d3 100644
--- a/src/main/target/OMNIBUS/target.h
+++ b/src/main/target/OMNIBUS/target.h
@@ -60,8 +60,12 @@
#define USB_IO
#define USB_CABLE_DETECTION
+
#define USB_DETECT_PIN PB5
+#undef GPS
+
+
#define USE_VCP
#define USE_UART1
#define USE_UART2
diff --git a/src/main/target/RCEXPLORERF3/target.h b/src/main/target/RCEXPLORERF3/target.h
index fda731bb3c..83cf74255b 100644
--- a/src/main/target/RCEXPLORERF3/target.h
+++ b/src/main/target/RCEXPLORERF3/target.h
@@ -58,8 +58,6 @@
#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 USB_IO
-
#define USE_VCP
#define USE_UART1
#define USE_UART2
diff --git a/src/main/target/RG_SSD_F3/target.h b/src/main/target/RG_SSD_F3/target.h
index afe500fec6..0782c20723 100644
--- a/src/main/target/RG_SSD_F3/target.h
+++ b/src/main/target/RG_SSD_F3/target.h
@@ -78,8 +78,6 @@
#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
diff --git a/src/main/target/SIRINFPV/target.h b/src/main/target/SIRINFPV/target.h
index 9ae3a3f2a3..362db90c83 100644
--- a/src/main/target/SIRINFPV/target.h
+++ b/src/main/target/SIRINFPV/target.h
@@ -53,8 +53,6 @@
#define MPU6500_CS_PIN PA4
#define MPU6500_SPI_INSTANCE SPI1
-#define USB_IO
-
#define USE_VCP
#define USE_UART1
#define USE_UART2
diff --git a/src/main/target/SPRACINGF3EVO/target.h b/src/main/target/SPRACINGF3EVO/target.h
index 3fbf7f0e33..75f6a91ce0 100755
--- a/src/main/target/SPRACINGF3EVO/target.h
+++ b/src/main/target/SPRACINGF3EVO/target.h
@@ -65,8 +65,6 @@
//#define SONAR
-#define USB_IO
-
#define USE_VCP
#define USE_UART1
#define USE_UART2
diff --git a/src/main/target/SPRACINGF3MINI/target.h b/src/main/target/SPRACINGF3MINI/target.h
index c859204012..21b18cb939 100644
--- a/src/main/target/SPRACINGF3MINI/target.h
+++ b/src/main/target/SPRACINGF3MINI/target.h
@@ -78,8 +78,6 @@
#define BRUSHED_ESC_AUTODETECT
-#define USB_IO
-
#define USE_VCP
#define USE_UART1
#define USE_UART2
@@ -107,12 +105,13 @@
#define UART3_TX_PIN PB10 // PB10 (AF7)
#define UART3_RX_PIN PB11 // PB11 (AF7)
-
#ifndef TINYBEEF3
#define SOFTSERIAL1_RX_PIN PA0 // PA0 / PAD3
#define SOFTSERIAL1_TX_PIN PA1 // PA1 / PAD4
#endif
+#define USB_DETECT_PIN PB5
+
#define SONAR_SOFTSERIAL1_EXCLUSIVE
#define USE_SPI
diff --git a/src/main/target/SPRACINGF3NEO/target.h b/src/main/target/SPRACINGF3NEO/target.h
index eba7318c4c..29d20b9b9d 100755
--- a/src/main/target/SPRACINGF3NEO/target.h
+++ b/src/main/target/SPRACINGF3NEO/target.h
@@ -53,8 +53,6 @@
#define USE_MAG_AK8975
#define USE_MAG_HMC5883
-#define USB_IO
-
#define USE_VCP
#define USE_UART1
#define USE_UART2
diff --git a/src/main/target/TINYFISH/target.h b/src/main/target/TINYFISH/target.h
index 294965d8a5..1deffa81bc 100644
--- a/src/main/target/TINYFISH/target.h
+++ b/src/main/target/TINYFISH/target.h
@@ -46,7 +46,6 @@
#if USB_VCP_ENABLED
#define USE_VCP
- #define USB_IO
#define USBD_PRODUCT_STRING "tinyFISH"
#define SERIAL_PORT_COUNT 6
#else