Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -radeea598350354a833fff375526b888d0e6b6d48 -r7ce76ebd80b818d51dc61fd7f0c0fe94a242d182 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision adeea598350354a833fff375526b888d0e6b6d48) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 7ce76ebd80b818d51dc61fd7f0c0fe94a242d182) @@ -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 @@ -367,7 +370,7 @@ *************************************************************************/ static void broadcastOperationMode( void ) { - if ( ++broadcastModeIntervalCtr >= getDGOpModePublishInterval() ) + if ( ++dataPublishCounter >= getDGOpModePublishInterval() ) { OP_MODES_DATA_T data; @@ -376,7 +379,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; } }