diff options
| author | hathach <[email protected]> | 2019-12-09 23:20:21 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2019-12-09 23:20:21 +0700 |
| commit | 75a2157715ba9977bd9b193b76f1d4182e24d760 (patch) | |
| tree | 74448f64807902abbe89ede7097e0d6d5d653e8d | |
| parent | 0316e0ecd4ba10324f53c341480949fe025b8869 (diff) | |
fix samd using TUSB_REQ_SET_ADDRESS in dcd_edpt0_status_complete
| -rw-r--r-- | src/portable/microchip/samd21/dcd_samd21.c | 4 | ||||
| -rw-r--r-- | src/portable/microchip/samd51/dcd_samd51.c | 6 | ||||
| -rw-r--r-- | src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c | 4 |
3 files changed, 9 insertions, 5 deletions
diff --git a/src/portable/microchip/samd21/dcd_samd21.c b/src/portable/microchip/samd21/dcd_samd21.c index 9f04ac062..5e44dc387 100644 --- a/src/portable/microchip/samd21/dcd_samd21.c +++ b/src/portable/microchip/samd21/dcd_samd21.c @@ -133,7 +133,9 @@ void dcd_remote_wakeup(uint8_t rhport) // May help DCD to prepare for next control transfer, this API is optional. void dcd_edpt0_status_complete(uint8_t rhport, tusb_control_request_t const * request) { - if (request->bRequest == TUSB_REQ_SET_ADDRESS) + if (request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_DEVICE && + request->bmRequestType_bit.type == TUSB_REQ_TYPE_STANDARD && + request->bRequest == TUSB_REQ_SET_ADDRESS ) { uint8_t const dev_addr = (uint8_t) request->wValue; USB->DEVICE.DADD.reg = USB_DEVICE_DADD_DADD(dev_addr) | USB_DEVICE_DADD_ADDEN; diff --git a/src/portable/microchip/samd51/dcd_samd51.c b/src/portable/microchip/samd51/dcd_samd51.c index 6ece35ac0..c298acc53 100644 --- a/src/portable/microchip/samd51/dcd_samd51.c +++ b/src/portable/microchip/samd51/dcd_samd51.c @@ -139,9 +139,9 @@ void dcd_remote_wakeup(uint8_t rhport) // May help DCD to prepare for next control transfer, this API is optional. void dcd_edpt0_status_complete(uint8_t rhport, tusb_control_request_t const * request) { - (void) rhport; - - if (request->bRequest == TUSB_REQ_SET_ADDRESS) + if (request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_DEVICE && + request->bmRequestType_bit.type == TUSB_REQ_TYPE_STANDARD && + request->bRequest == TUSB_REQ_SET_ADDRESS ) { uint8_t const dev_addr = (uint8_t) request->wValue; USB->DEVICE.DADD.reg = USB_DEVICE_DADD_DADD(dev_addr) | USB_DEVICE_DADD_ADDEN; diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c index a93a282e0..341aa5f55 100644 --- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c +++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c @@ -598,7 +598,9 @@ void dcd_edpt0_status_complete(uint8_t rhport, tusb_control_request_t const * re { (void) rhport; - if (request->bRequest == TUSB_REQ_SET_ADDRESS) + if (request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_DEVICE && + request->bmRequestType_bit.type == TUSB_REQ_TYPE_STANDARD && + request->bRequest == TUSB_REQ_SET_ADDRESS ) { uint8_t const dev_addr = (uint8_t) request->wValue; |
