diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2014-12-20 16:53:05 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2014-12-20 16:53:05 +0000 |
commit | 6184745e4e2c15aea3c78b7e2e8639fd6cbf7bf6 (patch) | |
tree | 04d85548e943d1434d088b815f307ffde222f75c | |
parent | 2e7aee242c1df1223b46abaaef063b0bbccd77e9 (diff) | |
download | ChibiOS-6184745e4e2c15aea3c78b7e2e8639fd6cbf7bf6.tar.gz ChibiOS-6184745e4e2c15aea3c78b7e2e8639fd6cbf7bf6.tar.bz2 ChibiOS-6184745e4e2c15aea3c78b7e2e8639fd6cbf7bf6.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7589 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | os/hal/ports/STM32/LLD/USBv1/stm32_usb.h | 16 | ||||
-rw-r--r-- | os/hal/ports/STM32/LLD/USBv1/usb_lld.h | 20 | ||||
-rw-r--r-- | os/hal/ports/STM32/STM32F0xx/stm32_registry.h | 1 | ||||
-rw-r--r-- | os/hal/ports/STM32/STM32F1xx/stm32_registry.h | 3 | ||||
-rw-r--r-- | os/hal/ports/STM32/STM32F37x/stm32_registry.h | 1 | ||||
-rw-r--r-- | os/hal/ports/STM32/STM32F3xx/stm32_registry.h | 5 | ||||
-rw-r--r-- | os/hal/ports/STM32/STM32L1xx/stm32_registry.h | 2 | ||||
-rw-r--r-- | testhal/STM32/STM32F0xx/USB_CDC/main.c | 7 |
8 files changed, 40 insertions, 15 deletions
diff --git a/os/hal/ports/STM32/LLD/USBv1/stm32_usb.h b/os/hal/ports/STM32/LLD/USBv1/stm32_usb.h index 69f7beb62..7b74bf7d9 100644 --- a/os/hal/ports/STM32/LLD/USBv1/stm32_usb.h +++ b/os/hal/ports/STM32/LLD/USBv1/stm32_usb.h @@ -65,6 +65,14 @@ typedef struct { * @brief Buffer Table Address.
*/
volatile uint32_t BTABLE;
+ /*
+ * @brief LPM Control and Status Register.
+ */
+ volatile uint32_t LPMCSR;
+ /*
+ * @brief Battery Charging Detector
+ */
+ volatile uint32_t BCDR;
} stm32_usb_t;
/**
@@ -95,14 +103,6 @@ typedef struct { * @brief RX counter register 1.
*/
volatile uint16_t RXCOUNT1;
- /*
- * @brief LPM Control and Status Register.
- */
- volatile uint32_t LPMCSR;
- /*
- * @brief Battery Charging Detector
- */
- volatile uint32_t BCDR;
} stm32_usb_descriptor_t;
/**
diff --git a/os/hal/ports/STM32/LLD/USBv1/usb_lld.h b/os/hal/ports/STM32/LLD/USBv1/usb_lld.h index 090200641..b32597921 100644 --- a/os/hal/ports/STM32/LLD/USBv1/usb_lld.h +++ b/os/hal/ports/STM32/LLD/USBv1/usb_lld.h @@ -404,6 +404,26 @@ struct USBDriver { #define usb_lld_get_transaction_size(usbp, ep) \
((usbp)->epc[ep]->out_state->rxcnt)
+#if STM32_USB_HAS_BCDR || defined(__DOXYGEN__)
+/**
+ * @brief Connects the USB device.
+ *
+ * @api
+ */
+#if !defined(usb_lld_connect_bus)
+#define usb_lld_connect_bus(usbp) (STM32_USB->BCDR |= USB_BCDR_DPPU)
+#endif
+
+/**
+ * @brief Disconnect the USB device.
+ *
+ * @api
+ */
+#if !defined(usb_lld_disconnect_bus)
+#define usb_lld_disconnect_bus(usbp) (STM32_USB->BCDR &= ~USB_BCDR_DPPU)
+#endif
+#endif /* STM32_USB_HAS_BCDR */
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
diff --git a/os/hal/ports/STM32/STM32F0xx/stm32_registry.h b/os/hal/ports/STM32/STM32F0xx/stm32_registry.h index 19607550c..0745791ba 100644 --- a/os/hal/ports/STM32/STM32F0xx/stm32_registry.h +++ b/os/hal/ports/STM32/STM32F0xx/stm32_registry.h @@ -195,6 +195,7 @@ #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || \
defined(STM32F078xx)
#define STM32_HAS_USB TRUE
+#define STM32_USB_HAS_BCDR TRUE
#else
#define STM32_HAS_USB FALSE
#endif
diff --git a/os/hal/ports/STM32/STM32F1xx/stm32_registry.h b/os/hal/ports/STM32/STM32F1xx/stm32_registry.h index bc09c7d59..474bf1332 100644 --- a/os/hal/ports/STM32/STM32F1xx/stm32_registry.h +++ b/os/hal/ports/STM32/STM32F1xx/stm32_registry.h @@ -582,6 +582,7 @@ /* USB attributes.*/
#define STM32_HAS_USB TRUE
+#define STM32_USB_HAS_BCDR FALSE
#define STM32_HAS_OTG1 FALSE
#define STM32_HAS_OTG2 FALSE
/** @} */
@@ -756,6 +757,7 @@ /* USB attributes.*/
#define STM32_HAS_USB TRUE
+#define STM32_USB_HAS_BCDR FALSE
#define STM32_HAS_OTG1 FALSE
#define STM32_HAS_OTG2 FALSE
/** @} */
@@ -930,6 +932,7 @@ /* USB attributes.*/
#define STM32_HAS_USB TRUE
+#define STM32_USB_HAS_BCDR FALSE
#define STM32_HAS_OTG1 FALSE
#define STM32_HAS_OTG2 FALSE
/** @} */
diff --git a/os/hal/ports/STM32/STM32F37x/stm32_registry.h b/os/hal/ports/STM32/STM32F37x/stm32_registry.h index 08c940a39..e0a38489a 100644 --- a/os/hal/ports/STM32/STM32F37x/stm32_registry.h +++ b/os/hal/ports/STM32/STM32F37x/stm32_registry.h @@ -206,6 +206,7 @@ /* USB attributes.*/
#define STM32_HAS_USB TRUE
+#define STM32_USB_HAS_BCDR FALSE
#define STM32_HAS_OTG1 FALSE
#define STM32_HAS_OTG2 FALSE
#endif /* defined(STM32F373xC) */
diff --git a/os/hal/ports/STM32/STM32F3xx/stm32_registry.h b/os/hal/ports/STM32/STM32F3xx/stm32_registry.h index 1336a6ed8..b60a40dc6 100644 --- a/os/hal/ports/STM32/STM32F3xx/stm32_registry.h +++ b/os/hal/ports/STM32/STM32F3xx/stm32_registry.h @@ -204,6 +204,7 @@ /* USB attributes.*/
#define STM32_HAS_USB TRUE
+#define STM32_USB_HAS_BCDR FALSE
#define STM32_HAS_OTG1 FALSE
#define STM32_HAS_OTG2 FALSE
#endif /* defined(STM32F303xC) */
@@ -658,6 +659,7 @@ /* USB attributes.*/
#define STM32_HAS_USB TRUE
+#define STM32_USB_HAS_BCDR FALSE
#define STM32_HAS_OTG1 FALSE
#define STM32_HAS_OTG2 FALSE
#endif /* defined(STM32F302x8) */
@@ -821,6 +823,7 @@ /* USB attributes.*/
#define STM32_HAS_USB TRUE
+#define STM32_USB_HAS_BCDR FALSE
#define STM32_HAS_OTG1 FALSE
#define STM32_HAS_OTG2 FALSE
#endif /* defined(STM32F302xC) */
@@ -971,6 +974,7 @@ /* USB attributes.*/
#define STM32_HAS_USB TRUE
+#define STM32_USB_HAS_BCDR FALSE
#define STM32_HAS_OTG1 FALSE
#define STM32_HAS_OTG2 FALSE
#endif /* defined(STM32F318x8) */
@@ -1283,6 +1287,7 @@ /* USB attributes.*/
#define STM32_HAS_USB TRUE
+#define STM32_USB_HAS_BCDR FALSE
#define STM32_HAS_OTG1 FALSE
#define STM32_HAS_OTG2 FALSE
#endif /* defined(STM32F358xC) */
diff --git a/os/hal/ports/STM32/STM32L1xx/stm32_registry.h b/os/hal/ports/STM32/STM32L1xx/stm32_registry.h index 08e5cc012..b9e811dd8 100644 --- a/os/hal/ports/STM32/STM32L1xx/stm32_registry.h +++ b/os/hal/ports/STM32/STM32L1xx/stm32_registry.h @@ -178,6 +178,7 @@ /* USB attributes.*/
#define STM32_HAS_USB TRUE
+#define STM32_USB_HAS_BCDR FALSE
#define STM32_HAS_OTG1 FALSE
#define STM32_HAS_OTG2 FALSE
@@ -333,6 +334,7 @@ /* USB attributes.*/
#define STM32_HAS_USB TRUE
+#define STM32_USB_HAS_BCDR FALSE
#define STM32_HAS_OTG1 FALSE
#define STM32_HAS_OTG2 FALSE
diff --git a/testhal/STM32/STM32F0xx/USB_CDC/main.c b/testhal/STM32/STM32F0xx/USB_CDC/main.c index f6f304cdc..24ee2c278 100644 --- a/testhal/STM32/STM32F0xx/USB_CDC/main.c +++ b/testhal/STM32/STM32F0xx/USB_CDC/main.c @@ -36,13 +36,6 @@ #define USBD1_INTERRUPT_REQUEST_EP 2
/*
- * DP resistor control is not possible on the STM32F3-Discovery, using stubs
- * for the connection macros.
- */
-#define usb_lld_connect_bus(usbp)
-#define usb_lld_disconnect_bus(usbp)
-
-/*
* Serial over USB Driver structure.
*/
static SerialUSBDriver SDU1;
|