From 78bc3f52ad2d7644f3c2521e9745b36faa639cc5 Mon Sep 17 00:00:00 2001 From: jflyper Date: Fri, 13 Apr 2018 02:07:58 +0900 Subject: [PATCH] Disable VBUSSENSING features on PA9 completely --- lib/main/STM32_USB_OTG_Driver/src/usb_core.c | 7 ++++--- src/main/drivers/usb_io.c | 11 +++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/main/STM32_USB_OTG_Driver/src/usb_core.c b/lib/main/STM32_USB_OTG_Driver/src/usb_core.c index 15213d28c..7f7552d2d 100644 --- a/lib/main/STM32_USB_OTG_Driver/src/usb_core.c +++ b/lib/main/STM32_USB_OTG_Driver/src/usb_core.c @@ -318,6 +318,7 @@ USB_OTG_STS USB_OTG_SelectCore(USB_OTG_CORE_HANDLE *pdev, return status; } +#include "build/debug.h" /** * @brief USB_OTG_CoreInit @@ -391,13 +392,13 @@ USB_OTG_STS USB_OTG_CoreInit(USB_OTG_CORE_HANDLE *pdev) /* Deactivate the power down*/ gccfg.d32 = 0; gccfg.b.pwdn = 1; +#ifdef VBUS_SENSING_ENABLED gccfg.b.vbussensingA = 1 ; gccfg.b.vbussensingB = 1 ; - -#ifndef VBUS_SENSING_ENABLED +#else gccfg.b.disablevbussensing = 1; #endif - + if(pdev->cfg.Sof_output) { gccfg.b.sofouten = 1; diff --git a/src/main/drivers/usb_io.c b/src/main/drivers/usb_io.c index 3de4bd030..c32d62c49 100644 --- a/src/main/drivers/usb_io.c +++ b/src/main/drivers/usb_io.c @@ -28,13 +28,13 @@ #include "sdcard.h" -#ifdef USB_DETECT_PIN +#ifdef USE_USB_DETECT static IO_t usbDetectPin = IO_NONE; #endif void usbCableDetectDeinit(void) { -#ifdef USB_DETECT_PIN +#ifdef USE_USB_DETECT IOInit(usbDetectPin, OWNER_FREE, 0); IOConfigGPIO(usbDetectPin, IOCFG_IN_FLOATING); usbDetectPin = IO_NONE; @@ -43,7 +43,10 @@ void usbCableDetectDeinit(void) void usbCableDetectInit(void) { -#ifdef USB_DETECT_PIN +#ifdef USE_USB_DETECT +#ifndef USB_DETECT_PIN +#define USB_DETECT_PIN NONE +#endif usbDetectPin = IOGetByTag(IO_TAG(USB_DETECT_PIN)); IOInit(usbDetectPin, OWNER_USB_DETECT, 0); @@ -55,7 +58,7 @@ bool usbCableIsInserted(void) { bool result = false; -#ifdef USB_DETECT_PIN +#ifdef USE_USB_DETECT result = IORead(usbDetectPin) != 0; #endif