Add new UsbCommand_GetModuleProperties() device protocol command.
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
// Macros:
|
// Macros:
|
||||||
|
|
||||||
#define SLOT_COUNT 4
|
#define SLOT_COUNT 4
|
||||||
#define IS_VALID_SLAVE_SLOT(slotId) (SlotId_LeftKeyboardHalf <= (slotId) && (slotId) <= SlotId_RightModule)
|
#define IS_VALID_MODULE_SLOT(slotId) (SlotId_LeftKeyboardHalf <= (slotId) && (slotId) <= SlotId_RightModule)
|
||||||
|
|
||||||
// Typedefs:
|
// Typedefs:
|
||||||
|
|
||||||
|
|||||||
21
right/src/usb_commands/usb_command_get_module_properties.c
Normal file
21
right/src/usb_commands/usb_command_get_module_properties.c
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#include "fsl_common.h"
|
||||||
|
#include "usb_commands/usb_command_get_module_properties.h"
|
||||||
|
#include "usb_protocol_handler.h"
|
||||||
|
#include "slot.h"
|
||||||
|
#include "slave_drivers/uhk_module_driver.h"
|
||||||
|
|
||||||
|
void UsbCommand_GetModuleProperties()
|
||||||
|
{
|
||||||
|
slot_t slotId = GetUsbRxBufferUint8(1);
|
||||||
|
|
||||||
|
if (!IS_VALID_MODULE_SLOT(slotId)) {
|
||||||
|
SetUsbTxBufferUint8(0, UsbStatusCode_ReadConfig_InvalidModuleSlotId);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t moduleDriverId = SLOT_ID_TO_UHK_MODULE_DRIVER_ID(slotId);
|
||||||
|
uhk_module_state_t *moduleState = UhkModuleStates + moduleDriverId;
|
||||||
|
|
||||||
|
GenericHidOutBuffer[1] = moduleState->moduleId;
|
||||||
|
memcpy(GenericHidOutBuffer + 2, &moduleState->moduleProtocolVersion, sizeof(version_t));
|
||||||
|
memcpy(GenericHidOutBuffer + 2 + sizeof(version_t), &moduleState->firmwareVersion, sizeof(version_t));
|
||||||
|
}
|
||||||
14
right/src/usb_commands/usb_command_get_module_properties.h
Normal file
14
right/src/usb_commands/usb_command_get_module_properties.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef __USB_COMMAND_GET_MODULE_PROPERTIES_H__
|
||||||
|
#define __USB_COMMAND_GET_MODULE_PROPERTIES_H__
|
||||||
|
|
||||||
|
// Functions:
|
||||||
|
|
||||||
|
void UsbCommand_GetModuleProperties();
|
||||||
|
|
||||||
|
// Typedefs:
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
UsbStatusCode_ReadConfig_InvalidModuleSlotId = 2,
|
||||||
|
} usb_status_code_get_module_properties_t;
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -7,7 +7,7 @@ void UsbCommand_JumpToModuleBootloader(void)
|
|||||||
{
|
{
|
||||||
uint8_t slotId = GetUsbRxBufferUint8(1);
|
uint8_t slotId = GetUsbRxBufferUint8(1);
|
||||||
|
|
||||||
if (!IS_VALID_SLAVE_SLOT(slotId)) {
|
if (!IS_VALID_MODULE_SLOT(slotId)) {
|
||||||
SetUsbTxBufferUint8(0, UsbStatusCode_JumpToModuleBootloader_InvalidSlaveSlotId);
|
SetUsbTxBufferUint8(0, UsbStatusCode_JumpToModuleBootloader_InvalidSlaveSlotId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ void UsbProtocolHandler(void)
|
|||||||
case UsbCommandId_SetLedPwmBrightness:
|
case UsbCommandId_SetLedPwmBrightness:
|
||||||
UsbCommand_SetLedPwmBrightness();
|
UsbCommand_SetLedPwmBrightness();
|
||||||
break;
|
break;
|
||||||
|
case UsbCommandId_GetModuleProperties:
|
||||||
|
UsbCommand_GetModuleProperties();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
SetUsbTxBufferUint8(0, UsbStatusCode_InvalidCommand);
|
SetUsbTxBufferUint8(0, UsbStatusCode_InvalidCommand);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
UsbCommandId_GetDebugBuffer = 0x0b,
|
UsbCommandId_GetDebugBuffer = 0x0b,
|
||||||
UsbCommandId_GetAdcValue = 0x0c,
|
UsbCommandId_GetAdcValue = 0x0c,
|
||||||
UsbCommandId_SetLedPwmBrightness = 0x0d,
|
UsbCommandId_SetLedPwmBrightness = 0x0d,
|
||||||
|
UsbCommandId_GetModuleProperties = 0x0e,
|
||||||
} usb_command_id_t;
|
} usb_command_id_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|||||||
Reference in New Issue
Block a user