Index: NVDataMgmt.c =================================================================== diff -u -rb840bc23aace9db7e7949aed313c4c315966aabd -rff5e595afd7ad79dd7693dfa598b24fdeacad95d --- NVDataMgmt.c (.../NVDataMgmt.c) (revision b840bc23aace9db7e7949aed313c4c315966aabd) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision ff5e595afd7ad79dd7693dfa598b24fdeacad95d) @@ -18,7 +18,7 @@ // Includes #include // For memcpy -#include // For ceil function +#include // For ceilf function #include "system.h" #include "F021.h" @@ -75,21 +75,18 @@ #define MAX_NUM_OF_EVENTS_IN_SECTOR1 ((MAX_NUM_OF_SECTORS_FOR_LOG_DATA - 2) * MAX_LOG_DATA_PER_SECTOR) ///< Max number of accumulated logs in sector 1 (512). // Data addresses and length in RTC RAM -#define BOOTLOADER_FLAG_ADDRESS 0x00000000 ///< Bootloader start address in RTC RAM (0). -#define BOOTLOADER_FLAG_LENGTH_BYTES 4U ///< Bootloader number of bytes (4 bytes). -#define LOG_RECORD_START_ADDRESS 0x00000010 // 16 ///< Log record start address in RTC RAM (16). -#define HD_TREATMENT_TIME_ADDRESS 0X00000030 // 48 ///< HD treatment time start address in RTC RAM (48). -#define DG_CONSUMED_WATER_ADDRESS 0X00000040 // 64 ///< DG water consumption start address in RTC RAM (64). -#define SERVICE_RECORD_START_ADDRESS 0X00000050 // 80 ///< Last service date record start address in RTC RAM (HD/DG) (80). -#define LAST_DISINFECTION_DATE_ADDRESS 0x00000060 // 96 //TODO remove ///< Last disinfection date start address in RTC RAM (96). -#define DG_SCHEDULED_RUNS_START_ADDRESS 0x00000070 // 112 ///< DG scheduler record start address in RTC RAM (112). +#define LOG_RECORD_START_ADDRESS 0x00000000 // 0 ///< Log record start address in RTC RAM (0). +#define HD_TREATMENT_TIME_ADDRESS 0x00000010 // 16 ///< HD treatment time start address in RTC RAM (16). +#define DG_CONSUMED_WATER_ADDRESS 0x00000020 // 32 ///< DG water consumption start address in RTC RAM (32). +#define SERVICE_RECORD_START_ADDRESS 0x00000030 // 48 ///< Service date record start address in RTC RAM (HD/DG) (48). +#define DG_SCHEDULED_RUNS_START_ADDRESS (SERVICE_RECORD_START_ADDRESS + MAX_RTC_RAM_OPS_BUFFER_BYTES) ///< DG scheduled runs start address in RTC RAM. // Data addresses in EEPROM -#define CALIBRATION_RECORD_START_ADDRESS ( BANK7_SECTOR0_START_ADDRESS + sizeof(MFG_RECORD_T) ) ///< Calibration record start address in EEPROM. +#define CALIBRATION_RECORD_START_ADDRESS (BANK7_SECTOR0_START_ADDRESS + sizeof(MFG_RECORD_T)) //TODO remove ///< Calibration record start address in EEPROM. -#define COMMAND_TIME_OUT 500U // time in ms ///< Timeout for an EEPROM or RTC command in ms. +#define COMMAND_TIME_OUT 500U ///< Timeout for an EEPROM or RTC command in ms. -#define ERASE_CALIBRATION_KEY 0xD2C3B4A5 ///< 32-bit key required for clearing calibration data. +#define ERASE_CALIBRATION_KEY 0xD2C3B4A5 ///< 32-bit key required for clearing calibration data. // ********** Calibration data defines ********** #define NUM_OF_BYTES_PER_CAL_PAYLOAD 150U ///< Number of bytes per calibration payload. @@ -99,10 +96,10 @@ #define RECORD_DATA_FIRST_RECEIVING_MSG_NUM 1 ///< Calibration data first receiving message number. #define SYSTEM_DATA_NV_MEM_START_ADDRESS BANK7_SECTOR0_START_ADDRESS + 2048 ///< System record storage start address in NV memory. -#define RECORD_BYTE_SIZE(r) ( sizeof(r) + sizeof(U16) ) ///< Record byte size macro. +#define RECORD_BYTE_SIZE(r) (sizeof(r) + sizeof(U16)) ///< Record byte size macro. // Padding length calculation: (DG struct size % bytes to write(16) == 0 ? 0 : (DG struct size / bytes to write(16)) + 1) * bytes to write(16) /// DG padding length macro that is calculated with the size of the provided structure. -#define RECORD_PADDING_LENGTH(rcrd, buf) ( RECORD_BYTE_SIZE(rcrd) % buf == 0 ? 0 : ( (U32)(RECORD_BYTE_SIZE(rcrd) / buf) + 1 ) ) * buf +#define RECORD_PADDING_LENGTH(rcrd, buf) (RECORD_BYTE_SIZE(rcrd) % buf == 0 ? 0 : ((U32)(RECORD_BYTE_SIZE(rcrd) / buf) + 1)) * buf /// NVDataMgmt self-test states enumeration. typedef enum NVDataMgmt_Self_Test_States @@ -259,21 +256,6 @@ U16 crc; ///< Water consumption CRC } WATER_CONSUMPTION_RECORD_T; -/// Manufacturing data structure. -typedef struct -{ - MFG_DATA_T mfgData; ///< Manufacturing data struct - U16 crc; ///< Manufacturing data CRC - U08 Padding[ 0x30 - sizeof(MFG_DATA_T) - sizeof(U16) ]; ///< Padding for reserved mfg data space -} MFG_RECORD_T; - -/// Service record structure. -typedef struct -{ - SERVICE_DATA_T serviceData; ///< Service date struct - U16 crc; ///< Service data CRC -} SERVICE_RECORD_T; - /// Calibration record structure. typedef struct { @@ -282,15 +264,8 @@ U08 Padding[ 0x50 - sizeof(CALIBRATION_DATA_T) - sizeof(U16) ]; ///< Padding for reserved cal data space } CALIBRATION_RECORD_T; //TODO remove -/// Last disinfection record structure. -typedef struct -{ - DISINFECTION_DATE_T date; ///< Disinfection date (char array) - U16 crc; ///< Disinfection date CRC -} LAST_DISINFECTION_RECORD_T; +// ********** HD/DG record structures ********** -// ********** Calibration data structures ********** - /// DG calibration groups structure typedef struct { @@ -299,12 +274,12 @@ DG_LOAD_CELLS_CAL_RECORD_T loadCellsCalRecord; ///< DG load cells. DG_TEMP_SENSORS_CAL_RECORD_T tempSensorsCalRecord; ///< DG temperature sensors. DG_COND_SENSORS_CAL_RECORD_T condSensorsCalRecord; ///< DG conductivity sensors. - DG_CONC_PUMPS_CAL_RECORD_T concentratePump[ NUM_OF_CONCENTRATE_PUMPS ]; ///< DG concentrate pumps. + DG_CONC_PUMPS_CAL_RECORD_T concentratePumps; ///< DG concentrate pumps. DG_DRAIN_PUMP_CAL_RECORD_T drainPump; ///< DG drain pump. DG_RO_PUMP_CAL_RECORD_T roPump; ///< DG RO pump. DG_DRAIN_LINE_VOLUME_T drainLineVolume; ///< DG drain line volume. DG_PRE_RO_PURGE_VOLUME_T preROPurgeVolume; ///< DG RO purge volume. - DG_RESERVOIR_VOLUME_T reservoir[ NUM_OF_CAL_DATA_RSRVRS ]; ///< DG reservoirs volume. + DG_RESERVOIR_VOLUME_RECORD_T reservoirVolumes; ///< DG reservoir volumes. DG_GENERIC_VOLUME_T genericVolume[ 4 ]; ///< DG generic volume (magic number because the value is unknown). DG_ACID_CONCENTRATES_T acidConcentrates; ///< DG acid concentrates. DG_BICARB_CONCENTRATES_T bicarbConcentrates; ///< DG bicarb concentrates. @@ -356,7 +331,7 @@ typedef struct { - HD_CALIBRATION_GROUPS_T hdCalibratiobGroups; + HD_CALIBRATION_GROUPS_T hdCalibrationGroups; } HD_CALIBRATION_RECORD_T; #pragma pack(pop) @@ -403,17 +378,13 @@ static LOG_RECORD_T logRecord; ///< Log record variable. static TREATMENT_TIME_RECORD_T treatmentTimeRecord; ///< Treatment time record. static WATER_CONSUMPTION_RECORD_T waterConsumptionRecord; ///< Water consumption record. -static MFG_RECORD_T mfgRecord; ///< Manufacturing record. static CALIBRATION_RECORD_T calibrationRecord; ///< Calibration record. -static SERVICE_RECORD_T serviceRecord; ///< Service record. -static LAST_DISINFECTION_RECORD_T lastDisinfectionRecord; ///< Disinfection record. static U08 queueRearIndex = QUEUE_START_INDEX; ///< Queue rear index. static U08 queueFrontIndex = QUEUE_START_INDEX; ///< Queue front index. static U08 queueCount = 0; ///< Queue count. static NVDATAMGMT_SELF_TEST_STATE_T NVDataMgmtSelfTestState = NVDATAMGMT_SELF_TEST_STATE_START; ///< NVDataMgmt self-test state variable. static NVDATAMGMT_EXEC_STATE_T NVDataMgmtExecState = NVDATAMGMT_EXEC_STATE_WAIT_FOR_POST; ///< NVDataMgmt exec state variable. static SELF_TEST_STATUS_T NVDataMgmtSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; ///< NVDataMgmt self-test result. -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. @@ -1132,63 +1103,196 @@ /*********************************************************************//** * @brief * The getDGPressureSensorsCalibrationRecord function returns the DG pressure - * sensors structure. + * sensors record. * @details Inputs: none * @details Outputs: none - * @return DG pressure sensors calibration structure + * @return DG pressure sensors calibration record *************************************************************************/ DG_PRES_SENSORS_CAL_RECORD_T getDGPressureSensorsCalibrationRecord( void ) { return dgCalibrationRecord.dgCalibrationGroups.presSensorsCalRecord; } -void getDGFlowSensorsCalibrationRecord( U08* buffer ) +/*********************************************************************//** + * @brief + * The getDGFlowSensorsCalibrationRecord function returns the DG flow + * sensors record. + * @details Inputs: none + * @details Outputs: none + * @return DG flow sensors calibration record + *************************************************************************/ + +DG_FLOW_SENSORS_CAL_RECORD_T getDGFlowSensorsCalibrationRecord( void ) { - //memcpy( buffer, &dgCalibrationRecord.flowSensorsCalRecord, sizeof(dgCalibrationRecord.condSensorsCalRecord)); + return dgCalibrationRecord.dgCalibrationGroups.flowSensorsCalRecord; } /*********************************************************************//** * @brief - * The setMfgData updates the structure that holds the manufacturing data, - * calls another function to calculate the CRC for the provided data and - * calls another function to erase sector 0 and write the new manufacturing - * data. - * @details Inputs: mfgRecord - * @details Outputs: mfgRecord - * @return TRUE is the enqueue was successfully scheduled + * The getDGLoadCellsCalibrationRecord function returns the DG load cells + * record. + * @details Inputs: none + * @details Outputs: none + * @return DG load cells calibration record *************************************************************************/ -BOOL setMfgData ( MFG_DATA_T data ) +DG_LOAD_CELLS_CAL_RECORD_T getDGLoadCellsCalibrationRecord( void ) { - mfgRecord.mfgData = data; - mfgRecord.crc = crc16 ( (U08*)&mfgRecord.mfgData, sizeof(MFG_DATA_T) ); - BOOL status = enqueueBank7Sector0Records(); - return status; + return dgCalibrationRecord.dgCalibrationGroups.loadCellsCalRecord; } /*********************************************************************//** * @brief - * The getMfgData returns the data in the structure that holds manufacturing - * record to buffer that the caller has provided. - * @details Inputs: mfgRecord + * The getDGTemperatureSensorsCalibrationRecord function returns the DG + * temperature sensors calibration record. + * @details Inputs: none * @details Outputs: none - * @param buffer address of manufacturing data buffer - * @return TRUE if the buffer pointer was not null and the copy was successful + * @return DG temperature sensors calibration record *************************************************************************/ -BOOL getMfgData ( MFG_DATA_T* buffer ) +DG_TEMP_SENSORS_CAL_RECORD_T getDGTemperatureSensorsCalibrationRecord( void ) { - BOOL status = FALSE; + return dgCalibrationRecord.dgCalibrationGroups.tempSensorsCalRecord; +} - if ( buffer != NULL ) - { - memcpy ( buffer, (U08*)&mfgRecord.mfgData, sizeof(MFG_DATA_T) ); - status = TRUE; - } +/*********************************************************************//** + * @brief + * The getDGConducitivitySensorsCalibrationRecord function returns the DG + * conductivity sensors calibration record. + * @details Inputs: none + * @details Outputs: none + * @return DG conductivity sensors calibration record + *************************************************************************/ +DG_COND_SENSORS_CAL_RECORD_T getDGConducitivitySensorsCalibrationRecord( void ) +{ + return dgCalibrationRecord.dgCalibrationGroups.condSensorsCalRecord; +} - return status; +/*********************************************************************//** + * @brief + * The getDGDrainLineVolumeRecord function returns the DG drain volume + * record. + * @details Inputs: none + * @details Outputs: none + * @return DG drain volume record + *************************************************************************/ +DG_DRAIN_LINE_VOLUME_T getDGDrainLineVolumeRecord( void ) +{ + return dgCalibrationRecord.dgCalibrationGroups.drainLineVolume; } /*********************************************************************//** * @brief + * The getDGPreROPurgeVolumeRecord function returns the DG pre RO purge + * volume record. + * @details Inputs: none + * @details Outputs: none + * @return DG pre RO purge volume record + *************************************************************************/ +DG_PRE_RO_PURGE_VOLUME_T getDGPreROPurgeVolumeRecord( void ) +{ + return dgCalibrationRecord.dgCalibrationGroups.preROPurgeVolume; +} + +/*********************************************************************//** + * @brief + * The getDGReservoirsVolumeRecord function returns the DG reservoirs + * volume record. + * @details Inputs: none + * @details Outputs: none + * @return DG reservoirs volume record + *************************************************************************/ +DG_RESERVOIR_VOLUME_RECORD_T getDGReservoirVolumeRecord( void ) +{ + return dgCalibrationRecord.dgCalibrationGroups.reservoirVolumes; +} + +/*********************************************************************//** + * @brief + * The getDGAcidConcentratesRecord function returns the DG acid concentrates + * record. + * @details Inputs: none + * @details Outputs: none + * @return DG acid concentrates record + *************************************************************************/ +DG_ACID_CONCENTRATES_T getDGAcidConcentratesRecord( void ) +{ + return dgCalibrationRecord.dgCalibrationGroups.acidConcentrates; +} + +/*********************************************************************//** + * @brief + * The getDGBicarbConcentratesRecord function returns the DG bicarb concentrates + * record. + * @details Inputs: none + * @details Outputs: none + * @return DG bicarb concentrates record + *************************************************************************/ +DG_BICARB_CONCENTRATES_T getDGBicarbConcentratesRecord( void ) +{ + return dgCalibrationRecord.dgCalibrationGroups.bicarbConcentrates; +} + +/*********************************************************************//** + * @brief + * The getDGFiltersRecord function returns the DG filters record. + * @details Inputs: none + * @details Outputs: none + * @return DG filters record + *************************************************************************/ +DG_FILTERS_CAL_RECORD_T getDGFiltersRecord( void ) +{ + return dgCalibrationRecord.dgCalibrationGroups.filters; +} + +/*********************************************************************//** + * @brief + * The getDGFansRecord function returns the DG fans record. + * @details Inputs: none + * @details Outputs: none + * @return DG fans record + *************************************************************************/ +DG_FANS_CAL_RECORD_T getDGFansRecord( void ) +{ + return dgCalibrationRecord.dgCalibrationGroups.fans; +} + +/*********************************************************************//** + * @brief + * The getDGSystemRecord function returns the DG systems record. + * @details Inputs: none + * @details Outputs: none + * @return DG systems record + *************************************************************************/ +DG_SYSTEM_RECORD_T getDGSystemRecord( void ) +{ + return dgSystemGroup.dgSystemRecord; +} + +/*********************************************************************//** + * @brief + * The getDGServiceRecord function returns the DG service record. + * @details Inputs: none + * @details Outputs: none + * @return DG service record + *************************************************************************/ +DG_SERVICE_RECORD_T getDGServiceRecord( void ) +{ + return dgServiceGroup.dgServiceRecord; +} + +/*********************************************************************//** + * @brief + * The getDGScheduledRunRecord function returns the DG scheduled runs record. + * @details Inputs: none + * @details Outputs: none + * @return DG scheduled runs record + *************************************************************************/ +DG_SCHEDULED_RUN_RECORD_T getDGScheduledRunRecord( void ) +{ + return dgScheduledRunGroup.dgScheduledRun; +} + +/*********************************************************************//** + * @brief * The setCalibrationData updates the structure that holds the calibration data, * calls another function to calculate the CRC for the provided data and * calls another function to erase sector 0 and write the new manufacturing @@ -1266,54 +1370,6 @@ /*********************************************************************//** * @brief - * The setServiceDate updates the structure that holds the calibration data, - * calls another function to calculate the CRC for the provided data if - * there is enough queues available, it schedules a write to RTC RAM. - * @details Inputs: serviceRecord - * @details Outputs: serviceRecord - * @param data service data buffer - * @return TRUE if the queue had enough space to schedule the job - *************************************************************************/ -BOOL setServiceDate ( SERVICE_DATA_T data ) -{ - BOOL status = FALSE; - serviceRecord.serviceData = data; - serviceRecord.crc = crc16 ( (U08*)&serviceRecord.serviceData, sizeof(SERVICE_DATA_T) ); - - if ( !isQueueFull() ) - { - //enqueue( NVDATAMGMT_WRITE, NVDATAMGMT_RTC, SERVICE_DATE_START_ADDRESS, - // (U08*)&serviceRecord, 0, sizeof(SERVICE_RECORD_T) ); - status = TRUE; - } - - return status; -} - -/*********************************************************************//** - * @brief - * The getServiceDate returns the data in the structure that holds service - * date to buffer that the caller has provided. - * @details Inputs: serviceRecord - * @details Outputs: none - * @param buffer address of service data buffer - * @return TRUE if the buffer address was not null - *************************************************************************/ -BOOL getServiceDate ( SERVICE_DATA_T* buffer ) -{ - BOOL status = FALSE; - - if ( buffer != NULL ) - { - memcpy ( buffer, (U08*)&serviceRecord.serviceData, sizeof(SERVICE_DATA_T) ); - status = TRUE; - } - - return status; -} - -/*********************************************************************//** - * @brief * The writeLogData checks if the queue is not full and if it is not, it calls * enqueue to schedule a job for writing the log data. * @details Inputs: logRecord @@ -1436,88 +1492,6 @@ /*********************************************************************//** * @brief - * The setDisinfectionDate gets the last disinfection date, calculates the - * CRC for it and if the queue is not full, it schedules a write to RTC RAM - * to store the last date. - * @details Inputs: lastDisinfectionRecord - * @details Outputs: lastDisinfectionRecord - * @param date disinfection date buffer - * @return TRUE if the queue was not full - *************************************************************************/ -BOOL setDisinfectionDate ( DISINFECTION_DATE_T date ) -{ - BOOL status = FALSE; - memcpy ( lastDisinfectionRecord.date.disinfectionDate, date.disinfectionDate, sizeof(DISINFECTION_DATE_T) ); - lastDisinfectionRecord.crc = crc16 ( (U08*)&lastDisinfectionRecord.date.disinfectionDate, sizeof(DISINFECTION_DATE_T) ); - - if ( !isQueueFull() ) - { - enqueue( NVDATAMGMT_WRITE, NVDATAMGMT_RTC, LAST_DISINFECTION_DATE_ADDRESS, - (U08*)&lastDisinfectionRecord, 0, sizeof(LAST_DISINFECTION_RECORD_T) ); - status = TRUE; - } - - return status; -} - -/*********************************************************************//** - * @brief - * The getDisinfectionDate populates the provided buffer with the last - * disinfection date. - * @details Inputs: lastDisinfectionRecord - * @details Outputs: none - * @param buffer address of disinfection date buffer - * @return TRUE if the buffer address was not null - *************************************************************************/ -BOOL getDisinfectionDate ( DISINFECTION_DATE_T* buffer ) -{ - BOOL status = FALSE; - - if ( buffer != NULL ) - { - memcpy ( buffer, lastDisinfectionRecord.date.disinfectionDate, sizeof(DISINFECTION_DATE_T) ); - status = TRUE; - } - - return status; -} - -/*********************************************************************//** - * @brief - * The setBootloaderFlag sets the bootloader flag to RTC RAM. - * @details Inputs: none - * @details Outputs: none - * @param flag the bootloader flag - * @return TRUE if the queue was not full - *************************************************************************/ -BOOL setBootloaderFlag ( U32 flag ) -{ - BOOL status = FALSE; - - if ( !isQueueFull() ) - { - enqueue ( NVDATAMGMT_WRITE, NVDATAMGMT_RTC, BOOTLOADER_FLAG_ADDRESS, - (U08*)&flag, 0, BOOTLOADER_FLAG_LENGTH_BYTES ); - status = TRUE; - } - - return status; -} - -/*********************************************************************//** - * @brief - * The getBootloaderFlag gets the bootloader flag from RTC RAM. - * @details Inputs: none - * @details Outputs: none - * @return bootloader flag as a U32 - *************************************************************************/ -U32 getBootloaderFlag( void ) -{ - return bootloaderFlag; -} - -/*********************************************************************//** - * @brief * The handleSelfTestStart enables the EEPROM bank sectors. * @details Inputs: currentTime * @details Outputs: currentTime @@ -1553,7 +1527,7 @@ // Enable was successful, Request a read for bootloader if ( getRTCRAMState() == RTC_RAM_STATE_READY ) { - readFromRAM( BOOTLOADER_FLAG_ADDRESS, BOOTLOADER_FLAG_LENGTH_BYTES ); + //readFromRAM( BOOTLOADER_FLAG_ADDRESS, BOOTLOADER_FLAG_LENGTH_BYTES ); // Get the time to check for timeout currentTime = getMSTimerCount(); state = NVDATAMGMT_SELF_TEST_STATE_READ_BOOTLOADER_FLAG; @@ -1579,7 +1553,7 @@ // If the read for bootloader is done, read it if ( getRTCRAMStatus() == RTC_RAM_STATUS_IDLE || timeoutStatus == TRUE ) { - getDataFromRAM( (U08*)&bootloaderFlag, BOOTLOADER_FLAG_LENGTH_BYTES ); + //getDataFromRAM( (U08*)&bootloaderFlag, BOOTLOADER_FLAG_LENGTH_BYTES ); // If the device is HD, read treatment time, // If the device is DG, read water consumption #ifdef _HD_ @@ -1674,14 +1648,14 @@ // If the RAM is in Idle, read the log records if ( getRTCRAMStatus() == RTC_RAM_STATUS_IDLE || timeoutStatus == TRUE ) { - U32 len = sizeof(MFG_RECORD_T) / sizeof(U32); - U32 *addr = (U32*)&mfgRecord; + //U32 len = sizeof(MFG_RECORD_T) / sizeof(U32); + //U32 *addr = (U32*)&mfgRecord; getDataFromRAM ( (U08*)&logRecord, sizeof(LOG_RECORD_T) ); currentTime = getMSTimerCount(); // Get ready for reading the manufacturing record - Fapi_doMarginRead( (U32*)BANK7_SECTOR0_START_ADDRESS, addr, len, Fapi_NormalRead ); + //Fapi_doMarginRead( (U32*)BANK7_SECTOR0_START_ADDRESS, addr, len, Fapi_NormalRead ); state = NVDATAMGMT_SELF_TEST_STATE_READ_MFG_RECORD; } @@ -1706,8 +1680,8 @@ { currentTime = getMSTimerCount(); // Send the read command for calibration record - Fapi_doMarginRead ( (U32*)CALIBRATION_RECORD_START_ADDRESS, (U32*)&calibrationRecord, - sizeof(CALIBRATION_RECORD_T) / sizeof(U32), Fapi_NormalRead ); + //Fapi_doMarginRead ( (U32*)CALIBRATION_RECORD_START_ADDRESS, (U32*)&calibrationRecord, + //sizeof(CALIBRATION_RECORD_T) / sizeof(U32), Fapi_NormalRead ); state = NVDATAMGMT_SELF_TEST_STATE_READ_CAL_RECORD; } @@ -1757,11 +1731,11 @@ if ( getRTCRAMStatus() == RTC_RAM_STATUS_IDLE || timeoutStatus == TRUE ) { - getDataFromRAM ( (U08*)&serviceRecord, sizeof(SERVICE_RECORD_T) ); + //getDataFromRAM ( (U08*)&serviceRecord, sizeof(SERVICE_RECORD_T) ); if ( getRTCRAMState() == RTC_RAM_STATE_READY ) { currentTime = getMSTimerCount(); - readFromRAM( LAST_DISINFECTION_DATE_ADDRESS, sizeof(LAST_DISINFECTION_RECORD_T) ); + //readFromRAM( LAST_DISINFECTION_DATE_ADDRESS, sizeof(LAST_DISINFECTION_RECORD_T) ); state = NVDATAMGMT_SELF_TEST_STATE_READ_LAST_DISINFECTION_DATE; } } @@ -1784,7 +1758,7 @@ if ( getRTCRAMStatus() == RTC_RAM_STATUS_IDLE || timeoutStatus == TRUE ) { - getDataFromRAM ( (U08*)&lastDisinfectionRecord, sizeof(LAST_DISINFECTION_RECORD_T) ); + //getDataFromRAM ( (U08*)&lastDisinfectionRecord, sizeof(LAST_DISINFECTION_RECORD_T) ); state = NVDATAMGMT_SELF_TEST_STATE_CHECK_CRC; } @@ -1827,8 +1801,8 @@ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_NVDATA_HW_USAGE_DATA_CRC_ERROR, recordCRC, calcCRC ); } // Check the CRC for last disinfection date - calcCRC = crc16 ( (U08*)&lastDisinfectionRecord.date.disinfectionDate, sizeof(DISINFECTION_DATE_T) ); - recordCRC = lastDisinfectionRecord.crc; + //calcCRC = crc16 ( (U08*)&lastDisinfectionRecord.date.disinfectionDate, sizeof(DISINFECTION_DATE_T) ); + //recordCRC = lastDisinfectionRecord.crc; if ( calcCRC != recordCRC ) { hasCRCPassed = FALSE; @@ -1852,8 +1826,8 @@ logRecord.logHeader.isHdrCorrupted = TRUE; } // Check CRC for manufacturing record - calcCRC = crc16 ( (U08*)&mfgRecord.mfgData, sizeof(MFG_DATA_T) ); - recordCRC = mfgRecord.crc; + //calcCRC = crc16 ( (U08*)&mfgRecord.mfgData, sizeof(MFG_DATA_T) ); + //recordCRC = mfgRecord.crc; if ( calcCRC != recordCRC ) { hasCRCPassed = FALSE; @@ -1874,8 +1848,8 @@ } #ifndef LIMITED_NVDATA_CRC_CHECKS // Check CRC for service record - calcCRC = crc16 ( (U08*)&serviceRecord.serviceData, sizeof(SERVICE_DATA_T) ); - recordCRC = serviceRecord.crc; + //calcCRC = crc16 ( (U08*)&serviceRecord.serviceData, sizeof(SERVICE_DATA_T) ); + //recordCRC = serviceRecord.crc; if ( calcCRC != recordCRC ) { hasCRCPassed = FALSE; @@ -2661,8 +2635,8 @@ { // Sector 0 must be erased first enqueue ( NVDATAMGMT_ERASE_SECTOR, NVDATAMGMT_EEPROM, BANK7_SECTOR0_START_ADDRESS, 0, 0, 0 ); - enqueue ( NVDATAMGMT_WRITE, NVDATAMGMT_EEPROM, BANK7_SECTOR0_START_ADDRESS, (U08*)&mfgRecord, 0, sizeof(MFG_RECORD_T) ); - enqueue ( NVDATAMGMT_WRITE, NVDATAMGMT_EEPROM, CALIBRATION_RECORD_START_ADDRESS, (U08*)&calibrationRecord, 0, sizeof(CALIBRATION_RECORD_T) ); + //enqueue ( NVDATAMGMT_WRITE, NVDATAMGMT_EEPROM, BANK7_SECTOR0_START_ADDRESS, (U08*)&mfgRecord, 0, sizeof(MFG_RECORD_T) ); + //enqueue ( NVDATAMGMT_WRITE, NVDATAMGMT_EEPROM, CALIBRATION_RECORD_START_ADDRESS, (U08*)&calibrationRecord, 0, sizeof(CALIBRATION_RECORD_T) ); status = TRUE; } Index: NVDataMgmt.h =================================================================== diff -u -r0ee608e8de70aef91f5bdf7ebfa1f1cccf2e43dd -rff5e595afd7ad79dd7693dfa598b24fdeacad95d --- NVDataMgmt.h (.../NVDataMgmt.h) (revision 0ee608e8de70aef91f5bdf7ebfa1f1cccf2e43dd) +++ NVDataMgmt.h (.../NVDataMgmt.h) (revision ff5e595afd7ad79dd7693dfa598b24fdeacad95d) @@ -21,6 +21,13 @@ #include "Common.h" #include "ConcentratePumps.h" +#ifdef _HD_ + #include "NVDataMgmtHDRecords.h" +#endif +#ifdef _DG_ + #include "NVDataMgmtDGRecords.h" +#endif + /** * @defgroup NVDataMgmt NVDataMgmt * @brief Non-volatile data management module. Handles Bank 7 of the TI processor and the @@ -32,27 +39,6 @@ // ********** public definitions ********** -#define MAX_TOP_LEVEL_PN_CHARS 10U ///< Max number of characters for top level part number. -#define MAX_TOP_LEVEL_SN_CHARS 15U ///< Max number of characters for top level serial number. - -#define MAX_HW_SERIAL_NUMBER_CHARACTERS 5U ///< Max number of characters for HD serial number TODO remove -#define MAX_DATE_CHARACTERS 10U ///< Max number of characters for date TODO REMOVE - -/// Manufacturing location enumeration. -typedef enum mfg_location -{ - MFG_LOC_FACTORY = 0, ///< Manufacturing location (HD/DG). - NUM_OF_MFG_LOC ///< Number of manufacturing location. -} MFG_LOCATION_T; - -/// Service location enumeration. -typedef enum service_location -{ - SERVICE_LOC_FACTORY = 0, ///< Service location factory (HD/DG). - SERVICE_LOC_FIELD, ///< Service location field (HD/DG). - NUM_OF_SERVICE_LOC ///< Number of service location. -} SERVICE_LOCATION_T; - /// Log event enumeration. typedef enum log_event { @@ -73,111 +59,8 @@ NVDATAMGMT_READ_COMPLETE ///< Read status complete. } NVDATAMGMT_READ_STATUS_T; -/// DG pressure sensors enumeration. -typedef enum dg_pressure_sensors -{ - CAL_DATA_RO_PUMP_INLET_PRES_SENSOR = 0, ///< DG calibration data RO pump inlet pressure sensor. - CAL_DATA_RO_PUMP_OUTLET_PRES_SENSOR, ///< DG calibration data RO pump outlet pressure sensor. - CAL_DATA_DRAIN_PUMP_INLET_PRES_SENSOR, ///< DG calibration data drain pump inlet pressure sensor. - CAL_DATA_DRAIN_PUMP_OUTLET_PRES_SENSOR, ///< DG calibration data drain pump outlet pressure sensor. - NUM_OF_CAL_DATA_PRES_SENSORS, ///< Number of calibration data pressure sensors. -} CAL_DATA_DG_PRES_SENSORS_T; - -/// DG flow sensors enumeration. -typedef enum dg_flow_sensors -{ - CAL_DATA_RO_PUMP_FLOW_SENSOR = 0, - NUM_OF_CAL_DATA_FLOW_SENSORS, -} CAL_DATA_DG_FLOW_SENSORS_T; - -/// DG load cells enumeration. -typedef enum dg_load_cells -{ - CAL_DATA_LOAD_CELL_A1 = 0, - CAL_DATA_LOAD_CELL_A2, - CAL_DATA_LOAD_CELL_B1, - CAL_DATA_LOAD_CELL_B2, - NUM_OF_CAL_DATA_LOAD_CELLS, -} CAL_DATA_DG_LOAD_CELLS_T; - -/// DG temperature sensors enumeration. -typedef enum dg_temperature_sensors -{ - CAL_DATA_FPGA_BOARD_TEMP = 0, - CAL_DATA_LOAD_CELL_A1_B1_TEMP, - CAL_DATA_LOAD_CELL_A2_B2_TEMP, - CAL_DATA_INTERNAL_THDO_RTD_TEMP, - CAL_DATA_INTERNAL_TDI_RTD_TEMP, - CAL_DATA_INTERNAL_COND_SENSOR_TEMP, - CAL_DATA_THERMISTOR_DG_ONBOARD_NTC_TEMP, - CAL_DATA_THERMISTOR_POWER_SUPPLY_1_TEMP, - CAL_DATA_THERMISTOR_POWER_SUPPLY_2_TEMP, - CAL_DATA_OUTLET_REDUNDANT_TEMP, - CAL_DATA_INLET_DIALYSATE_TEMP, - CAL_DATA_INLET_PRIMARY_HEATER_TEMP, - CAL_DATA_OUTLET_PRIMARY_HEATER_TEMP, - CAL_DATA_COND_SENSOR_1_TEMP, - CAL_DATA_COND_SENSOR_2_TEMP, - NUM_OF_CAL_DATA_TEMP_SENSORS, -} CAL_DATA_DG_TEMP_SENSORS_T; - -/// DG conductivity sensors enumeration. -typedef enum dg_conductivity_sensors -{ - CAL_DATA_CPI_COND_SENSOR = 0, - CAL_DATA_CPO_COND_SENSOR, - CAL_DATA_CD1_COND_SENSOR, - CAL_DATA_CD2_COND_SENSOR, - NUM_OF_CAL_DATA_COND_SENSORS, -} CAL_DATA_DG_COND_SENSORS_T; - -/// DG pumps enumeration. -typedef enum dg_pumps -{ - CAL_DATA_CONC_PUMP_1 = 0, - CAL_DATA_CONC_PUMP_2, - CAL_DATA_DRAIN_PUMP, - CAL_DATA_RO_PUMP, - NUM_OF_CAL_DATA_DG_PUMPS -} CAL_DATA_DG_PUMPS_T; - -typedef enum dg_reservoirs -{ - CAL_DATA_RSRVR_1 = 0, - CAL_DATA_RSRVR_2, - NUM_OF_CAL_DATA_RSRVRS -} CAL_DATA_DG_RESERVOIRS_T; - -typedef enum dg_acid_concentrate -{ - CAL_DATA_ACID_CONCENTRATE_1 = 0, - CAL_DATA_ACID_CONCENTRATE_2, - CAL_DATA_ACID_CONCENTRATE_3, - CAL_DATA_ACID_CONCENTRATE_4, - CAL_DATA_ACID_CONCENTRATE_5, - NUM_OF_CAL_DATA_ACID_CONCENTRATES -} CAL_DATA_DG_ACID_CONCENTRATE_T; - -typedef enum dg_bicarb_concentrate -{ - CAL_DATA_BICARB_CONCENTRATE_1 = 0, - CAL_DATA_BICARB_CONCENTRATE_2, - CAL_DATA_BICARB_CONCENTRATE_3, - CAL_DATA_BICARB_CONCENTRATE_4, - CAL_DATA_BICARB_CONCENTRATE_5, - NUM_OF_CAL_DATA_BICARB_CONCENTRATES -} CAL_DATA_DG_BICARB_CONCENTRATE_T; - -/// DG scheduled runs -typedef enum dg_scheduled_runs -{ - FLUSH = 0, - HEAT_DISINFECT, - CHEMICAL_DISINFECT, - NUM_OF_DG_SCHEDULED_RUNS -} SCHEDULED_DG_RUNS_T; - #pragma pack(push, 1) +/********************** OLD STRUCTS TODO REMOVE ******************/ /// Payload record structure for a linear calibration message. TODO remove typedef struct { @@ -186,226 +69,6 @@ } LINEAR_F32_CAL_PAYLOAD_T; // TODO remove the above structure -/// Linear calibration structure -typedef struct -{ - F32 gain; - F32 offset; - U32 calibrationTime; - U16 crc; -} LINEAR_CAL_PAYLOAD_T; - -/// DG concentrate pumps one-gain payload -typedef struct -{ - F32 stepSpeed2FlowRatio; - U32 calibrationTime; - U16 crc; -} DG_CONC_PUMPS_CAL_RECORD_T; - -/// DG drain pump two-gain payload -typedef struct -{ - F32 voltage2SpeedRatio; - F32 stepSpeed2FlowRatio; - U32 calibrationTime; - U16 crc; -} DG_DRAIN_PUMP_CAL_RECORD_T; - -/// DG RO pump calibration structure. -typedef struct -{ - F32 gain1Ratio; - F32 gain2Ratio; - F32 gain3Ratio; - U32 calibrationTime; - U16 crc; -} DG_RO_PUMP_CAL_RECORD_T; - -/// Pressure sensors calibration structure -typedef struct -{ - LINEAR_CAL_PAYLOAD_T pressureSensors[ NUM_OF_CAL_DATA_PRES_SENSORS ]; ///< Pressure sensors to calibrate. - // NOTE: The reserved space is for 6 sensors. This portion of the struct should be eventually be - // reduced, so #define was not used for the size of the array - LINEAR_CAL_PAYLOAD_T reservedSpace[ 6 ]; ///< Reserved space for future pressure sensors. -} DG_PRES_SENSORS_CAL_RECORD_T; - -/// Flow sensors calibration structure -typedef struct -{ - LINEAR_CAL_PAYLOAD_T flowSensors[ NUM_OF_CAL_DATA_FLOW_SENSORS ]; ///< Flow sensors to calibrate. - // NOTE: The reserved space is for 6 sensors. This portion of the struct should be eventually be - // reduced, so #define was not used for the size of the array - LINEAR_CAL_PAYLOAD_T reservedSpace[ 3 ]; ///< Reserved space for future flow sensors. -} DG_FLOW_SENSORS_CAL_RECORD_T; - -/// Load cells calibration structure -typedef struct -{ - LINEAR_CAL_PAYLOAD_T loadCells[ NUM_OF_CAL_DATA_LOAD_CELLS ]; ///< Load cells to calibrate. -} DG_LOAD_CELLS_CAL_RECORD_T; - -/// Temperature sensors calibration structure -typedef struct -{ - LINEAR_CAL_PAYLOAD_T tempSensors[ NUM_OF_CAL_DATA_TEMP_SENSORS ]; ///< Temperature sensors to calibrate. - // NOTE: The reserved space is for 6 sensors. This portion of the struct should be eventually be - // reduced, so #define was not used for the size of the array - LINEAR_CAL_PAYLOAD_T reservedSpace[ 5 ]; ///< Reserved space for future temperature sensors. -} DG_TEMP_SENSORS_CAL_RECORD_T; - -/// Conductivity sensors calibration structure -typedef struct -{ - LINEAR_CAL_PAYLOAD_T condSensors[ NUM_OF_CAL_DATA_COND_SENSORS ]; ///< Conductivity sensors to calibrate. - // NOTE: The reserved space is for 6 sensors. This portion of the struct should be eventually be - // reduced, so #define was not used for the size of the array - LINEAR_CAL_PAYLOAD_T reservedSpace[ 2 ]; ///< Reserved space for future conductivity sensors. -} DG_COND_SENSORS_CAL_RECORD_T; - -/// Drain line volume calibration structure -typedef struct -{ - F32 volume; ///< DG Drain line volume. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. -} DG_DRAIN_LINE_VOLUME_T; - -/// DG pre RO purge volume calibration structure -typedef struct -{ - F32 pressure2FlowRatio; ///< Pressure to flow ratio. - F32 volume; ///< Volume. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. -} DG_PRE_RO_PURGE_VOLUME_T; - -/// DG reservoir volume calibration structure -typedef struct -{ - F32 rsrvrVolume; ///< Reservoir volume. - F32 normalFillVolume; ///< Normal fill volume. - F32 maxResidualFluid; ///< Max residual fluid. - F32 rsrvrUnfilledWeight; ///< Reservoir unfilled weight. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. -} DG_RESERVOIR_VOLUME_T; - -/// DG generic volumes (reserved space) -typedef struct -{ - F32 volume; ///< Volume. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. -} DG_GENERIC_VOLUME_T; - -/// DG acid concentrate -typedef struct -{ - F32 acidConcMixRatio; ///< Acid concentrate mix ratio. - F32 startVolume; ///< Start volume. - F32 reserverdSpace; ///< Reserved space. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. -} DG_ACID_CONCENTRATE_T; - -/// DG bicarb concentrate -typedef struct -{ - F32 bicarbConcMixRatio; ///< Bicarb concentrate mix ratio. - F32 startVolume; ///< Start volume. - F32 reservedSpace; ///< Reserved space. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. -} DG_BICARB_CONCENTRATE_T; - -/// DG acid concentrates -typedef struct -{ - DG_ACID_CONCENTRATE_T acidConcentrate[ NUM_OF_CAL_DATA_ACID_CONCENTRATES ]; ///< DG acid concentrates. -} DG_ACID_CONCENTRATES_T; - -/// DG bicarb concentrates -typedef struct -{ - DG_BICARB_CONCENTRATE_T bicarbConcentrate[ NUM_OF_CAL_DATA_BICARB_CONCENTRATES ]; ///< DG bicarb concentrates. -} DG_BICARB_CONCENTRATES_T; - -/// DG filter calibration record -typedef struct -{ - F32 reservedSpace1; ///< DG filter reserved space 1. - F32 reservedSpace2; ///< DG filter reserved space 2. - F32 reservedSpace3; ///< DG filter reserved space 3 - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. -} DG_FILTER_CAL_RECORD_T; - -/// DG filters calibration data structure -typedef struct -{ - DG_FILTER_CAL_RECORD_T roFilter; ///< RO filter. - DG_FILTER_CAL_RECORD_T ultraFilter; ///< Ultra filter. - DG_FILTER_CAL_RECORD_T sedimentFilter; ///< Sediment filter. - DG_FILTER_CAL_RECORD_T carbonFilter; ///< Carbon filter. - DG_FILTER_CAL_RECORD_T carbonPolishFilter; ///< Carbon polish filter. -} DG_FILTERS_CAL_RECORD_T; - -/// DG fan calibration data structure -typedef struct -{ - F32 reservedSpace1; ///< Reserved space 1. - F32 reservedSpace2; ///< Reserved space 2. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. -} DG_FAN_CAL_RECORD_T; - -/// DG fans calibration data structure -typedef struct -{ - DG_FAN_CAL_RECORD_T fan1; ///< Fan 1. - DG_FAN_CAL_RECORD_T fan2; ///< Fan 2. -} DG_FANS_CAL_RECORD_T; - -/// DG systems record structure -typedef struct -{ - char topLevelPN[ MAX_TOP_LEVEL_PN_CHARS ]; ///< DG top level part number. - char topLevelSN[ MAX_TOP_LEVEL_SN_CHARS ]; ///< DG top level serial number. - MFG_LOCATION_T mfgLocation; ///< DG manufacturing location. - U32 mfgDate; ///< DG manufacturing date. - U16 crc; ///< CRC for the DG system record structure. -} DG_SYSTEM_RECORD_T; - -/// DG service record structure -typedef struct -{ - SERVICE_LOCATION_T lastServiceLoc; ///< DG service location. - U32 lastServiceDate; ///< DG service date. - U16 crc; ///< CRC for the DG last service record structure. -} DG_SERVICE_RECORD_T; - -typedef struct -{ - U32 lastRunTime; - U16 crc; -} DG_SCHEDULED_RUN_T; - -typedef struct -{ - DG_SCHEDULED_RUN_T dgScheduledRun[ NUM_OF_DG_SCHEDULED_RUNS ]; -} DG_SCHEDULED_RUN_RECORD_T; - -/********************** OLD STRUCTS TODO REMOVE ******************/ -/// Manufacturing data structure. TODO remove -typedef struct mfg_Data -{ - char SYSSerialNumber [ MAX_TOP_LEVEL_PN_CHARS ]; ///< SYS serial number. - char HWSerialNumber [ MAX_HW_SERIAL_NUMBER_CHARACTERS ]; ///< HW serial number. - char mfgDate [ MAX_DATE_CHARACTERS ]; ///< Manufacturing date. -} MFG_DATA_T; - /// Calibration data structure. typedef struct calibration_Data { @@ -421,16 +84,10 @@ char calDateBloodFlow[ MAX_DATE_CHARACTERS ]; ///< Last calibration date of blood flow sensor char calDateDialysateFlow[ MAX_DATE_CHARACTERS ]; ///< Last calibration date of blood flow sensor #endif - char calDateAccel[ MAX_DATE_CHARACTERS ]; ///< Last calibration date of accelerometer + //char calDateAccel[ MAX_DATE_CHARACTERS ]; ///< Last calibration date of accelerometer } CALIBRATION_DATA_T; -/// Service dates structure. TODo remove -typedef struct service_dates -{ - char currentServiceDate [ MAX_DATE_CHARACTERS ]; ///< Current service date - char nextServiceDate [ MAX_DATE_CHARACTERS ]; ///< Next service date -} SERVICE_DATA_T; -/********************** OLD STRUCTS REMOVE ******************/ +/********************** TODO OLD STRUCT REMOVE ******************/ /// Read data status structure. typedef struct get_data @@ -451,13 +108,6 @@ F32 data4; ///< Log data 4 F32 data5; ///< Log data 5 } LOG_DATA_T; - -/// Disinfection date structure. -typedef struct -{ - char disinfectionDate [ MAX_DATE_CHARACTERS ]; ///< Disinfection Date -} DISINFECTION_DATE_T; - #pragma pack(pop) void initNVDataMgmt ( void ); @@ -482,32 +132,36 @@ BOOL getScheduledRunsRecord( void ); BOOL setScheduledRunsRecord( U32 currentMessage, U32 totalMessages, U32 length, U08 *addressPtr ); +#ifdef _DG_ DG_PRES_SENSORS_CAL_RECORD_T getDGPressureSensorsCalibrationRecord( void ); -void getDGFlowSensorsCalibrationRecord( U08* buffer ); +DG_FLOW_SENSORS_CAL_RECORD_T getDGFlowSensorsCalibrationRecord( void ); +DG_LOAD_CELLS_CAL_RECORD_T getDGLoadCellsCalibrationRecord( void ); +DG_TEMP_SENSORS_CAL_RECORD_T getDGTemperatureSensorsCalibrationRecord( void ); +DG_COND_SENSORS_CAL_RECORD_T getDGConducitivitySensorsCalibrationRecord( void ); +DG_DRAIN_LINE_VOLUME_T getDGDrainLineVolumeRecord( void ); +DG_PRE_RO_PURGE_VOLUME_T getDGPreROPurgeVolumeRecord( void ); +DG_RESERVOIR_VOLUME_RECORD_T getDGReservoirsVolumeRecord( void ); +DG_ACID_CONCENTRATES_T getDGAcidConcentratesRecord( void ); +DG_BICARB_CONCENTRATES_T getDGBicarbConcentratesRecord( void ); +DG_FILTERS_CAL_RECORD_T getDGFiltersRecord( void ); +DG_FANS_CAL_RECORD_T getDGFansRecord( void ); +DG_SYSTEM_RECORD_T getDGSystemRecord( void ); +DG_SERVICE_RECORD_T getDGServiceRecord( void ); +DG_SCHEDULED_RUN_RECORD_T getDGScheduledRunRecord( void ); +DG_RO_PUMP_CAL_RECORD_T getDGROPumpRecord( void ); +DG_DRAIN_PUMP_CAL_RECORD_T getDGDrainPumpRecord( void ); +#endif -// TODO clean up -BOOL setBootloaderFlag ( U32 flag ); -U32 getBootloaderFlag ( void ); - -BOOL setMfgData ( MFG_DATA_T data ); -BOOL getMfgData ( MFG_DATA_T* buffer ); - BOOL setCalibrationData ( CALIBRATION_DATA_T data ); //TODO remove BOOL getCalibrationData ( CALIBRATION_DATA_T* buffer ); //TODO remove -BOOL testResetCalibrationData( U32 key ); +BOOL testResetCalibrationData( U32 key ); // TODO clean up -BOOL setServiceDate ( SERVICE_DATA_T data ); -BOOL getServiceDate ( SERVICE_DATA_T* buffer ); - BOOL setTreatmentTime ( U32 hours ); U32 getTreatmentTime ( void ); BOOL setWaterConsumption ( U32 liters ); U32 getWaterConsumption ( void ); -BOOL setDisinfectionDate ( DISINFECTION_DATE_T date ); -BOOL getDisinfectionDate ( DISINFECTION_DATE_T* buffer ); - BOOL writeLogData ( LOG_DATA_T* data ); BOOL readLogData ( READ_DATA_T* buffer, U32 length ); Index: NVDataMgmtDGRecords.h =================================================================== diff -u -r0ee608e8de70aef91f5bdf7ebfa1f1cccf2e43dd -rff5e595afd7ad79dd7693dfa598b24fdeacad95d --- NVDataMgmtDGRecords.h (.../NVDataMgmtDGRecords.h) (revision 0ee608e8de70aef91f5bdf7ebfa1f1cccf2e43dd) +++ NVDataMgmtDGRecords.h (.../NVDataMgmtDGRecords.h) (revision ff5e595afd7ad79dd7693dfa598b24fdeacad95d) @@ -1,13 +1,373 @@ -/* - * NVDataMgmtDGRecords.h - * - * Created on: Feb 12, 2021 - * Author: fw - */ #ifndef FWCOMMON_NVDATAMGMTDGRECORDS_H_ #define FWCOMMON_NVDATAMGMTDGRECORDS_H_ +#include "Common.h" +#include "ConcentratePumps.h" +/** + * @defgroup NVDataMgmtDGRecords NVDataMgmtDGRecords + * @brief Non-volatile DG data records including calibration records, system records, + * service records, and the scheduled runs record. + * + * @addtogroup NVDataMgmtDGRecords + * @{ + */ -#endif /* FWCOMMON_NVDATAMGMTDGRECORDS_H_ */ +// ********** public definitions ********** + +#define MAX_TOP_LEVEL_PN_CHARS 10U ///< Max number of characters for top level part number. +#define MAX_TOP_LEVEL_SN_CHARS 15U ///< Max number of characters for top level serial number. + +/// Manufacturing location enumeration. +typedef enum mfg_location +{ + MFG_LOC_FACTORY = 0, ///< Manufacturing location (HD/DG). + NUM_OF_MFG_LOC ///< Number of manufacturing location. +} MFG_LOCATION_T; + +/// Service location enumeration. +typedef enum service_location +{ + SERVICE_LOC_FACTORY = 0, ///< Service location factory (HD/DG). + SERVICE_LOC_FIELD, ///< Service location field (HD/DG). + NUM_OF_SERVICE_LOC ///< Number of service location. +} SERVICE_LOCATION_T; + +/// DG pressure sensors enumeration. +typedef enum dg_pressure_sensors +{ + CAL_DATA_RO_PUMP_INLET_PRES_SENSOR = 0, ///< DG calibration data RO pump inlet pressure sensor. + CAL_DATA_RO_PUMP_OUTLET_PRES_SENSOR, ///< DG calibration data RO pump outlet pressure sensor. + CAL_DATA_DRAIN_PUMP_INLET_PRES_SENSOR, ///< DG calibration data drain pump inlet pressure sensor. + CAL_DATA_DRAIN_PUMP_OUTLET_PRES_SENSOR, ///< DG calibration data drain pump outlet pressure sensor. + NUM_OF_CAL_DATA_PRES_SENSORS, ///< Number of calibration data pressure sensors. +} CAL_DATA_DG_PRES_SENSORS_T; + +/// DG flow sensors enumeration. +typedef enum dg_flow_sensors +{ + CAL_DATA_RO_PUMP_FLOW_SENSOR = 0, ///< RO pump flow sensor. + NUM_OF_CAL_DATA_FLOW_SENSORS, ///< Number of flow sensors. +} CAL_DATA_DG_FLOW_SENSORS_T; + +/// DG load cells enumeration. +typedef enum dg_load_cells +{ + CAL_DATA_LOAD_CELL_A1 = 0, ///< Load cell A1. + CAL_DATA_LOAD_CELL_A2, ///< Load cell A2. + CAL_DATA_LOAD_CELL_B1, ///< Load cell B1. + CAL_DATA_LOAD_CELL_B2, ///< Load cell B2. + NUM_OF_CAL_DATA_LOAD_CELLS, ///< Number of load cells. +} CAL_DATA_DG_LOAD_CELLS_T; + +/// DG temperature sensors enumeration. +typedef enum dg_temperature_sensors +{ + CAL_DATA_FPGA_BOARD_TEMP = 0, ///< FPGA board temperature sensor. + CAL_DATA_LOAD_CELL_A1_B1_TEMP, ///< Load cell A1/B1 temperature sensor. + CAL_DATA_LOAD_CELL_A2_B2_TEMP, ///< Load cell A2/B2 temperature sensor. + CAL_DATA_INTERNAL_THDO_RTD_TEMP, ///< Internal THDO RTC temperature sensor. + CAL_DATA_INTERNAL_TDI_RTD_TEMP, ///< Internal TDI RTD temperature sensor. + CAL_DATA_INTERNAL_COND_SENSOR_TEMP, ///< Internal conductivity sensor temperature sensor. + CAL_DATA_THERMISTOR_DG_ONBOARD_NTC_TEMP, ///< DG onboard NTC thermistor. + CAL_DATA_THERMISTOR_POWER_SUPPLY_1_TEMP, ///< Power supply 1 thermistor. + CAL_DATA_THERMISTOR_POWER_SUPPLY_2_TEMP, ///< Power supply 2 thermistor. + CAL_DATA_OUTLET_REDUNDANT_TEMP, ///< Outlet redundant temperature sensor. + CAL_DATA_INLET_DIALYSATE_TEMP, ///< Inlet dialysate temperature sensor. + CAL_DATA_INLET_PRIMARY_HEATER_TEMP, ///< Inlet primary heater temperature sensor. + CAL_DATA_OUTLET_PRIMARY_HEATER_TEMP, ///< Outlet primary heater temperature sensor. + CAL_DATA_COND_SENSOR_1_TEMP, ///< Conductivity sensor 1 temperature sensor. + CAL_DATA_COND_SENSOR_2_TEMP, ///< Conductivity sensor 2 temperature sensor. + NUM_OF_CAL_DATA_TEMP_SENSORS, ///< Number of temperature sensors. +} CAL_DATA_DG_TEMP_SENSORS_T; + +/// DG conductivity sensors enumeration. +typedef enum dg_conductivity_sensors +{ + CAL_DATA_CPI_COND_SENSOR = 0, ///< CPi conductivity sensor. + CAL_DATA_CPO_COND_SENSOR, ///< CPo conductivity sensor. + CAL_DATA_CD1_COND_SENSOR, ///< CD1 conductivity sensor. + CAL_DATA_CD2_COND_SENSOR, ///< CD2 conductivity sensor. + NUM_OF_CAL_DATA_COND_SENSORS, ///< Number of conductivity sensors. +} CAL_DATA_DG_COND_SENSORS_T; + +/// DG pumps enumeration. +typedef enum dg_pumps +{ + CAL_DATA_CONC_PUMP_1 = 0, ///< Concentrate pump 1. + CAL_DATA_CONC_PUMP_2, ///< Concentrate pump 2. + CAL_DATA_DRAIN_PUMP, ///< Drain pump. + CAL_DATA_RO_PUMP, ///< RO pump. + NUM_OF_CAL_DATA_DG_PUMPS ///< Number of DG pump. +} CAL_DATA_DG_PUMPS_T; + +/// DG reservoirs enumeration. +typedef enum dg_reservoirs +{ + CAL_DATA_RSRVR_1 = 0, ///< Reservoir 1. + CAL_DATA_RSRVR_2, ///< Reservoir 2. + NUM_OF_CAL_DATA_RSRVRS ///< Number of reservoirs. +} CAL_DATA_DG_RESERVOIRS_T; + +/// DG acid concentrate enumeration. +typedef enum dg_acid_concentrate +{ + CAL_DATA_ACID_CONCENTRATE_1 = 0, ///< Acid concentrate 1. + CAL_DATA_ACID_CONCENTRATE_2, ///< Acid concentrate 2. + CAL_DATA_ACID_CONCENTRATE_3, ///< Acid concentrate 3. + CAL_DATA_ACID_CONCENTRATE_4, ///< Acid concentrate 4. + CAL_DATA_ACID_CONCENTRATE_5, ///< Acid concentrate 5. + NUM_OF_CAL_DATA_ACID_CONCENTRATES ///< Number of acid concentrates. +} CAL_DATA_DG_ACID_CONCENTRATES_T; + +/// DG bicarb concentrate enumeration. +typedef enum dg_bicarb_concentrate +{ + CAL_DATA_BICARB_CONCENTRATE_1 = 0, ///< Bicarb concentrate 1. + CAL_DATA_BICARB_CONCENTRATE_2, ///< Bicarb concentrate 2. + CAL_DATA_BICARB_CONCENTRATE_3, ///< Bicarb concentrate 3. + CAL_DATA_BICARB_CONCENTRATE_4, ///< Bicarb concentrate 4. + CAL_DATA_BICARB_CONCENTRATE_5, ///< Bicarb concentrate 5. + NUM_OF_CAL_DATA_BICARB_CONCENTRATES ///< Number of bicarb concentrates. +} CAL_DATA_DG_BICARB_CONCENTRATES_T; + +/// DG scheduled runs enumeration. +typedef enum dg_scheduled_runs +{ + FLUSH = 0, ///< Flush run. + HEAT_DISINFECT, ///< Heat disinfect run. + CHEMICAL_DISINFECT, ///< Chemical disinfect run. + NUM_OF_DG_SCHEDULED_RUNS ///< Number of DG scheduled runs. +} SCHEDULED_DG_RUNS_T; + +#pragma pack(push, 1) +/// Linear calibration structure +typedef struct +{ + F32 gain; ///< Gain. + F32 offset; ///< Offset. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the linear calibration payload. +} LINEAR_CAL_PAYLOAD_T; + +/// DG concentrate pumps one-gain payload +typedef struct +{ + F32 stepSpeed2FlowRatio; ///< Step speed to flow ratio. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the DG concentrate pumps calibration data. +} DG_CONC_PUMPS_CAL_DATA_T; + +/// DG concentrate pumps calibration record +typedef struct +{ + DG_CONC_PUMPS_CAL_DATA_T concentratePump[ NUM_OF_CONCENTRATE_PUMPS ]; ///< DG concentrate pumps calibration data. +} DG_CONC_PUMPS_CAL_RECORD_T; + +/// DG drain pump two-gain payload +typedef struct +{ + F32 voltage2SpeedRatio; ///< Voltage to speed ratio. + F32 stepSpeed2FlowRatio; ///< Step speed to flow ratio. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the drain pump structure. +} DG_DRAIN_PUMP_CAL_RECORD_T; + +/// DG RO pump calibration structure. +typedef struct +{ + F32 gain1Ratio; ///< RO pump gain1 ratio. + F32 gain2Ratio; ///< RO pump gain2 ratio. + F32 gain3Ratio; ///< RO pump gain3 ratio. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the DG RO pump calibration structure. +} DG_RO_PUMP_CAL_RECORD_T; + +/// Pressure sensors calibration structure +typedef struct +{ + LINEAR_CAL_PAYLOAD_T pressureSensors[ NUM_OF_CAL_DATA_PRES_SENSORS ]; ///< Pressure sensors to calibrate. + // NOTE: The reserved space is for 6 sensors. This portion of the struct should be eventually be + // reduced, so #define was not used for the size of the array + LINEAR_CAL_PAYLOAD_T reservedSpace[ 6 ]; ///< Reserved space for future pressure sensors. +} DG_PRES_SENSORS_CAL_RECORD_T; + +/// Flow sensors calibration structure +typedef struct +{ + LINEAR_CAL_PAYLOAD_T flowSensors[ NUM_OF_CAL_DATA_FLOW_SENSORS ]; ///< Flow sensors to calibrate. + // NOTE: The reserved space is for 6 sensors. This portion of the struct should be eventually be + // reduced, so #define was not used for the size of the array + LINEAR_CAL_PAYLOAD_T reservedSpace[ 3 ]; ///< Reserved space for future flow sensors. +} DG_FLOW_SENSORS_CAL_RECORD_T; + +/// Load cells calibration structure +typedef struct +{ + LINEAR_CAL_PAYLOAD_T loadCells[ NUM_OF_CAL_DATA_LOAD_CELLS ]; ///< Load cells to calibrate. +} DG_LOAD_CELLS_CAL_RECORD_T; + +/// Temperature sensors calibration structure +typedef struct +{ + LINEAR_CAL_PAYLOAD_T tempSensors[ NUM_OF_CAL_DATA_TEMP_SENSORS ]; ///< Temperature sensors to calibrate. + // NOTE: The reserved space is for 6 sensors. This portion of the struct should be eventually be + // reduced, so #define was not used for the size of the array + LINEAR_CAL_PAYLOAD_T reservedSpace[ 5 ]; ///< Reserved space for future temperature sensors. +} DG_TEMP_SENSORS_CAL_RECORD_T; + +/// Conductivity sensors calibration structure +typedef struct +{ + LINEAR_CAL_PAYLOAD_T condSensors[ NUM_OF_CAL_DATA_COND_SENSORS ]; ///< Conductivity sensors to calibrate. + // NOTE: The reserved space is for 6 sensors. This portion of the struct should be eventually be + // reduced, so #define was not used for the size of the array + LINEAR_CAL_PAYLOAD_T reservedSpace[ 2 ]; ///< Reserved space for future conductivity sensors. +} DG_COND_SENSORS_CAL_RECORD_T; + +/// Drain line volume calibration structure +typedef struct +{ + F32 volume; ///< DG Drain line volume. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC. +} DG_DRAIN_LINE_VOLUME_T; + +/// DG pre RO purge volume calibration structure +typedef struct +{ + F32 pressure2FlowRatio; ///< Pressure to flow ratio. + F32 volume; ///< Volume. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC. +} DG_PRE_RO_PURGE_VOLUME_T; + +/// DG reservoir volume calibration structure +typedef struct +{ + F32 rsrvrVolume; ///< Reservoir volume. + F32 normalFillVolume; ///< Normal fill volume. + F32 maxResidualFluid; ///< Max residual fluid. + F32 rsrvrUnfilledWeight; ///< Reservoir unfilled weight. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC. +} DG_RESERVOIR_VOLUME_DATA_T; + +/// DG reservoir volume record +typedef struct +{ + DG_RESERVOIR_VOLUME_DATA_T reservoir[ NUM_OF_CAL_DATA_RSRVRS ]; ///< DG reservoir volume data. +} DG_RESERVOIR_VOLUME_RECORD_T; + +/// DG generic volumes (reserved space) +typedef struct +{ + F32 volume; ///< Volume. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC. +} DG_GENERIC_VOLUME_T; + +/// DG acid concentrate +typedef struct +{ + F32 acidConcMixRatio; ///< Acid concentrate mix ratio. + F32 startVolume; ///< Start volume. + F32 reserverdSpace; ///< Reserved space. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC. +} DG_ACID_CONCENTRATE_T; + +/// DG bicarb concentrate +typedef struct +{ + F32 bicarbConcMixRatio; ///< Bicarb concentrate mix ratio. + F32 startVolume; ///< Start volume. + F32 reservedSpace; ///< Reserved space. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC. +} DG_BICARB_CONCENTRATE_T; + +/// DG acid concentrates +typedef struct +{ + DG_ACID_CONCENTRATE_T acidConcentrate[ NUM_OF_CAL_DATA_ACID_CONCENTRATES ]; ///< DG acid concentrates. +} DG_ACID_CONCENTRATES_T; + +/// DG bicarb concentrates +typedef struct +{ + DG_BICARB_CONCENTRATE_T bicarbConcentrate[ NUM_OF_CAL_DATA_BICARB_CONCENTRATES ]; ///< DG bicarb concentrates. +} DG_BICARB_CONCENTRATES_T; + +/// DG filter calibration record +typedef struct +{ + F32 reservedSpace1; ///< DG filter reserved space 1. + F32 reservedSpace2; ///< DG filter reserved space 2. + F32 reservedSpace3; ///< DG filter reserved space 3 + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC. +} DG_FILTER_CAL_RECORD_T; + +/// DG filters calibration data structure +typedef struct +{ + DG_FILTER_CAL_RECORD_T roFilter; ///< RO filter. + DG_FILTER_CAL_RECORD_T ultraFilter; ///< Ultra filter. + DG_FILTER_CAL_RECORD_T sedimentFilter; ///< Sediment filter. + DG_FILTER_CAL_RECORD_T carbonFilter; ///< Carbon filter. + DG_FILTER_CAL_RECORD_T carbonPolishFilter; ///< Carbon polish filter. +} DG_FILTERS_CAL_RECORD_T; + +/// DG fan calibration data structure +typedef struct +{ + F32 reservedSpace1; ///< Reserved space 1. + F32 reservedSpace2; ///< Reserved space 2. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC. +} DG_FAN_CAL_RECORD_T; + +/// DG fans calibration data structure +typedef struct +{ + DG_FAN_CAL_RECORD_T fan1; ///< Fan 1. + DG_FAN_CAL_RECORD_T fan2; ///< Fan 2. +} DG_FANS_CAL_RECORD_T; + +/// DG systems record structure +typedef struct +{ + char topLevelPN[ MAX_TOP_LEVEL_PN_CHARS ]; ///< DG top level part number. + char topLevelSN[ MAX_TOP_LEVEL_SN_CHARS ]; ///< DG top level serial number. + MFG_LOCATION_T mfgLocation; ///< DG manufacturing location. + U32 mfgDate; ///< DG manufacturing date. + U16 crc; ///< CRC for the DG system record structure. +} DG_SYSTEM_RECORD_T; + +/// DG service record structure +typedef struct +{ + SERVICE_LOCATION_T serviceLoc; ///< DG service location. + U32 serviceDate; ///< DG service date. + U16 crc; ///< CRC for the DG service record structure. +} DG_SERVICE_RECORD_T; + +/// DG scheduled runs record structure +typedef struct +{ + U32 lastRunTime; ///< DG scheduled run last run time. + U16 crc; ///< CRC for the DG scheduled run record structure. +} DG_SCHEDULED_RUN_T; + +/// DG scheduled run record structure +typedef struct +{ + DG_SCHEDULED_RUN_T dgScheduledRun[ NUM_OF_DG_SCHEDULED_RUNS ]; ///< DG scheduled run. +} DG_SCHEDULED_RUN_RECORD_T; +#pragma pack(pop) + +/**@}*/ + +#endif Index: NVDataMgmtHDRecords.h =================================================================== diff -u --- NVDataMgmtHDRecords.h (revision 0) +++ NVDataMgmtHDRecords.h (revision ff5e595afd7ad79dd7693dfa598b24fdeacad95d) @@ -0,0 +1,179 @@ + + +#ifndef FWCOMMON_NVDATAMGMTHDRECORDS_H_ +#define FWCOMMON_NVDATAMGMTHDRECORDS_H_ + +#include "Common.h" +#include "ConcentratePumps.h" + +/** + * @defgroup NVDataMgmtHDRecords NVDataMgmtHDRecords + * @brief Non-volatile HD data records including calibration records, system records, + * service records, and the scheduled runs record. + * + * @addtogroup NVDataMgmtHDRecords + * @{ + */ + +// ********** public definitions ********** + +#define MAX_TOP_LEVEL_PN_CHARS 10U ///< Max number of characters for top level part number. +#define MAX_TOP_LEVEL_SN_CHARS 15U ///< Max number of characters for top level serial number. + +/// Manufacturing location enumeration. +typedef enum mfg_location +{ + MFG_LOC_FACTORY = 0, ///< Manufacturing location (HD/DG). + NUM_OF_MFG_LOC ///< Number of manufacturing location. +} MFG_LOCATION_T; + +/// Service location enumeration. +typedef enum service_location +{ + SERVICE_LOC_FACTORY = 0, ///< Service location factory (HD/DG). + SERVICE_LOC_FIELD, ///< Service location field (HD/DG). + NUM_OF_SERVICE_LOC ///< Number of service location. +} SERVICE_LOCATION_T; + +/// HD pumps enumeration. +typedef enum hd_pumps +{ + CAL_DATA_BLOOD_PUMP = 0, ///< Blood pump. + CAL_DATA_DIALYSATE_PUMP_IN, ///< Inlet dialysate pump. + CAL_DATA_DIALYSATE_PUMP_OUT, ///< Outlet dialysate pump. + NUM_OF_CAL_DATA_HD_PUMPS ///< Number of HD pumps. +} CAL_DATA_HD_PUMPS_T; + +/// HD valves enumeration. +typedef enum hd_valves +{ + CAL_DATA_BLOOD_VENOUS_VALVE = 0, ///< Blood venous valve. + CAL_DATA_BLOOD_ARTERAIL_VALVE, ///< Blood arterial valve. + CAL_DATA_DIALYZER_INLET_VALVE, ///< Dialyzer inlet valve. + CAL_DATA_DIALYZER_OUTLET_VALVE, ///< Dialyzer outlet valve. + NUM_OF_CAL_DATA_HD_VALVES ///< Number of HD valves. +} CAL_DATA_HD_VALVES_T; + +/// HD occlusion sensor enumeration. +typedef enum hd_occlusion_sensors +{ + CAL_DATA_BLOOD_PUMP_OCCLUSION_SENSOR = 0, ///< Blood pump occlusion sensor. + CAL_DATA_DIALYSATE_INLET_PUMP_OCCLUSION_SENSOR, ///< Dialysate inlet occlusion sensor. + CAL_DATA_DIALYSATE_OUTLET_PUMP_OCCLUSION_SENSOR, ///< Dialysate outlet occlusion sensor. + NUM_OF_CAL_DATA_OCCLUSION_SENSORS, ///< Number of occlusion sensors. +} CAL_DATA_HD_OCCLUSION_SENSORS_T; + +/// HD flow sensors enumeration. +typedef enum hd_flow_sensors +{ + CAL_DATA_HD_BLOOD_FLOW_SENSOR = 0, ///< Blood flow sensor. + CAL_DATA_HD_DIALYZER_FLOW_SENSOR, ///< Dialyzer flow sensor. + NUM_OF_CAL_DATA_HD_FLOW_SENSORS, ///< Number of HD flow sensors. +} CAL_DATA_HD_FLOW_SENSORS_T; + +/// HD pressure sensors enumeration. +typedef enum hd_pressure_sensors +{ + CAL_DATA_ARTERIAL_PRESSURE_SENSOR = 0, ///< Arterial pressure sensor. + CAL_DATA_VENOUS_PRESSURE_SENSOR, ///< Venous pressure sensor. + NUM_OF_CAL_DATA_HD_PRESSURE_SESNSORS, ///< Number of HD pressure sensors. +} CAL_DATA_HD_PRESSURE_SENSORS_T; + +/// HD temperature sensors enumeration. +typedef enum hd_temperature_sensors +{ + CAL_DATA_HD_BOARD_TEMP_SENSOR_1 = 0, ///< Board temperature sensor 1. + CAL_DATA_HD_BOARD_TEMP_SENSOR_2, ///< Board temperature sensor 2. + CAL_DATA_HD_BOARD_TEMP_SENSOR_3, ///< Board temperature sensor 3. + CAL_DATA_HD_POWER_SUPPLY_TEMP_SENSOR, ///< Power supply temperature sensor. + NUM_OF_CAL_DATA_HD_TEMP_SENSORS, ///< Number of HD temperature sensors. +} CAL_DATA_HD_TEMEPERATURE_SENSORS_T; + +#pragma pack(push, 1) +/// Linear calibration structure +typedef struct +{ + F32 gain; ///< Gain. + F32 offset; ///< Offset. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the linear calibration payload. +} LINEAR_CAL_PAYLOAD_T; + +/// Non-linear calibration structure +typedef struct +{ + F32 gain; ///< Gain. + F32 offset; ///< Offset. + F32 reservedParam1; ///< Reserved parameter 1 + F32 reservedParam2; ///< Reserved parameter 2 + F32 reservedParam3; ///< Reserved parameter 3 + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the non-linear calibration payload. +} NON_LINEAR_CAL_PAYLOAD_T; + +/// HD pump calibration structure +typedef struct +{ + F32 pwm2Speed; ///< PWM to speed. + F32 speed2Flow; ///< Speed to flow. + F32 minCurrentLimit; ///< Minimum current limit. + F32 maxCurrentLinit; ///< Maximum current limit. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the HD pumps calibration payload. +} HD_PUMP_CAL_PAYLOAD_T; + +/// HD valve calibration structure +typedef struct +{ + F32 counts2Position; ///< Counts to position scalar. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the HD valves calibration payload. +} HD_VALVE_CAL_PAYLOAD_T; + +/// HD blood pumps calibration record +typedef struct +{ + HD_PUMP_CAL_PAYLOAD_T hdPumps[ NUM_OF_CAL_DATA_HD_PUMPS ]; ///< HD pumps calibration data. +} HD_PUMPS_CAL_RECORD_T; + +/// HD valves calibration record +typedef struct +{ + HD_VALVE_CAL_PAYLOAD_T hdvalves[ NUM_OF_CAL_DATA_HD_VALVES ]; ///< HD valves calibration data. +} HD_VALVES_CAL_RECORD_T; + +/// HD occlusion sensors calibration record +typedef struct +{ + LINEAR_CAL_PAYLOAD_T hdOcclusionSensors[ NUM_OF_CAL_DATA_OCCLUSION_SENSORS ]; ///< HD occlusion sensors calibration data. +} HD_OCCLUSION_SENSORS_CAL_RECORD_T; + +/// HD flow sensors calibration record +typedef struct +{ + LINEAR_CAL_PAYLOAD_T hdFlowSensors[ NUM_OF_CAL_DATA_HD_FLOW_SENSORS ]; ///< HD flow sensors calibration data. +} HD_FLOW_SENSORS_CAL_RECORD_T; + +/// HD pressure sensors calibration record +typedef struct +{ + NON_LINEAR_CAL_PAYLOAD_T hdPressureSensors[ NUM_OF_CAL_DATA_HD_PRESSURE_SESNSORS ]; ///< HD pressure sensors calibration data. +} HD_PRESSURE_SENSORS_CAL_RECORD_T; + +/// HD temperature sensors calibration record +typedef struct +{ + NON_LINEAR_CAL_PAYLOAD_T hdTemperatureSensors[ NUM_OF_CAL_DATA_HD_TEMP_SENSORS ]; ///< HD temperature sensors calibration data. +} HD_TEMP_SENSORS_CAL_RECORD_T; + +/// HD heparin force sensor calibration record +typedef struct +{ + NON_LINEAR_CAL_PAYLOAD_T hdHeparinForceSensor; ///< HD heparin force sensor calibration data. +} HD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T; + +#pragma pack(pop) + +/**@}*/ + +#endif