Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r9e5ee62245eb2a73b167eabd6c274a71a76a7b0e -r4bc08dca28a9fdb177449cd165cea7d145d0ebe0 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 9e5ee62245eb2a73b167eabd6c274a71a76a7b0e) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 4bc08dca28a9fdb177449cd165cea7d145d0ebe0) @@ -57,7 +57,6 @@ /// DG operation mode data publish interval. static OVERRIDE_U32_T dgOpModePublishInterval = { BROADCAST_DG_OP_MODE_INTERVAL, BROADCAST_DG_OP_MODE_INTERVAL, 0, 0 }; static U32 dataPublishCounter; ///< Interval counter used to determine when to broadcast operation mode. Initialize to 11 to stagger broadcast. -static U32 priorSubMode; ///< The prior submode state. /// This matrix determines legal transitions from one mode to another. static const DG_OP_MODE_T MODE_TRANSITION_TABLE[ NUM_OF_DG_MODES - 1 ][ NUM_OF_DG_MODES - 1 ] = @@ -90,7 +89,7 @@ * The initOperationModes function initializes the operation modes module. * @details Inputs: none * @details Outputs: modeRequest, lastMode, currentMode, currentSubMode, - * priorSubMode, dataPublishCounter + * dataPublishCounter * @return none *************************************************************************/ void initOperationModes( void ) @@ -107,7 +106,6 @@ lastMode = DG_MODE_INIT; currentMode = DG_MODE_INIT; currentSubMode = 0; - priorSubMode = 0; dataPublishCounter = DATA_PUBLISH_COUNTER_START_COUNT; transitionToNewOperationMode( DG_MODE_INIT ); @@ -131,17 +129,15 @@ /*********************************************************************//** * @brief * The execOperationModes function executes the operation modes state machine. - * @details Inputs: currentMode - * @details Outputs: Operation modes' state machine executed + * @details Inputs: currentMode, currentSubMode + * @details Outputs: currentMode, currentSubMode * @return none *************************************************************************/ void execOperationModes( void ) { DG_OP_MODE_T newMode; U32 priorSubMode = currentSubMode; - priorSubMode = currentSubMode; - // any new mode requests? newMode = arbitrateModeRequest(); // will return current mode if no pending requests newMode = MODE_TRANSITION_TABLE[ currentMode ][ newMode ]; @@ -157,7 +153,6 @@ if ( currentMode != newMode ) { // handle transition to new mode - priorSubMode = 0; lastMode = currentMode; transitionToNewOperationMode( newMode ); currentMode = newMode; @@ -231,8 +226,6 @@ SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_SUB_MODE_CHANGE, priorSubMode, currentSubMode ) } - priorSubMode = currentSubMode; - // publish op mode on interval broadcastOperationMode(); } @@ -325,13 +318,15 @@ * @brief * The transitionToNewOperationMode function undergo the process of transition * to new operation mode. - * @details Inputs: none + * @details Inputs: currentSubMode * @details Outputs: Transition to new mode * @param newMode new op mode to transition to * @return none *************************************************************************/ static void transitionToNewOperationMode( DG_OP_MODE_T newMode ) { + U32 priorSubMode = currentSubMode; + SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_OP_MODE_CHANGE, lastMode, newMode ) // setup for new operating mode @@ -381,9 +376,11 @@ break; } - SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_SUB_MODE_CHANGE, priorSubMode, currentSubMode ) - - priorSubMode = currentSubMode; + // Send sub-mode change event when appropriate + if ( priorSubMode != currentSubMode ) + { + SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_SUB_MODE_CHANGE, priorSubMode, currentSubMode ) + } } /*********************************************************************//**