Refactor UsbCommandId_LaunchEepromTransfer, change its arguments, and change its ID to 0x08.
This commit is contained in:
@@ -125,3 +125,8 @@ status_t EEPROM_LaunchTransfer(eeprom_operation_t operation, config_buffer_id_t
|
|||||||
IsEepromBusy = LastEepromTransferStatus == kStatus_Success;
|
IsEepromBusy = LastEepromTransferStatus == kStatus_Success;
|
||||||
return LastEepromTransferStatus;
|
return LastEepromTransferStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsEepromOperationValid(eeprom_operation_t operation)
|
||||||
|
{
|
||||||
|
return operation == EepromOperation_Read || operation == EepromOperation_Write;
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,5 +31,6 @@
|
|||||||
|
|
||||||
void EEPROM_Init(void);
|
void EEPROM_Init(void);
|
||||||
status_t EEPROM_LaunchTransfer(eeprom_operation_t operation, config_buffer_id_t config_buffer_id, void (*successCallback));
|
status_t EEPROM_LaunchTransfer(eeprom_operation_t operation, config_buffer_id_t config_buffer_id, void (*successCallback));
|
||||||
|
bool IsEepromOperationValid(eeprom_operation_t operation);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
25
right/src/usb_commands/usb_command_launch_eeprom_transfer.c
Normal file
25
right/src/usb_commands/usb_command_launch_eeprom_transfer.c
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include "fsl_common.h"
|
||||||
|
#include "usb_commands/usb_command_launch_eeprom_transfer.h"
|
||||||
|
#include "usb_protocol_handler.h"
|
||||||
|
#include "eeprom.h"
|
||||||
|
#include "config_parser/config_globals.h"
|
||||||
|
|
||||||
|
void UsbCommand_LaunchEepromTransfer(void)
|
||||||
|
{
|
||||||
|
eeprom_operation_t eepromOperation = GetUsbRxBufferUint8(1);
|
||||||
|
config_buffer_id_t configBufferId = GetUsbRxBufferUint8(2);
|
||||||
|
|
||||||
|
if (!IsEepromOperationValid(eepromOperation)) {
|
||||||
|
SetUsbTxBufferUint8(0, UsbStatusCode_LaunchEepromTransfer_InvalidEepromOperation);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsConfigBufferIdValid(configBufferId)) {
|
||||||
|
SetUsbTxBufferUint8(0, UsbStatusCode_LaunchEepromTransfer_InvalidConfigBufferId);
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t status = EEPROM_LaunchTransfer(eepromOperation, configBufferId, NULL);
|
||||||
|
if (status != kStatus_Success) {
|
||||||
|
SetUsbTxBufferUint8(0, UsbStatusCode_LaunchEepromTransfer_TransferError);
|
||||||
|
SetUsbTxBufferUint32(1, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
16
right/src/usb_commands/usb_command_launch_eeprom_transfer.h
Normal file
16
right/src/usb_commands/usb_command_launch_eeprom_transfer.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef __USB_COMMAND_LAUNCH_EEPROM_TRANSFER_H__
|
||||||
|
#define __USB_COMMAND_LAUNCH_EEPROM_TRANSFER_H__
|
||||||
|
|
||||||
|
// Typedef
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
UsbStatusCode_LaunchEepromTransfer_InvalidEepromOperation = 2,
|
||||||
|
UsbStatusCode_LaunchEepromTransfer_InvalidConfigBufferId = 3,
|
||||||
|
UsbStatusCode_LaunchEepromTransfer_TransferError = 4,
|
||||||
|
} usb_status_code_launch_eeprom_transfer_t;
|
||||||
|
|
||||||
|
// Functions:
|
||||||
|
|
||||||
|
void UsbCommand_LaunchEepromTransfer(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#include "fsl_common.h"
|
|
||||||
#include "usb_commands/usb_command_launch_eeprom_transfer_legacy.h"
|
|
||||||
#include "usb_protocol_handler.h"
|
|
||||||
#include "eeprom.h"
|
|
||||||
|
|
||||||
void UsbCommand_LaunchEepromTransferLegacy(void)
|
|
||||||
{
|
|
||||||
uint8_t legacyEepromTransferId = GetUsbRxBufferUint8(1);
|
|
||||||
switch (legacyEepromTransferId) {
|
|
||||||
case 0:
|
|
||||||
EEPROM_LaunchTransfer(EepromOperation_Read, ConfigBufferId_HardwareConfig, NULL);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
EEPROM_LaunchTransfer(EepromOperation_Write, ConfigBufferId_HardwareConfig, NULL);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
EEPROM_LaunchTransfer(EepromOperation_Read, ConfigBufferId_ValidatedUserConfig, NULL);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
EEPROM_LaunchTransfer(EepromOperation_Write, ConfigBufferId_ValidatedUserConfig, NULL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#ifndef __USB_COMMAND_LAUNCH_EEPROM_TRANSFER_LEGACY_H__
|
|
||||||
#define __USB_COMMAND_LAUNCH_EEPROM_TRANSFER_LEGACY_H__
|
|
||||||
|
|
||||||
// Functions:
|
|
||||||
|
|
||||||
void UsbCommand_LaunchEepromTransferLegacy(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "usb_commands/usb_command_apply_config.h"
|
#include "usb_commands/usb_command_apply_config.h"
|
||||||
#include "usb_commands/usb_command_set_led_pwm_brightness.h"
|
#include "usb_commands/usb_command_set_led_pwm_brightness.h"
|
||||||
#include "usb_commands/usb_command_get_adc_value.h"
|
#include "usb_commands/usb_command_get_adc_value.h"
|
||||||
#include "usb_commands/usb_command_launch_eeprom_transfer_legacy.h"
|
#include "usb_commands/usb_command_launch_eeprom_transfer.h"
|
||||||
#include "usb_commands/usb_command_read_config.h"
|
#include "usb_commands/usb_command_read_config.h"
|
||||||
#include "usb_commands/usb_command_get_keyboard_state.h"
|
#include "usb_commands/usb_command_get_keyboard_state.h"
|
||||||
#include "usb_commands/usb_command_get_debug_buffer.h"
|
#include "usb_commands/usb_command_get_debug_buffer.h"
|
||||||
@@ -40,8 +40,8 @@ void UsbProtocolHandler(void)
|
|||||||
case UsbCommandId_GetAdcValue:
|
case UsbCommandId_GetAdcValue:
|
||||||
UsbCommand_GetAdcValue();
|
UsbCommand_GetAdcValue();
|
||||||
break;
|
break;
|
||||||
case UsbCommandId_LaunchEepromTransferLegacy:
|
case UsbCommandId_LaunchEepromTransfer:
|
||||||
UsbCommand_LaunchEepromTransferLegacy();
|
UsbCommand_LaunchEepromTransfer();
|
||||||
break;
|
break;
|
||||||
case UsbCommandId_ReadConfig:
|
case UsbCommandId_ReadConfig:
|
||||||
UsbCommand_ReadConfig();
|
UsbCommand_ReadConfig();
|
||||||
|
|||||||
@@ -13,23 +13,23 @@
|
|||||||
// Typedefs:
|
// Typedefs:
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
UsbCommandId_GetProperty = 0x00,
|
UsbCommandId_GetProperty = 0x00,
|
||||||
|
|
||||||
UsbCommandId_Reenumerate = 0x01,
|
UsbCommandId_Reenumerate = 0x01,
|
||||||
UsbCommandId_JumpToModuleBootloader = 0x02, // was 0x12
|
UsbCommandId_JumpToModuleBootloader = 0x02, // was 0x12
|
||||||
UsbCommandId_SendKbootCommandToModule = 0x03, // was 0x13
|
UsbCommandId_SendKbootCommandToModule = 0x03, // was 0x13
|
||||||
|
|
||||||
UsbCommandId_ReadConfig = 0x04, // was 0x0d and 0x0f
|
UsbCommandId_ReadConfig = 0x04, // was 0x0d and 0x0f
|
||||||
UsbCommandId_WriteHardwareConfig = 0x05, // was 0x0e
|
UsbCommandId_WriteHardwareConfig = 0x05, // was 0x0e
|
||||||
UsbCommandId_WriteStagingUserConfig = 0x06, // was 0x08
|
UsbCommandId_WriteStagingUserConfig = 0x06, // was 0x08
|
||||||
UsbCommandId_ApplyConfig = 0x07, // was 0x09,
|
UsbCommandId_ApplyConfig = 0x07, // was 0x09
|
||||||
UsbCommandId_LaunchEepromTransferLegacy = 0x0C,
|
UsbCommandId_LaunchEepromTransfer = 0x08, // was 0x0C
|
||||||
|
|
||||||
UsbCommandId_GetKeyboardState = 0x10,
|
UsbCommandId_GetKeyboardState = 0x10,
|
||||||
UsbCommandId_SetTestLed = 0x14, //was 0x02
|
UsbCommandId_SetTestLed = 0x14, // was 0x02
|
||||||
UsbCommandId_GetDebugBuffer = 0x11,
|
UsbCommandId_GetDebugBuffer = 0x11,
|
||||||
UsbCommandId_GetAdcValue = 0x0B,
|
UsbCommandId_GetAdcValue = 0x0B,
|
||||||
UsbCommandId_SetLedPwmBrightness = 0x0A,
|
UsbCommandId_SetLedPwmBrightness = 0x0A,
|
||||||
} usb_command_id_t;
|
} usb_command_id_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|||||||
Reference in New Issue
Block a user