Explorar o código

Merge pull request #350 from hathach/synopsys-msp430-dcd-disconnect-connect

Synopsys msp430 dcd disconnect connect
Ha Thach %!s(int64=5) %!d(string=hai) anos
pai
achega
19e2eb66c0

+ 8 - 9
src/portable/espressif/esp32s2/dcd_esp32s2.c

@@ -190,9 +190,6 @@ void dcd_init(uint8_t rhport)
                  USB_ENUMDONEMSK_M |
                  USB_ENUMDONEMSK_M |
                  USB_RESETDETMSK_M |
                  USB_RESETDETMSK_M |
                  USB_DISCONNINTMSK_M;
                  USB_DISCONNINTMSK_M;
-
-  ESP_LOGV(TAG, "DCD init - Soft CONNECT");
-  USB0.dctl &= ~USB_SFTDISCON_M; // Connect
 }
 }
 
 
 void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
 void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
@@ -216,18 +213,20 @@ void dcd_remote_wakeup(uint8_t rhport)
   (void)rhport;
   (void)rhport;
 }
 }
 
 
-// disconnect by disabling internal pull-up resistor on D+/D-
-void dcd_disconnect(uint8_t rhport)
-{
-  USB0.dctl |= USB_SFTDISCON_M;
-}
-
 // connect by enabling internal pull-up resistor on D+/D-
 // connect by enabling internal pull-up resistor on D+/D-
 void dcd_connect(uint8_t rhport)
 void dcd_connect(uint8_t rhport)
 {
 {
+  (void) rhport;
   USB0.dctl &= ~USB_SFTDISCON_M;
   USB0.dctl &= ~USB_SFTDISCON_M;
 }
 }
 
 
+// disconnect by disabling internal pull-up resistor on D+/D-
+void dcd_disconnect(uint8_t rhport)
+{
+  (void) rhport;
+  USB0.dctl |= USB_SFTDISCON_M;
+}
+
 /*------------------------------------------------------------------*/
 /*------------------------------------------------------------------*/
 /* DCD Endpoint port
 /* DCD Endpoint port
  *------------------------------------------------------------------*/
  *------------------------------------------------------------------*/

+ 12 - 0
src/portable/sony/cxd56/dcd_cxd56.c

@@ -201,6 +201,18 @@ void dcd_remote_wakeup(uint8_t rhport)
   DEV_WAKEUP(usbdev);
   DEV_WAKEUP(usbdev);
 }
 }
 
 
+#if 0 // TODO implement for Spresense
+void dcd_connect(uint8_t rhport)
+{
+  (void) rhport;
+}
+
+void dcd_disconnect(uint8_t rhport)
+{
+  (void) rhport;
+}
+#endif
+
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+
 // Endpoint API
 // Endpoint API
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+

+ 17 - 4
src/portable/st/synopsys/dcd_synopsys.c

@@ -209,10 +209,6 @@ void dcd_init (uint8_t rhport)
 
 
   // Enable USB transceiver.
   // Enable USB transceiver.
   USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_PWRDWN;
   USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_PWRDWN;
-
-  // Soft Connect -> Enable pullup on D+/D-.
-  // This step does not appear to be specified in the programmer's model.
-  dev->DCTL &= ~USB_OTG_DCTL_SDIS;
 }
 }
 
 
 void dcd_int_enable (uint8_t rhport)
 void dcd_int_enable (uint8_t rhport)
@@ -250,6 +246,23 @@ void dcd_remote_wakeup(uint8_t rhport)
   (void) rhport;
   (void) rhport;
 }
 }
 
 
+void dcd_connect(uint8_t rhport)
+{
+  (void) rhport;
+  USB_OTG_DeviceTypeDef * dev = DEVICE_BASE;
+
+  dev->DCTL &= ~USB_OTG_DCTL_SDIS;
+}
+
+void dcd_disconnect(uint8_t rhport)
+{
+  (void) rhport;
+  USB_OTG_DeviceTypeDef * dev = DEVICE_BASE;
+
+  dev->DCTL |= USB_OTG_DCTL_SDIS;
+}
+
+
 /*------------------------------------------------------------------*/
 /*------------------------------------------------------------------*/
 /* DCD Endpoint port
 /* DCD Endpoint port
  *------------------------------------------------------------------*/
  *------------------------------------------------------------------*/

+ 22 - 3
src/portable/ti/msp430x5xx/dcd_msp430x5xx.c

@@ -134,9 +134,6 @@ void dcd_init (uint8_t rhport)
   // Enable reset and wait for it before continuing.
   // Enable reset and wait for it before continuing.
   USBIE |= RSTRIE;
   USBIE |= RSTRIE;
 
 
-  // Enable pullup.
-  USBCNF |= PUR_EN;
-
   USBKEYPID = 0;
   USBKEYPID = 0;
 }
 }
 
 
@@ -207,6 +204,28 @@ void dcd_remote_wakeup(uint8_t rhport)
   (void) rhport;
   (void) rhport;
 }
 }
 
 
+void dcd_connect(uint8_t rhport)
+{
+  dcd_int_disable(rhport);
+
+  USBKEYPID = USBKEY;
+  USBCNF |= PUR_EN; // Enable pullup.
+  USBKEYPID = 0;
+
+  dcd_int_enable(rhport);
+}
+
+void dcd_disconnect(uint8_t rhport)
+{
+  dcd_int_disable(rhport);
+
+  USBKEYPID = USBKEY;
+  USBCNF &= ~PUR_EN; // Disable pullup.
+  USBKEYPID = 0;
+
+  dcd_int_enable(rhport);
+}
+
 /*------------------------------------------------------------------*/
 /*------------------------------------------------------------------*/
 /* DCD Endpoint port
 /* DCD Endpoint port
  *------------------------------------------------------------------*/
  *------------------------------------------------------------------*/