Browse Source

VBUS_DETECTION for V2 driver moved to global USBD_VBUS_DETECT

Dmitry 8 years ago
parent
commit
7e5621a9bc
2 changed files with 7 additions and 7 deletions
  1. 5 4
      inc/usbd_core.h
  2. 2 3
      src/usb_32v2.c

+ 5 - 4
inc/usbd_core.h

@@ -25,11 +25,12 @@
 /**\name Compile-time control macros
  * @{ */
 #define USBD_SOF_DISABLED   /**<\brief Disables SOF handling.*/
+#define USBD_VBUS_DETECT    /**<\brief Enables Vbus detection for V2 driver.*/
 /** @} */
 #endif
-        
+
 /**\addtogroup USBD_HW USB hardware driver
- * \brief Contains HW driver API 
+ * \brief Contains HW driver API
  * @{ */
 /**\anchor USB_EVENTS
  * \name USB device events
@@ -63,7 +64,7 @@
 /** @} */
 
 /**\addtogroup USBD_CORE USB device core
- * \brief Contains core API 
+ * \brief Contains core API
  * @{ */
 #define USB_EPTYPE_DBLBUF   0x04    /**<\brief Doublebuffered endpoint (bulk endpoint only).*/
 
@@ -186,7 +187,7 @@ typedef usbd_respond (*usbd_ctl_callback)(usbd_device *dev, usbd_ctlreq *req, us
 /**\brief USB get descriptor callback function
  * \details Called when GET_DESCRIPTOR request issued
  * \param[in] req pointer to usb control request structure
- * \param[in,out] address pointer to the descriptor in memory. Points to req->data by default. You 
+ * \param[in,out] address pointer to the descriptor in memory. Points to req->data by default. You
  * can use this buffer.
  * \param[in,out] dsize descriptor size. maximum buffer size by default.
  * \return usbd_ack if you passed the correct descriptor, usbd_fail otherwise.

+ 2 - 3
src/usb_32v2.c

@@ -20,7 +20,6 @@
 
 #if defined(USE_STMV2_DRIVER)
 
-#define VBUS_DETECTION  0
 #define MAX_EP          6
 #define MAX_RX_PACKET   128
 #define MAX_CONTROL_EP  1
@@ -108,7 +107,7 @@ void enable(bool enable) {
         OTG->GUSBCFG = USB_OTG_GUSBCFG_FDMOD | USB_OTG_GUSBCFG_PHYSEL |
                        _VAL2FLD(USB_OTG_GUSBCFG_TRDT, 0x06);
         /* configuring Vbus sense and powerup PHY */
-#if (VBUS_DETECTION)
+#if defined(USBD_VBUS_DETECT)
         OTG->GCCFG |= USB_OTG_GCCFG_VBDEN | USB_OTG_GCCFG_PWRDWN;
 #else
         OTG->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN | USB_OTG_GOTGCTL_BVALOVAL;
@@ -156,7 +155,7 @@ void reset (void) {
 
 uint8_t connect(bool connect) {
     uint8_t res;
-#if (VBUS_DETECTION)
+#if defined(USBD_VBUS_DETECT)
     #define SET_GCCFG(x) OTG->GCCFG = USB_OTG_GCCFG_VBDEN | (x)
 #else
     #define SET_GCCFG(x) OTG->GCCFG = (x)