aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2015-09-01 13:10:09 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2015-09-01 13:10:09 +0000
commit2c934bb1fa9037c5088ad7001d417f3e1598ccbf (patch)
treeae990a3be34c76b5ea5478b2110cf835874a0aa4
parent7f8853b700e2a76a9965f6a5736b43314b71bc19 (diff)
downloadChibiOS-2c934bb1fa9037c5088ad7001d417f3e1598ccbf.tar.gz
ChibiOS-2c934bb1fa9037c5088ad7001d417f3e1598ccbf.tar.bz2
ChibiOS-2c934bb1fa9037c5088ad7001d417f3e1598ccbf.zip
OTG_FS working on F7.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8266 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/hal/ports/STM32/LLD/OTGv1/stm32_otg.h7
-rw-r--r--os/hal/ports/STM32/LLD/OTGv1/usb_lld.c12
-rw-r--r--os/hal/ports/STM32/LLD/OTGv1/usb_lld.h4
-rw-r--r--testhal/STM32/STM32F4xx/USB_CDC/main.c11
-rw-r--r--testhal/STM32/STM32F7xx/USB_CDC/main.c11
5 files changed, 17 insertions, 28 deletions
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. */
diff --git a/testhal/STM32/STM32F4xx/USB_CDC/main.c b/testhal/STM32/STM32F4xx/USB_CDC/main.c
index fcd346160..a7b70c23e 100644
--- a/testhal/STM32/STM32F4xx/USB_CDC/main.c
+++ b/testhal/STM32/STM32F4xx/USB_CDC/main.c
@@ -486,17 +486,6 @@ int main(void) {
usbConnectBus(serusbcfg.usbp);
/*
- * Stopping and restarting the USB in order to test the stop procedure. The
- * following lines are not usually required.
- */
- chThdSleepMilliseconds(3000);
- usbDisconnectBus(serusbcfg.usbp);
- usbStop(serusbcfg.usbp);
- chThdSleepMilliseconds(1500);
- usbStart(serusbcfg.usbp, &usbcfg);
- usbConnectBus(serusbcfg.usbp);
-
- /*
* Shell manager initialization.
*/
shellInit();
diff --git a/testhal/STM32/STM32F7xx/USB_CDC/main.c b/testhal/STM32/STM32F7xx/USB_CDC/main.c
index f5395ebca..b4e41c396 100644
--- a/testhal/STM32/STM32F7xx/USB_CDC/main.c
+++ b/testhal/STM32/STM32F7xx/USB_CDC/main.c
@@ -193,17 +193,6 @@ int main(void) {
usbConnectBus(serusbcfg.usbp);
/*
- * Stopping and restarting the USB in order to test the stop procedure. The
- * following lines are not usually required.
- */
- chThdSleepMilliseconds(3000);
- usbDisconnectBus(serusbcfg.usbp);
- usbStop(serusbcfg.usbp);
- chThdSleepMilliseconds(1500);
- usbStart(serusbcfg.usbp, &usbcfg);
- usbConnectBus(serusbcfg.usbp);
-
- /*
* Shell manager initialization.
*/
shellInit();