Implement DevicePropertyId_CurrentKbootCommand

This commit is contained in:
László Monda
2018-01-10 02:58:31 +01:00
parent fcd75b2af2
commit 4a4c471b9e
5 changed files with 10 additions and 5 deletions

View File

@@ -27,7 +27,7 @@ status_t KbootSlaveDriver_Update(uint8_t kbootInstanceId)
{
status_t status = kStatus_Uhk_IdleSlave;
switch (KbootDriverState.commandType) {
switch (KbootDriverState.command) {
case KbootCommand_Idle:
break;
case KbootCommand_Ping:
@@ -49,7 +49,7 @@ status_t KbootSlaveDriver_Update(uint8_t kbootInstanceId)
case KbootPhase_CheckPingResponseStatus:
KbootDriverState.status = Slaves[SlaveId_KbootDriver].previousStatus;
if (KbootDriverState.status == kStatus_Success) {
KbootDriverState.commandType = KbootCommand_Idle;
KbootDriverState.command = KbootCommand_Idle;
} else {
KbootDriverState.phase = KbootPhase_SendPing;
return kStatus_Uhk_IdleCycle;
@@ -72,7 +72,7 @@ status_t KbootSlaveDriver_Update(uint8_t kbootInstanceId)
break;
case KbootPhase_CheckResetSendAck:
status = tx(ackMessage, sizeof(ackMessage));
KbootDriverState.commandType = KbootCommand_Idle;
KbootDriverState.command = KbootCommand_Idle;
break;
}
break;

View File

@@ -39,7 +39,7 @@
} kboot_reset_phase_t;
typedef struct {
kboot_command_t commandType;
kboot_command_t command;
uint8_t i2cAddress;
uint8_t phase;
uint32_t status;

View File

@@ -3,6 +3,7 @@
#include "usb_protocol_handler.h"
#include "eeprom.h"
#include "versions.h"
#include "slave_drivers/kboot_driver.h"
version_t deviceProtocolVersion = {
DEVICE_PROTOCOL_MAJOR_VERSION,
@@ -55,6 +56,9 @@ void UsbCommand_GetDeviceProperty(void)
case DevicePropertyId_ConfigSizes:
memcpy(GenericHidOutBuffer+1, (uint8_t*)&configSizes, sizeof(configSizes));
break;
case DevicePropertyId_CurrentKbootCommand:
GenericHidOutBuffer[1] = KbootDriverState.command;
break;
default:
SetUsbTxBufferUint8(0, UsbStatusCode_GetDeviceProperty_InvalidProperty);
break;

View File

@@ -7,6 +7,7 @@
DevicePropertyId_DeviceProtocolVersion = 0,
DevicePropertyId_ProtocolVersions = 1,
DevicePropertyId_ConfigSizes = 2,
DevicePropertyId_CurrentKbootCommand = 3,
} system_property_t;
typedef enum {

View File

@@ -6,5 +6,5 @@ void UsbCommand_SendKbootCommandToModule(void)
{
KbootDriverState.phase = 0;
KbootDriverState.i2cAddress = GetUsbRxBufferUint8(2);
KbootDriverState.commandType = GetUsbRxBufferUint8(1); // Command should be set last.
KbootDriverState.command = GetUsbRxBufferUint8(1); // Command should be set last.
}