1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 14:25:20 +03:00

Added USB disconnect pulse for F4 / F7.

This commit is contained in:
mikeller 2017-02-19 16:18:55 +13:00 committed by Dominic Clifton
parent 9515088a98
commit ca67cf1990
20 changed files with 18 additions and 108 deletions

View file

@ -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 \

View file

@ -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 */

View file

@ -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;
}

View file

@ -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);

View file

@ -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

View file

@ -488,7 +488,7 @@ void init(void)
}
#endif
#ifdef USB_CABLE_DETECTION
#ifdef USB_DETECT_PIN
usbCableDetectInit();
#endif

View file

@ -49,8 +49,6 @@
#define REMAP_TIM16_DMA
#define REMAP_TIM17_DMA
#define USB_IO
#define USE_VCP
#define USE_UART1
#define USE_UART2

View file

@ -75,8 +75,6 @@
#define USE_MAG_AK8963
#define USE_MAG_AK8975
#define USB_IO
#define USE_VCP
#define USE_UART1
#define USE_UART2

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -113,8 +113,6 @@
#define ACC_MPU6500_ALIGN CW270_DEG
#endif
#define USB_IO
#define USE_VCP
#define USE_UART1
#define USE_UART2

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -65,8 +65,6 @@
//#define SONAR
#define USB_IO
#define USE_VCP
#define USE_UART1
#define USE_UART2

View file

@ -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

View file

@ -53,8 +53,6 @@
#define USE_MAG_AK8975
#define USE_MAG_HMC5883
#define USB_IO
#define USE_VCP
#define USE_UART1
#define USE_UART2

View file

@ -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