Implement KbootCommand_Ping and set set left BOOTLOADER_TIMEOUT_MS back to 100 ms.

This commit is contained in:
László Monda
2017-10-23 21:33:08 +02:00
parent c46dcad490
commit 85b1a65ea7
6 changed files with 38 additions and 9 deletions

View File

@@ -5,6 +5,7 @@
kboot_driver_state_t KbootDriverState;
static uint8_t rxBuffer[MAX_KBOOT_COMMAND_LENGTH];
static uint8_t pingCommand[] = {0x5a, 0xa6};
static uint8_t resetCommand[] = {0x5a, 0xa4, 0x04, 0x00, 0x6f, 0x46, 0x0b, 0x00, 0x00, 0x00};
static uint8_t ackMessage[] = {0x5a, 0xa1};
@@ -30,6 +31,28 @@ status_t KbootSlaveDriver_Update(uint8_t kbootInstanceId)
case KbootCommand_Idle:
break;
case KbootCommand_Ping:
switch (KbootDriverState.phase) {
case 0:
status = tx(pingCommand, sizeof(pingCommand));
KbootDriverState.phase++;
break;
case 1:
KbootDriverState.status = Slaves[SlaveId_KbootDriver].previousStatus;
KbootDriverState.phase = KbootDriverState.status == kStatus_Success ? 2 : 0;
return kStatus_Uhk_NoTransfer;
case 2:
status = rx(10);
KbootDriverState.phase++;
break;
case 3:
KbootDriverState.status = Slaves[SlaveId_KbootDriver].previousStatus;
if (KbootDriverState.status == kStatus_Success) {
KbootDriverState.commandType = KbootCommand_Idle;
} else {
KbootDriverState.phase = 0;
return kStatus_Uhk_NoTransfer;
}
}
break;
case KbootCommand_Reset:
switch (KbootDriverState.phase) {

View File

@@ -25,6 +25,7 @@
kboot_command_t commandType;
uint8_t i2cAddress;
uint8_t phase;
uint32_t status;
} kboot_driver_state_t;
// Variables:

View File

@@ -57,6 +57,8 @@ static void slaveSchedulerCallback(I2C_Type *base, i2c_master_handle_t *handle,
uhk_slave_t *previousSlave = Slaves + previousSlaveId;
uhk_slave_t *currentSlave = Slaves + currentSlaveId;
previousSlave->previousStatus = previousStatus;
if (isFirstIteration) {
bool wasPreviousSlaveConnected = previousSlave->isConnected;
previousSlave->isConnected = previousStatus == kStatus_Success;

View File

@@ -13,6 +13,7 @@
SlaveId_RightAddon,
SlaveId_RightLedDriver,
SlaveId_LeftLedDriver,
SlaveId_KbootDriver,
} slave_id_t;
typedef void (slave_init_t)(uint8_t);
@@ -25,6 +26,7 @@
slave_update_t *update;
slave_disconnect_t *disconnect;
bool isConnected;
status_t previousStatus;
} uhk_slave_t;
typedef enum {