Massive refactor to accommodate RISC-V targets
- Refactored entire codebase (excluding the Insight component) to accommodate multiple target architectures (no longer specific to AVR) - Deleted 'generate SVD' GDB monitor command - I will eventually move this functionality to the Bloom website - Added unit size property to address spaces - Many other changes which I couldn't be bothered to describe here
This commit is contained in:
@@ -24,10 +24,10 @@ namespace Usb
|
||||
|
||||
const auto statusCode = ::libusb_claim_interface(this->deviceHandle, this->interfaceNumber);
|
||||
if (statusCode != 0) {
|
||||
throw DeviceInitializationFailure(
|
||||
throw DeviceInitializationFailure{
|
||||
"Failed to claim USB interface (number: " + std::to_string(this->interfaceNumber) + ") - error code: "
|
||||
+ std::to_string(statusCode)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
this->claimed = true;
|
||||
@@ -49,11 +49,11 @@ namespace Usb
|
||||
std::uint8_t endpointAddress,
|
||||
std::optional<std::chrono::milliseconds> timeout
|
||||
) {
|
||||
auto output = std::vector<unsigned char>();
|
||||
auto output = std::vector<unsigned char>{};
|
||||
|
||||
constexpr auto transferSize = 512;
|
||||
auto bytesTransferred = int(0);
|
||||
auto totalByteCount = std::size_t(0);
|
||||
auto bytesTransferred = int{0};
|
||||
auto totalByteCount = std::size_t{0};
|
||||
|
||||
do {
|
||||
output.resize(totalByteCount + transferSize, 0x00);
|
||||
@@ -68,12 +68,12 @@ namespace Usb
|
||||
);
|
||||
|
||||
if (statusCode != 0) {
|
||||
throw DeviceCommunicationFailure("Failed to read from bulk endpoint");
|
||||
throw DeviceCommunicationFailure{"Failed to read from bulk endpoint"};
|
||||
}
|
||||
|
||||
if (totalByteCount == 0) {
|
||||
// After the first read, set the timeout to 1 millisecond, as we don't want to wait for subsequent data
|
||||
timeout = std::chrono::milliseconds(1);
|
||||
timeout = std::chrono::milliseconds{1};
|
||||
}
|
||||
|
||||
totalByteCount += static_cast<std::size_t>(bytesTransferred);
|
||||
@@ -86,11 +86,11 @@ namespace Usb
|
||||
|
||||
void UsbInterface::writeBulk(std::uint8_t endpointAddress, std::vector<unsigned char>&& buffer) {
|
||||
if (buffer.size() > std::numeric_limits<int>::max()) {
|
||||
throw DeviceCommunicationFailure("Attempted to send too much data to bulk endpoint");
|
||||
throw DeviceCommunicationFailure{"Attempted to send too much data to bulk endpoint"};
|
||||
}
|
||||
|
||||
const auto length = static_cast<int>(buffer.size());
|
||||
auto bytesTransferred = int(0);
|
||||
auto bytesTransferred = int{0};
|
||||
|
||||
const auto statusCode = ::libusb_bulk_transfer(
|
||||
this->deviceHandle,
|
||||
@@ -106,7 +106,7 @@ namespace Usb
|
||||
"Attempted to write " + std::to_string(length) + " bytes to USB bulk endpoint. Bytes written: "
|
||||
+ std::to_string(bytesTransferred) + ". Status code: " + std::to_string(statusCode)
|
||||
);
|
||||
throw DeviceCommunicationFailure("Failed to write data to bulk endpoint");
|
||||
throw DeviceCommunicationFailure{"Failed to write data to bulk endpoint"};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user