Remove function prototypes for USB handlers and move usbProtocolHandler to the end of the file.

This commit is contained in:
László Monda
2017-07-23 00:55:06 +02:00
parent b87cafd10e
commit c86bfff38f

View File

@@ -13,22 +13,6 @@
#include "peripherals/adc.h" #include "peripherals/adc.h"
#include "eeprom.h" #include "eeprom.h"
void setError(uint8_t error);
void setGenericError();
void usbProtocolHandler();
void getSystemProperty();
void reenumerate();
void setTestLed();
void readLedDriver();
void writeEeprom();
void readEeprom();
void readMergeSensor();
void uploadConfig();
void applyConfig();
void setLedPwm();
void getAdcValue(void);
void launchEepromTransfer(void);
// Functions for setting error statuses // Functions for setting error statuses
void setError(uint8_t error) { void setError(uint8_t error) {
@@ -46,53 +30,6 @@ void SetResponseByte(uint8_t response)
GenericHidOutBuffer[1] = response; GenericHidOutBuffer[1] = response;
} }
// The main protocol handler function
void usbProtocolHandler()
{
bzero(GenericHidOutBuffer, USB_GENERIC_HID_OUT_BUFFER_LENGTH);
uint8_t command = GenericHidInBuffer[0];
switch (command) {
case UsbCommand_GetSystemProperty:
getSystemProperty();
break;
case UsbCommand_Reenumerate:
reenumerate();
break;
case UsbCommand_SetTestLed:
setTestLed();
break;
case UsbCommand_WriteLedDriver:
break;
case UsbCommand_WriteEeprom:
writeEeprom();
break;
case UsbCommand_ReadEeprom:
readEeprom();
break;
case UsbCommand_ReadMergeSensor:
readMergeSensor();
break;
case UsbCommand_UploadConfig:
uploadConfig();
break;
case UsbCommand_ApplyConfig:
applyConfig();
break;
case UsbCommand_SetLedPwm:
setLedPwm();
break;
case UsbCommand_GetAdcValue:
getAdcValue();
break;
case UsbCommand_LaunchEepromTransfer:
launchEepromTransfer();
break;
default:
break;
}
}
// Per command protocol command handlers // Per command protocol command handlers
void getSystemProperty() { void getSystemProperty() {
@@ -205,3 +142,50 @@ void launchEepromTransfer(void)
eeprom_transfer_t transferType = GenericHidInBuffer[1]; eeprom_transfer_t transferType = GenericHidInBuffer[1];
EEPROM_LaunchTransfer(transferType); EEPROM_LaunchTransfer(transferType);
} }
// The main protocol handler function
void usbProtocolHandler()
{
bzero(GenericHidOutBuffer, USB_GENERIC_HID_OUT_BUFFER_LENGTH);
uint8_t command = GenericHidInBuffer[0];
switch (command) {
case UsbCommand_GetSystemProperty:
getSystemProperty();
break;
case UsbCommand_Reenumerate:
reenumerate();
break;
case UsbCommand_SetTestLed:
setTestLed();
break;
case UsbCommand_WriteLedDriver:
break;
case UsbCommand_WriteEeprom:
writeEeprom();
break;
case UsbCommand_ReadEeprom:
readEeprom();
break;
case UsbCommand_ReadMergeSensor:
readMergeSensor();
break;
case UsbCommand_UploadConfig:
uploadConfig();
break;
case UsbCommand_ApplyConfig:
applyConfig();
break;
case UsbCommand_SetLedPwm:
setLedPwm();
break;
case UsbCommand_GetAdcValue:
getAdcValue();
break;
case UsbCommand_LaunchEepromTransfer:
launchEepromTransfer();
break;
default:
break;
}
}