From 2c934bb1fa9037c5088ad7001d417f3e1598ccbf Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 1 Sep 2015 13:10:09 +0000 Subject: OTG_FS working on F7. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8266 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/STM32/LLD/OTGv1/stm32_otg.h | 7 +++++++ os/hal/ports/STM32/LLD/OTGv1/usb_lld.c | 12 ++++++++---- os/hal/ports/STM32/LLD/OTGv1/usb_lld.h | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'os/hal') diff --git a/os/hal/ports/STM32/LLD/OTGv1/stm32_otg.h b/os/hal/ports/STM32/LLD/OTGv1/stm32_otg.h index 00d86f91c..a8991c127 100644 --- a/os/hal/ports/STM32/LLD/OTGv1/stm32_otg.h +++ b/os/hal/ports/STM32/LLD/OTGv1/stm32_otg.h @@ -189,10 +189,17 @@ typedef struct { #define GOTGCTL_ASVLD (1U<<18) /**< A-Session Valid. */ #define GOTGCTL_DBCT (1U<<17) /**< Long/Short debounce time. */ #define GOTGCTL_CIDSTS (1U<<16) /**< Connector ID status. */ +#define GOTGCTL_EHEN (1U<<12) #define GOTGCTL_DHNPEN (1U<<11) /**< Device HNP enabled. */ #define GOTGCTL_HSHNPEN (1U<<10) /**< Host Set HNP enable. */ #define GOTGCTL_HNPRQ (1U<<9) /**< HNP request. */ #define GOTGCTL_HNGSCS (1U<<8) /**< Host negotiation success. */ +#define GOTGCTL_BVALOVAL (1U<<7) +#define GOTGCTL_BVALOEN (1U<<6) +#define GOTGCTL_AVALOVAL (1U<<5) +#define GOTGCTL_AVALOEN (1U<<4) +#define GOTGCTL_VBVALOVAL (1U<<3) +#define GOTGCTL_VBVALOEN (1U<<2) #define GOTGCTL_SRQ (1U<<1) /**< Session request. */ #define GOTGCTL_SRQSCS (1U<<0) /**< Session request success. */ /** @} */ diff --git a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c index 3bd5f7140..650bc51bb 100644 --- a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c +++ b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c @@ -846,12 +846,16 @@ void usb_lld_start(USBDriver *usbp) { /* PHY enabled.*/ otgp->PCGCCTL = 0; - /* Internal FS PHY activation.*/ + /* VBUS sensing and transceiver enabled.*/ + otgp->GOTGCTL = GOTGCTL_BVALOEN | GOTGCTL_BVALOVAL; +#if defined(STM32F7XX) + otgp->GCCFG = GCCFG_PWRDWN; +#else #if defined(BOARD_OTG_NOVBUSSENS) - otgp->GCCFG = GCCFG_NOVBUSSENS | GCCFG_VBUSASEN | GCCFG_VBUSBSEN | - GCCFG_PWRDWN; + otgp->GCCFG = GCCFG_NOVBUSSENS | GCCFG_PWRDWN; #else - otgp->GCCFG = GCCFG_VBUSASEN | GCCFG_VBUSBSEN | GCCFG_PWRDWN; + otgp->GCCFG = GCCFG_PWRDWN; +#endif #endif /* Soft core reset.*/ diff --git a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.h b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.h index 293c94b02..8a1b26872 100644 --- a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.h +++ b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.h @@ -501,14 +501,14 @@ struct USBDriver { * * @api */ -#define usb_lld_connect_bus(usbp) ((usbp)->otg->GCCFG |= GCCFG_VBUSBSEN) +#define usb_lld_connect_bus(usbp) ((usbp)->otg->DCTL &= ~DCTL_SDIS) /** * @brief Disconnect the USB device. * * @api */ -#define usb_lld_disconnect_bus(usbp) ((usbp)->otg->GCCFG &= ~GCCFG_VBUSBSEN) +#define usb_lld_disconnect_bus(usbp) ((usbp)->otg->DCTL |= DCTL_SDIS) /*===========================================================================*/ /* External declarations. */ -- cgit v1.2.3