From 99b85059d30e5092a130005c6fb89d21d04916ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Sat, 15 Apr 2017 00:56:35 +0200 Subject: [PATCH] Remove the redundant CommandHandlerEntry and command_processor_data_t.handlerEntry. --- right/src/buspal/bm_usb/hid_bootloader.c | 2 +- right/src/buspal/command.c | 21 +-------------------- right/src/buspal/command.h | 6 ------ 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/right/src/buspal/bm_usb/hid_bootloader.c b/right/src/buspal/bm_usb/hid_bootloader.c index ac5f722..433af96 100644 --- a/right/src/buspal/bm_usb/hid_bootloader.c +++ b/right/src/buspal/bm_usb/hid_bootloader.c @@ -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; diff --git a/right/src/buspal/command.c b/right/src/buspal/command.c index 297e9ce..be04230 100644 --- a/right/src/buspal/command.c +++ b/right/src/buspal/command.c @@ -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) { diff --git a/right/src/buspal/command.h b/right/src/buspal/command.h index 75d1a54..61d505c 100644 --- a/right/src/buspal/command.h +++ b/right/src/buspal/command.h @@ -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();