Remove the redundant CommandHandlerEntry and command_processor_data_t.handlerEntry.
This commit is contained in:
@@ -41,7 +41,7 @@ usb_status_t usb_device_hid_generic_callback(class_handle_t handle, uint32_t eve
|
||||
g_device_composite->hid_generic.hid_packet.reportSize = hid_report_param->reportLength;
|
||||
|
||||
g_device_composite->hid_generic.hid_packet.didReceiveFirstReport = true;
|
||||
TEST_LED_OFF();
|
||||
|
||||
// Wake up the read packet handler.
|
||||
sync_signal(&g_device_composite->hid_generic.hid_packet.receiveSync);
|
||||
error = kStatus_USB_Success;
|
||||
|
||||
@@ -11,7 +11,6 @@ void handle_reset(uint8_t *packet, uint32_t packetLength);
|
||||
void send_generic_response(uint32_t commandStatus, uint32_t commandTag);
|
||||
|
||||
static status_t handle_command_internal(uint8_t *packet, uint32_t packetLength);
|
||||
static status_t handle_data(bool *hasMoreData);
|
||||
static uint16_t calculate_framing_crc16(framing_data_packet_t *packet, const uint8_t *data);
|
||||
static status_t handle_data_read(bool *hasMoreData);
|
||||
static void handle_read_memory_command(uint8_t *packet, uint32_t packetLength);
|
||||
@@ -446,12 +445,7 @@ status_t bootloader_command_pump()
|
||||
break;
|
||||
|
||||
case kCommandState_DataPhase:
|
||||
status = handle_data(&hasMoreData);
|
||||
if (status != kStatus_Success)
|
||||
{
|
||||
g_commandData.state = kCommandState_CommandPhase;
|
||||
break;
|
||||
}
|
||||
status = kStatus_Success;
|
||||
g_commandData.state = hasMoreData ? kCommandState_DataPhase : kCommandState_CommandPhase;
|
||||
break;
|
||||
}
|
||||
@@ -552,19 +546,6 @@ static status_t handle_command_internal(uint8_t *packet, uint32_t packetLength)
|
||||
return status;
|
||||
}
|
||||
|
||||
//! @brief Handle a data transaction.
|
||||
static status_t handle_data(bool *hasMoreData)
|
||||
{
|
||||
if (g_commandData.handlerEntry)
|
||||
{
|
||||
// Run data phase if present, otherwise just return success.
|
||||
*hasMoreData = 0;
|
||||
return g_commandData.handlerEntry->handleData ? g_commandData.handlerEntry->handleData(hasMoreData) :
|
||||
kStatus_Success;
|
||||
}
|
||||
return kStatus_Success;
|
||||
}
|
||||
|
||||
//! @brief Reset command handler.
|
||||
void handle_reset(uint8_t *packet, uint32_t packetLength)
|
||||
{
|
||||
|
||||
@@ -17,11 +17,6 @@ typedef enum _buspal_state
|
||||
kBuspal_I2c,
|
||||
} buspal_state_t;
|
||||
|
||||
typedef struct CommandHandlerEntry
|
||||
{
|
||||
status_t (*handleData)(bool *hasMoreData);
|
||||
} command_handler_entry_t;
|
||||
|
||||
typedef struct CommandProcessorData {
|
||||
int32_t state; // Current state machine state
|
||||
uint8_t *packet; // Pointer to packet in process
|
||||
@@ -34,7 +29,6 @@ typedef struct CommandProcessorData {
|
||||
uint8_t commandTag; // Tag of command running data phase
|
||||
uint8_t option; // Option for special command
|
||||
} dataPhase;
|
||||
const command_handler_entry_t *handlerEntry; // Pointer to handler table entry for packet in process
|
||||
} command_processor_data_t;
|
||||
|
||||
void handleUsbBusPalCommand();
|
||||
|
||||
Reference in New Issue
Block a user