Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r5acce83ec629eff9621c0193fae57b7b63ad8de8 -r1541f5c438744fffa0dc3157935da528342f01e7 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 5acce83ec629eff9621c0193fae57b7b63ad8de8) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 1541f5c438744fffa0dc3157935da528342f01e7) @@ -38,10 +38,12 @@ // ********** private definitions ********** #define WAIT_FOR_UPDATE_FROM_UI_MS 1000 ///< Wait for update timeout in milliseconds. +#define WAIT_BEFORE_BOOTLOADER_RESET_MS 200 ///< Wait before bootloader reset in milliseconds. // ********** private data ********** static MODE_STANDBY_STATE_T standbyCurrentState; ///< Standby current state. +static U32 stateTimerMS; ///< Timeout before bootloader reset in milliseconds. // ********** private function prototypes ********** @@ -58,12 +60,13 @@ * @brief * The initStandbyMode function initializes the standby mode. * @details \b Inputs: none - * @details \b Outputs: standbyCurrentState + * @details \b Outputs: standbyCurrentState, stateTimerMS * @return none *************************************************************************/ void initStandbyMode( void ) { standbyCurrentState = STANDBY_CHECK_FOR_UPDATE_STATE; + stateTimerMS = 0; } /*********************************************************************//** @@ -234,13 +237,14 @@ *************************************************************************/ static MODE_STANDBY_STATE_T handleStandbyModeCheckUpdatedImageStates( void ) { - SW_UPDATE_RESP_STATUS_T resp; - U32 calcCRC = 0; + U16 cmdMsgID = getCurrentCmdMessageID(); MODE_STANDBY_STATE_T state = STANDBY_RESET_BOOTLOADER_STATE; SW_UPDATE_DESINTATION_T dest = getSWUpdateDestination(); ACK_NACK_STATUS_T ackStatus = ACK; BOOL status = FALSE; + stateTimerMS = getMSTimerCount(); + switch( dest ) { case UPDATE_FPGA: @@ -258,15 +262,8 @@ break; } - // NOTE: FPGA is check in self configure - resp.msgID = getCurrentCmdMessageID(); - resp.msgAckNackStatus = ackStatus; - resp.spareSpace = 0; - resp.msgCRC = crc32( calcCRC, (U08*)&resp, sizeof( SW_UPDATE_RESP_STATUS_T ) - sizeof( U32 ) ); + prepareAndSendBootLoaderResponseMessage( cmdMsgID, ackStatus ); - // If both firmware and FPGA results passed, send an ack otherwise send a nack - sendAckNackStatusFromBootloader( (U08*)&resp ); - return state; } @@ -281,11 +278,16 @@ *************************************************************************/ static MODE_STANDBY_STATE_T handleStandyModeResetBootloaderState( void ) { - MODE_STANDBY_STATE_T state = STANDBY_IDLE_STATE; + MODE_STANDBY_STATE_T state = STANDBY_RESET_BOOTLOADER_STATE; - // Reset the bootloader regardless of whether the update was successful or not - resetBootloader(); + if ( TRUE == didTimeout( stateTimerMS, WAIT_BEFORE_BOOTLOADER_RESET_MS) ) + { + state = STANDBY_IDLE_STATE; + // Reset the bootloader regardless of whether the update was successful or not + resetBootloader(); + } + return state; }