Rename UsbResponse_*() to UsbStatusCode_*(), SetUsbError() to SetUsbStatusCode(), and other USB status codes consistently.
This commit is contained in:
@@ -16,7 +16,7 @@ void UsbCommand_ApplyConfig(void)
|
||||
*(uint16_t*)(GenericHidOutBuffer+1) = StagingUserConfigBuffer.offset;
|
||||
GenericHidOutBuffer[3] = 0;
|
||||
|
||||
if (GenericHidOutBuffer[0] != UsbResponse_Success) {
|
||||
if (GenericHidOutBuffer[0] != UsbStatusCode_Success) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ void UsbCommand_ApplyConfig(void)
|
||||
*(uint16_t*)(GenericHidOutBuffer+1) = ValidatedUserConfigBuffer.offset;
|
||||
GenericHidOutBuffer[3] = 1;
|
||||
|
||||
if (GenericHidOutBuffer[0] != UsbResponse_Success) {
|
||||
if (GenericHidOutBuffer[0] != UsbStatusCode_Success) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ void UsbCommand_GetProperty(void)
|
||||
SetUsbResponseWord(USER_CONFIG_SIZE);
|
||||
break;
|
||||
default:
|
||||
SetUsbError(1);
|
||||
SetUsbStatusCode(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ void UsbCommand_JumpToSlaveBootloader(void)
|
||||
uint8_t uhkModuleDriverId = GenericHidInBuffer[1];
|
||||
|
||||
if (uhkModuleDriverId >= UHK_MODULE_MAX_COUNT) {
|
||||
SetUsbError(JumpToBootloaderError_InvalidModuleDriverId);
|
||||
SetUsbStatusCode(UsbStatusCode_JumpToSlaveBootloader_InvalidModuleDriverId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ void UsbCommand_ReadConfig(bool isHardware)
|
||||
uint16_t offset = *(uint16_t*)(GenericHidInBuffer+2);
|
||||
|
||||
if (length > USB_GENERIC_HID_OUT_BUFFER_LENGTH-1) {
|
||||
SetUsbError(ConfigTransferResponse_LengthTooLarge);
|
||||
SetUsbStatusCode(UsbStatusCode_TransferConfig_LengthTooLarge);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ void UsbCommand_ReadConfig(bool isHardware)
|
||||
uint16_t bufferLength = isHardware ? HARDWARE_CONFIG_SIZE : USER_CONFIG_SIZE;
|
||||
|
||||
if (offset + length > bufferLength) {
|
||||
SetUsbError(ConfigTransferResponse_BufferOutOfBounds);
|
||||
SetUsbStatusCode(UsbStatusCode_TransferConfig_BufferOutOfBounds);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ void UsbCommand_WriteConfig(bool isHardware)
|
||||
uint16_t offset = *((uint16_t*)(GenericHidInBuffer+1+1));
|
||||
|
||||
if (length > USB_GENERIC_HID_OUT_BUFFER_LENGTH-1-1-2) {
|
||||
SetUsbError(ConfigTransferResponse_LengthTooLarge);
|
||||
SetUsbStatusCode(UsbStatusCode_TransferConfig_LengthTooLarge);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ void UsbCommand_WriteConfig(bool isHardware)
|
||||
uint16_t bufferLength = isHardware ? HARDWARE_CONFIG_SIZE : USER_CONFIG_SIZE;
|
||||
|
||||
if (offset + length > bufferLength) {
|
||||
SetUsbError(ConfigTransferResponse_BufferOutOfBounds);
|
||||
SetUsbStatusCode(UsbStatusCode_TransferConfig_BufferOutOfBounds);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "usb_commands/usb_command_jump_to_slave_bootloader.h"
|
||||
#include "usb_commands/usb_command_send_kboot_command.h"
|
||||
|
||||
void SetUsbError(uint8_t error)
|
||||
void SetUsbStatusCode(uint8_t error)
|
||||
{
|
||||
GenericHidOutBuffer[0] = error;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ void UsbProtocolHandler(void)
|
||||
UsbCommand_SendKbootCommand();
|
||||
break;
|
||||
default:
|
||||
SetUsbError(UsbResponse_InvalidCommand);
|
||||
SetUsbStatusCode(UsbStatusCode_InvalidCommand);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,23 +27,23 @@
|
||||
} usb_command_id_t;
|
||||
|
||||
typedef enum {
|
||||
UsbResponse_Success = 0,
|
||||
UsbResponse_InvalidCommand = 1,
|
||||
UsbStatusCode_Success = 0,
|
||||
UsbStatusCode_InvalidCommand = 1,
|
||||
} usb_response_t;
|
||||
|
||||
typedef enum {
|
||||
ConfigTransferResponse_LengthTooLarge = 1,
|
||||
ConfigTransferResponse_BufferOutOfBounds = 2,
|
||||
UsbStatusCode_TransferConfig_LengthTooLarge = 1,
|
||||
UsbStatusCode_TransferConfig_BufferOutOfBounds = 2,
|
||||
} config_transfer_response_t;
|
||||
|
||||
typedef enum {
|
||||
JumpToBootloaderError_InvalidModuleDriverId = 1,
|
||||
UsbStatusCode_JumpToSlaveBootloader_InvalidModuleDriverId = 1,
|
||||
} jump_to_bootloader_error_t;
|
||||
|
||||
// Functions:
|
||||
|
||||
void UsbProtocolHandler(void);
|
||||
void SetUsbError(uint8_t error);
|
||||
void SetUsbStatusCode(uint8_t status);
|
||||
void SetUsbResponseByte(uint8_t response);
|
||||
void SetUsbResponseWord(uint16_t response);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user