Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -rc48a99d2d1c852adcc986253b6c420a90dab7bfe -ra75923f40bea362b44fc082ce8eebde7bfa97c9a --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision a75923f40bea362b44fc082ce8eebde7bfa97c9a) @@ -33,13 +33,16 @@ // ********** private data ********** +static OVERRIDE_U32_T loadCellDataPublishInterval = { LOAD_CELL_REPORT_PERIOD, LOAD_CELL_REPORT_PERIOD, 0, 0 }; ///< Broadcast load cell data interval in ms/task interval. static U32 measuredLoadCellReadingsRaw[ NUM_OF_LOAD_CELLS ]; ///< Latest measured raw load cell readings. static U32 measuredLoadCellReadingsSum[ NUM_OF_LOAD_CELLS ]; ///< Raw load cell sums for averaging. static OVERRIDE_F32_T filteredLoadCellWeights[ NUM_OF_LOAD_CELLS ]; ///< Latest filtered load cell weights. static U32 loadCellDataPublicationTimerCounter = 0; ///< used to schedule load cell data publication to CAN bus. // ********** private function prototypes ********** +static U32 getLoadCellDataPublishInterval( void ); + /*********************************************************************//** * @brief * The initLoadCell function initializes the LoadCell module. @@ -87,7 +90,7 @@ measuredLoadCellReadingsSum[ LOAD_CELL_B2 ] += measuredLoadCellReadingsRaw[ LOAD_CELL_B2 ]; // broadcast load cell data if we are at scheduled interval. - if ( ++loadCellDataPublicationTimerCounter == LOAD_CELL_REPORT_PERIOD ) + if ( ++loadCellDataPublicationTimerCounter >= getLoadCellDataPublishInterval() ) // TODO - decouple averaging and conversion so that interval can be overridden { loadCellDataPublicationTimerCounter = 0; // calculate load cell average weights @@ -139,7 +142,28 @@ return result; } +/*********************************************************************//** + * @brief + * The getLoadCellDataPublishInterval function gets the load cell data \n + * publication interval. + * @details + * Inputs : loadCellDataPublishInterval + * Outputs : none + * @return the current load cell data publication interval (in ms/task interval). + *************************************************************************/ +static U32 getLoadCellDataPublishInterval( void ) +{ + U32 result = loadCellDataPublishInterval.data; + if ( OVERRIDE_KEY == loadCellDataPublishInterval.override ) + { + result = loadCellDataPublishInterval.ovData; + } + + return result; +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -193,3 +217,52 @@ return result; } + +/*********************************************************************//** + * @brief + * The testSetLoadCellDataPublishIntervalOverride function overrides the \n + * load cell data publish interval. + * @details + * Inputs : none + * Outputs : loadCellDataPublishInterval + * @param value : override load cell data publish interval with (in ms) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetLoadCellDataPublishIntervalOverride( U32 value ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + U32 intvl = value / TASK_PRIORITY_INTERVAL; + + result = TRUE; + loadCellDataPublishInterval.ovData = intvl; + loadCellDataPublishInterval.override = OVERRIDE_KEY; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetLoadCellDataPublishIntervalOverride function resets the override \n + * of the load cell data publish interval. + * @details + * Inputs : none + * Outputs : loadCellDataPublishInterval + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetLoadCellDataPublishIntervalOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + loadCellDataPublishInterval.override = OVERRIDE_RESET; + loadCellDataPublishInterval.ovData = loadCellDataPublishInterval.ovInitData; + } + + return result; +}