Extract system properties to usb_command_get_property.c

This commit is contained in:
László Monda
2017-11-04 02:38:00 +01:00
parent 336c2e5368
commit ad4fe1a18d
4 changed files with 43 additions and 35 deletions

View File

@@ -0,0 +1,33 @@
#include "fsl_common.h"
#include "usb_commands/usb_command_get_property.h"
#include "usb_protocol_handler.h"
#include "eeprom.h"
void UsbCommand_GetProperty(void)
{
uint8_t propertyId = GenericHidInBuffer[1];
switch (propertyId) {
case SystemPropertyId_UsbProtocolVersion:
SetUsbResponseByte(SYSTEM_PROPERTY_USB_PROTOCOL_VERSION);
break;
case SystemPropertyId_BridgeProtocolVersion:
SetUsbResponseByte(SYSTEM_PROPERTY_BRIDGE_PROTOCOL_VERSION);
break;
case SystemPropertyId_DataModelVersion:
SetUsbResponseByte(SYSTEM_PROPERTY_DATA_MODEL_VERSION);
break;
case SystemPropertyId_FirmwareVersion:
SetUsbResponseByte(SYSTEM_PROPERTY_FIRMWARE_VERSION);
break;
case SystemPropertyId_HardwareConfigSize:
SetUsbResponseWord(HARDWARE_CONFIG_SIZE);
break;
case SystemPropertyId_UserConfigSize:
SetUsbResponseWord(USER_CONFIG_SIZE);
break;
default:
SetUsbError(1);
break;
}
}

View File

@@ -0,0 +1,26 @@
#ifndef __USB_COMMAND_GET_PROPERTY_H__
#define __USB_COMMAND_GET_PROPERTY_H__
// Macros:
#define SYSTEM_PROPERTY_USB_PROTOCOL_VERSION 1
#define SYSTEM_PROPERTY_BRIDGE_PROTOCOL_VERSION 1
#define SYSTEM_PROPERTY_DATA_MODEL_VERSION 1
#define SYSTEM_PROPERTY_FIRMWARE_VERSION 1
// Typedefs:
typedef enum {
SystemPropertyId_UsbProtocolVersion = 0,
SystemPropertyId_BridgeProtocolVersion = 1,
SystemPropertyId_DataModelVersion = 2,
SystemPropertyId_FirmwareVersion = 3,
SystemPropertyId_HardwareConfigSize = 4,
SystemPropertyId_UserConfigSize = 5,
} system_property_t;
// Functions:
void UsbCommand_GetProperty(void);
#endif