Index: firmware/App/Drivers/CPLD.c =================================================================== diff -u -redbd697a40ad892873bfb67b05247fc12894f17e -r7d4711edd7b40cd3e29f43e766f79a8a09586fe9 --- firmware/App/Drivers/CPLD.c (.../CPLD.c) (revision edbd697a40ad892873bfb67b05247fc12894f17e) +++ firmware/App/Drivers/CPLD.c (.../CPLD.c) (revision 7d4711edd7b40cd3e29f43e766f79a8a09586fe9) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-2022 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2024 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file CPLD.c * -* @author (last) Dara Navaei -* @date (last) 22-Jul-2021 +* @author (last) Michael Garthwaite +* @date (last) 08-Mar-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -19,11 +19,10 @@ #include "mibspi.h" #include "het.h" -#include "WatchdogMgmt.h" #include "CPLD.h" -#include "SystemComm.h" #include "SystemCommMessages.h" #include "TaskPriority.h" +#include "WatchdogMgmt.h" /** * @addtogroup CPLD @@ -32,9 +31,6 @@ // ********** 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. @@ -64,16 +60,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 ********** -static void broadcastCPLDStatus( void ); - /*********************************************************************//** * @brief * The initCPLD function initializes the CPLD module. @@ -83,8 +73,6 @@ *************************************************************************/ void initCPLD( void ) { - cpldDataPublishCounter = DATA_PUBLISH_COUNTER_START_COUNT; - // initialize watchdog pet output low (inactive) CLR_WD_PET(); @@ -161,8 +149,8 @@ color = CPLD_CLEAN_LED_OFF; break; } + cpldStatus.clean_led = color; - broadcastCPLDStatus(); } /*********************************************************************//** @@ -171,9 +159,10 @@ * @details Inputs: none * @details Outputs: alarm LED signal set to given level. * @param level LOW or HIGH + * @param fault BOOL * @return none *************************************************************************/ -void setCPLDFaultLED( PIN_SIGNAL_STATE_T level ) +void setCPLDFaultLED( PIN_SIGNAL_STATE_T level, BOOL fault ) { if ( level == PIN_SIGNAL_HIGH ) { @@ -183,8 +172,8 @@ { CLR_FAULT_LED(); } - cpldStatus.fault_led = level; - broadcastCPLDStatus(); + + cpldStatus.fault_led = fault; // Use fault for LED State because it flashes } /*********************************************************************//** @@ -205,8 +194,8 @@ { CLR_AUDIO_ALARM(); } + cpldStatus.audio = level; - broadcastCPLDStatus(); } /*********************************************************************//** @@ -234,59 +223,10 @@ * @details Outputs: none * @return none *************************************************************************/ -static void broadcastCPLDStatus( void ) +void broadcastCPLDStatus( void ) { - 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; - } + getCPLDStatus( &cpldStatus ); + broadcastData( MSG_ID_DG_CPLD_STATUS_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&cpldStatus, sizeof( CPLD_STATUS_T ) ); } -/*********************************************************************//** - * @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; -} - /**@}*/