Index: FPGA.c =================================================================== diff -u -r3402723ffaf9fb1256d51fd23f4273ad7c087836 -r9512aac6feeb1379d6d425361fa78d58f75c86f6 --- FPGA.c (.../FPGA.c) (revision 3402723ffaf9fb1256d51fd23f4273ad7c087836) +++ FPGA.c (.../FPGA.c) (revision 9512aac6feeb1379d6d425361fa78d58f75c86f6) @@ -48,76 +48,76 @@ /// Enumeration of FPGA states. typedef enum FPGA_States { - FPGA_STATE_START = 0, ///< Start state for the FPGA. - FPGA_STATE_READ_HEADER, ///< Read header command state for the FPGA. - FPGA_STATE_RCV_HEADER, ///< Receive header state for the FPGA. - FPGA_STATE_WRITE_ALL_ACTUATORS, ///< Write actuators command state for the FPGA. - FPGA_STATE_RCV_ALL_SENSORS, ///< Receive sensors state for the FPGA. - FPGA_STATE_FAILED, ///< Failed state for the FPGA. - NUM_OF_FPGA_STATES ///< Number of FPGA states. + FPGA_STATE_START = 0, ///< Start state for the FPGA. + FPGA_STATE_READ_HEADER, ///< Read header command state for the FPGA. + FPGA_STATE_RCV_HEADER, ///< Receive header state for the FPGA. + FPGA_STATE_WRITE_ALL_ACTUATORS, ///< Write actuators command state for the FPGA. + FPGA_STATE_RCV_ALL_SENSORS, ///< Receive sensors state for the FPGA. + FPGA_STATE_FAILED, ///< Failed state for the FPGA. + NUM_OF_FPGA_STATES ///< Number of FPGA states. } FPGA_STATE_T; -#define FPGA_PAGE_SIZE 256 ///< FPGA register pages are 256 bytes. +#define FPGA_PAGE_SIZE 256 ///< FPGA register pages are 256 bytes. -#define FPGA_HEADER_START_ADDR 0x0000 ///< Start address for FPGA header data. -#define FPGA_BULK_READ_START_ADDR 0x0100 ///< Start address for FPGA continuous priority reads. -#define FPGA_BULK_WRITE_START_ADDR 0x000B ///< Start address for FPGA continuous priority writes. +#define FPGA_HEADER_START_ADDR 0x0000 ///< Start address for FPGA header data. +#define FPGA_BULK_READ_START_ADDR 0x0100 ///< Start address for FPGA continuous priority reads. +#define FPGA_BULK_WRITE_START_ADDR 0x000B ///< Start address for FPGA continuous priority writes. -#define FPGA_WRITE_CMD_BUFFER_LEN (FPGA_PAGE_SIZE+8) ///< FPGA write command buffer byte length. -#define FPGA_READ_CMD_BUFFER_LEN 8 ///< FPGA read command buffer byte length. -#define FPGA_WRITE_RSP_BUFFER_LEN 8 ///< FPGA write command response buffer byte length. -#define FPGA_READ_RSP_BUFFER_LEN (FPGA_PAGE_SIZE+8) ///< FPGA read command response buffer byte length. +#define FPGA_WRITE_CMD_BUFFER_LEN (FPGA_PAGE_SIZE+8) ///< FPGA write command buffer byte length. +#define FPGA_READ_CMD_BUFFER_LEN 8 ///< FPGA read command buffer byte length. +#define FPGA_WRITE_RSP_BUFFER_LEN 8 ///< FPGA write command response buffer byte length. +#define FPGA_READ_RSP_BUFFER_LEN (FPGA_PAGE_SIZE+8) ///< FPGA read command response buffer byte length. -#define FPGA_WRITE_CMD_CODE 0x55 ///< FPGA write command code. -#define FPGA_READ_CMD_CODE 0x5A ///< FPGA read command code. -#define FPGA_WRITE_CMD_ACK 0xA5 ///< FPGA write command ACK code. -#define FPGA_READ_CMD_ACK 0xAA ///< FPGA read command ACK code. -#define FPGA_CMD_NAK 0xEE ///< FPGA command NAK code. +#define FPGA_WRITE_CMD_CODE 0x55 ///< FPGA write command code. +#define FPGA_READ_CMD_CODE 0x5A ///< FPGA read command code. +#define FPGA_WRITE_CMD_ACK 0xA5 ///< FPGA write command ACK code. +#define FPGA_READ_CMD_ACK 0xAA ///< FPGA read command ACK code. +#define FPGA_CMD_NAK 0xEE ///< FPGA command NAK code. -#define FPGA_CRC_LEN 2 ///< FPGA CRC byte length. -#define FPGA_WRITE_CMD_HDR_LEN 4 ///< FPGA write command header byte length. -#define FPGA_READ_CMD_HDR_LEN 4 ///< FPGA read command header byte length. -#define FPGA_WRITE_RSP_HDR_LEN 3 ///< FPGA write command response header byte length. -#define FPGA_READ_RSP_HDR_LEN 3 ///< FPGA read command response header byte length. +#define FPGA_CRC_LEN 2 ///< FPGA CRC byte length. +#define FPGA_WRITE_CMD_HDR_LEN 4 ///< FPGA write command header byte length. +#define FPGA_READ_CMD_HDR_LEN 4 ///< FPGA read command header byte length. +#define FPGA_WRITE_RSP_HDR_LEN 3 ///< FPGA write command response header byte length. +#define FPGA_READ_RSP_HDR_LEN 3 ///< FPGA read command response header byte length. -#define SCI2_RECEIVE_DMA_REQUEST 28 ///< Serial port 2 receive DMA request line. -#define SCI2_TRANSMIT_DMA_REQUEST 29 ///< Serial port 2 transmit DMA request line. +#define SCI2_RECEIVE_DMA_REQUEST 28 ///< Serial port 2 receive DMA request line. +#define SCI2_TRANSMIT_DMA_REQUEST 29 ///< Serial port 2 transmit DMA request line. -#define FPGA_INPUT_VOLTAGE_SCALE 3.0F ///< FPGA source and aux voltage. -#define FPGA_PVN_VOLTAGE_SCALE 1.0F ///< FPGA pvn voltage. +#define FPGA_INPUT_VOLTAGE_SCALE 3.0F ///< FPGA source and aux voltage. +#define FPGA_PVN_VOLTAGE_SCALE 1.0F ///< FPGA pvn voltage. -#define FPGA_ADC1_AUTO_READ_ENABLE 0x01 ///< Auto-read enable bit for ADC1 control register. +#define FPGA_ADC1_AUTO_READ_ENABLE 0x01 ///< Auto-read enable bit for ADC1 control register. -#define FPGA_AIRTRAP_LEVEL_LOW_MASK 0x0008 ///< Bit mask for air trap lower level sensor. -#define FPGA_AIRTRAP_LEVEL_HIGH_MASK 0x0004 ///< Bit mask for air trap upper level sensor. +#define FPGA_AIRTRAP_LEVEL_LOW_MASK 0x0008 ///< Bit mask for air trap lower level sensor. +#define FPGA_AIRTRAP_LEVEL_HIGH_MASK 0x0004 ///< Bit mask for air trap upper level sensor. -#define FPGA_FLUID_LEAK_STATE_MASK 0x0040 ///< Bit mask for fluid leak detector. +#define FPGA_FLUID_LEAK_STATE_MASK 0x0040 ///< Bit mask for fluid leak detector. -#define FPGA_BLOOD_LEAK_STATUS_MASK 0x1000 ///< Bit mask for blood leak detector. -#define FPGA_BLOOD_LEAK_ST_BIT_INDEX 12 ///< Bit index for the blood leak self test status bit. -#define FPGA_BLOOD_LEAK_ZERO_STATE_MASK 0x2000 ///< Bit mask for blood leak detector zero. -#define FPAG_BLOOD_LEAK_ZERO_BIT_INDEX 13 ///< Bit index for the blood leak zero status bit. -#define FPGA_BLOOD_LEAK_ZERO_CMD 0x02 ///< Bit for blood leak detector zero command. -#define FPGA_BLOOD_LEAK_SELF_TEST_CMD 0x01 ///< Bit for blood leak detector self test command. +#define FPGA_BLOOD_LEAK_STATUS_MASK 0x1000 ///< Bit mask for blood leak detector. +#define FPGA_BLOOD_LEAK_ST_BIT_INDEX 12 ///< Bit index for the blood leak self test status bit. +#define FPGA_BLOOD_LEAK_ZERO_STATE_MASK 0x2000 ///< Bit mask for blood leak detector zero. +#define FPAG_BLOOD_LEAK_ZERO_BIT_INDEX 13 ///< Bit index for the blood leak zero status bit. +#define FPGA_BLOOD_LEAK_ZERO_CMD 0x02 ///< Bit for blood leak detector zero command. +#define FPGA_BLOOD_LEAK_SELF_TEST_CMD 0x01 ///< Bit for blood leak detector self test command. -#define FPGA_ADA_BUBBLE_STATUS_MASK 0x0001 ///< Bit mask for arterial air bubble detector input status. -#define FPGA_ADV_BUBBLE_STATUS_MASK 0x0002 ///< Bit mask for venous air bubble detector input status. -#define FPGA_ADA_BUBBLE_SELF_TEST_CMD 0x04 ///< Bit for arterial air bubble detector self-test command. -#define FPGA_ADV_BUBBLE_SELF_TEST_CMD 0x08 ///< Bit for venous air bubble detector self-test command. +#define FPGA_ADA_BUBBLE_STATUS_MASK 0x0001 ///< Bit mask for arterial air bubble detector input status. +#define FPGA_ADV_BUBBLE_STATUS_MASK 0x0002 ///< Bit mask for venous air bubble detector input status. +#define FPGA_ADA_BUBBLE_SELF_TEST_CMD 0x04 ///< Bit for arterial air bubble detector self-test command. +#define FPGA_ADV_BUBBLE_SELF_TEST_CMD 0x08 ///< Bit for venous air bubble detector self-test command. -#define FPGA_PBO_TEMP_DIVISOR 2047.0F ///< Used in conversion of PBo temperature reading to deg C. -#define FPGA_PBO_TEMP_GAIN 200.0F ///< Used in conversion of PBo temperature reading to deg C. -#define FPGA_PBO_TEMP_OFFSET 50.0F ///< Used in conversion of PBo temperature reading to deg C. +#define FPGA_PBO_TEMP_DIVISOR 2047.0F ///< Used in conversion of PBo temperature reading to deg C. +#define FPGA_PBO_TEMP_GAIN 200.0F ///< Used in conversion of PBo temperature reading to deg C. +#define FPGA_PBO_TEMP_OFFSET 50.0F ///< Used in conversion of PBo temperature reading to deg C. -#define FPGA_ALARM_AUDIO_VOLUME_SHIFT 3 ///< Shift alarm audio volume 3 bits to left before writing to register. -#define FPGA_ALARM_AUDIO_DIVIDE_SHIFT 6 ///< Shift alarm audio volume divider 6 bits to left before writing to register. +#define FPGA_ALARM_AUDIO_VOLUME_SHIFT 3 ///< Shift alarm audio volume 3 bits to left before writing to register. +#define FPGA_ALARM_AUDIO_DIVIDE_SHIFT 6 ///< Shift alarm audio volume divider 6 bits to left before writing to register. -#define FPGA_BACKUP_ALARM_AUDIO_CONVERT 0.4F ///< Converts backup (piezo) alarm audio ADC volts to amps. +#define FPGA_BACKUP_ALARM_AUDIO_CONVERT 0.4F ///< Converts backup (piezo) alarm audio ADC volts to amps. -#define FRONT_DOOR_SWITCH_MASK 0x0010 ///< Front door switch bit mask. Bit 4 of the GPIO register. -#define PUMP_TRACK_SWITCH_MASK 0x0020 ///< Pump track switch bit mask. Bit 5 of the GPIO register. +#define FRONT_DOOR_SWITCH_MASK 0x0010 ///< Front door switch bit mask. Bit 4 of the GPIO register. +#define PUMP_TRACK_SWITCH_MASK 0x0020 ///< Pump track switch bit mask. Bit 5 of the GPIO register. -#define FPGA_VALVES_MIN_PWM_MODE_COUNT 2500 ///< FPGA valves minimum PWM in PWM mode in counts. +#define FPGA_VALVES_MIN_PWM_MODE_COUNT 2500 ///< FPGA valves minimum PWM in PWM mode in counts. // ********** private data ********** @@ -174,9 +174,9 @@ /*********************************************************************//** * @brief - * The initFPGA function initializes the FPGA module. - * @details Inputs: none - * @details Outputs: FPGA module initialized. + * The initFPGA function initializes the FPGA unit. + * @details \b Inputs: none + * @details \b Outputs: FPGA unit initialized. * @return none *************************************************************************/ void initFPGA( U08* hdr, U08* sen, U08* act, U32 hdrSize, U32 senSize, U32 actSize ) @@ -288,8 +288,8 @@ * @brief * The resetFPGACommFlags function resets the various fpga comm flags and * counters. - * @details Inputs: none - * @details Outputs: fpga comm flags & counters reset + * @details \b Inputs: none + * @details \b Outputs: fpga comm flags and counters reset * @return none *************************************************************************/ static void resetFPGACommFlags( void ) @@ -306,9 +306,12 @@ /*********************************************************************//** * @brief * The signalFPGAReceiptCompleted function increments a counter to indicate - * that another DMA receipt from the FPGA has completed. - * @details Inputs: none - * @details Outputs: fpgaReceiptCounter + * that another DMA receipt from the FPGA has completed and sets comm flags + * indicating pending response from FPGA is completed. + * @details \b Inputs: none + * @details \b Outputs: fpgaReceiptCounter, fpgaWriteCommandInProgress, + * fpgaWriteCommandResponseReceived, fpgaReadCommandInProgress, + * fpgaReadCommandResponseReceived, fpgaBulkWriteAndReadInProgress * @return none *************************************************************************/ void signalFPGAReceiptCompleted( void ) @@ -341,8 +344,8 @@ * @brief * The signalFPGATransmitCompleted function increments a counter to indicate * that another DMA transmit to the FPGA has completed. - * @details Inputs: none - * @details Outputs: fpgaReceiptCounter + * @details \b Inputs: none + * @details \b Outputs: fpgaTransmitCounter * @return none *************************************************************************/ void signalFPGATransmitCompleted( void ) @@ -353,16 +356,20 @@ /*********************************************************************//** * @brief * The execFPGA function manages incoming data exchanges with the FPGA. - * @details Inputs: fpgaState - * @details Outputs: fpgaState + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if current FPGA state is invalid. + * @details \b Inputs: fpgaState + * @details \b Outputs: fpgaState + * @param in Flag indicating whether we are executing the in or out cycle of the state machine. * @return none *************************************************************************/ -void execFPGAIn( void ) +void execFPGA( BOOL in ) { + if ( TRUE == in ) + { + // Check if FE or OE error has occurred + checkFPGAFEOEFailure(); + } - // Check if FE or OE error has occurred - checkFPGAFEOEFailure(); - // FPGA incoming state machine switch ( fpgaState ) { @@ -378,42 +385,6 @@ fpgaState = handleFPGAReceiveAllSensorsState(); break; - case FPGA_STATE_FAILED: - // Do nothing - we will be stuck here - break; - - default: - if ( fpgaState >= NUM_OF_FPGA_STATES ) - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_INVALID_IN_STATE, fpgaState ) - } - else - { - // Ok, some states handled in the outgoing state machine - } - break; - } - - // Reset comm flags after processing incoming responses - resetFPGACommFlags(); - - // Monitor the power status - monitorFPGAPowerStatus(); -} - -/*********************************************************************//** - * @brief - * The execFPGAOut function manages outgoing data exchanges with the FPGA. - * @details Inputs: fpgaState - * @details Outputs: fpgaState - * @return none - *************************************************************************/ -void execFPGAOut( void ) -{ - - // FPGA outgoing state machine - switch ( fpgaState ) - { case FPGA_STATE_READ_HEADER: fpgaState = handleFPGAReadHeaderState(); break; @@ -427,24 +398,34 @@ break; default: - if ( fpgaState >= NUM_OF_FPGA_STATES ) - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_INVALID_OUT_STATE, fpgaState ) - } - else - { - // Ok, some states handled in the incoming state machine - } +#ifdef _TD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_INVALID_STATE, fpgaState ) +#endif +#ifdef _DD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_INVALID_STATE, fpgaState ) +#endif +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_INVALID_STATE, fpgaState ) +#endif break; } + + if ( TRUE == in ) + { + // Reset comm flags after processing incoming responses + resetFPGACommFlags(); + + // Monitor the power status + monitorFPGAPowerStatus(); + } } /*********************************************************************//** * @brief * The handleFPGAReadHeaderState function handles the FPGA state where - * the read header registers command is sent to the FPGA. - * @details Inputs: none - * @details Outputs: read command sent to FPGA + * the read FPGA header registers command is sent to the FPGA. + * @details \b Inputs: none + * @details \b Outputs: read header command transmit to FPGA is initiated * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAReadHeaderState( void ) @@ -474,8 +455,8 @@ * @brief * The handleFPGAReceiveHeaderState function handles the FPGA state * where the header registers read response should be ready to take in. - * @details Inputs: none - * @details Outputs: header register values updated + * @details \b Inputs: fpgaReadCommandResponseReceived, fpgaReadResponseBuffer[] + * @details \b Outputs: header register values updated * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAReceiveHeaderState( void ) @@ -523,9 +504,10 @@ /*********************************************************************//** * @brief * The handleFPGAWriteAllActuatorsState function handles the FPGA state - * where the bulk write command is sent to the FPGA. - * @details Inputs: actuator set points - * @details Outputs: actuator set points sent to FPGA + * where the bulk write and read commands are setup for DMA and the builk + * write command transmit to FPGA is initiated. + * @details \b Inputs: actuator set points + * @details \b Outputs: fpgaWriteCmdBuffer[], fpgaReadCmdBuffer[] * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAWriteAllActuatorsState( void ) @@ -573,9 +555,12 @@ /*********************************************************************//** * @brief * The handleFPGAReceiveAllSensorsState function handles the FPGA state - * where the bulk read response should be ready to parse. - * @details Inputs: none - * @details Outputs: sensor values updated + * where the bulk write and read responses should be ready to parse. The + * bulk write command response is checked to ensure FPGA acknowledged it. + * The bulk read command response is CRC checked and registers updated. + * @details \b Inputs: fpgaWriteCommandResponseReceived, fpgaWriteResponseBuffer[], + * fpgaReadCommandResponseReceived, fpgaReadResponseBuffer[] + * @details \b Outputs: Register (sensor) values updated * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAReceiveAllSensorsState( void ) @@ -662,10 +647,10 @@ /*********************************************************************//** * @brief * The consumeUnexpectedData function checks to see if a byte is sitting in - * the SCI2 received data register. - * @details Inputs: fpgaHeader - * @details Outputs: none - * @return fpgaDiag + * the SCI2 received data register and consumes the byte if found. + * @details \b Inputs: SCI FLR register + * @details \b Outputs: SCI errors cleared, unexpected byte consumed + * @return none *************************************************************************/ static void consumeUnexpectedData( void ) { @@ -682,8 +667,8 @@ /*********************************************************************//** * @brief * The monitorFPGAPowerStatus function monitors the status of the FPGA power source. - * @details Inputs: none - * @details Outputs: none + * @details \b Inputs: TBD + * @details \b Outputs: TBD * @return none *************************************************************************/ static void monitorFPGAPowerStatus( void ) @@ -695,8 +680,8 @@ * @brief * The setupDMAForWriteCmd function sets the byte count for the next DMA * write command to the FPGA. - * @details Inputs: none - * @details Outputs: number of bytes for next FPGA write command is set + * @details \b Inputs: none + * @details \b Outputs: number of bytes for next FPGA write command is set * @param bytes2Transmit number of bytes to be transmitted via DMA to the FPGA * @return none *************************************************************************/ @@ -717,8 +702,8 @@ * @brief * The startDMAWriteCmd function initiates the DMA transmit for the next * DMA write command to the FPGA. - * @details Inputs: none - * @details Outputs: DMA write command to FPGA is initiated + * @details \b Inputs: fpgaDMAWriteControlRecord + * @details \b Outputs: DMA write command to FPGA is initiated * @return none *************************************************************************/ static void startDMAWriteCmd( void ) @@ -732,8 +717,9 @@ * @brief * The setupDMAForWriteResp function sets the expected byte count for the * next DMA write command response from the FPGA. - * @details Inputs: none - * @details Outputs: number of expected bytes for next FPGA write command response is set + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if byte count exceeds buffer size. + * @details \b Inputs: none + * @details \b Outputs: fpgaDMAWriteRespControlRecord * @param bytes2Receive number of bytes expected to be transmitted via DMA from the FPGA * @return none *************************************************************************/ @@ -754,8 +740,8 @@ * @brief * The startDMAReceiptOfWriteResp function initiates readiness of the DMA * receiver for the next DMA write command response from the FPGA. - * @details Inputs: none - * @details Outputs: DMA write command response is ready to be received from the FPGA + * @details \b Inputs: fpgaDMAWriteRespControlRecord + * @details \b Outputs: DMA write command response is made ready to be received from the FPGA * @return none *************************************************************************/ static void startDMAReceiptOfWriteResp( void ) @@ -769,8 +755,9 @@ * @brief * The setupDMAForReadCmd function sets the byte count for the next DMA * read command to the FPGA. - * @details Inputs: none - * @details Outputs: number of bytes for next FPGA read command is set + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if byte count exceeds buffer size. + * @details \b Inputs: none + * @details \b Outputs: fpgaDMAReadControlRecord * @param bytes2Transmit number of bytes to be transmitted via DMA to the FPGA * @return none *************************************************************************/ @@ -791,8 +778,8 @@ * @brief * The startDMAReadCmd function initiates the DMA transmit for the next * DMA read command to the FPGA. - * @details Inputs: none - * @details Outputs: DMA read command to FPGA is initiated + * @details \b Inputs: fpgaDMAReadControlRecord + * @details \b Outputs: DMA read command to FPGA is initiated * @return none *************************************************************************/ static void startDMAReadCmd( void ) @@ -806,8 +793,9 @@ * @brief * The setupDMAForReadResp function sets the expected byte count for the * next DMA read command response from the FPGA. - * @details Inputs: none - * @details Outputs: number of expected bytes for next FPGA read command response is set + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if byte count exceeds buffer size. + * @details \b Inputs: none + * @details \b Outputs: fpgaDMAReadRespControlRecord * @param bytes2Receive number of expected bytes to be transmitted via DMA from the FPGA * @return none *************************************************************************/ @@ -828,8 +816,8 @@ * @brief * The startDMAReceiptOfReadResp function initiates readiness of the DMA * receiver for the next DMA read command response from the FPGA. - * @details Inputs: none - * @details Outputs: DMA read command response is ready to be received from the FPGA + * @details \b Inputs: fpgaDMAReadRespControlRecord + * @details \b Outputs: DMA read command response is ready to be received from the FPGA * @return none *************************************************************************/ static void startDMAReceiptOfReadResp( void ) Index: FPGA.h =================================================================== diff -u -r3402723ffaf9fb1256d51fd23f4273ad7c087836 -r9512aac6feeb1379d6d425361fa78d58f75c86f6 --- FPGA.h (.../FPGA.h) (revision 3402723ffaf9fb1256d51fd23f4273ad7c087836) +++ FPGA.h (.../FPGA.h) (revision 9512aac6feeb1379d6d425361fa78d58f75c86f6) @@ -38,10 +38,10 @@ * This module is driven by the Priority Task via calls to two FPGA executive functions: * 1) an incoming executive manages the states of the state machine that deal with responses and data received from the FPGA * 2) an outgoing executive manages transmission of write and read commands to the FPGA. - * This module first reads the header record that includes the FPGA ID and revision and - * verifies the FPGA ID to check FPGA communication. It then initializes and configures the ADCs and - * various other sensors that are interfaced via the FPGA. Then, it essentially enters an infinite loop - * where a bulk write command updates actuator set points and a bulk read command retrieves the latest sensor readings. + * This unit first reads the header record that includes the FPGA ID and revision and + * verifies the FPGA ID to check FPGA communication. Then, it essentially enters an infinite loop + * where a bulk write command updates actuator set points and a bulk read command retrieves the + * latest sensor readings. * * @addtogroup FPGA * @{ @@ -52,8 +52,7 @@ // ********** public function prototypes ********** void initFPGA( U08* hdr, U08* sen, U08* act, U32 hdrSize, U32 senSize, U32 actSize ); -void execFPGAIn( void ); -void execFPGAOut( void ); +void execFPGA( BOOL in ); void signalFPGAReceiptCompleted( void ); void signalFPGATransmitCompleted( void ); Index: MessageSupport.c =================================================================== diff -u -r6d80d69a210f45c733e5307859351f2cd820a8e7 -r9512aac6feeb1379d6d425361fa78d58f75c86f6 --- MessageSupport.c (.../MessageSupport.c) (revision 6d80d69a210f45c733e5307859351f2cd820a8e7) +++ MessageSupport.c (.../MessageSupport.c) (revision 9512aac6feeb1379d6d425361fa78d58f75c86f6) @@ -23,18 +23,16 @@ * @{ */ -// ********** private function prototypes ********** - - /*********************************************************************//** * @brief - * The broadcastData function queues a broadcast message for transmission. - * @details Inputs: none - * @details Outputs: broadcast data msg constructed and queued - * @param msgID message ID of the data is broadcast - * @param buffer comm buffer ID - * @param dataPtr pointer to the start of the buffer - * @param length length of the data buffer + * The broadcastData function queues a broadcast message for transmission + * to a given CAN buffer. + * @details \b Inputs: none + * @details \b Outputs: broadcast data msg constructed and queued + * @param msgID ID of message to broadcast + * @param buffer ID of CAN transmit buffer to add broadcast message to + * @param dataPtr pointer to the start of the serialized message data to queue + * @param length length of the serialized message data * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastData( MSG_ID_T msgID, COMM_BUFFER_T buffer, U08* dataPtr, U32 length ) Index: MessageSupport.h =================================================================== diff -u -r6d80d69a210f45c733e5307859351f2cd820a8e7 -r9512aac6feeb1379d6d425361fa78d58f75c86f6 --- MessageSupport.h (.../MessageSupport.h) (revision 6d80d69a210f45c733e5307859351f2cd820a8e7) +++ MessageSupport.h (.../MessageSupport.h) (revision 9512aac6feeb1379d6d425361fa78d58f75c86f6) @@ -22,7 +22,8 @@ /** * @defgroup MessageSupport MessageSupport - * @brief Provides commonly used function for messaging + * @brief Provides functions to support messaging on the CAN bus that are + * common to all firmware stacks. * * @addtogroup MessageSupport * @{ Index: PersistentAlarm.c =================================================================== diff -u -rc9b16409a91c7d6943dad4400ae1858433f5adf5 -r9512aac6feeb1379d6d425361fa78d58f75c86f6 --- PersistentAlarm.c (.../PersistentAlarm.c) (revision c9b16409a91c7d6943dad4400ae1858433f5adf5) +++ PersistentAlarm.c (.../PersistentAlarm.c) (revision 9512aac6feeb1379d6d425361fa78d58f75c86f6) @@ -42,10 +42,10 @@ typedef struct { ALARM_ID_T alarm; ///< Alarm ID. - U32 persistentClearPeriod; ///< Persistent count limit before clear alarm. - U32 persistentTriggerPeriod; ///< Persistent count limit before trigger alarm. - U32 errorClearedStartTime; ///< Error cleared start time. - U32 errorOccurredStartTime; ///< Error occurred start time. + U32 persistentClearPeriod_ms; ///< Persistent time limit before clear alarm (in ms). + U32 persistentTriggerPeriod_ms; ///< Persistent time limit before trigger alarm (in ms). + U32 errorClearedStartTime; ///< Error cleared start time stamp. + U32 errorOccurredStartTime; ///< Error occurred start time stamp. BOOL alarmActive; ///< State of alarm last time alarm checked. } PERSISTENT_ALARM_DATA_T; @@ -62,8 +62,8 @@ typedef struct { ALARM_ID_T fpgaAlarm; ///< FPGA read alarm. - U32 fpgaPersistentClearPeriod; ///< FPGA persistent count limit before clear alarm. - U32 fpgaPersistentTriggerPeriod; ///< FPGA persistent count limit before trigger alarm. + U32 fpgaPersistentClearPeriod_ms; ///< FPGA persistent time limit before clear alarm (in ms). + U32 fpgaPersistentTriggerPeriod_ms; ///< FPGA persistent time limit before trigger alarm (in ms). FPGA_ALARM_DATA_T fpgaAlarmData[ NUM_OF_FPGA_ERROR_TYPES ]; ///< FPGA persistent alarm data. } FPGA_PERSISTENT_ALARM_GROUP_T; @@ -78,77 +78,80 @@ /*********************************************************************//** * @brief - * The initPersistentAlarm function initializes the PersistentAlarm module - * when the alarm count lower than maximum persistent alarm allowed. - * @details Inputs: none - * @details Outputs: PersistentAlarm module initialized - * @param alarmId Alarm id - * @param persistentClearPeriod Persistent period limit before clear alarm (in ms) - * @param persistentTriggerPeriod Persistent period limit before trigger alarm (in ms) + * The initPersistentAlarm function initializes a given persistent alarm. + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if given persistent alarm is invalid. + * @details \b Inputs: none + * @details \b Outputs: persistentAlarms[] + * @param alarmId ID of alarm to initialize persistence for + * @param persistentClearPeriod Persistent period for clearing alarm condition (in ms) + * @param persistentTriggerPeriod Persistent period for triggering alarm (in ms) * @return none *************************************************************************/ void initPersistentAlarm( ALARM_ID_T alarmId, U32 persistentClearPeriod, U32 persistentTriggerPeriod ) { if ( alarmId < NUM_OF_ALARM_IDS ) { - persistentAlarms[ alarmId ].persistentClearPeriod = persistentClearPeriod; - persistentAlarms[ alarmId ].persistentTriggerPeriod = persistentTriggerPeriod; + persistentAlarms[ alarmId ].persistentClearPeriod_ms = persistentClearPeriod; + persistentAlarms[ alarmId ].persistentTriggerPeriod_ms = persistentTriggerPeriod; persistentAlarms[ alarmId ].errorClearedStartTime = 0U; persistentAlarms[ alarmId ].errorOccurredStartTime = 0U; persistentAlarms[ alarmId ].alarmActive = FALSE; } else { +#ifdef _TD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_PERSISTENT_ALARM_INVALID_INDEX1, alarmId ); +#endif #ifdef _DD_ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_PERSISTENT_ALARM_INVALID_INDEX1, alarmId ); -#else - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_PERSISTENT_ALARM_INVALID_INDEX1, alarmId ); #endif +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_PERSISTENT_ALARM_INVALID_INDEX1, alarmId ); +#endif } } /*********************************************************************//** * @brief - * The initFPGAPersistentAlarm function initializes the FPGA persistent alarm - * when the alarm count lower than maximum persistent alarm allowed and the FPGA - * sensor group is less than the maximum allowed sensor group. - * @details Inputs: none - * @details Outputs: fpgaPersistentAlarmGroup - * @param group which is the FPGA persistent alarm group - * @param alarmId Alarm id - * @param persistentClearPeriod Persistent period limit before clear alarm (in ms) - * @param persistentTriggerPeriod Persistent period limit before trigger alarm (in ms) + * The initFPGAPersistentAlarm function initializes a given FPGA persistent alarm. + * @details \b Inputs: none + * @details \b Outputs: fpgaPersistentAlarmGroup + * @param group ID of FPGA persistent alarm group to initialize + * @param alarmId ID of alarm to associate with the given FPGA persistent alarm group + * @param persistentClearPeriod Persistent period for clearing alarm (in ms) + * @param persistentTriggerPeriod Persistent period for triggering alarm (in ms) * @return none *************************************************************************/ void initFPGAPersistentAlarm( FPGA_PERSISTENT_ALARMS_GROUP_T group, ALARM_ID_T alarmIndex, U32 persistentClearPeriod, U32 persistentTriggerPeriod ) { -// if ( ( group < NUM_OF_FPGA_SENSOR_GROUPS ) && ( alarmIndex < NUM_OF_ALARM_IDS ) ) -// { -// fpgaPersistentAlarmGroup[ group ].fpgaAlarm = alarmIndex; -// fpgaPersistentAlarmGroup[ group ].fpgaPersistentClearPeriod = persistentClearPeriod; -// fpgaPersistentAlarmGroup[ group ].fpgaPersistentTriggerPeriod = persistentTriggerPeriod; -// -// fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_READ_ALARM_INDEX ].fpgaIsConditionClear = TRUE; -// fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_READ_ALARM_INDEX ].fpagErrorClearedStartTime = 0; -// fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_READ_ALARM_INDEX ].fpgaErrorOccurredStartTime = 0; -// fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_READ_ALARM_INDEX ].fpgaPreviousCount = 0; -// -// fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_ERROR_ALARM_INDEX ].fpgaIsConditionClear = TRUE; -// fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_ERROR_ALARM_INDEX ].fpagErrorClearedStartTime = 0; -// fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_ERROR_ALARM_INDEX ].fpgaErrorOccurredStartTime = 0; -// fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_ERROR_ALARM_INDEX ].fpgaPreviousCount = 0; -// } + if ( ( group < NUM_OF_FPGA_SENSOR_GROUPS ) && ( alarmIndex < NUM_OF_ALARM_IDS ) ) + { + fpgaPersistentAlarmGroup[ group ].fpgaAlarm = alarmIndex; + fpgaPersistentAlarmGroup[ group ].fpgaPersistentClearPeriod_ms = persistentClearPeriod; + fpgaPersistentAlarmGroup[ group ].fpgaPersistentTriggerPeriod_ms = persistentTriggerPeriod; + + fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_READ_ALARM_INDEX ].fpgaIsConditionClear = TRUE; + fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_READ_ALARM_INDEX ].fpagErrorClearedStartTime = 0; + fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_READ_ALARM_INDEX ].fpgaErrorOccurredStartTime = 0; + fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_READ_ALARM_INDEX ].fpgaPreviousCount = 0; + + fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_ERROR_ALARM_INDEX ].fpgaIsConditionClear = TRUE; + fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_ERROR_ALARM_INDEX ].fpagErrorClearedStartTime = 0; + fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_ERROR_ALARM_INDEX ].fpgaErrorOccurredStartTime = 0; + fpgaPersistentAlarmGroup[ group ].fpgaAlarmData[ FPGA_ERROR_ALARM_INDEX ].fpgaPreviousCount = 0; + } } /*********************************************************************//** * @brief * The isPersistentAlarmTriggered function checks if the error condition has - * persisted for given time limit. - * @details Inputs: persistentAlarms[] - * @details Outputs: none - * @param alarmId Alarm id - * @param isErrorOccurred Flag indicates error condition is occurring or not - * @return TRUE if error condition persisted over given time limit, FALSE if not + * persisted long enough to meet its trigger persistence time. + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if given alarm ID is invalid. + * @details \b Inputs: persistentAlarms[] + * @details \b Outputs: none + * @param alarmId ID of alarm to check persistence for + * @param isErrorOccurred has alarm criteria otherwise been met (T/F) + * @return TRUE if error condition has persisted long enough to be triggered, FALSE if not *************************************************************************/ BOOL isPersistentAlarmTriggered( ALARM_ID_T alarmId, BOOL const isErrorOccurred ) { @@ -173,7 +176,7 @@ if ( TRUE == isErrorOccurred ) { - isAlarmTriggered = didTimeout( persistentAlarms[ alarmId ].errorOccurredStartTime, persistentAlarms[ alarmId ].persistentTriggerPeriod ); + isAlarmTriggered = didTimeout( persistentAlarms[ alarmId ].errorOccurredStartTime, persistentAlarms[ alarmId ].persistentTriggerPeriod_ms ); } else { @@ -182,11 +185,15 @@ } else { +#ifdef _TD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_PERSISTENT_ALARM_INVALID_INDEX2, alarmId ); +#endif #ifdef _DD_ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_PERSISTENT_ALARM_INVALID_INDEX2, alarmId ); -#else - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_PERSISTENT_ALARM_INVALID_INDEX2, alarmId ); #endif +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_PERSISTENT_ALARM_INVALID_INDEX2, alarmId ); +#endif } return isAlarmTriggered; @@ -195,12 +202,13 @@ /*********************************************************************//** * @brief * The isPersistentAlarmConditionCleared function checks if the error condition has - * been cleared for given time limit. - * @details Inputs: persistentAlarms[] - * @details Outputs: none - * @param alarmId Alarm id - * @param isErrorOccurred Flag indicates error condition is occurring or not - * @return TRUE if error condition has been cleared over given time limit, FALSE if not + * been cleared long enough to clear the alarm condition. + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if given alarm ID is invalid. + * @details \b Inputs: persistentAlarms[] + * @details \b Outputs: persistentAlarms[] + * @param alarmId AD of alarm to check clear persistence for + * @param isErrorOccurred Flag indicates whether error condition is occurring or not + * @return TRUE if error condition has been cleared long enough to clear the condition, FALSE if not *************************************************************************/ BOOL isPersistentAlarmConditionCleared( ALARM_ID_T alarmId, BOOL const isErrorOccurred ) { @@ -216,7 +224,7 @@ if ( FALSE == isErrorOccurred ) { - isErrorConditionCleared = didTimeout( persistentAlarms[ alarmId ].errorClearedStartTime, persistentAlarms[ alarmId ].persistentClearPeriod ); + isErrorConditionCleared = didTimeout( persistentAlarms[ alarmId ].errorClearedStartTime, persistentAlarms[ alarmId ].persistentClearPeriod_ms ); } else { @@ -225,11 +233,14 @@ } else { +#ifdef _TD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_PERSISTENT_ALARM_INVALID_INDEX3, alarmId ) +#endif #ifdef _DD_ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_PERSISTENT_ALARM_INVALID_INDEX3, alarmId ) #endif -#ifdef _TD_ - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_PERSISTENT_ALARM_INVALID_INDEX3, alarmId ) +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_PERSISTENT_ALARM_INVALID_INDEX3, alarmId ) #endif } @@ -238,20 +249,20 @@ /*********************************************************************//** * @brief - * The checkPersistentAlarm function triggers/clears an alarm if an alarm condition - * has persisted/cleared over given time limit. - * @details Inputs: none - * @details Outputs: checks whether an alarm is triggered or an alarm condition is cleared - * @param alarmID ID of alarm to check - * @param isErrorOccured Flag indicates alarm condition is active or not + * The checkPersistentAlarm function triggers or clears an alarm if an alarm condition + * has persisted or been cleared long enough to meet the persistence time. + * @details \b Alarm: given alarm is triggered if trigger persistence period elapsed + * @details \b Alarm: given alarm condition is cleared if clear persistence period elapsed + * @details \b Inputs: none + * @details \b Outputs: checks whether an alarm is triggered or an alarm condition is cleared + * @param alarmID ID of alarm to check persistence for + * @param isErrorOccured Flag indicates whether alarm condition is active or not * @param data alarm data * @param limit alarm condition limit - * @return TRUE if given alarm is active, FALSE if not + * @return none *************************************************************************/ -BOOL checkPersistentAlarm( ALARM_ID_T alarm, BOOL isErrorOccured, F32 data, F32 limit ) +void checkPersistentAlarm( ALARM_ID_T alarm, BOOL isErrorOccured, F32 data, F32 limit ) { - BOOL status = FALSE; - if ( TRUE == isPersistentAlarmTriggered( alarm, isErrorOccured ) ) { SET_ALARM_WITH_2_F32_DATA( alarm, data, limit ); @@ -260,19 +271,15 @@ if ( TRUE == isPersistentAlarmConditionCleared( alarm, isErrorOccured ) ) { clearAlarmCondition( alarm ); - status = TRUE; } - - return status; } /*********************************************************************//** * @brief - * The resetPersistentAlarmTimer function resets the start time for error - * condition clear start time and error start time. - * @details Inputs: none - * @details Outputs: reset condition clear start time and error occur start time - * @param alarmId Alarm id of the alarm to reset timer + * The resetPersistentAlarmTimer function resets the timing for a given alarm. + * @details \b Inputs: none + * @details \b Outputs: persistentAlarms[] + * @param alarmId ID of alarm to reset persistence for * @return none *************************************************************************/ void resetPersistentAlarmTimer( ALARM_ID_T alarmId ) @@ -283,13 +290,15 @@ /*********************************************************************//** * @brief - * The checkFPGAPersistentAlarms function checks the FPGA persistent alarm - * status of the provided FPGA persistent alarm group. - * @details Inputs: fpgaPersistentAlarmGroup - * @details Outputs: fpgaPersistentAlarmGroup - * @param alarmGroup which is the alarm group of the persistent alarm - * (i.e. 2-wire temperature sensor) - * @param readCount which is the FPGA read count of the sensor group + * The checkFPGAPersistentAlarms function checks the FPGA persistent + * read count of the provided FPGA persistent sensor group. + * @details \b Alarm: Alarm associated with given FPGA alarm group triggered + * if given sensor has not been read since last check. + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if given FPGA sensor group is invalid. + * @details \b Inputs: fpgaPersistentAlarmGroup + * @details \b Outputs: fpgaPersistentAlarmGroup + * @param alarmGroup ID of FPGA sensor group to check + * @param readCount Current read count reported by FPGA * @return none *************************************************************************/ void checkFPGAPersistentAlarms( FPGA_PERSISTENT_ALARMS_GROUP_T group, U32 readCount ) @@ -306,24 +315,29 @@ } else { +#ifdef _TD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_FPGA_SENSOR_GROUP_SELECTED1, (U32)group ) +#endif #ifdef _DD_ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_FPGA_SENSOR_GROUP_SELECTED1, (U32)group ) #endif -#ifdef _TD_ - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_FPGA_SENSOR_GROUP_SELECTED1, (U32)group ) +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_FPGA_SENSOR_GROUP_SELECTED1, (U32)group ) #endif } } /*********************************************************************//** * @brief * The checkFPGAPersistentErrorCountAlarm function checks the FPGA persistent - * error count alarm status of the provided FPGA persistent alarm group. - * @details Inputs: fpgaPersistentAlarmGroup - * @details Outputs: none - * @param alarmGroup which is the alarm group of the persistent alarm - * (i.e. 2-wire temperature sensor) - * @param errorCount which is the FPGA error count of the sensor group + * error count of the provided FPGA persistent sensor group. + * @details \b Alarm: Alarm associated with given FPGA alarm group triggered + * if error count changes or read count does not change since last read. + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if given FPGA alarm group is invalid. + * @details \b Inputs: fpgaPersistentAlarmGroup + * @details \b Outputs: none + * @param alarmGroup ID of FPGA sensor group to check counts for + * @param errorCount Current error count reported by FPGA * @return none *************************************************************************/ void checkFPGAPersistentErrorCountAlarm( FPGA_PERSISTENT_ALARMS_GROUP_T group, U32 errorCount ) @@ -339,26 +353,29 @@ } else { +#ifdef _TD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_FPGA_SENSOR_GROUP_SELECTED2, (U32)group ) +#endif #ifdef _DD_ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_FPGA_SENSOR_GROUP_SELECTED2, (U32)group ) #endif -#ifdef _TD_ - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_FPGA_SENSOR_GROUP_SELECTED2, (U32)group ) +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_FPGA_SENSOR_GROUP_SELECTED2, (U32)group ) #endif } } /*********************************************************************//** * @brief - * The isFPGAPersistentAlarmTriggered function checks whether persistent alarm - * has been triggered or not. - * @details Inputs: alarmGroup - * @details Outputs: alarmGroup - * @param alarmGroup which is the alarm group of the persistent alarm - * (i.e. 2-wire temperature sensor) - * @param fpgaCount which is the FPGA count of the sensor group - * @param errorType which is the FPGA error type (i.e. read or error count) - * @return TRUE if the persistent alarm is triggered otherwise, FALSE + * The isFPGAPersistentAlarmTriggered function checks whether a given FPGA sensor + * group has stopped reading or reported a new error (depending on given error type). + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given FPGA error type is invalid. + * @details \b Inputs: none + * @details \b Outputs: none + * @param alarmGroup ID of FPGA sensor group to report error status for + * @param fpgaCount Current error or read count for FPGA sensor group + * @param errorType The type of error status being requested (error or failure to read) + * @return TRUE if the given error type is detected, otherwise FALSE *************************************************************************/ static BOOL isFPGAPersistentAlarmTriggered( FPGA_PERSISTENT_ALARM_GROUP_T* alarmGroup, U32 fpgaCount, FPGA_ERROR_TYPE_T errorType ) { @@ -376,11 +393,14 @@ break; default: +#ifdef _TD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_FPGA_SENSOR_GROUP_SELECTED3, errorType ) +#endif #ifdef _DD_ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_FPGA_SENSOR_GROUP_SELECTED3, errorType ) #endif -#ifdef _TD_ - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_FPGA_SENSOR_GROUP_SELECTED3, errorType ) +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_FPGA_SENSOR_GROUP_SELECTED3, errorType ) #endif break; } @@ -392,7 +412,7 @@ alarmGroup->fpgaAlarmData[ errorType ].fpgaIsConditionClear = FALSE; alarmGroup->fpgaAlarmData[ errorType ].fpgaErrorOccurredStartTime = getMSTimerCount(); } - else if ( TRUE == didTimeout( alarmGroup->fpgaAlarmData[ errorType ].fpgaErrorOccurredStartTime, alarmGroup->fpgaPersistentTriggerPeriod ) ) + else if ( TRUE == didTimeout( alarmGroup->fpgaAlarmData[ errorType ].fpgaErrorOccurredStartTime, alarmGroup->fpgaPersistentTriggerPeriod_ms ) ) { isPersistentTriggered = TRUE; } Index: PersistentAlarm.h =================================================================== diff -u -r6d80d69a210f45c733e5307859351f2cd820a8e7 -r9512aac6feeb1379d6d425361fa78d58f75c86f6 --- PersistentAlarm.h (.../PersistentAlarm.h) (revision 6d80d69a210f45c733e5307859351f2cd820a8e7) +++ PersistentAlarm.h (.../PersistentAlarm.h) (revision 9512aac6feeb1379d6d425361fa78d58f75c86f6) @@ -22,8 +22,8 @@ /** * @defgroup PersistentAlarm PersistentAlarm - * @brief Persistent alarm monitor module. - * Check for persistent error and return indication on whether alarm is triggered or alarm condition is cleared. + * @brief Persistent alarms unit. + * Provides functions that add persistence to alarm criteria. * * @addtogroup PersistentAlarm * @{ @@ -53,24 +53,21 @@ /// FPGA persistent alarm groups data structure typedef enum { - FPGA_PERS_ERROR_OCCLUSION_PRESSURE_SENSOR = 0, ///< FPGA persistent error occlusion pressure sensor. - FPGA_PERS_ERROR_ARTERIAL_PRESSURE_SENSOR, ///< FPGA persistent error arterial pressure sensor. + FPGA_PERS_ERROR_ARTERIAL_PRESSURE_SENSOR = 0, ///< FPGA persistent error arterial pressure sensor. FPGA_PERS_ERROR_VENOUS_PRESSURE_SESNOR, ///< FPGA persistent error venous pressure sensor. FPGA_PERS_ERROR_SYRINGE_PUMP_ADC, ///< FPGA persistent error syringe pump ADC. - NUM_OF_FPGA_SENSOR_GROUPS ///< Number of FPGA sensor groups. + NUM_OF_FPGA_SENSOR_GROUPS ///< Number of FPGA persistent error sensor groups. } FPGA_PERSISTENT_ALARMS_GROUP_T; #endif // ********** public function prototypes ********** -// Persistent period resolution is in ms void initPersistentAlarm( ALARM_ID_T alarmIndex, U32 persistentClearPeriod, U32 persistentTriggerPeriod ); - void initFPGAPersistentAlarm( FPGA_PERSISTENT_ALARMS_GROUP_T group, ALARM_ID_T alarmIndex, U32 persistentClearPeriod, U32 persistentTriggerPeriod ); BOOL isPersistentAlarmTriggered( ALARM_ID_T alarmIndex, BOOL const isErrorOccurred ); BOOL isPersistentAlarmConditionCleared( ALARM_ID_T alarmIndex, BOOL const isErrorOccurred ); -BOOL checkPersistentAlarm( ALARM_ID_T alarm, BOOL isErrorOccured, F32 data, F32 limit ); +void checkPersistentAlarm( ALARM_ID_T alarm, BOOL isErrorOccured, F32 data, F32 limit ); void resetPersistentAlarmTimer( ALARM_ID_T alarmId ); void checkFPGAPersistentAlarms( FPGA_PERSISTENT_ALARMS_GROUP_T group, U32 readCount );