Index: Common.h =================================================================== diff -u -re8828d66e4a76e0590c3f06b7f6235f33df64e80 -rb6692fc38b400e9f2c12520fcadc2438e5a31e36 --- Common.h (.../Common.h) (revision e8828d66e4a76e0590c3f06b7f6235f33df64e80) +++ Common.h (.../Common.h) (revision b6692fc38b400e9f2c12520fcadc2438e5a31e36) @@ -105,6 +105,7 @@ #define SEC_PER_MIN 60 ///< # of seconds in a minute. #define FRACTION_TO_PERCENT_FACTOR 100.0 ///< Percentage factor (100). #define MIN_PER_HOUR 60 ///< # of minutes in an hour. +#define PI 3.1415927 ///< PI. // **** Common Macros **** @@ -126,6 +127,7 @@ #define MAKE_LONG_OF_WORDS(h, l) ((((U32)(h) << SHIFT_16_BITS_FOR_WORD_SHIFT) & MASK_OFF_LSW) | ((U32)(l) & MASK_OFF_MSW)) ///< Macro merges two 2-byte words into a 4-byte word. #define GET_TOGGLE(v, l, h) ((v) == (l) ? (h) : (l)) ///< Macro toggles a value. #define BIT_BY_POS(p) (1U << (p)) ///< Macro returns a bit mask for a bit of given position. +#define RAD2DEG(r) ((r) * 180.0 / PI) ///< Macro converts radians to degrees /**@}*/ Index: NVDataMgmt.c =================================================================== diff -u -re8828d66e4a76e0590c3f06b7f6235f33df64e80 -rb6692fc38b400e9f2c12520fcadc2438e5a31e36 --- NVDataMgmt.c (.../NVDataMgmt.c) (revision e8828d66e4a76e0590c3f06b7f6235f33df64e80) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision b6692fc38b400e9f2c12520fcadc2438e5a31e36) @@ -72,7 +72,7 @@ #define LAST_DISINFECTION_DATE_ADDRESS 0x00000060 // 96 ///< Last disinfection date start address in RTC RAM (96) // Data addresses in EEPROM -#define CALIBRATION_RECORD_START_ADDRESS (BANK7_SECTOR0_START_ADDRESS + 0x100) ///< Calibration record start address in EEPROM +#define CALIBRATION_RECORD_START_ADDRESS ( BANK7_SECTOR0_START_ADDRESS + sizeof(MFG_RECORD_T) ) ///< Calibration record start address in EEPROM #define COMMAND_TIME_OUT 500U // time in ms ///< Timeout for an EEPROM or RTC command in ms @@ -172,6 +172,7 @@ { MFG_DATA_T mfgData; ///< Manufacturing data struct U16 crc; ///< Manufacturing data CRC + U08 Padding[ 0x400 - sizeof(MFG_DATA_T) - sizeof(U16) ]; ///< } MFG_RECORD_T; /// Service record struct @@ -186,6 +187,7 @@ { CALIBRATION_DATA_T calData; ///< Calibration data struct U16 crc; ///< Calibration data CRC + U08 Padding[ 0x400 - sizeof(CALIBRATION_DATA_T) - sizeof(U16) ]; ///< } CALIBRATION_RECORD_T; /// Last disinfection record struct @@ -216,6 +218,7 @@ static U32 bootloaderFlag = 0; ///< Bootloader flag static BOOL hasCommandTimedout = FALSE; ///< Boolean flag for timeout of the commands static U32 currentTime = 0; ///< Current time +static BOOL calRecordIsValid = FALSE; ///< Flag indicates whether stored calibration record was found to be valid // Private functions @@ -358,7 +361,7 @@ { BOOL status = FALSE; - if ( buffer != NULL ) + if ( ( buffer != NULL ) && ( TRUE == calRecordIsValid ) ) { memcpy ( buffer, (U08*)&calibrationRecord.calData, sizeof(CALIBRATION_DATA_T) ); status = TRUE; @@ -1098,11 +1101,13 @@ #ifdef _HD_ calcCRC = crc16 ( (U08*)&treatmentTimeRecord.treatmentTime, sizeof(U32) ); recordCRC = treatmentTimeRecord.crc; +#ifndef LIMITED_NVDATA_CRC_CHECKS if ( calcCRC != recordCRC ) { hasCRCPassed = FALSE; SET_ALARM_WITH_2_U32_DATA( ALARM_ID_NVDATA_HW_USAGE_DATA_CRC_ERROR, recordCRC, calcCRC ); } +#endif #else calcCRC = crc16 ( (U08*)&waterConsumptionRecord.waterConsumption, sizeof(U32) ); recordCRC = waterConsumptionRecord.crc; @@ -1120,6 +1125,7 @@ SET_ALARM_WITH_2_U32_DATA( AlARM_ID_NVDATA_DISINFECTION_DATE_CRC_ERROR, recordCRC, calcCRC ); } #endif +#ifndef LIMITED_NVDATA_CRC_CHECKS // Check log header record calcCRC = crc16 ( (U08*)&logRecord.logHeader, sizeof(LOG_HEADER_T) ); recordCRC = logRecord.crc; @@ -1143,6 +1149,7 @@ hasCRCPassed = FALSE; SET_ALARM_WITH_2_U32_DATA( ALARM_ID_NVDATA_MFG_RECORD_CRC_ERROR, recordCRC, calcCRC ); } +#endif // Check CRC for calibration record calcCRC = crc16 ( (U08*)&calibrationRecord.calData, sizeof(CALIBRATION_DATA_T) ); recordCRC = calibrationRecord.crc; @@ -1151,6 +1158,11 @@ hasCRCPassed = FALSE; SET_ALARM_WITH_2_U32_DATA( ALARM_ID_NVDATA_CAL_RECORD_CRC_ERROR, recordCRC, calcCRC ); } + else + { + calRecordIsValid = TRUE; + } +#ifndef LIMITED_NVDATA_CRC_CHECKS // Check CRC for service record calcCRC = crc16 ( (U08*)&serviceRecord.serviceData, sizeof(SERVICE_DATA_T) ); recordCRC = serviceRecord.crc; @@ -1159,8 +1171,8 @@ hasCRCPassed = FALSE; SET_ALARM_WITH_2_U32_DATA( ALARM_ID_NVDATA_SRVC_RECORD_CRC_ERROR, recordCRC, calcCRC ); } - // There should be no failed CRCs or no command should - // timeout for the self test to pass +#endif + // There should be no failed CRCs and no command should timeout for the self test to pass if ( hasCRCPassed && !hasCommandTimedout ) { NVDataMgmtSelfTestResult = SELF_TEST_STATUS_PASSED; Index: NVDataMgmt.h =================================================================== diff -u -re8828d66e4a76e0590c3f06b7f6235f33df64e80 -rb6692fc38b400e9f2c12520fcadc2438e5a31e36 --- NVDataMgmt.h (.../NVDataMgmt.h) (revision e8828d66e4a76e0590c3f06b7f6235f33df64e80) +++ NVDataMgmt.h (.../NVDataMgmt.h) (revision b6692fc38b400e9f2c12520fcadc2438e5a31e36) @@ -20,6 +20,8 @@ #include "Common.h" +// ********** public definitions ********** + #define MAX_SYS_SERIAL_NUMBER_CHARACTERS 7U ///< Max number of characters for SYS serial number #define MAX_HW_SERIAL_NUMBER_CHARACTERS 5U ///< Max number of characters for HD serial number #define MAX_DATE_CHARACTERS 10U ///< Max number of characters for date @@ -53,21 +55,31 @@ char mfgDate [ MAX_DATE_CHARACTERS ]; ///< Manufacturing date } MFG_DATA_T; +/// Calibration data struct +typedef struct calibration_Data +{ + U32 calRecordRevision; ///< Revision of calibration record (rev when structure changes to determine compatibility with f/w version) + S32 accelXOffset; ///< Accelerometer X axis offset + S32 accelYOffset; ///< Accelerometer Y axis offset + S32 accelZOffset; ///< Accelerometer Z axis offset +#ifdef _HD_ + F32 bloodFlowGain; ///< Gain for blood flow sensor + F32 bloodFlowOffset_mL_min; ///< Offset for blood flow sensor + char calDateBloodFlow[ MAX_DATE_CHARACTERS ]; ///< Last calibration date of blood flow sensor + F32 dialysateFlowGain; ///< + F32 dialysateFlowOffset_mL_min; ///< + char calDateDialysateFlow[ MAX_DATE_CHARACTERS ]; ///< Last calibration date of blood flow sensor +#endif + U16 crc; ///< CRC for this calibration record +} CALIBRATION_DATA_T; + /// Service dates struct typedef struct service_dates { char currentServiceDate [ MAX_DATE_CHARACTERS ]; ///< Current service date char nextServiceDate [ MAX_DATE_CHARACTERS ]; ///< Next service date } SERVICE_DATA_T; -/// Calibration data struct -typedef struct calibration_Data -{ - F32 occSensorOffset; ///< Item 1 - F32 tempSensorOffset; ///< Item 2 - char calibrationDate [ MAX_DATE_CHARACTERS ]; ///< Calibration date -} CALIBRATION_DATA_T; - /// Read data status typedef struct get_data { Index: Utilities.h =================================================================== diff -u -re8828d66e4a76e0590c3f06b7f6235f33df64e80 -rb6692fc38b400e9f2c12520fcadc2438e5a31e36 --- Utilities.h (.../Utilities.h) (revision e8828d66e4a76e0590c3f06b7f6235f33df64e80) +++ Utilities.h (.../Utilities.h) (revision b6692fc38b400e9f2c12520fcadc2438e5a31e36) @@ -33,13 +33,13 @@ /// Enumeration of time-windowed counts. typedef enum TimeWindowedCounts { - TIME_WINDOWED_COUNT_BAD_MSG_CRC = 0, ///< Bad message CRC. - TIME_WINDOWED_COUNT_CAN_WARNING, ///< CAN warning. - TIME_WINDOWED_COUNT_CAN_PASSIVE, ///< CAN passive mode. - TIME_WINDOWED_COUNT_CAN_OFF, ///< CAN off. - TIME_WINDOWED_COUNT_CAN_PARITY, ///< CAN parity error. - TIME_WINDOWED_COUNT_FPGA_UART_FRAME_ERROR, ///< FPGA UART frame error. - TIME_WINDOWED_COUNT_FPGA_UART_OVERRUN, ///< FPGA UART overrun error. + TIME_WINDOWED_COUNT_BAD_MSG_CRC = 0, ///< Bad message CRC + TIME_WINDOWED_COUNT_CAN_WARNING, ///< CAN warning + TIME_WINDOWED_COUNT_CAN_PASSIVE, ///< CAN passive mode + TIME_WINDOWED_COUNT_CAN_OFF, ///< CAN off + TIME_WINDOWED_COUNT_CAN_PARITY, ///< CAN parity error + TIME_WINDOWED_COUNT_FPGA_UART_FRAME_ERROR, ///< FPGA UART frame error + TIME_WINDOWED_COUNT_FPGA_UART_OVERRUN, ///< FPGA UART overrun error #ifdef _HD_ #endif #ifdef _DG_