diff --git a/right/src/usb_interface_generic_hid.c b/right/src/usb_interface_generic_hid.c index e5a80ce..beb0fb2 100644 --- a/right/src/usb_interface_generic_hid.c +++ b/right/src/usb_interface_generic_hid.c @@ -60,7 +60,7 @@ usb_status_t UsbGenericHidCallback(class_handle_t handle, uint32_t event, void * case kUSB_DeviceHidEventSendResponse: break; case kUSB_DeviceHidEventRecvResponse: - UsbProtocolHandler(); + usbProtocolHandler(); USB_DeviceHidSend(UsbCompositeDevice.genericHidHandle, USB_GENERIC_HID_ENDPOINT_IN_INDEX, diff --git a/right/src/usb_protocol_handler.c b/right/src/usb_protocol_handler.c index 54846ac..fe4ea34 100644 --- a/right/src/usb_protocol_handler.c +++ b/right/src/usb_protocol_handler.c @@ -7,29 +7,29 @@ #include "deserialize.h" #include "config_buffer.h" -void SetError(uint8_t error); -void SetGenericError(); -void UsbProtocolHandler(); -void GetSystemProperty(); -void JumpToBootloader(); -void GetSetTestLed(); -void WriteLedDriver(); -void ReadLedDriver(); -void WriteEeprom(); -void ReadEeprom(); -void ReadMergeSensor(); +void setError(uint8_t error); +void setGenericError(); +void usbProtocolHandler(); +void getSystemProperty(); +void jumpToBootloader(); +void getSetTestLed(); +void writeLedDriver(); +void readLedDriver(); +void writeEeprom(); +void readEeprom(); +void readMergeSensor(); void uploadConfig(); void applyConfig(); // Functions for setting error statuses -void SetError(uint8_t error) { +void setError(uint8_t error) { GenericHidOutBuffer[0] = error; } -void SetGenericError() +void setGenericError() { - SetError(PROTOCOL_RESPONSE_GENERIC_ERROR); + setError(PROTOCOL_RESPONSE_GENERIC_ERROR); } // Set a single byte as the response. @@ -40,34 +40,34 @@ void SetResponseByte(uint8_t response) // The main protocol handler function -void UsbProtocolHandler() +void usbProtocolHandler() { bzero(GenericHidOutBuffer, USB_GENERIC_HID_OUT_BUFFER_LENGTH); uint8_t command = GenericHidInBuffer[0]; switch (command) { case USB_COMMAND_GET_SYSTEM_PROPERTY: - GetSystemProperty(); + getSystemProperty(); break; case USB_COMMAND_JUMP_TO_BOOTLOADER: - JumpToBootloader(); + jumpToBootloader(); break; case USB_COMMAND_TEST_LED: - GetSetTestLed(); + getSetTestLed(); break; case USB_COMMAND_WRITE_LED_DRIVER: - WriteLedDriver(); + writeLedDriver(); break; case USB_COMMAND_READ_LED_DRIVER: - ReadLedDriver(); + readLedDriver(); break; case USB_COMMAND_WRITE_EEPROM: - WriteEeprom(); + writeEeprom(); break; case USB_COMMAND_READ_EEPROM: - ReadEeprom(); + readEeprom(); break; case USB_COMMAND_READ_MERGE_SENSOR: - ReadMergeSensor(); + readMergeSensor(); break; case USB_COMMAND_UPLOAD_CONFIG: uploadConfig(); @@ -82,7 +82,7 @@ void UsbProtocolHandler() // Per command protocol command handlers -void GetSystemProperty() { +void getSystemProperty() { uint8_t propertyId = GenericHidInBuffer[1]; switch (propertyId) { @@ -99,19 +99,19 @@ void GetSystemProperty() { SetResponseByte(SYSTEM_PROPERTY_FIRMWARE_VERSION); break; default: - SetGenericError(); + setGenericError(); break; } } -void JumpToBootloader() { +void jumpToBootloader() { // We should reset the device here SCB->AIRCR = (0x5FA<AIRCR = 0x05fA0002; // If the masked version doesn't work, this should also reset the core. for(;;); } -void GetSetTestLed() +void getSetTestLed() { uint8_t ledState = GenericHidInBuffer[1]; uint8_t data[] = {1, ledState}; @@ -127,47 +127,47 @@ void GetSetTestLed() } } -void WriteLedDriver() +void writeLedDriver() { uint8_t i2cAddress = GenericHidInBuffer[1]; uint8_t i2cPayloadSize = GenericHidInBuffer[2]; if (!IS_I2C_LED_DRIVER_ADDRESS(i2cAddress)) { - SetError(WRITE_LED_DRIVER_RESPONSE_INVALID_ADDRESS); + setError(WRITE_LED_DRIVER_RESPONSE_INVALID_ADDRESS); return; } if (i2cPayloadSize > USB_GENERIC_HID_OUT_BUFFER_LENGTH-3) { - SetError(WRITE_LED_DRIVER_RESPONSE_INVALID_PAYLOAD_SIZE); + setError(WRITE_LED_DRIVER_RESPONSE_INVALID_PAYLOAD_SIZE); return; } I2cWrite(I2C_MAIN_BUS_BASEADDR, i2cAddress, GenericHidInBuffer+3, i2cPayloadSize); } -void ReadLedDriver() +void readLedDriver() { } -void WriteEeprom() +void writeEeprom() { uint8_t i2cPayloadSize = GenericHidInBuffer[1]; if (i2cPayloadSize > USB_GENERIC_HID_OUT_BUFFER_LENGTH-2) { - SetError(WRITE_EEPROM_RESPONSE_INVALID_PAYLOAD_SIZE); + setError(WRITE_EEPROM_RESPONSE_INVALID_PAYLOAD_SIZE); return; } I2cWrite(I2C_EEPROM_BUS_BASEADDR, I2C_ADDRESS_EEPROM, GenericHidInBuffer+2, i2cPayloadSize); } -void ReadEeprom() +void readEeprom() { uint8_t i2cPayloadSize = GenericHidInBuffer[1]; if (i2cPayloadSize > USB_GENERIC_HID_OUT_BUFFER_LENGTH-1) { - SetError(WRITE_EEPROM_RESPONSE_INVALID_PAYLOAD_SIZE); + setError(WRITE_EEPROM_RESPONSE_INVALID_PAYLOAD_SIZE); return; } @@ -177,7 +177,7 @@ void ReadEeprom() GenericHidOutBuffer[0] = PROTOCOL_RESPONSE_SUCCESS; } -void ReadMergeSensor() +void readMergeSensor() { SetResponseByte(MERGE_SENSOR_IS_MERGED); } @@ -188,7 +188,7 @@ void uploadConfig() uint16_t memoryOffset = *((uint16_t*)(GenericHidInBuffer+2)); if (byteCount > USB_GENERIC_HID_OUT_BUFFER_LENGTH-4) { - SetError(UPLOAD_CONFIG_INVALID_PAYLOAD_SIZE); + setError(UPLOAD_CONFIG_INVALID_PAYLOAD_SIZE); return; } diff --git a/right/src/usb_protocol_handler.h b/right/src/usb_protocol_handler.h index 69a1789..0b82deb 100644 --- a/right/src/usb_protocol_handler.h +++ b/right/src/usb_protocol_handler.h @@ -31,6 +31,6 @@ // Functions: - extern void UsbProtocolHandler(); + extern void usbProtocolHandler(); #endif