Index: firmware/App/Drivers/CPLD.c =================================================================== diff -u -r4d637d588c0d78d95645e24ccbfdc01d45718a2f -r78b895b9f71a4f3d4b888a1072552a1c0f4cd43d --- firmware/App/Drivers/CPLD.c (.../CPLD.c) (revision 4d637d588c0d78d95645e24ccbfdc01d45718a2f) +++ firmware/App/Drivers/CPLD.c (.../CPLD.c) (revision 78b895b9f71a4f3d4b888a1072552a1c0f4cd43d) @@ -20,7 +20,9 @@ #include "het.h" #include "WatchdogMgmt.h" -#include "CPLD.h" +#include "CPLD.h" +#include "SystemComm.h" +#include "SystemCommMessages.h" /** * @addtogroup CPLD @@ -56,6 +58,14 @@ #define SET_WD_PET() gioSetBit( gioPORTB, WD_PET_GIO_PORT_PIN, PIN_SIGNAL_HIGH ) ///< Set watchdog GPIO macro. #define CLR_WD_PET() gioSetBit( gioPORTB, WD_PET_GIO_PORT_PIN, PIN_SIGNAL_LOW ) ///< Clear watchdog GPIO macro. +// ********** private data ********** + +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. @@ -72,6 +82,11 @@ CLR_CLEAN_LED(); CLR_FAULT_LED(); CLR_AUDIO_ALARM(); + + cpldStatus.wdog = getCPLDWatchdogExpired(); + cpldStatus.clean_led = CPLD_CLEAN_LED_OFF; + cpldStatus.fault_led = 0; + cpldStatus.audio = 0; } /*********************************************************************//** @@ -133,8 +148,11 @@ default: CLR_CLEAN_LED(); SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_LED_COLOR_SELECTED, color ) + color = CPLD_CLEAN_LED_OFF; break; } + cpldStatus.clean_led = color; + broadcastCPLDStatus(); } /*********************************************************************//** @@ -155,6 +173,8 @@ { CLR_FAULT_LED(); } + cpldStatus.fault_led = level; + broadcastCPLDStatus(); } /*********************************************************************//** @@ -175,6 +195,39 @@ { CLR_AUDIO_ALARM(); } + cpldStatus.audio = level; + broadcastCPLDStatus(); } +/*********************************************************************//** + * @brief + * The getCPLDStatus function gets the CPLD Status. + * @details Inputs: none + * @details Outputs: none. + * @param status struct pointer + * @return updated status pointer + *************************************************************************/ +void getCPLDStatus( CPLD_STATUS_T *status ) +{ + // Watchdog status needs to be read. Others are updated on change. + cpldStatus.wdog = getCPLDWatchdogExpired(); + status->wdog = cpldStatus.wdog; + status->audio = cpldStatus.audio; + status->clean_led = cpldStatus.clean_led; + status->fault_led = cpldStatus.fault_led; +} + +/*********************************************************************//** + * @brief + * The broadcastCPLDStatus function broadcasts the CPLD Status. + * @details Inputs: cpldStatus + * @details Outputs: none + * @return none + *************************************************************************/ +static void broadcastCPLDStatus( void ) +{ + getCPLDStatus( &cpldStatus ); + broadcastData( MSG_ID_DG_CPLD_STATUS, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&cpldStatus, sizeof( CPLD_STATUS_T ) ); +} + /**@}*/