Make UsbCommand_JumpToModuleBootloader() more robust by not making it dependent on the state of the module driver.

This commit is contained in:
László Monda
2017-12-13 01:27:04 +01:00
parent a52df9da7e
commit 6a54944cb1
4 changed files with 10 additions and 17 deletions

View File

@@ -69,6 +69,13 @@ status_t UhkModuleSlaveDriver_Update(uint8_t uhkModuleDriverId)
switch (*uhkModulePhase) { switch (*uhkModulePhase) {
// Jump to bootloader
case UhkModulePhase_JumpToBootloader:
txMessage.data[0] = SlaveCommand_JumpToBootloader;
txMessage.length = 1;
status = tx(i2cAddress);
break;
// Sync communication // Sync communication
case UhkModulePhase_RequestSync: case UhkModulePhase_RequestSync:
txMessage.data[0] = SlaveCommand_RequestProperty; txMessage.data[0] = SlaveCommand_RequestProperty;
@@ -177,19 +184,6 @@ status_t UhkModuleSlaveDriver_Update(uint8_t uhkModuleDriverId)
} }
} }
status = kStatus_Uhk_NoTransfer; status = kStatus_Uhk_NoTransfer;
*uhkModulePhase = UhkModulePhase_JumpToBootloader;
break;
// Jump to bootloader
case UhkModulePhase_JumpToBootloader:
if (uhkModuleState->jumpToBootloader) {
txMessage.data[0] = SlaveCommand_JumpToBootloader;
txMessage.length = 1;
status = tx(i2cAddress);
uhkModuleState->jumpToBootloader = false;
} else {
status = kStatus_Uhk_NoTransfer;
}
*uhkModulePhase = UhkModulePhase_SetTestLed; *uhkModulePhase = UhkModulePhase_SetTestLed;
break; break;

View File

@@ -49,9 +49,9 @@
UhkModulePhase_ProcessKeystates, UhkModulePhase_ProcessKeystates,
// Misc phases // Misc phases
UhkModulePhase_JumpToBootloader,
UhkModulePhase_SetTestLed, UhkModulePhase_SetTestLed,
UhkModulePhase_SetLedPwmBrightness, UhkModulePhase_SetLedPwmBrightness,
UhkModulePhase_JumpToBootloader,
} uhk_module_phase_t; } uhk_module_phase_t;
@@ -70,7 +70,6 @@
uint8_t firmwareI2cAddress; uint8_t firmwareI2cAddress;
uint8_t bootloaderI2cAddress; uint8_t bootloaderI2cAddress;
uhk_module_features_t features; uhk_module_features_t features;
bool jumpToBootloader;
} uhk_module_state_t; } uhk_module_state_t;
typedef struct { typedef struct {

View File

@@ -13,5 +13,5 @@ void UsbCommand_JumpToModuleBootloader(void)
} }
uint8_t uhkModuleDriverId = SLOT_ID_TO_UHK_MODULE_DRIVER_ID(slotId); uint8_t uhkModuleDriverId = SLOT_ID_TO_UHK_MODULE_DRIVER_ID(slotId);
UhkModuleStates[uhkModuleDriverId].jumpToBootloader = true; UhkModuleStates[uhkModuleDriverId].phase = UhkModulePhase_JumpToBootloader;
} }