Extract system properties to usb_command_get_property.c
This commit is contained in:
33
right/src/usb_commands/usb_command_get_property.c
Normal file
33
right/src/usb_commands/usb_command_get_property.c
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef __SYSTEM_PROPERTIES_H__
|
#ifndef __USB_COMMAND_GET_PROPERTY_H__
|
||||||
#define __SYSTEM_PROPERTIES_H__
|
#define __USB_COMMAND_GET_PROPERTY_H__
|
||||||
|
|
||||||
// Macros:
|
// Macros:
|
||||||
|
|
||||||
@@ -19,4 +19,8 @@
|
|||||||
SystemPropertyId_UserConfigSize = 5,
|
SystemPropertyId_UserConfigSize = 5,
|
||||||
} system_property_t;
|
} system_property_t;
|
||||||
|
|
||||||
|
// Functions:
|
||||||
|
|
||||||
|
void UsbCommand_GetProperty(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "usb_protocol_handler.h"
|
#include "usb_protocol_handler.h"
|
||||||
#include "system_properties.h"
|
|
||||||
#include "peripherals/test_led.h"
|
#include "peripherals/test_led.h"
|
||||||
#include "i2c_addresses.h"
|
#include "i2c_addresses.h"
|
||||||
#include "peripherals/led_driver.h"
|
#include "peripherals/led_driver.h"
|
||||||
@@ -18,6 +17,7 @@
|
|||||||
#include "i2c_watchdog.h"
|
#include "i2c_watchdog.h"
|
||||||
#include "usb_commands/usb_command_apply_config.h"
|
#include "usb_commands/usb_command_apply_config.h"
|
||||||
#include "usb_commands/usb_command_read_config.h"
|
#include "usb_commands/usb_command_read_config.h"
|
||||||
|
#include "usb_commands/usb_command_get_property.h"
|
||||||
|
|
||||||
uint8_t UsbDebugInfo[USB_GENERIC_HID_OUT_BUFFER_LENGTH];
|
uint8_t UsbDebugInfo[USB_GENERIC_HID_OUT_BUFFER_LENGTH];
|
||||||
|
|
||||||
@@ -40,35 +40,6 @@ void SetUsbResponseWord(uint16_t response)
|
|||||||
|
|
||||||
// Per command protocol command handlers
|
// Per command protocol command handlers
|
||||||
|
|
||||||
void getSystemProperty(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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void reenumerate(void)
|
void reenumerate(void)
|
||||||
{
|
{
|
||||||
Wormhole.magicNumber = WORMHOLE_MAGIC_NUMBER;
|
Wormhole.magicNumber = WORMHOLE_MAGIC_NUMBER;
|
||||||
@@ -193,8 +164,8 @@ void UsbProtocolHandler(void)
|
|||||||
bzero(GenericHidOutBuffer, USB_GENERIC_HID_OUT_BUFFER_LENGTH);
|
bzero(GenericHidOutBuffer, USB_GENERIC_HID_OUT_BUFFER_LENGTH);
|
||||||
uint8_t command = GenericHidInBuffer[0];
|
uint8_t command = GenericHidInBuffer[0];
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case UsbCommandId_GetSystemProperty:
|
case UsbCommandId_GetProperty:
|
||||||
getSystemProperty();
|
UsbCommand_GetProperty();
|
||||||
break;
|
break;
|
||||||
case UsbCommandId_Reenumerate:
|
case UsbCommandId_Reenumerate:
|
||||||
reenumerate();
|
reenumerate();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
// Typedefs:
|
// Typedefs:
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
UsbCommandId_GetSystemProperty = 0,
|
UsbCommandId_GetProperty = 0,
|
||||||
UsbCommandId_Reenumerate = 1,
|
UsbCommandId_Reenumerate = 1,
|
||||||
UsbCommandId_SetTestLed = 2,
|
UsbCommandId_SetTestLed = 2,
|
||||||
UsbCommandId_WriteLedDriver = 3,
|
UsbCommandId_WriteLedDriver = 3,
|
||||||
|
|||||||
Reference in New Issue
Block a user