Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rebbb1f85550a1f9b8f946655f7b2b63f76fbf67d -r5a36a768d11cc597a36b894c1fb3a5e5590130f1 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision ebbb1f85550a1f9b8f946655f7b2b63f76fbf67d) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 5a36a768d11cc597a36b894c1fb3a5e5590130f1) @@ -23,6 +23,7 @@ #include "FPGA.h" #include "Comm.h" +#include "Compatible.h" #include "SystemCommMessages.h" #include "Utilities.h" @@ -46,7 +47,7 @@ } FPGA_STATE_T; #define FPGA_PAGE_SIZE 256 ///< FPGA page size. -#define FPGA_EXPECTED_ID 0x60 ///< FPGA expected ID. +#define FPGA_EXPECTED_ID 0x61 ///< FPGA expected ID. #define FPGA_HEADER_START_ADDR 0x0000 ///< FPGA header start address. #define FPGA_BULK_READ_START_ADDR 0x0100 ///< FPGA bulk read start address. @@ -106,8 +107,8 @@ U32 fpgaTPiTemp; ///< Reg 292. ADC RTD channel 3 - conductivity sensor CPi temperature U32 fpgaRTDTemp; ///< Reg 296. ADC RTD channel 4 - internal temperature - U32 fpgaTHDo; ///< Reg 300. ADC THDo channel 0 - temperature - U32 fpgaTHDoTemp; ///< Reg 304. ADC THDo channel 1 - internal temperature + U32 fpgaTRo; ///< Reg 300. ADC TRo channel 0 - temperature + U32 fpgaTRoTemp; ///< Reg 304. ADC TRo channel 1 - internal temperature U32 fpgaTDi; ///< Reg 308. ADC TDi channel 0 - temperature U32 fpgaTDiTemp; ///< Reg 312. ADC TDi channel 1 - internal temperature @@ -140,8 +141,8 @@ U08 fpgaADC2ErrorCnt; ///< Reg 357. U08 fpgaRTDReadCnt; ///< Reg 358. Temperature sensors read count U08 fpgaRTDErrorCnt; ///< Reg 359. Temperature sensors error count - U08 fpgaTHDoReadCnt; ///< Reg 360. Redundant outlet temperature sensor read count - U08 fpgaTHDoErrorCnt; ///< Reg 361. Redundant outlet temperature sensor error count + U08 fpgaTRoReadCnt; ///< Reg 360. Redundant outlet temperature sensor read count + U08 fpgaTRoErrorCnt; ///< Reg 361. Redundant outlet temperature sensor error count U08 fpgaTDiReadCnt; ///< Reg 362. Dialysate inlet temperature sensor read count U08 fpgaTDiErrorCnt; ///< Reg 363. Dialysate inlet temperature sensor error count U08 fpgaPrimaryHeaterFlags; ///< Reg 364. Primary heater flags @@ -176,7 +177,7 @@ U16 fpgaFanOut2Pulse; ///< Reg 398. Fan outlet 2 pulse time in 2.5 resolution U16 fpgaFanIn3Pulse; ///< Reg 400. Fan inlet 3 pulse time in 2.5 resolution U16 fpgaFanOut3Pulse; ///< Reg 402. Fan outlet 3 pulse time in 2.5 resolution - + U16 fpgaTimerCount_ms; ///< Reg 404. Internal FPGA timer count in ms. } DG_FPGA_SENSORS_T; typedef struct @@ -466,10 +467,15 @@ break; } - // if retries for commands exceeds limit, fault - if ( fpgaCommRetryCount > MAX_COMM_ERROR_RETRIES ) + // if retries for commands exceeds limit or FPGA reports comm error, fault + if ( ( fpgaCommRetryCount > MAX_COMM_ERROR_RETRIES ) +#ifdef _RELEASE_ + || ( fpgaSensorReadings.fpgaIOErrorCntProcessor > MAX_COMM_ERROR_RETRIES ) ) +#else + ) +#endif { - // TODO - FPGA comm fault + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_FPGA_COMM_TIMEOUT, fpgaCommRetryCount, (U32)fpgaSensorReadings.fpgaIOErrorCntProcessor ) } // reset comm flags after processing incoming responses @@ -722,12 +728,28 @@ if ( 1 ) #endif { - result = SELF_TEST_STATUS_PASSED; + // Check FPGA compatibility w/ firmware + if ( fpgaHeader.fpgaRevMajor > MIN_DG_FPGA_MAJOR ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + if ( ( MIN_DG_FPGA_MAJOR == fpgaHeader.fpgaRevMajor ) && ( fpgaHeader.fpgaRevMinor >= MIN_DG_FPGA_MINOR ) ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_FPGA_POST_TEST_FAILED, (U32)fpgaHeader.fpgaRevMajor, (U32)fpgaHeader.fpgaRevMinor ) + } + } } else { result = SELF_TEST_STATUS_FAILED; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_FPGA_POST_TEST_FAILED, (U32)fpgaHeader.fpgaId ) + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_FPGA_POST_TEST_FAILED, (U32)fpgaHeader.fpgaId ) } return result; @@ -1047,49 +1069,57 @@ /*********************************************************************//** * @brief * The getFPGALoadCellA1 function gets the latest load cell A 1 reading. + * Least significant 24 bits are the reading. Most significant bit indicates + * CRC or status error. * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last load cell A 1 reading *************************************************************************/ U32 getFPGALoadCellA1( void ) { - return ( fpgaSensorReadings.fpgaLCA1 & MASK_OFF_U32_MSB ); + return fpgaSensorReadings.fpgaLCA1; } /*********************************************************************//** * @brief * The getFPGALoadCellA2 function gets the latest load cell A 2 reading. + * Least significant 24 bits are the reading. Most significant bit indicates + * CRC or status error. * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last load cell A 2 reading *************************************************************************/ U32 getFPGALoadCellA2( void ) { - return ( fpgaSensorReadings.fpgaLCA2 & MASK_OFF_U32_MSB ); + return fpgaSensorReadings.fpgaLCA2; } /*********************************************************************//** * @brief * The getFPGALoadCellB1 function gets the latest load cell B 1 reading. + * Least significant 24 bits are the reading. Most significant bit indicates + * CRC or status error. * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last load cell B 1 reading *************************************************************************/ U32 getFPGALoadCellB1( void ) { - return ( fpgaSensorReadings.fpgaLCB1 & MASK_OFF_U32_MSB ); + return fpgaSensorReadings.fpgaLCB1; } /*********************************************************************//** * @brief * The getFPGALoadCellB2 function gets the latest load cell B 2 reading. + * Least significant 24 bits are the reading. Most significant bit indicates + * CRC or status error. * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last load cell B 2 reading *************************************************************************/ U32 getFPGALoadCellB2( void ) { - return ( fpgaSensorReadings.fpgaLCB2 & MASK_OFF_U32_MSB ); + return fpgaSensorReadings.fpgaLCB2; } /*********************************************************************//** @@ -1210,37 +1240,37 @@ * @brief * The getFPGATRoTemp function gets the latest redundant sensor outlet * temperature reading in ADC. - * @details Inputs: fpgaSensorReadings.fpgaTHDoTemp + * @details Inputs: fpgaSensorReadings.fpgaTRo * @details Outputs: none * @return Last redundant sensor outlet temperature reading *************************************************************************/ -U32 getFPGATHDoTemp( void ) +U32 getFPGATRoTemp( void ) { - return fpgaSensorReadings.fpgaTHDo; + return fpgaSensorReadings.fpgaTRo; } /*********************************************************************//** * @brief - * The getFPGATHDoErrorCount gets the error count of the THDo (redundant) temperature sensor. - * @details Inputs: fpgaSensorReadings.fpgaTHDoErrorCnt + * The getFPGATRoErrorCount gets the error count of the THDo (redundant) temperature sensor. + * @details Inputs: fpgaSensorReadings.fpgaTRoErrorCnt * @details Outputs: none * @return Last redundant sensor outlet temperature error count *************************************************************************/ -U08 getFPGATHDoErrorCount( void ) +U08 getFPGATRoErrorCount( void ) { - return fpgaSensorReadings.fpgaTHDoErrorCnt; + return fpgaSensorReadings.fpgaTRoErrorCnt; } /*********************************************************************//** * @brief - * The getFPGATHDoReadCount gets the read count of the THDo (redundant) temperature sensor. - * @details Inputs: fpgaSensorReadings.fpgaTHDoReadCnt + * The getFPGATRoReadCount gets the read count of the THDo (redundant) temperature sensor. + * @details Inputs: fpgaSensorReadings.fpgaTRoReadCnt * @details Outputs: none * @return Last redundant sensor outlet temperature error count reading *************************************************************************/ -U08 getFPGATHDoReadCount( void ) +U08 getFPGATRoReadCount( void ) { - return fpgaSensorReadings.fpgaTHDoReadCnt; + return fpgaSensorReadings.fpgaTRoReadCnt; } /*********************************************************************//** @@ -1703,14 +1733,14 @@ /*********************************************************************//** * @brief - * The getFPGATHDoInternalTemp function gets THDo internal temperature reading. + * The getFPGATRoInternalTemp function gets TRo internal temperature reading. * @details Inputs: fpgaSensorReadings * @details Outputs: none - * @return THDo internal temperature reading in ADC counts + * @return TRo internal temperature reading in ADC counts *************************************************************************/ -U32 getFPGATHDoInternalTemp( void ) +U32 getFPGATRoInternalTemp( void ) { - return fpgaSensorReadings.fpgaTHDoTemp; + return fpgaSensorReadings.fpgaTRoTemp; } /*********************************************************************//** @@ -1788,6 +1818,18 @@ /*********************************************************************//** * @brief + * The getFPGATimerCount function gets the latest FPGA timer millisecond count. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last FPGA timer count + *************************************************************************/ +U16 getFPGATimerCount( void ) +{ + return fpgaSensorReadings.fpgaTimerCount_ms; +} + +/*********************************************************************//** + * @brief * The noFluidLeakDetected function returns TRUE if no fluid leak has been * detected (dry) and FALSE if a fluid leak has been detected (wet). * @details Inputs: fpgaSensorReadings