diff --git a/right/src/usb_commands/usb_command_write_config.c b/right/src/usb_commands/usb_command_write_config.c index 0297dc4..ec7d0da 100644 --- a/right/src/usb_commands/usb_command_write_config.c +++ b/right/src/usb_commands/usb_command_write_config.c @@ -3,7 +3,7 @@ #include "usb_protocol_handler.h" #include "eeprom.h" -void UsbCommand_WriteConfig(bool isHardware) +void UsbCommand_WriteConfig(config_buffer_id_t configBufferId) { uint8_t length = GetUsbRxBufferUint8(1); uint16_t offset = GetUsbRxBufferUint16(2); @@ -14,8 +14,8 @@ void UsbCommand_WriteConfig(bool isHardware) return; } - uint8_t *buffer = isHardware ? HardwareConfigBuffer.buffer : StagingUserConfigBuffer.buffer; - uint16_t bufferLength = isHardware ? HARDWARE_CONFIG_SIZE : USER_CONFIG_SIZE; + uint8_t *buffer = ConfigBufferIdToConfigBuffer(configBufferId)->buffer; + uint16_t bufferLength = ConfigBufferIdToBufferSize(configBufferId); if (offset + length > bufferLength) { SetUsbTxBufferUint8(0, UsbStatusCode_WriteConfig_BufferOutOfBounds); diff --git a/right/src/usb_commands/usb_command_write_config.h b/right/src/usb_commands/usb_command_write_config.h index 6b08d38..7fde91b 100644 --- a/right/src/usb_commands/usb_command_write_config.h +++ b/right/src/usb_commands/usb_command_write_config.h @@ -1,9 +1,9 @@ #ifndef __USB_COMMAND_WRITE_CONFIG_H__ #define __USB_COMMAND_WRITE_CONFIG_H__ -// Functions: +// Includes: - void UsbCommand_WriteConfig(bool isHardware); + #include "config_parser/config_globals.h" // Typedefs: @@ -12,4 +12,8 @@ UsbStatusCode_WriteConfig_BufferOutOfBounds = 3, } usb_status_code_write_config_t; +// Functions: + + void UsbCommand_WriteConfig(config_buffer_id_t configBufferId); + #endif diff --git a/right/src/usb_protocol_handler.c b/right/src/usb_protocol_handler.c index 4c824bb..9546697 100644 --- a/right/src/usb_protocol_handler.c +++ b/right/src/usb_protocol_handler.c @@ -28,8 +28,8 @@ void UsbProtocolHandler(void) case UsbCommandId_SetTestLed: UsbCommand_SetTestLed(); break; - case UsbCommandId_WriteUserConfig: - UsbCommand_WriteConfig(false); + case UsbCommandId_WriteStagingUserConfig: + UsbCommand_WriteConfig(ConfigBufferId_StagingUserConfig); break; case UsbCommandId_ApplyConfig: UsbCommand_ApplyConfig(); @@ -47,7 +47,7 @@ void UsbProtocolHandler(void) UsbCommand_ReadConfig(); break; case UsbCommandId_WriteHardwareConfig: - UsbCommand_WriteConfig(true); + UsbCommand_WriteConfig(ConfigBufferId_HardwareConfig); break; case UsbCommandId_GetKeyboardState: UsbCommand_GetKeyboardState(); diff --git a/right/src/usb_protocol_handler.h b/right/src/usb_protocol_handler.h index 98beabb..8b0e884 100644 --- a/right/src/usb_protocol_handler.h +++ b/right/src/usb_protocol_handler.h @@ -20,8 +20,8 @@ UsbCommandId_SendKbootCommandToModule = 0x03, // was 0x13 UsbCommandId_ReadConfig = 0x04, // was 0x0d and 0x0f - UsbCommandId_WriteHardwareConfig = 0x0E, - UsbCommandId_WriteUserConfig = 0x08, + UsbCommandId_WriteHardwareConfig = 0x05, // was 0x0e + UsbCommandId_WriteStagingUserConfig = 0x06, // was 0x08 UsbCommandId_ApplyConfig = 0x09, UsbCommandId_LaunchEepromTransferLegacy = 0x0C,