diff --git a/TESTS/usb_device/basic/USBTester.cpp b/TESTS/usb_device/basic/USBTester.cpp index a6010c7be3..bf700d241d 100644 --- a/TESTS/usb_device/basic/USBTester.cpp +++ b/TESTS/usb_device/basic/USBTester.cpp @@ -67,11 +67,11 @@ USBTester::~USBTester() const char *USBTester::get_desc_string(const uint8_t *desc) { - static char ret_string[128] = {}; + static char ret_string[128] = { }; const uint8_t desc_size = desc[0] - 2; const uint8_t *desc_str = &desc[2]; uint32_t j = 0; - for(uint32_t i = 0; i < desc_size; i+=2, j++) { + for (uint32_t i = 0; i < desc_size; i += 2, j++) { ret_string[j] = desc_str[i]; } ret_string[j] = '\0'; @@ -80,7 +80,7 @@ const char *USBTester::get_desc_string(const uint8_t *desc) void USBTester::suspend(bool suspended) { - if(suspended) { + if (suspended) { ++suspend_count; } else { ++resume_count; @@ -146,7 +146,7 @@ void USBTester::callback_request(const setup_packet_t *setup) case VENDOR_TEST_CTRL_OUT: result = Receive; data = ctrl_buf; - size = setup->wValue < 8 ? setup->wValue : 8; + size = setup->wValue < 8 ? setup->wValue : 8; break; case VENDOR_TEST_CTRL_NONE: result = Success; @@ -176,8 +176,6 @@ void USBTester::callback_request(const setup_packet_t *setup) } else { complete_request(result, data, size); } - - } void USBTester::callback_request_xfer_done(const setup_packet_t *setup, bool aborted) diff --git a/usb/device/USBDevice/USBDevice.cpp b/usb/device/USBDevice/USBDevice.cpp index d0a915febd..3b69734e84 100644 --- a/usb/device/USBDevice/USBDevice.cpp +++ b/usb/device/USBDevice/USBDevice.cpp @@ -62,6 +62,7 @@ bool USBDevice::_request_get_descriptor() #endif switch (DESCRIPTOR_TYPE(_transfer.setup.wValue)) { case DEVICE_DESCRIPTOR: + { if (device_desc() != NULL) { if ((device_desc()[0] == DEVICE_DESCRIPTOR_LENGTH) \ && (device_desc()[1] == DEVICE_DESCRIPTOR)) { @@ -75,6 +76,7 @@ bool USBDevice::_request_get_descriptor() } } break; + } case CONFIGURATION_DESCRIPTOR: { const uint8_t idx = DESCRIPTOR_INDEX(_transfer.setup.wValue); @@ -96,6 +98,7 @@ bool USBDevice::_request_get_descriptor() break; } case STRING_DESCRIPTOR: + { #ifdef DEBUG printf("str descriptor\r\n"); #endif @@ -156,21 +159,29 @@ bool USBDevice::_request_get_descriptor() break; } break; + } case INTERFACE_DESCRIPTOR: + { #ifdef DEBUG printf("interface descr\r\n"); #endif + break; + } case ENDPOINT_DESCRIPTOR: + { #ifdef DEBUG printf("endpoint descr\r\n"); #endif /* TODO: Support is optional, not implemented here */ break; + } default: + { #ifdef DEBUG printf("ERROR\r\n"); #endif break; + } } return success; @@ -406,7 +417,6 @@ void USBDevice::_complete_set_configuration() _phy->ep0_stall(); return; } - } bool USBDevice::_request_get_configuration()