Index: firmware/App/Controllers/AlarmLamp.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Controllers/AlarmLamp.c (.../AlarmLamp.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Controllers/AlarmLamp.c (.../AlarmLamp.c) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -267,9 +267,11 @@ red = PIN_SIGNAL_HIGH; } +#ifndef TASK_TIMING_OUTPUT_ENABLED setCPLDLampGreen( green ); setCPLDLampBlue( blue ); - setCPLDLampRed( red ); + setCPLDLampRed( red ); +#endif } Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -804,7 +804,7 @@ *************************************************************************/ static void publishBloodFlowData( void ) { - // publish blood flow data on interval + // publish blood flow data on interval #ifndef FLOW_DEBUG if ( ++bloodFlowDataPublicationTimerCounter >= getPublishBloodFlowDataInterval() ) #endif Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -724,11 +724,7 @@ { dialOutBroadCastVariables.refUFVolMl = getTotalTargetDialOutUFVolumeInMl(); dialOutBroadCastVariables.measUFVolMl = getTotalMeasuredUFVolumeInMl(); -#ifndef SHOW_LOAD_CELL_IN_ROTOR_RPM dialOutBroadCastVariables.measRotSpdRPM = getMeasuredDialOutPumpRotorSpeed(); -#else - dialOutBroadCastVariables.measRotSpdRPM = getLoadCellWeightInGrams( LOAD_CELL_RESERVOIR_1_PRIMARY ); -#endif dialOutBroadCastVariables.measSpdRPM = getMeasuredDialOutPumpSpeed(); dialOutBroadCastVariables.measMCSpdRPM = getMeasuredDialOutPumpMCSpeed(); dialOutBroadCastVariables.measMCCurrmA = getMeasuredDialOutPumpMCCurrent(); Index: firmware/App/Drivers/InternalADC.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Drivers/InternalADC.c (.../InternalADC.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Drivers/InternalADC.c (.../InternalADC.c) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -15,8 +15,9 @@ * ***************************************************************************/ -#include "adc.h" - +#include "adc.h" + +#include "CPLD.h" #include "InternalADC.h" // ********** private definitions ********** Index: firmware/App/Drivers/SafetyShutdown.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Drivers/SafetyShutdown.c (.../SafetyShutdown.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Drivers/SafetyShutdown.c (.../SafetyShutdown.c) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -97,8 +97,6 @@ if ( TRUE == isTestingActivated() ) { - MOTOR_DIR_T dir; - // remember natural state before override so we can reset safetyShutdownOverrideResetState = safetyShutdownActivated; // override safety shutdown signal Index: firmware/App/HDCommon.h =================================================================== diff -u -rd8852f18895c6cf3c7339aba976395720d2aa5e8 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/HDCommon.h (.../HDCommon.h) (revision d8852f18895c6cf3c7339aba976395720d2aa5e8) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -30,27 +30,27 @@ // ********** build switches ********** #ifndef _RELEASE_ -#define UF_TEST_ENABLED 1 -#define UF_TEST_WITH_DG 1 +#define UF_TEST_ENABLED 1 // ultrafiltration test build (hard codes treatment params, re-purposes off/stop buttons) +#define UF_TEST_WITH_DG 1 // ultrafiltration test build (sets up DG in standby mode) #ifndef _VECTORCAST_ -// #define RM46_EVAL_BOARD_TARGET 1 -// #define BREADBOARD_TARGET 1 -// #define SIMULATE_UI 1 - #define SKIP_POST 1 - #define DISABLE_CRC_ERROR 1 - #define DISABLE_ACK_ERRORS 1 - #define DISABLE_MOTOR_CURRENT_CHECKS 1 - #define DISABLE_PUMP_FLOW_CHECKS 1 - #define DISABLE_PUMP_SPEED_CHECKS 1 - #define DISABLE_PUMP_DIRECTION_CHECKS 1 - #define DISABLE_PRESSURE_CHECKS 1 - #define DISABLE_UF_ALARMS 1 -// #define RAW_FLOW_SENSOR_DATA 1 -// #define SHOW_LOAD_CELL_IN_ROTOR_RPM 1 -// #define READ_FPGA_ASYNC_DATA 1 -// #define FLOW_DEBUG 1 -// #define EMC_TEST_BUILD 1 - #define ALARMS_DEBUG 1 +// #define RM46_EVAL_BOARD_TARGET 1 // limited build runs on RM46 eval board +// #define BREADBOARD_TARGET 1 // old breadboard system build - no longer used? +// #define SIMULATE_UI 1 // build w/o requirement that UI be there +// #define TASK_TIMING_OUTPUT_ENABLED 1 // re-purposes alarm lamp pins for task timing + #define SKIP_POST 1 // skip POST tests - all pass + #define DISABLE_CRC_ERROR 1 // do not error on bad CRC for CAN messages + #define DISABLE_ACK_ERRORS 1 // do not error on failure of other node(s) to ACK a message + #define DISABLE_MOTOR_CURRENT_CHECKS 1 // do not error on HD pump current checks + #define DISABLE_PUMP_FLOW_CHECKS 1 // do not error on HD pump flow checks + #define DISABLE_PUMP_SPEED_CHECKS 1 // do not error on HD pump speed checks + #define DISABLE_PUMP_DIRECTION_CHECKS 1 // do not error on HD pump direction checks + #define DISABLE_PRESSURE_CHECKS 1 // do not error on HD pressure checks + #define DISABLE_UF_ALARMS 1 // do not error on HD ultrafiltration checks +// #define RAW_FLOW_SENSOR_DATA 1 // test build will not filter flow sensor data +// #define READ_FPGA_ASYNC_DATA 1 // test build reads non-priority register page every other time +// #define FLOW_DEBUG 1 // test build sends flow, signal strength, and occlusion readings to debug UART +// #define EMC_TEST_BUILD 1 // EMC test build - HD/DG run separately but connected, HD pumps toggle on/off w/ stop button + #define ALARMS_DEBUG 1 // triggered alarms sent to debug UART #include #include Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -293,12 +293,14 @@ activateAlarm( alarm ); #ifdef DEBUG_ENABLED #ifdef ALARMS_DEBUG - { - // TODO - temporary debug code - remove later - char debugStr[ 256 ]; - sprintf( debugStr, "ALARM triggered:%5d \n", alarm ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - } + if ( FALSE == alarmIsActive[ alarm ] ) + { + // TODO - temporary debug code - remove later + char debugStr[ 256 ]; + sprintf( debugStr, "ALARM trig:%5d \n", alarm ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); + } #endif #endif } @@ -325,12 +327,14 @@ activateAlarm( alarm ); #ifdef DEBUG_ENABLED #ifdef ALARMS_DEBUG - { - // TODO - temporary debug code - remove later - char debugStr[ 256 ]; - sprintf( debugStr, "ALARM triggered:%5d %8X \n", alarm, alarmData.data.uInt.data ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - } + if ( FALSE == alarmIsActive[ alarm ] ) + { + // TODO - temporary debug code - remove later + char debugStr[ 256 ]; + sprintf( debugStr, "ALARM trig:%5d %8X \n", alarm, alarmData.data.uInt.data ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); + } #endif #endif } @@ -358,12 +362,14 @@ activateAlarm( alarm ); #ifdef DEBUG_ENABLED #ifdef ALARMS_DEBUG - { - // TODO - temporary debug code - remove later - char debugStr[ 256 ]; - sprintf( debugStr, "ALARM triggered:%5d %8X %8X \n", (S32)alarm, alarmData1.data.uInt.data, alarmData2.data.uInt.data ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - } + if ( FALSE == alarmIsActive[ alarm ] ) + { + // TODO - temporary debug code - remove later + char debugStr[ 256 ]; + sprintf( debugStr, "ALARM trig:%5d %8X %8X \n", (S32)alarm, alarmData1.data.uInt.data, alarmData2.data.uInt.data ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); + } #endif #endif } @@ -404,6 +410,7 @@ char debugStr[ 256 ]; sprintf( debugStr, "ALARM cleared:%5d \n", alarm ); sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); } #endif #endif Index: firmware/App/Services/CommBuffers.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -143,6 +143,12 @@ } else // buffer too full to add this much data { +#ifdef DEBUG_ENABLED + char debugStr[50]; + sprintf( debugStr, "Buf OF:#%3d,%3d, %02X %02X %02X %02X %02X %02X %02X %02X \n", buffer, len, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7] ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); +#endif bufferFull = TRUE; clearBuffer( buffer ); } @@ -165,14 +171,6 @@ { firstBufferOverflowTimeStamp = getMSTimerCount(); } -#ifdef DEBUG_ENABLED - { - // TODO - temporary debug code - remove later - char debugStr[ 256 ]; - sprintf( debugStr, "Comm Buffer Overflow:%5d \n", (U32)buffer ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - } -#endif } else { // if good for persistence time period, reset persistence check Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -238,7 +238,9 @@ static FPGA_HEADER_T fpgaHeader; ///< Record of last received FPGA header data. static FPGA_SENSORS_T fpgaSensorReadings; ///< Record of last received FPGA priority sensor data. static FPGA_ACTUATORS_T fpgaActuatorSetPoints; ///< Record of next transmitted FPGA priority actuator data. +#ifdef READ_FPGA_ASYNC_DATA static FPGA_SENSORS_ASYNC_T fpgaSensorReadingsAsync; ///< Record of last received async (as needed) FPGA sensor data. +#endif // ********** private function prototypes ********** @@ -1014,19 +1016,21 @@ setSCI2DMAReceiveInterrupt(); } -/*********************************************************************//** - * @brief - * The getFPGAStatus function gets the version read from the diagnostic register \n - * of the FPGA. - * @details - * Inputs : fpgaHeader - * Outputs : none - * @return fpgaHeader.fpgaStatus - *************************************************************************/ -U16 getFPGAStatus( void ) -{ - return fpgaHeader.fpgaStatus; -} +/*********************************************************************//** + * @brief + * The getFPGAVersions function gets the fpga version numbers. + * @details + * Inputs : fpgaHeader + * Outputs : none + * @return none + *************************************************************************/ +void getFPGAVersions( U08 *Id, U08 *Maj, U08 *Min, U08 *Lab ) +{ + *Id = fpgaHeader.fpgaId; + *Maj = fpgaHeader.fpgaRev; + *Min = fpgaHeader.fpgaRevMajor; + *Lab = fpgaHeader.fpgaRevLab; +} /*********************************************************************//** * @brief Index: firmware/App/Services/FPGA.h =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -43,7 +43,7 @@ void signalFPGAReceiptCompleted( void ); void signalFPGATransmitCompleted( void ); -U16 getFPGAStatus( void ); +void getFPGAVersions( U08 *Id, U08 *Maj, U08 *Min, U08 *Lab ); F32 getFPGABloodFlowSignalStrength( void ); F32 getFPGADialysateFlowSignalStrength( void ); Index: firmware/App/Services/Interrupts.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -24,7 +24,7 @@ #include "AlarmMgmt.h" #include "BloodFlow.h" -#include "Comm.h" +#include "Comm.h" #include "DialInFlow.h" #include "DialOutFlow.h" #include "Interrupts.h" @@ -143,45 +143,45 @@ void canErrorNotification(canBASE_t *node, uint32 notification) { #ifdef DEBUG_ENABLED - // TODO - temporary debug code - remove later char debugStr[ 256 ]; -#endif +#endif + if ( node == canREG1 ) { if ( notification & canLEVEL_PARITY_ERR ) { can1ParityCnt++; #ifdef DEBUG_ENABLED - // TODO - temporary debug code - remove later - sprintf( debugStr, "CAN parity error:%5d \n", can1ParityCnt ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sprintf( debugStr, "CAN parity error:%5d \n", can1ParityCnt ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); #endif } else if ( notification & canLEVEL_BUS_OFF ) { can1BusOffCnt++; #ifdef DEBUG_ENABLED - // TODO - temporary debug code - remove later - sprintf( debugStr, "CAN bus off error:%5d \n", can1BusOffCnt ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sprintf( debugStr, "CAN bus off error:%5d \n", can1BusOffCnt ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); #endif } else if ( notification & canLEVEL_WARNING ) { can1WarningCnt++; #ifdef DEBUG_ENABLED - // TODO - temporary debug code - remove later - sprintf( debugStr, "CAN bus warning:%5d \n", can1WarningCnt ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sprintf( debugStr, "CAN bus warning:%5d \n", can1WarningCnt ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); #endif } else if ( notification & canLEVEL_PASSIVE ) { can1PassiveCnt++; #ifdef DEBUG_ENABLED - // TODO - temporary debug code - remove later - sprintf( debugStr, "CAN passive warning:%5d \n", can1PassiveCnt ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sprintf( debugStr, "CAN passive warning:%5d \n", can1PassiveCnt ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); #endif } else @@ -217,9 +217,9 @@ clearSCI2CommErrors(); // TODO - try to do something to recover (+ max retries = comm fault) #ifdef DEBUG_ENABLED - // TODO - temporary debug code - remove later - sprintf( debugStr, "FPGA UART frame error:%5d \n", sci2FrameErrorCnt ); + sprintf( debugStr, "FPGA UART FR err:%5d \n", sci2FrameErrorCnt ); sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); #endif } if ( ( flags & SCI_OE_INT ) != 0 ) @@ -228,9 +228,9 @@ clearSCI2CommErrors(); // TODO - try to do something to recover (+ max retries = comm fault) #ifdef DEBUG_ENABLED - // TODO - temporary debug code - remove later - sprintf( debugStr, "FPGA UART overrun error:%5d \n", sci2OverrunErrorCnt ); + sprintf( debugStr, "FPGA UART OR err:%5d \n", sci2OverrunErrorCnt ); sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); #endif } } @@ -242,20 +242,18 @@ sci1FrameErrorCnt++; clearSCI1CommErrors(); // TODO - try to do something to recover (+ max retries = comm fault) - - // TODO - temporary debug code - remove later - sprintf( debugStr, "Debug UART frame error:%5d \n", sci1FrameErrorCnt ); + sprintf( debugStr, "Debug UART FR err:%5d\n", sci1FrameErrorCnt ); sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); } if ( ( flags & SCI_OE_INT ) != 0 ) { sci1OverrunErrorCnt++; clearSCI1CommErrors(); // TODO - try to do something to recover (+ max retries = comm fault) - - // TODO - temporary debug code - remove later - sprintf( debugStr, "Debug UART overrun error:%5d \n", sci1OverrunErrorCnt ); + sprintf( debugStr, "Debug UART OR err:%5d\n", sci1OverrunErrorCnt ); sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); } } #endif Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -344,13 +344,15 @@ // message interrupt is for a transmit message box? if ( TRUE == isCANBoxForXmit( srcCANBox ) ) { - U32 bytesXmitted = transmitNextCANPacket(); + U32 bytesXmitted; + + bytesXmitted = transmitNextCANPacket(); // if nothing more to send, signal that transmitter is available if ( 0 == bytesXmitted ) { signalCANXmitsCompleted(); - } + } } else if ( TRUE == isCANBoxForRecv( srcCANBox ) ) { @@ -1069,6 +1071,14 @@ #endif break; + case MSG_ID_ALARM_TRIGGERED: + handleAlarmTriggered( message ); + break; + + case MSG_ID_ALARM_CLEARED: + handleAlarmCleared( message ); + break; + case MSG_ID_DG_CHECK_IN: handleDGCheckIn( message ); break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -22,7 +22,8 @@ #include "Buttons.h" #include "DGInterface.h" #include "DialInFlow.h" -#include "Dialysis.h" +#include "Dialysis.h" +#include "FPGA.h" #include "ModeTreatment.h" #include "PresOccl.h" #include "SafetyShutdown.h" @@ -35,7 +36,11 @@ // ********** private definitions ********** #define ACK_REQUIRED TRUE -#define ACK_NOT_REQUIRED FALSE +#define ACK_NOT_REQUIRED FALSE + +#ifdef DEBUG_ENABLED + #define DEBUG_EVENT_MAX_TEXT_LEN 40 +#endif #pragma pack(push,1) @@ -52,6 +57,18 @@ U32 silenceExpiresIn; // seconds U16 alarmsFlags; // bit flags: 1 = true, 0 = false for each bit } ALARM_COMP_STATUS_PAYLOAD_T; + +typedef struct +{ + U08 major; + U08 minor; + U08 micro; + U16 build; + U08 fpgaId; + U08 fpgaMajor; + U08 fpgaMinor; + U08 fpgaLab; +} HD_VERSIONS_T; typedef struct { @@ -1227,6 +1244,61 @@ { checkInFromUI(); } + +/************************************************************************* + * @brief + * The handleAlarmTriggered function handles a triggered alarm event message. + * @details + * Inputs : none + * Outputs : alarm triggered. + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleAlarmTriggered( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == ( sizeof( U16 ) + sizeof( ALARM_DATA_T ) + sizeof( ALARM_DATA_T ) ) ) + { + U08 *payloadPtr = message->payload; + U16 alarmID; + ALARM_DATA_T alm1, alm2; + + memcpy( &alarmID, payloadPtr, sizeof( U16 ) ); + payloadPtr += sizeof( U16 ); + memcpy( &alm1, payloadPtr, sizeof( ALARM_DATA_T ) ); + payloadPtr += sizeof( ALARM_DATA_T ); + memcpy( &alm2, payloadPtr, sizeof( ALARM_DATA_T ) ); + + if ( (ALARM_ID_T)alarmID < NUM_OF_ALARM_IDS ) + { + activateAlarm2Data( (ALARM_ID_T)alarmID, alm1, alm2 ); + } + } +} + +/************************************************************************* + * @brief + * The handleAlarmCleared function handles a cleared alarm event message. + * @details + * Inputs : none + * Outputs : alarm cleared. + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleAlarmCleared( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( U16 ) ) + { + U08 *payloadPtr = message->payload; + U16 alarmID; + + memcpy( &alarmID, payloadPtr, sizeof( U16 ) ); + + if ( (ALARM_ID_T)alarmID < NUM_OF_ALARM_IDS ) + { + clearAlarm( (ALARM_ID_T)alarmID ); + } + } +} /************************************************************************* * @brief handleOffButtonConfirmMsgFromUI @@ -1564,26 +1636,25 @@ *************************************************************************/ void handleFWVersionRequest( MESSAGE_T *message ) { - MESSAGE_T msg; - U08 major = (U08)HD_VERSION_MAJOR; - U08 minor = (U08)HD_VERSION_MINOR; - U08 micro = (U08)HD_VERSION_MICRO; - U16 build = (U16)HD_VERSION_BUILD; - U08 *payloadPtr = msg.payload; + MESSAGE_T msg; + HD_VERSIONS_T payload; + U08 *payloadPtr = msg.payload; + + // populate payload + payload.major = (U08)HD_VERSION_MAJOR; + payload.minor = (U08)HD_VERSION_MINOR; + payload.micro = (U08)HD_VERSION_MICRO; + payload.build = (U16)HD_VERSION_BUILD; + getFPGAVersions( &payload.fpgaId, &payload.fpgaMajor, &payload.fpgaMinor, &payload.fpgaLab ); // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_VERSION; - msg.hdr.payloadLen = sizeof( U08 ) + sizeof( U08 ) + sizeof( U08 ) + sizeof( U16 ); + msg.hdr.payloadLen = sizeof( HD_VERSIONS_T ); + + // fill message payload + memcpy( payloadPtr, &payload, sizeof( HD_VERSIONS_T ) ); - memcpy( payloadPtr, &major, sizeof( U08 ) ); - payloadPtr += sizeof( U08 ); - memcpy( payloadPtr, &minor, sizeof( U08 ) ); - payloadPtr += sizeof( U08 ); - memcpy( payloadPtr, µ, sizeof( U08 ) ); - payloadPtr += sizeof( U08 ); - memcpy( payloadPtr, &build, sizeof( U16 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); } @@ -1594,27 +1665,55 @@ *************************************************************************/ -/************************************************************************* - * @brief sendDebugData - * The sendDebugData function sends debug data out to the PC port. - * @details - * Inputs : none - * Outputs : PC serial port - * @param dbgData : Pointer to debug data - * @param len : # of bytes of debug data - * @return TRUE if debug data was successfully queued for transmit, FALSE if not - *************************************************************************/ -#ifdef DEBUG_ENABLED -BOOL sendDebugData( U08 *dbgData, U32 len ) -{ - BOOL result; +#ifdef DEBUG_ENABLED + /************************************************************************* + * @brief + * The sendDebugData function sends debug data out to the PC port. + * @details + * Inputs : none + * Outputs : PC serial port + * @param dbgData : Pointer to debug data + * @param len : # of bytes of debug data + * @return TRUE if debug data was successfully queued for transmit, FALSE if not + *************************************************************************/ + BOOL sendDebugData( U08 *dbgData, U32 len ) + { + BOOL result; - // add serialized message data to appropriate comm buffer - result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, dbgData, len ); + // add serialized message data to appropriate comm buffer + result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, dbgData, len ); - return result; -} -#endif + return result; + } + + /************************************************************************* + * @brief + * The sendDebugDataToUI function sends debug string to the UI for logging. + * @details + * Inputs : none + * Outputs : Message constructed and queued for transmit + * @param str : Pointer to debug string + * @return none + *************************************************************************/ + void sendDebugDataToUI( U08 *str ) + { + MESSAGE_T msg; + U32 txtLen = strlen( (char*)str ); + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_DEBUG_EVENT; + msg.hdr.payloadLen = DEBUG_EVENT_MAX_TEXT_LEN + 1; // add 1 byte for null terminator + if ( txtLen <= DEBUG_EVENT_MAX_TEXT_LEN ) + { + memcpy( payloadPtr, str, txtLen + 1 ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); + } + } +#endif /************************************************************************* * @brief isTestingActivated Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -42,6 +42,12 @@ // MSG_ID_OFF_BUTTON_PRESS BOOL sendOffButtonMsgToUI( U08 cmd ); void handleOffButtonConfirmMsgFromUI( MESSAGE_T *message ); + +// MSG_ID_ALARM_TRIGGERED +void handleAlarmTriggered( MESSAGE_T *message ); + +// MSG_ID_ALARM_CLEARED +void handleAlarmCleared( MESSAGE_T *message ); // MSG_ID_LOAD_CELL_READINGS void handleLoadCellReadingsFromDG( MESSAGE_T *message ); @@ -159,8 +165,11 @@ // *********** public test support message functions ********** #ifdef DEBUG_ENABLED -// DEBUG OUTPUT -BOOL sendDebugData( U08 *dbgData, U32 len ); +// DEBUG OUTPUT to debug UART +BOOL sendDebugData( U08 *dbgData, U32 len ); + +// Debug message to UI for logging +void sendDebugDataToUI( U08 *str ); #endif // MSG_TESTER_LOG_IN Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -15,10 +15,9 @@ * ***************************************************************************/ -//#include "gio.h" - #include "AlarmLamp.h" -#include "BloodFlow.h" +#include "BloodFlow.h" +#include "CPLD.h" #include "DialInFlow.h" #include "DialOutFlow.h" #include "OperationModes.h" @@ -50,6 +49,11 @@ *************************************************************************/ void taskGeneral( void ) { +#ifdef TASK_TIMING_OUTPUT_ENABLED + // set GPIO high to indicate general task has begun executing + setCPLDLampGreen( PIN_SIGNAL_HIGH ); +#endif + // check in with watchdog manager checkInWithWatchdogMgmt( TASK_GENERAL ); // do this first to keep timing consistent with watchdog management @@ -105,7 +109,9 @@ execSystemCommTx(); } - // toggle GPIO to indicate general task has executed -// gioToggleBit( gioPORTB, 1 ); +#ifdef TASK_TIMING_OUTPUT_ENABLED + // set GPIO low to indicate general task has finished executing + setCPLDLampGreen( PIN_SIGNAL_LOW ); +#endif } Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -15,11 +15,10 @@ * ***************************************************************************/ -//#include "gio.h" - #include "InternalADC.h" #include "BloodFlow.h" -#include "Buttons.h" +#include "Buttons.h" +#include "CPLD.h" #include "DialInFlow.h" #include "DialOutFlow.h" #include "FPGA.h" @@ -37,6 +36,11 @@ *************************************************************************/ void taskPriority( void ) { +#ifdef TASK_TIMING_OUTPUT_ENABLED + // set GPIO high to indicate priority task has begun executing + setCPLDLampRed( PIN_SIGNAL_HIGH ); +#endif + // prevent most processing until UI has started communicating #ifndef SIMULATE_UI if ( TRUE == uiCommunicated() ) @@ -67,8 +71,10 @@ // check in with watchdog manager checkInWithWatchdogMgmt( TASK_PRIORITY ); - - // toggle GPIO to indicate priority task has executed -// gioToggleBit( gioPORTB, 3 ); + +#ifdef TASK_TIMING_OUTPUT_ENABLED + // set GPIO low to indicate priority task has finished executing + setCPLDLampRed( PIN_SIGNAL_LOW ); +#endif } Index: firmware/App/Tasks/TaskTimer.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -r31c4bf94671f58375d2e1dbbbb37b37c6949e0c4 --- firmware/App/Tasks/TaskTimer.c (.../TaskTimer.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Tasks/TaskTimer.c (.../TaskTimer.c) (revision 31c4bf94671f58375d2e1dbbbb37b37c6949e0c4) @@ -15,11 +15,10 @@ * ***************************************************************************/ -//#include "gio.h" - -#include "WatchdogMgmt.h" -#include "Timers.h" +#include "CPLD.h" #include "TaskTimer.h" +#include "WatchdogMgmt.h" +#include "Timers.h" /************************************************************************* * @brief taskTimer @@ -32,14 +31,21 @@ *************************************************************************/ void taskTimer( void ) { +#ifdef TASK_TIMING_OUTPUT_ENABLED + // set GPIO high to indicate timer task has begun executing + setCPLDLampBlue( PIN_SIGNAL_HIGH ); +#endif + // increment ms timer count incMSTimerCount(); // check in with watchdog manager checkInWithWatchdogMgmt( TASK_TIMER ); - - // toggle GPIO to indicate timer task has executed - //gioToggleBit( gioPORTB, 0 ); + +#ifdef TASK_TIMING_OUTPUT_ENABLED + // set GPIO low to indicate timer task has finished executing + setCPLDLampBlue( PIN_SIGNAL_LOW ); +#endif }