Index: firmware/App/Drivers/CPLD.c =================================================================== diff -u -r256d5cb05f1ef09e19e2f2733a111f600c73a7ee -re2e31bba8ccc7b60ba6036377799c71f9ceee63f --- firmware/App/Drivers/CPLD.c (.../CPLD.c) (revision 256d5cb05f1ef09e19e2f2733a111f600c73a7ee) +++ firmware/App/Drivers/CPLD.c (.../CPLD.c) (revision e2e31bba8ccc7b60ba6036377799c71f9ceee63f) @@ -19,16 +19,18 @@ #include "mibspi.h" #include "het.h" -#include "WatchdogMgmt.h" -#include "CPLD.h" +#include "CPLD.h" +#include "SystemCommMessages.h" +#include "TaskPriority.h" +#include "WatchdogMgmt.h" /** * @addtogroup CPLD * @{ */ // ********** private definitions ********** - + #define WD_PET_GIO_PORT_PIN 1U ///< Watchdog pet GPIO pin number. #define WD_EXP_GIO_PORT_PIN 0U ///< Watchdog expired GPIO pin number. @@ -56,6 +58,12 @@ #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 ********** + /*********************************************************************//** * @brief * The initCPLD function initializes the CPLD module. @@ -64,14 +72,19 @@ * @return none *************************************************************************/ void initCPLD( void ) -{ +{ // initialize watchdog pet output low (inactive) CLR_WD_PET(); // initialize alarm lamp color LED outputs low (off) 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 +146,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; } /*********************************************************************//** @@ -143,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 ) { @@ -155,6 +172,8 @@ { CLR_FAULT_LED(); } + + cpldStatus.fault_led = fault; // Use fault for LED State because it flashes } /*********************************************************************//** @@ -175,6 +194,39 @@ { CLR_AUDIO_ALARM(); } + + cpldStatus.audio = level; } +/*********************************************************************//** + * @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 + *************************************************************************/ +void broadcastCPLDStatus( void ) +{ + getCPLDStatus( &cpldStatus ); + broadcastData( MSG_ID_DG_CPLD_STATUS, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&cpldStatus, sizeof( CPLD_STATUS_T ) ); +} + /**@}*/