Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -r31aa23b12f37b9d16b5160369ccb7dab6c6eca4d --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 31aa23b12f37b9d16b5160369ccb7dab6c6eca4d) @@ -40,7 +40,8 @@ // ********** private definitions ********** -#define BROADCAST_DG_OP_MODE_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the operation mode is published on the CAN bus. +#define BROADCAST_DG_OP_MODE_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the operation mode is published on the CAN bus. +#define DATA_PUBLISH_COUNTER_START_COUNT 11 ///< Data publish counter start count. // ********** private data ********** @@ -50,7 +51,7 @@ static U32 currentSubMode = 0; ///< The currently active state of the active mode. /// 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 broadcastModeIntervalCtr = 11; ///< Interval counter used to determine when to broadcast operation mode. Initialize to 11 to stagger broadcast. +static U32 dataPublishCounter; ///< Interval counter used to determine when to broadcast operation mode. Initialize to 11 to stagger broadcast. static U32 priorSubMode = 0; ///< The prior submode state. /// This matrix determines legal transitions from one mode to another. @@ -99,6 +100,8 @@ currentMode = DG_MODE_INIT; currentSubMode = 0; priorSubMode = 0; + dataPublishCounter = DATA_PUBLISH_COUNTER_START_COUNT; + transitionToNewOperationMode( DG_MODE_INIT ); // call initializers for the individual modes @@ -369,7 +372,7 @@ *************************************************************************/ static void broadcastOperationMode( void ) { - if ( ++broadcastModeIntervalCtr >= getDGOpModePublishInterval() ) + if ( ++dataPublishCounter >= getDGOpModePublishInterval() ) { OP_MODES_DATA_T data; @@ -378,7 +381,7 @@ broadcastData( MSG_ID_DG_OP_MODE, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( OP_MODES_DATA_T ) ); - broadcastModeIntervalCtr = 0; + dataPublishCounter = DATA_PUBLISH_COUNTER_START_COUNT; } }