summaryrefslogtreecommitdiff
path: root/src/portable/microchip
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-03-13 23:14:48 +0700
committerhathach <[email protected]>2019-03-13 23:14:48 +0700
commiteda56769b9126460f7721a9b3f04d4e4f6efd60d (patch)
tree7a1d6bdde8db8af92b9e16583982eabbf0eff43e /src/portable/microchip
parent195a44172a964b377330bc7f269b611bb920fdc7 (diff)
dcd_set_address include status response, usbd control stall both control in and out
Diffstat (limited to 'src/portable/microchip')
-rw-r--r--src/portable/microchip/samd21/dcd_samd21.c9
-rw-r--r--src/portable/microchip/samd51/dcd_samd51.c9
2 files changed, 6 insertions, 12 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;
- }
}
}