Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r19f13e67288117e7f81c1245a75cc6b5f8aaf899 -ra1a592eaed002ee7ef84e56fb7864b8d40b14661 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 19f13e67288117e7f81c1245a75cc6b5f8aaf899) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision a1a592eaed002ee7ef84e56fb7864b8d40b14661) @@ -61,6 +61,7 @@ static HD_OP_MODE_T currentMode; ///< Current operation mode. static U32 currentSubMode; ///< The currently active state of the active mode. static U32 broadcastModeIntervalCtr; ///< Interval counter used to determine when to broadcast operation mode. Initialize to 11 to stagger broadcast. +static U32 currentSubState; /// Interval (in task intervals) at which to publish operation mode data to CAN bus. static OVERRIDE_U32_T opModePublishInterval = { BROADCAST_HD_OP_MODE_INTERVAL, BROADCAST_HD_OP_MODE_INTERVAL, BROADCAST_HD_OP_MODE_INTERVAL, 0 }; /// Local structure init for saving confirmation requests @@ -88,6 +89,7 @@ static void transitionToNewOperationMode( HD_OP_MODE_T newMode ); static void broadcastOperationMode( void ); static void updateConfirmationRequestTimeouts( void ); +static void sendOperationStatusEvent( void ); /*********************************************************************//** * @brief @@ -110,6 +112,7 @@ lastMode = MODE_INIT; currentMode = MODE_INIT; currentSubMode = 0; + currentSubState = 0xFF; broadcastModeIntervalCtr = DATA_PUBLISH_COUNTER_START_COUNT; transitionToNewOperationMode( MODE_INIT ); @@ -136,6 +139,8 @@ { HD_OP_MODE_T newMode; U32 priorSubMode = currentSubMode; + U32 priorSubState = currentSubState; + U32 priorOpMode = (U32)currentMode; // Any new mode requests? newMode = arbitrateModeRequest(); // Will return current mode if no pending requests @@ -151,8 +156,8 @@ // Has mode changed? if ( currentMode != newMode ) { - // Handle transition to new mode lastMode = currentMode; + // Handle transition to new mode transitionToNewOperationMode( newMode ); currentMode = newMode; @@ -209,9 +214,10 @@ break; } // End switch - // Send sub-mode change event when appropriate - if ( priorSubMode != currentSubMode ) + // Send operation status event when appropriate + if ( priorOpMode != currentMode || priorSubMode != currentSubMode || priorSubState != currentSubState ) { + sendOperationStatusEvent(); SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_MODE_CHANGE, priorSubMode, currentSubMode ) } @@ -372,8 +378,6 @@ *************************************************************************/ static void transitionToNewOperationMode( HD_OP_MODE_T newMode ) { - SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_OP_MODE_CHANGE, lastMode, newMode ) - // Setup for new operating mode switch ( newMode ) { @@ -574,7 +578,46 @@ return new_id; } +/*********************************************************************//** + * @brief + * The setCurrentSubState function sets the current subState. + * @details Inputs: subState + * @details Outputs: currentSubState + * @param subState the enumerated sub state. + * @return none + *************************************************************************/ +void setCurrentSubState( U32 subState ) +{ + currentSubState = subState; +} +/*********************************************************************//** + * @brief + * The sendOperationStatusEvent function constructs and sends an HD operation + * status event. + * @details Inputs: currentMode, currentSubMode, currentSubState + * @details Outputs: dat1, dat2. + * @param none + * @return none + *************************************************************************/ +static void sendOperationStatusEvent( void ) +{ + EVENT_DATA_T dat1; + EVENT_DATA_T dat2; + U32 opData = ( (U08)currentMode + + ( (U08)currentSubMode << SHIFT_8_BITS_FOR_BYTE_SHIFT ) + + ( (U08)currentSubState << SHIFT_16_BITS_FOR_WORD_SHIFT ) ); + + dat2.dataType = EVENT_DATA_TYPE_U32; + dat2.data.uInt.data = 0; + + dat1.dataType = EVENT_DATA_TYPE_U32; + dat1.data.uInt.data = opData; + + sendEvent( HD_EVENT_OPERATION_STATUS, dat1, dat2 ); +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/