Index: firmware/App/Drivers/CPLD.c =================================================================== diff -u -r78b895b9f71a4f3d4b888a1072552a1c0f4cd43d -redbd697a40ad892873bfb67b05247fc12894f17e --- firmware/App/Drivers/CPLD.c (.../CPLD.c) (revision 78b895b9f71a4f3d4b888a1072552a1c0f4cd43d) +++ firmware/App/Drivers/CPLD.c (.../CPLD.c) (revision edbd697a40ad892873bfb67b05247fc12894f17e) @@ -23,13 +23,17 @@ #include "CPLD.h" #include "SystemComm.h" #include "SystemCommMessages.h" +#include "TaskPriority.h" /** * @addtogroup CPLD * @{ */ // ********** private definitions ********** + +#define CPLD_REPORT_PERIOD ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Broadcast CPLD values message every second. +#define DATA_PUBLISH_COUNTER_START_COUNT 27 ///< Data publish counter start count. #define WD_PET_GIO_PORT_PIN 1U ///< Watchdog pet GPIO pin number. #define WD_EXP_GIO_PORT_PIN 0U ///< Watchdog expired GPIO pin number. @@ -60,6 +64,10 @@ // ********** private data ********** +static OVERRIDE_U32_T cpldDataPublishInterval = { CPLD_REPORT_PERIOD, + CPLD_REPORT_PERIOD, 0, 0 }; ///< CPLD publish time interval override. +static U32 cpldDataPublishCounter; ///< Conductivity sensors data publish timer counter. + CPLD_STATUS_T cpldStatus = { 0, 0, 0, CPLD_CLEAN_LED_OFF }; // ********** private function prototypes ********** @@ -74,7 +82,9 @@ * @return none *************************************************************************/ void initCPLD( void ) -{ +{ + cpldDataPublishCounter = DATA_PUBLISH_COUNTER_START_COUNT; + // initialize watchdog pet output low (inactive) CLR_WD_PET(); @@ -226,8 +236,57 @@ *************************************************************************/ static void broadcastCPLDStatus( void ) { - getCPLDStatus( &cpldStatus ); - broadcastData( MSG_ID_DG_CPLD_STATUS, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&cpldStatus, sizeof( CPLD_STATUS_T ) ); + if ( ++cpldDataPublishCounter >= getU32OverrideValue( &cpldDataPublishInterval ) ) + { + getCPLDStatus( &cpldStatus ); + broadcastData( MSG_ID_DG_CPLD_STATUS, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&cpldStatus, sizeof( CPLD_STATUS_T ) ); + cpldDataPublishCounter = 0; + } } +/*********************************************************************//** + * @brief + * The testSetCpldDataPublishIntervalOverride function overrides + * the cpld data publish interval. + * @details Inputs: conductivityDataPublishInterval + * @details Outputs: conductivityDataPublishInterval + * @param value override cpld data publish interval with (in ms) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetCpldDataPublishIntervalOverride( U32 interval_ms ) +{ + BOOL result = FALSE; + + if ( isTestingActivated() ) + { + result = TRUE; + cpldDataPublishInterval.ovData = interval_ms / TASK_PRIORITY_INTERVAL; + cpldDataPublishInterval.override = OVERRIDE_KEY; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetCpldDataPublishIntervalOverride function resets + * the override of the cpld data publish interval. + * @details Inputs: conductivityDataPublishInterval + * @details Outputs: conductivityDataPublishInterval + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetCpldDataPublishIntervalOverride( void ) +{ + BOOL result = FALSE; + + if ( isTestingActivated() ) + { + result = TRUE; + cpldDataPublishInterval.ovData = cpldDataPublishInterval.ovInitData; + cpldDataPublishInterval.override = OVERRIDE_RESET; + } + + return result; +} + /**@}*/