diff options
| author | hathach <[email protected]> | 2019-03-13 23:14:48 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2019-03-13 23:14:48 +0700 |
| commit | eda56769b9126460f7721a9b3f04d4e4f6efd60d (patch) | |
| tree | 7a1d6bdde8db8af92b9e16583982eabbf0eff43e /src/portable | |
| parent | 195a44172a964b377330bc7f269b611bb920fdc7 (diff) | |
dcd_set_address include status response, usbd control stall both control in and out
Diffstat (limited to 'src/portable')
| -rw-r--r-- | src/portable/microchip/samd21/dcd_samd21.c | 9 | ||||
| -rw-r--r-- | src/portable/microchip/samd51/dcd_samd51.c | 9 | ||||
| -rw-r--r-- | src/portable/nordic/nrf5x/dcd_nrf5x.c | 2 | ||||
| -rw-r--r-- | src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c | 16 | ||||
| -rw-r--r-- | src/portable/nxp/lpc17_40/dcd_lpc17_40.c | 6 | ||||
| -rw-r--r-- | src/portable/nxp/lpc18_43/dcd_lpc18_43.c | 12 | ||||
| -rw-r--r-- | src/portable/st/stm32f4/dcd_stm32f4.c | 3 |
7 files changed, 23 insertions, 34 deletions
diff --git a/src/portable/microchip/samd21/dcd_samd21.c b/src/portable/microchip/samd21/dcd_samd21.c index 6140812bc..130825f74 100644 --- a/src/portable/microchip/samd21/dcd_samd21.c +++ b/src/portable/microchip/samd21/dcd_samd21.c @@ -110,10 +110,12 @@ void dcd_int_disable(uint8_t rhport) void dcd_set_address (uint8_t rhport, uint8_t dev_addr) { - (void) rhport; + // Response with status first before changing device address + dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0); // Wait for EP0 to finish before switching the address. while (USB->DEVICE.DeviceEndpoint[0].EPSTATUS.bit.BK1RDY == 1) {} + USB->DEVICE.DADD.reg = USB_DEVICE_DADD_DADD(dev_addr) | USB_DEVICE_DADD_ADDEN; } @@ -230,11 +232,6 @@ void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1; } else { ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ0; - - // for control, stall both IN & OUT - if (ep_addr == 0) { - ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1; - } } } diff --git a/src/portable/microchip/samd51/dcd_samd51.c b/src/portable/microchip/samd51/dcd_samd51.c index 1de3fadb2..27c5c4db4 100644 --- a/src/portable/microchip/samd51/dcd_samd51.c +++ b/src/portable/microchip/samd51/dcd_samd51.c @@ -115,10 +115,12 @@ void dcd_int_disable(uint8_t rhport) void dcd_set_address (uint8_t rhport, uint8_t dev_addr) { - (void) rhport; + // Response with status first before changing device address + dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0); // Wait for EP0 to finish before switching the address. while (USB->DEVICE.DeviceEndpoint[0].EPSTATUS.bit.BK1RDY == 1) {} + USB->DEVICE.DADD.reg = USB_DEVICE_DADD_DADD(dev_addr) | USB_DEVICE_DADD_ADDEN; } @@ -234,11 +236,6 @@ void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1; } else { ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ0; - - // for control, stall both IN & OUT - if (ep_addr == 0) { - ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1; - } } } diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c index 49984eae8..1280fe7c2 100644 --- a/src/portable/nordic/nrf5x/dcd_nrf5x.c +++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c @@ -211,7 +211,7 @@ void dcd_set_address (uint8_t rhport, uint8_t dev_addr) { (void) rhport; (void) dev_addr; - // Set Address is automatically update by hw controller + // Set Address is automatically update by hw controller, nothing to do } void dcd_set_config (uint8_t rhport, uint8_t config_num) diff --git a/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c b/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c index a9ba5e336..36dcf88ff 100644 --- a/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c +++ b/src/portable/nxp/lpc11_13_15/dcd_lpc11_13_15.c @@ -159,7 +159,8 @@ void dcd_set_config(uint8_t rhport, uint8_t config_num) void dcd_set_address(uint8_t rhport, uint8_t dev_addr) { - (void) rhport; + // Response with status first before changing device address + dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0); LPC_USB->DEVCMDSTAT &= ~CMDSTAT_DEVICE_ADDR_MASK; LPC_USB->DEVCMDSTAT |= dev_addr; @@ -196,16 +197,9 @@ void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) { (void) rhport; - if ( tu_edpt_number(ep_addr) == 0 ) - { - // TODO cannot able to STALL Control OUT endpoint !!!!! FIXME try some walk-around - _dcd.ep[0][0].stall = _dcd.ep[1][0].stall = 1; - } - else - { - uint8_t const ep_id = ep_addr2id(ep_addr); - _dcd.ep[ep_id][0].stall = 1; - } + // TODO cannot able to STALL Control OUT endpoint !!!!! FIXME try some walk-around + uint8_t const ep_id = ep_addr2id(ep_addr); + _dcd.ep[ep_id][0].stall = 1; } bool dcd_edpt_stalled(uint8_t rhport, uint8_t ep_addr) diff --git a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c index e3286b1cb..e0ccbf96a 100644 --- a/src/portable/nxp/lpc17_40/dcd_lpc17_40.c +++ b/src/portable/nxp/lpc17_40/dcd_lpc17_40.c @@ -199,7 +199,7 @@ bool dcd_init(uint8_t rhport) NVIC_ClearPendingIRQ(USB_IRQn); NVIC_EnableIRQ(USB_IRQn); - return TUSB_ERROR_NONE; + return true; } void dcd_int_enable(uint8_t rhport) @@ -216,7 +216,9 @@ void dcd_int_disable(uint8_t rhport) void dcd_set_address(uint8_t rhport, uint8_t dev_addr) { - (void) rhport; + // Response with status first before changing device address + dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0); + sie_write(SIE_CMDCODE_SET_ADDRESS, 1, 0x80 | dev_addr); // 7th bit is : device_enable } diff --git a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c index 65b0728eb..7731b3f03 100644 --- a/src/portable/nxp/lpc18_43/dcd_lpc18_43.c +++ b/src/portable/nxp/lpc18_43/dcd_lpc18_43.c @@ -164,6 +164,9 @@ void dcd_int_disable(uint8_t rhport) void dcd_set_address(uint8_t rhport, uint8_t dev_addr) { + // Response with status first before changing device address + dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0); + LPC_USB[rhport]->DEVICEADDR = (dev_addr << 25) | TU_BIT(24); } @@ -214,14 +217,7 @@ void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) uint8_t const epnum = tu_edpt_number(ep_addr); uint8_t const dir = tu_edpt_dir(ep_addr); - if ( epnum == 0) - { - // Stall both Control IN and OUT - LPC_USB[rhport]->ENDPTCTRL[epnum] |= ( (ENDPTCTRL_MASK_STALL << 16) || (ENDPTCTRL_MASK_STALL << 0) ); - }else - { - LPC_USB[rhport]->ENDPTCTRL[epnum] |= ENDPTCTRL_MASK_STALL << (dir ? 16 : 0); - } + LPC_USB[rhport]->ENDPTCTRL[epnum] |= ENDPTCTRL_MASK_STALL << (dir ? 16 : 0); } bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) diff --git a/src/portable/st/stm32f4/dcd_stm32f4.c b/src/portable/st/stm32f4/dcd_stm32f4.c index e3b7b2db4..dace9ed3e 100644 --- a/src/portable/st/stm32f4/dcd_stm32f4.c +++ b/src/portable/st/stm32f4/dcd_stm32f4.c @@ -182,6 +182,9 @@ void dcd_set_address (uint8_t rhport, uint8_t dev_addr) USB_OTG_DeviceTypeDef * dev = DEVICE_BASE; dev->DCFG |= (dev_addr << USB_OTG_DCFG_DAD_Pos) & USB_OTG_DCFG_DAD_Msk; + + // Response with status after changing device address + dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0); } void dcd_set_config (uint8_t rhport, uint8_t config_num) |
