Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r5ff39fd6948ae3656b4035c85325bd8fca0a37f3 -rc548570b37339819da825092dd07c7081437f30b --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 5ff39fd6948ae3656b4035c85325bd8fca0a37f3) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision c548570b37339819da825092dd07c7081437f30b) @@ -16,6 +16,7 @@ #include "gio.h" +#include "SystemCommMessages.h" #include "TaskGeneral.h" #include "OperationModes.h" #include "ModeChemicalDisinfect.h" @@ -37,12 +38,13 @@ // ********** private definitions ********** -#define DG_OP_MODE_BROADCAST_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the op mode is published on the CAN bus. +#define BROADCAST_DG_OP_MODE_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the op mode is published on the CAN bus. // ********** private data ********** static volatile BOOL modeRequest[NUM_OF_MODES - 1]; ///< Array of mode request flags. static OP_MODE currentMode = MODE_INIT; ///< The currently active mode. +static U32 broadcastModeIntervalCtr = 11; ///< Interval counter used to determine when to broadcase operation mode. Initialize to 11 to stagger broadcast. /// This matrix determines legal transitions from one mode to another. static const OP_MODE MODE_TRANSITION_TABLE[NUM_OF_MODES - 1][NUM_OF_MODES - 1] = @@ -67,6 +69,7 @@ static OP_MODE arbitrateModeRequest( void ); static void transitionToNewOperationMode( OP_MODE newMode ); +static void broadcastOperationMode( void ); /*********************************************************************//** * @brief execOperationModes @@ -194,11 +197,7 @@ } // end switch // publish op mode on interval - if ( ++dgOpModePublicationTimerCounter >= DG_OP_MODE_BROADCAST_INTERVAL ) - { - broadcastDGOpMode( (U32)currentMode ); - dgOpModePublicationTimerCounter = 0; - } + broadcastOperationMode(); } /*********************************************************************//**** @@ -330,4 +329,22 @@ } } +/************************************************************************* + * @brief + * The broadcastOperationMode function sends the current operation mode at \n + * the prescribed interval. + * @details + * Inputs : broadcastModeIntervalCtr + * Outputs : DG operation mode broadcast message sent. + * @return none + *************************************************************************/ +static void broadcastOperationMode( void ) +{ + if ( ++broadcastModeIntervalCtr >= BROADCAST_DG_OP_MODE_INTERVAL ) + { + broadcastModeIntervalCtr = 0; + broadcastDGOperationMode( currentMode ); + } +} + /**@}*/