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

Synopsys msp430 dcd disconnect connect
This commit is contained in:
Ha Thach 2020-04-17 09:51:15 +07:00 committed by GitHub
commit 19e2eb66c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 16 deletions

View File

@ -190,9 +190,6 @@ void dcd_init(uint8_t rhport)
USB_ENUMDONEMSK_M |
USB_RESETDETMSK_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)
@ -216,18 +213,20 @@ void dcd_remote_wakeup(uint8_t 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-
void dcd_connect(uint8_t rhport)
{
(void) rhport;
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
*------------------------------------------------------------------*/

View File

@ -201,6 +201,18 @@ void dcd_remote_wakeup(uint8_t rhport)
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
//--------------------------------------------------------------------+

View File

@ -209,10 +209,6 @@ void dcd_init (uint8_t rhport)
// Enable USB transceiver.
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)
@ -250,6 +246,23 @@ void dcd_remote_wakeup(uint8_t 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
*------------------------------------------------------------------*/

View File

@ -134,9 +134,6 @@ void dcd_init (uint8_t rhport)
// Enable reset and wait for it before continuing.
USBIE |= RSTRIE;
// Enable pullup.
USBCNF |= PUR_EN;
USBKEYPID = 0;
}
@ -207,6 +204,28 @@ void dcd_remote_wakeup(uint8_t 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
*------------------------------------------------------------------*/