From f7e26eef8a7f25a54918d0d442ca7218226d408f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Sun, 5 Nov 2017 22:14:49 +0100 Subject: [PATCH] Split usb_status_code_transfer_config_t as usb_status_code_read_config_t and usb_status_code_write_config_t --- right/src/usb_commands/usb_command_read_config.c | 4 ++-- right/src/usb_commands/usb_command_read_config.h | 7 +++++++ right/src/usb_commands/usb_command_write_config.c | 4 ++-- right/src/usb_commands/usb_command_write_config.h | 7 +++++++ right/src/usb_protocol_handler.h | 5 ----- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/right/src/usb_commands/usb_command_read_config.c b/right/src/usb_commands/usb_command_read_config.c index 064cbc5..8c88943 100644 --- a/right/src/usb_commands/usb_command_read_config.c +++ b/right/src/usb_commands/usb_command_read_config.c @@ -9,7 +9,7 @@ void UsbCommand_ReadConfig(bool isHardware) uint16_t offset = GET_USB_BUFFER_UINT16(2); if (length > USB_GENERIC_HID_OUT_BUFFER_LENGTH-1) { - SET_USB_BUFFER_UINT8(0, UsbStatusCode_TransferConfig_LengthTooLarge); + SET_USB_BUFFER_UINT8(0, UsbStatusCode_ReadConfig_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) { - SET_USB_BUFFER_UINT8(0, UsbStatusCode_TransferConfig_BufferOutOfBounds); + SET_USB_BUFFER_UINT8(0, UsbStatusCode_ReadConfig_BufferOutOfBounds); return; } diff --git a/right/src/usb_commands/usb_command_read_config.h b/right/src/usb_commands/usb_command_read_config.h index e85fec5..21b0eea 100644 --- a/right/src/usb_commands/usb_command_read_config.h +++ b/right/src/usb_commands/usb_command_read_config.h @@ -5,4 +5,11 @@ void UsbCommand_ReadConfig(bool isHardware); +// Typedefs: + + typedef enum { + UsbStatusCode_ReadConfig_LengthTooLarge = 2, + UsbStatusCode_ReadConfig_BufferOutOfBounds = 3, + } usb_status_code_read_config_t; + #endif diff --git a/right/src/usb_commands/usb_command_write_config.c b/right/src/usb_commands/usb_command_write_config.c index 44024f3..5e647c7 100644 --- a/right/src/usb_commands/usb_command_write_config.c +++ b/right/src/usb_commands/usb_command_write_config.c @@ -9,7 +9,7 @@ void UsbCommand_WriteConfig(bool isHardware) uint16_t offset = GET_USB_BUFFER_UINT16(2); if (length > USB_GENERIC_HID_OUT_BUFFER_LENGTH-4) { - SET_USB_BUFFER_UINT8(0, UsbStatusCode_TransferConfig_LengthTooLarge); + SET_USB_BUFFER_UINT8(0, UsbStatusCode_WriteConfig_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) { - SET_USB_BUFFER_UINT8(0, UsbStatusCode_TransferConfig_BufferOutOfBounds); + SET_USB_BUFFER_UINT8(0, UsbStatusCode_WriteConfig_BufferOutOfBounds); return; } diff --git a/right/src/usb_commands/usb_command_write_config.h b/right/src/usb_commands/usb_command_write_config.h index 4ae039e..6b08d38 100644 --- a/right/src/usb_commands/usb_command_write_config.h +++ b/right/src/usb_commands/usb_command_write_config.h @@ -5,4 +5,11 @@ void UsbCommand_WriteConfig(bool isHardware); +// Typedefs: + + typedef enum { + UsbStatusCode_WriteConfig_LengthTooLarge = 2, + UsbStatusCode_WriteConfig_BufferOutOfBounds = 3, + } usb_status_code_write_config_t; + #endif diff --git a/right/src/usb_protocol_handler.h b/right/src/usb_protocol_handler.h index fa655da..6ce7426 100644 --- a/right/src/usb_protocol_handler.h +++ b/right/src/usb_protocol_handler.h @@ -41,11 +41,6 @@ UsbStatusCode_InvalidCommand = 1, } usb_status_code_general_t; - typedef enum { - UsbStatusCode_TransferConfig_LengthTooLarge = 2, - UsbStatusCode_TransferConfig_BufferOutOfBounds = 3, - } usb_status_code_transfer_config_t; - // Functions: void UsbProtocolHandler(void);