diff options
| author | Nathan Conrad <[email protected]> | 2020-03-27 15:30:40 -0400 |
|---|---|---|
| committer | Nathan Conrad <[email protected]> | 2020-03-27 15:54:37 -0400 |
| commit | 6606cf289661909cfe238787bef7b91112d40f0d (patch) | |
| tree | aee28fe8cff9078b3d0f628c0fb7063a2a2e478e /src/device | |
| parent | aef2a59f3265b6eb47b02503694dddce6bb5db10 (diff) | |
USBD: Use tud_control_xfer only for data
Diffstat (limited to 'src/device')
| -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) ); |
