Moved wMaxPacketSize retrieval to Usb::UsbDevice class.
And some other bits of tidying
This commit is contained in:
@@ -40,7 +40,9 @@ namespace DebugToolDrivers::Microchip
|
||||
|
||||
auto cmsisHidInterface = Usb::HidInterface(
|
||||
this->cmsisHidInterfaceNumber,
|
||||
this->getCmsisHidReportSize(),
|
||||
this->getEndpointMaxPacketSize(
|
||||
this->getFirstEndpointAddress(this->cmsisHidInterfaceNumber, LIBUSB_ENDPOINT_IN)
|
||||
),
|
||||
this->vendorId,
|
||||
this->productId
|
||||
);
|
||||
@@ -157,33 +159,4 @@ namespace DebugToolDrivers::Microchip
|
||||
|
||||
this->sessionStarted = false;
|
||||
}
|
||||
|
||||
std::uint16_t EdbgDevice::getCmsisHidReportSize() {
|
||||
const auto activeConfigDescriptor = this->getConfigDescriptor();
|
||||
|
||||
for (auto interfaceIndex = 0; interfaceIndex < activeConfigDescriptor->bNumInterfaces; ++interfaceIndex) {
|
||||
const auto* interfaceDescriptor = (activeConfigDescriptor->interface + interfaceIndex)->altsetting;
|
||||
|
||||
if (interfaceDescriptor->bInterfaceNumber != this->cmsisHidInterfaceNumber) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto endpointIndex = 0; endpointIndex < activeConfigDescriptor->bNumInterfaces; ++endpointIndex) {
|
||||
const auto* endpointDescriptor = (interfaceDescriptor->endpoint + endpointIndex);
|
||||
|
||||
if ((endpointDescriptor->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) != LIBUSB_ENDPOINT_IN) {
|
||||
// Not an IN endpoint
|
||||
continue;
|
||||
}
|
||||
|
||||
return endpointDescriptor->wMaxPacketSize;
|
||||
}
|
||||
}
|
||||
|
||||
throw DeviceInitializationFailure(
|
||||
"Failed to obtain CMSIS-DAP HID report size via endpoint descriptor - could not find IN endpoint for "
|
||||
"selected configuration value (" + std::to_string(activeConfigDescriptor->bConfigurationValue)
|
||||
+ ") and interface number (" + std::to_string(this->cmsisHidInterfaceNumber) + ")"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,17 +155,6 @@ namespace DebugToolDrivers::Microchip
|
||||
|
||||
bool sessionStarted = false;
|
||||
|
||||
/**
|
||||
* Because EDBG devices require fixed-length reports to be transmitted to/from their HID interface, we must
|
||||
* know the HID report size (as it differs across EDBG devices).
|
||||
*
|
||||
* This member function will obtain the report size from the endpoint descriptor of the IN endpoint, from the
|
||||
* HID interface.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
std::uint16_t getCmsisHidReportSize();
|
||||
|
||||
virtual void configureAvr8Interface() {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user