Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rfc99f47309c9d96f73a2d4696b42d6d302f334a7 -rc74c1d99a011dd0fb7f98f183faecda675221fce --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision fc99f47309c9d96f73a2d4696b42d6d302f334a7) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision c74c1d99a011dd0fb7f98f183faecda675221fce) @@ -1,9 +1,3 @@ -/* - * ModeStandby.c - * - * Created on: Aug 7, 2024 - * Author: fw - */ #include // For memcpy and memset @@ -18,32 +12,62 @@ #include "Timers.h" #include "Utilities.h" +/** + * @addtogroup BLStandbyMode + * @{ + */ -#define WAIT_FOR_UPDATE_FROM_UI_MS 1000 +// ********** private definitions ********** -static MODE_STANDBY_STATE_T standbyCurrentState; -static U32 waitForUpdateMsgStartTimeMS; +#define WAIT_FOR_UPDATE_FROM_UI_MS 1000 ///< Wait for update timeout in milliseconds. +// ********** private data ********** + +static MODE_STANDBY_STATE_T standbyCurrentState; ///< Standby current state. +static U32 waitForUpdateMsgStartTimeMS; ///< Wait for update start time in milliseconds. + +// ********** private function prototypes ********** + static MODE_STANDBY_STATE_T handleStandbyModeCheckForUpdateState( void ); static MODE_STANDBY_STATE_T handleStandbyModeCheckFWAndFPGAImages( void ); static MODE_STANDBY_STATE_T handleStandbyModeIdleState( void ); static void jumpToApplication( void ); - +/*********************************************************************//** + * @brief + * The initStandbyMode function initializes the standby mode. + * @details \b Inputs: none + * @details \b Outputs: standbyCurrentState, waitForUpdateMsgStartTimeMS + * @return none + *************************************************************************/ void initStandbyMode( void ) { standbyCurrentState = STANDBY_CHECK_FOR_UPDATE_STATE; waitForUpdateMsgStartTimeMS = getMSTimerCount(); } +/*********************************************************************//** + * @brief + * The transitionToStandbyMode function prepares for transition to Standby Mode. + * @details \b Inputs: none + * @details \b Outputs: Standby Mode unit re-initialized + * @return none + *************************************************************************/ U32 transitionToStandbyMode( void ) { initStandbyMode(); return 0; } +/*********************************************************************//** + * @brief + * The execStandbyMode function executes the Standby Mode state machine. + * @details \b Inputs: standbyCurrentState + * @details \b Outputs: standbyCurrentState + * @return current state (sub-mode) + *************************************************************************/ U32 execStandbyMode( void ) { // If the bootloader is the standby mode and and update request is received at any time, request a transition to update mode @@ -76,7 +100,17 @@ return standbyCurrentState; } - +/*********************************************************************//** + * @brief + * The handleStandbyModeCheckForUpdateState function handles the standby + * check for update state. + * This state waits for a software update command (i.e. verify or abort) and + * then transitions accordingly. Also, if the wait for update has timed out + * it transitions to the verifying firmware and FPGA images. + * @details \b Inputs: waitForUpdateMsgStartTimeMS + * @details \b Outputs: none + * @return next state of the standby mode state machine + *************************************************************************/ static MODE_STANDBY_STATE_T handleStandbyModeCheckForUpdateState( void ) { MODE_STANDBY_STATE_T state = STANDBY_CHECK_FOR_UPDATE_STATE; @@ -104,6 +138,16 @@ return state; } +/*********************************************************************//** + * @brief + * The handleStandbyModeCheckFWAndFPGAImages function handles the standby + * check firmware and FPGA images state. + * This state checks the integrity of the firmware as well as the FPGA header + * to make sure the images are valid. + * @details \b Inputs: waitForUpdateMsgStartTimeMS + * @details \b Outputs: none + * @return next state of the standby mode state machine + *************************************************************************/ static MODE_STANDBY_STATE_T handleStandbyModeCheckFWAndFPGAImages( void ) { MODE_STANDBY_STATE_T state = STANDBY_CHECK_FW_AND_FPGA_IMAGES_STATE; @@ -139,6 +183,14 @@ return state; } +/*********************************************************************//** + * @brief + * The handleStandbyModeIdleState function handles the standby idle state. + * This state waits until a new update request arrives. + * @details \b Inputs: none + * @details \b Outputs: none + * @return next state of the standby mode state machine + *************************************************************************/ static MODE_STANDBY_STATE_T handleStandbyModeIdleState( void ) { MODE_STANDBY_STATE_T state = STANDBY_IDLE_STATE; @@ -149,6 +201,15 @@ return state; } +/*********************************************************************//** + * @brief + * The jumpToApplication function handles the jump to application commands. + * This function, disables interrupts that were used in the bootloader and + * then it jumps to the fimrware start address. + * @details \b Inputs: none + * @details \b Outputs: none + * @return none + *************************************************************************/ static void jumpToApplication( void ) { U32 jumpAddress = (U32)FIRMWARE_START_ADDRESS; @@ -167,3 +228,5 @@ while(1); } +/**@}*/ +