diff options
| author | Ha Thach <[email protected]> | 2020-03-28 14:25:19 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-03-28 14:25:19 +0700 |
| commit | 033b295761e6d536e842c8443cd20cae1527a194 (patch) | |
| tree | 7934ba78d02dcf563ecb4ffbe4ca19f0a6ef1506 /src | |
| parent | 7640cd875cbdb5fe0a29ef01ab6b845e0de8f883 (diff) | |
| parent | 6606cf289661909cfe238787bef7b91112d40f0d (diff) | |
Merge pull request #310 from pigrew/ep0_zeroLenResponses
USBD: Fix zero-length EP0 responses
Diffstat (limited to 'src')
| -rw-r--r-- | src/device/usbd_control.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c index 4fd40c440..c61606f18 100644 --- a/src/device/usbd_control.c +++ b/src/device/usbd_control.c @@ -101,22 +101,29 @@ static bool _data_stage_xact(uint8_t rhport) return dcd_edpt_xfer(rhport, ep_addr, xact_len ? _usbd_ctrl_buf : NULL, xact_len); } +// Transmit data to/from the control endpoint. +// +// If the request's wLength is zero, a status packet is sent instead. bool tud_control_xfer(uint8_t rhport, tusb_control_request_t const * request, void* buffer, uint16_t len) { _ctrl_xfer.request = (*request); _ctrl_xfer.buffer = (uint8_t*) buffer; - _ctrl_xfer.total_xferred = 0; + _ctrl_xfer.total_xferred = 0U; _ctrl_xfer.data_len = tu_min16(len, request->wLength); - - if ( _ctrl_xfer.data_len ) + + if (request->wLength > 0U) { - TU_ASSERT(buffer); + if(_ctrl_xfer.data_len > 0U) + { + TU_ASSERT(buffer); + } TU_LOG2(" XFER Endpoint: 0x%02X, Bytes: %d\r\n", request->bmRequestType_bit.direction ? EDPT_CTRL_IN : EDPT_CTRL_OUT, _ctrl_xfer.data_len); // Data stage TU_ASSERT( _data_stage_xact(rhport) ); - }else + } + else { // Status stage TU_ASSERT( _status_stage_xact(rhport, request) ); |
