Index: firmware/App/Services/NVRecordsDD.c =================================================================== diff -u -r66b03c4d4724df628b4fd175567880f23eb35259 -r63c3a65e681810f037718377c6ed5a28c897d0ca --- firmware/App/Services/NVRecordsDD.c (.../NVRecordsDD.c) (revision 66b03c4d4724df628b4fd175567880f23eb35259) +++ firmware/App/Services/NVRecordsDD.c (.../NVRecordsDD.c) (revision 63c3a65e681810f037718377c6ed5a28c897d0ca) @@ -201,6 +201,16 @@ static BOOL isDDFillConductiviesRecordValid( DD_ACID_BICARB_FILL_COND_VALUES_T* record, DD_ACID_TYPES_T acidType, DD_FILL_COND_OPS_T operation ); static BOOL isDDBloodLeakSesnorValid( DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T* record ); +/*********************************************************************//** + * @brief + * The initNVRecordsDD function initializes the NV records data management + * state and resets related control variables. It sets the self-test + * process to start reading records. + * @details \b Inputs: none + * @details \b Outputs: nvDataMgmtSelfTestState, + * nvDataMgmtSelfTestResult, usageWriteTries + * @return none + *************************************************************************/ void initNVRecordsDD( void ) { // Initialize the parameters @@ -211,9 +221,14 @@ /*********************************************************************//** * @brief - * The execNVDataMgmtSelfTest runs the NVDataMgmt POST during the self-test. - * @details Inputs: nvDataMgmtSelfTestState, nvDataMgmtSelfTestResult - * @details Outputs: nvDataMgmtSelfTestState + * The execNVDataMgmtSelfTest function runs the NV data management + * self-test state machine. It processes states and updates the result + * based on self-test execution. + * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT + * @details \b Inputs: nvDataMgmtSelfTestState, + * nvDataMgmtSelfTestResult + * @details \b Outputs: nvDataMgmtSelfTestState, + * nvDataMgmtSelfTestResult * @return nvDataMgmtSelfTestResult the result of self-test *************************************************************************/ SELF_TEST_STATUS_T execNVDataMgmtSelfTest ( void ) @@ -243,28 +258,49 @@ return nvDataMgmtSelfTestResult; } +/*********************************************************************//** + * @brief + * The getProcessRecord function gets the process record + * specification for the given job. + * @details \b Inputs: RECORDS_SPECS + * @details \b Outputs: none + * @param job Record job identifier used to select the process record + * @return RECORDS_SPECS[job] corresponding process record specification + *************************************************************************/ + PROCESS_RECORD_SPECS_T getProcessRecord( RECORD_JOBS_STATE_T job ) { return RECORDS_SPECS[ job ]; } +/*********************************************************************//** + * @brief + * The getTemporaryRxRecord function gets the temporary RX record + * specification for the given job. + * @details \b Inputs: tempRxRecords + * @details \b Outputs: none + * @param job Record job identifier used to select the temporary RX record + * @return tempRxRecords[job] corresponding temporary RX record + *************************************************************************/ PROCESS_RECORD_SPECS_T getTemporaryRxRecord( RECORD_JOBS_STATE_T job ) { return tempRxRecords[ job ]; } /*********************************************************************//** * @brief - * The handleSelfTestReadRecords waits for the records to be read - * @details Inputs: none - * @details Outputs: none - * @return next state + * The handleSelfTestReadRecords function waits for the records to be + * read and updates the state when reading is complete. + * @details \b Inputs: isSelfTestReadRecordsDone + * @details \b Outputs: none + * @return state next self-test state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadRecords( void ) { NVDATAMGMT_SELF_TEST_STATE_T state = NVDATAMGMT_SELF_TEST_STATE_READ_RECORDS; - // Check if the queues are empty and the exec state machine is in Idle meaning all the records have been read and the state machine + // Check if the queues are empty and the exec state machine is in Idle meaning + // all the records have been read and the state machine // is back at Idle so even the last job in the queue has been processed if ( TRUE == isSelfTestReadRecordsDone ) { @@ -277,11 +313,13 @@ /*********************************************************************//** * @brief - * The handleSelfTestCheckCRC calculates the CRC of the records and compares - * them to the CRC that was read. If they don't match, it will fail POST. - * @details Inputs: nvDataMgmtSelfTestResult - * @details Outputs: none - * @return next state + * The handleSelfTestCheckCRC function checks the CRC of records and + * compares them with stored CRC values. If they don't match, it will fail POST. + * It updates the self-test result + * and schedules rewrite for invalid records. + * @details \b Inputs: nvDataMgmtSelfTestResult + * @details \b Outputs: nvDataMgmtSelfTestResult + * @return state next self-test state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestCheckCRC ( void ) { @@ -344,12 +382,12 @@ /*********************************************************************//** * @brief - * The benignPolynomialCalRecord function benigns the provided polynomial - * calibration record. - * @details Inputs: none - * @details Outputs: none - * @return record which is a pointer to a polynomial calibration record - * otherwise none + * The benignPolynomialCalRecord function fills the provided polynomial + * calibration record with benign default values and updates its CRC. + * @details \b Inputs: none + * @details \b Outputs: none + * @param record Pointer to the polynomial calibration record to update + * @return none *************************************************************************/ void benignPolynomialCalRecord( POLYNOMIAL_CAL_PAYLOAD_T* record ) { @@ -364,15 +402,12 @@ /*********************************************************************//** * @brief - * The isPolynomialRecordValid function checks whether the records are - * still valid by calculating the CRCs and comparing it to the strucutre's - * CRC. - * @details Inputs: none - * @details Outputs: none - * @param record: pointer to a polynomial payload. The actual calibration - * data to be checked - * @param isRecordNeeded: TRUE is the calibration record is need in the - * firmware right now otherwise, FALSE + * The isPolynomialRecordValid function checks if the polynomial record + * is valid by comparing calculated CRC with stored CRC. If invalid, + * it updates the record with benign values. + * @details \b Inputs: none + * @details \b Outputs: none + * @param record Pointer to the polynomial calibration record to check * @return TRUE if the records' data is valid otherwise FALSE *************************************************************************/ static BOOL isPolynomialRecordValid( POLYNOMIAL_CAL_PAYLOAD_T* record ) @@ -394,12 +429,17 @@ /*********************************************************************//** * @brief - * The isDDSystemRecordValid function checks the validity of the DG system - * record. - * @details Inputs: ddSystemGroup.ddSystemRecord - * @details Outputs: none - * @return TRUE if the DG system record is valid otherwise FALSE + * The isDDSystemRecordValid function checks the validity of the DD + * system record. It verifies CRC and updates the record with default + * values if invalid. + * @details \b Alarms: ALARM_ID_DD_NVM_INVALID_SYSTEM_RECORD_CRC if CRC + * check fails, ALARM_ID_DD_NVM_INVALID_SERIAL_NUMBER if serial number + * is not initialized + * @details \b Inputs: ddSystemGroup.ddSystemRecord + * @details \b Outputs: ddSystemGroup.ddSystemRecord, ddSystemGroup.crc + * @return TRUE if the DD system record is valid otherwise FALSE *************************************************************************/ + static BOOL isDDSystemRecordValid( void ) { BOOL status = TRUE; @@ -435,11 +475,15 @@ /*********************************************************************//** * @brief - * The isDDServiceRecordValid function checks the validity of the DG service - * record. - * @details Inputs: ddServiceGroup.ddServiceRecord - * @details Outputs: none - * @return TRUE if the DG service record is valid otherwise FALSE + * The isDDServiceRecordValid function checks the validity of the DD + * service record. It verifies CRC and updates the record with default + * values if invalid. + * @details \b Alarms: ALARM_ID_DD_NVM_INVALID_SERVICE_RECORD_CRC if CRC + * check fails + * @details \b Inputs: ddServiceGroup.ddServiceRecord + * @details \b Outputs: ddServiceGroup.ddServiceRecord, + * ddServiceGroup.crc + * @return TRUE if the DD service record is valid otherwise FALSE *************************************************************************/ static BOOL isDDServiceRecordValid( void ) { @@ -466,11 +510,14 @@ /*********************************************************************//** * @brief - * The isDDUsageRecordValid function checks whether the DG usage information - * is valid or not. - * @details Inputs: ddUsageInfoGroup - * @details Outputs: ddUsageInfoGroup - * @return TRUE if the DG usage record is valid otherwise FALSE + * The isDDUsageRecordValid function checks the validity of the DD + * usage information record. It verifies CRC and updates the record + * with default values if invalid. + * @details \b Alarms: ALARM_ID_DD_NVM_INVALID_USAGE_RECORD_CRC if CRC + * check fails + * @details \b Inputs: ddUsageInfoGroup + * @details \b Outputs: ddUsageInfoGroup + * @return TRUE if the DD usage record is valid otherwise FALSE *************************************************************************/ static BOOL isDDUsageRecordValid( void ) { @@ -496,11 +543,14 @@ /*********************************************************************//** * @brief - * The isDDCalibrationRecordValid function calls other functions to check - * the validity of DG calibration record. - * @details Inputs: ddCalibrationRecord - * @details Outputs: none - * @return TRUE if the DG calibration record is valid otherwise FALSE + * The isDDCalibrationRecordValid function checks the validity of the DD + * calibration record. It verifies all calibration sub-records and + * updates them with benign values if invalid. + * @details \b Alarms: ALARM_ID_DD_NVM_INVALID_CALIBRATION_RECORD_CRC if + * CRC check fails or any sub-record is invalid + * @details \b Inputs: ddCalibrationRecord + * @details \b Outputs: ddCalibrationRecord + * @return TRUE if the DD calibration record is valid otherwise FALSE *************************************************************************/ static BOOL isDDCalibrationRecordValid( void ) { @@ -605,11 +655,12 @@ /*********************************************************************//** * @brief - * The isDDAcidConcentrateRecordValid function checks whether the calibration - * record of acid concentrate is valid or not. - * @details Inputs: none - * @details Outputs: none - * @param record: DD_ACID_CONCENTRATE_T pointer + * The isDDAcidConcentrateRecordValid function checks if the acid + * concentrate calibration record is valid. It verifies CRC and updates + * the record with default values if invalid. + * @details \b Inputs: none + * @details \b Outputs: none + * @param record Pointer to DD acid concentrate record to check * @return TRUE if the record is valid otherwise FALSE *************************************************************************/ static BOOL isDDAcidConcentrateRecordValid( DD_ACID_CONCENTRATE_T* record ) @@ -635,11 +686,12 @@ /*********************************************************************//** * @brief - * The isDDBicarbConcentrateRecordValid function checks whether the - * calibration record of bicarb concentrate is valid or not. - * @details Inputs: none - * @details Outputs: none - * @param record: DD_BICARB_CONCENTRATE_T pointer + * The isDDBicarbConcentrateRecordValid function checks if the bicarb + * concentrate calibration record is valid. It verifies CRC and updates + * the record with default values if invalid. + * @details \b Inputs: none + * @details \b Outputs: none + * @param record Pointer to DD bicarb concentrate record to check * @return TRUE if the record is valid otherwise FALSE *************************************************************************/ static BOOL isDDBicarbConcentrateRecordValid( DD_BICARB_CONCENTRATE_T* record ) @@ -665,11 +717,12 @@ /*********************************************************************//** * @brief - * The isDDAccelerometerSensorRecordValid function checks whether the - * calibration record of accelerometer sensor is valid or not. - * @details Inputs: none - * @details Outputs: none - * @param record: DD_ACCELEROMETER_SENSOR_CAL_RECORD_T pointer + * The isDDAccelerometerSensorRecordValid function checks if the + * accelerometer sensor calibration record is valid. It verifies CRC + * and updates the record with default values if invalid. + * @details \b Inputs: none + * @details \b Outputs: none + * @param record Pointer to accelerometer sensor calibration record to check * @return TRUE if the record is valid otherwise FALSE *************************************************************************/ static BOOL isDDAccelerometerSensorRecordValid( DD_ACCEL_SENSOR_CAL_RECORD_T* record ) @@ -696,17 +749,20 @@ /*********************************************************************//** * @brief - * The isDGFillConductiviesRecordValid function checks whether fill conductivity - * record is valid or not. - * @details Inputs: none - * @details Outputs: none - * @param record: DG_ACID_BICARB_FILL_COND_VALUES_T pointer containing the - * fill conductivities of acid and bicrab - * @param operation which is the type fill operation that is check (e.g. normal ops) - * @param acidType whcih is the type of acid that its values are checked (e.g. 0-1251-1) + * The isDDFillConductiviesRecordValid function checks if the fill + * conductivity record is valid. It verifies CRC and updates the record + * with default values based on operation and acid type if invalid. + * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT if invalid acidType or + * operation is detected + * @details \b Inputs: none + * @details \b Outputs: none + * @param record Pointer to fill conductivity record to check + * @param acidType Type of acid for which values are checked + * @param operation Type of fill operation being checked * @return TRUE if the record is valid otherwise FALSE *************************************************************************/ -static BOOL isDDFillConductiviesRecordValid( DD_ACID_BICARB_FILL_COND_VALUES_T* record, DD_ACID_TYPES_T acidType, DD_FILL_COND_OPS_T operation ) +static BOOL isDDFillConductiviesRecordValid( DD_ACID_BICARB_FILL_COND_VALUES_T* record, + DD_ACID_TYPES_T acidType, DD_FILL_COND_OPS_T operation ) { BOOL status = TRUE; U16 calcCRC = crc16 ( (U08*)record, sizeof(DD_ACID_BICARB_FILL_COND_VALUES_T) - sizeof(U16) ); @@ -795,11 +851,12 @@ /*********************************************************************//** * @brief - * The isDDBloodLeakSesnorValid function checks whether the calibration record - * of DD blood leak sensor is valid or not. - * @details Inputs: none - * @details Outputs: none - * @param record: DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T pointer + * The isDDBloodLeakSesnorValid function checks if the blood leak sensor + * calibration record is valid. It verifies CRC and updates the record + * with default values if invalid. + * @details \b Inputs: none + * @details \b Outputs: none + * @param record Pointer to blood leak sensor calibration record to check * @return TRUE if the record is valid otherwise FALSE *************************************************************************/ static BOOL isDDBloodLeakSesnorValid( DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T* record ) @@ -823,13 +880,15 @@ /*********************************************************************//** * @brief - * The setLastDisinfectDate sets a queue job to write the last time that DG - * was disinfected. - * @details Inputs: dgUsageInfoGroup - * @details Outputs: dgUsageInfoGroup - * @param disinfect type (i.e chemical) - * @param epochTime last disinfect time in epoch - * @return TRUE if queue is not full + * The setLastDisinfectDate function updates the last disinfect time in + * usage info and schedules a write to memory if queue is available. + * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT if invalid disinfect + * type is selected or write retries exceed limit + * @details \b Inputs: ddUsageInfoGroup, usageWriteTries + * @details \b Outputs: ddUsageInfoGroup, usageWriteTries + * @param disinfect Type of disinfect operation + * @param epochTime Last disinfect time in epoch + * @return TRUE if queue is not full otherwise FALSE *************************************************************************/ BOOL setLastDisinfectDate( DD_USAGE_INFO_ITEMS_T disinfect, U32 epochTime ) { @@ -878,12 +937,13 @@ /*********************************************************************//** * @brief - * The setServiceTime function sets the latest service time in epoch and updates - * the usage information after the service. - * @details Inputs: none - * @details Outputs: hdServiceGroup, hdUsageInfoGroup - * @return TRUE if the queue has sufficient space to enqueue all the changed - * records + * The setServiceTime function updates the latest service time and + * resets related usage information. It schedules writing updated + * records if sufficient queue space is available. + * @details \b Inputs: ddServiceGroup, ddUsageInfoGroup + * @details \b Outputs: ddServiceGroup, ddUsageInfoGroup + * @return TRUE if the queue has sufficient space to enqueue all the + * changed records otherwise FALSE *************************************************************************/ BOOL setServiceTime( void ) { @@ -919,10 +979,10 @@ /*********************************************************************//** * @brief - * The getMinRORejectionRatioInInstitRecordPCT returns the value of the min RO - * rejection ratio in institutional record in percent - * @details Inputs: ddInstitutionalGroup - * Output: none + * The getMinRORejectionRatioInInstitRecordPCT function gets the minimum + * RO rejection ratio value from the institutional record in percent. + * @details \b Inputs: ddInstitutionalGroup + * @details \b Outputs: none * @return the min RO rejection ratio in institutional record in percent *************************************************************************/ U32 getMinRORejectionRatioInInstitRecordPCT( void ) @@ -932,12 +992,15 @@ /*********************************************************************//** * @brief - * The getMinInletWaterConductivityLimitInstitRecord returns the value of - * the inlet water conductivity alarm limit in uS/cm in institutional record - * @details Inputs: ddInstitutionalGroup - * Output: none - * @return the inlet water conductivity alarm limit in uS/cm in institutional record + * The getMinInletWaterConductivityLimitInstitRecordUSPCM function gets + * the inlet water conductivity alarm limit value from the institutional + * record in uS/cm. + * @details \b Inputs: ddInstitutionalGroup + * @details \b Outputs: none + * @return the inlet water conductivity alarm limit in uS/cm in + * institutional record *************************************************************************/ + F32 getMinInletWaterConductivityLimitInstitRecordUSPCM( void ) { return ddInstitutionalGroup.ddInstitutionalRecord.minInletWaterCondAlarmLimitUSPCM; @@ -946,20 +1009,22 @@ /*********************************************************************//** * @brief * The getNVRecord2Driver function copies the requested non-volatile - * data into the provided buffer by the caller. The function then checks if - * the non-volatile data is valid. If the data is not valid, it raises the - * provided alarm by the caller. - * @details Inputs: ddCalibrationRecord - * @details Outputs: ddCalibrationRecord - * @param nvData the non-volatile data to be copied - * @param bufferAddress the address of the provided buffer by the caller - * @param bufferLength the length of the provided buffer by the caller - * @param numOfSnsrs2Check the number of sensors to check in a array of sensors called + * data into the provided buffer and checks if the data is valid. It + * raises the specified alarm if invalid data is detected. + * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT if invalid record is + * selected, nvAlarm if non-volatile data is invalid + * @details \b Inputs: ddCalibrationRecord + * @details \b Outputs: none + * @param nvData The non-volatile data to be copied + * @param bufferAddress Address of the provided buffer + * @param bufferLength Length of the provided buffer + * @param numOfSnsrs2Check Number of sensors to check * @param nvAlarm the corresponding alarm of the non-volatile data to be raised * if the data is not valid - * @return TRUE if the non-volatile data is valid otherwise, FALSE + * @return TRUE if the non-volatile data is valid otherwise FALSE *************************************************************************/ -BOOL getNVRecord2Driver( NV_DATA_T nvData, U08* bufferAddress, U32 bufferLength, U08 numOfSnsrs2Check, ALARM_ID_T nvAlarm ) +BOOL getNVRecord2Driver( NV_DATA_T nvData, U08* bufferAddress, U32 bufferLength, + U08 numOfSnsrs2Check, ALARM_ID_T nvAlarm ) { U08 i; U08* nvDataStartPtr = 0; @@ -1082,29 +1147,66 @@ return ( FALSE == isNVDataInvalid ? TRUE : FALSE ); } +/*********************************************************************//** + * @brief + * The updateNVSelfTestResult function updates the NV data management + * self-test result with the provided value. + * @details \b Inputs: none + * @details \b Outputs: nvDataMgmtSelfTestResult + * @param result Self-test result to be updated + * @return none + *************************************************************************/ void updateNVSelfTestResult( SELF_TEST_STATUS_T result ) { nvDataMgmtSelfTestResult = result; } +/*********************************************************************//** + * @brief + * The updateNVSelfTestState function updates the NV data management + * self-test state with the provided value. + * @details \b Inputs: none + * @details \b Outputs: nvDataMgmtSelfTestState + * @param state Self-test state to be updated + * @return none + *************************************************************************/ void updateNVSelfTestState( NVDATAMGMT_SELF_TEST_STATE_T state ) { nvDataMgmtSelfTestState = state; } -void updateSelfTestReadRecordsFlag ( BOOL value ) +/*********************************************************************//** + * @brief + * The updateSelfTestReadRecordsFlag function updates the flag that + * indicates whether self-test record reading is complete. + * @details \b Inputs: none + * @details \b Outputs: isSelfTestReadRecordsDone + * @param value Flag value to be updated + * @return none + *************************************************************************/ +void updateSelfTestReadRecordsFlag( BOOL value ) { isSelfTestReadRecordsDone = value; } + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + /*********************************************************************//** * @brief - * The testSetNVRecordCRCOverride overrides the non-volatile record CRC override. - * @details Inputs: none - * @details Outputs: none - * @param job the job to override its CRC (i.e. calibration record) - * @param crc the value its CRC to be overridden - * @return TRUE if the job was scheduled successfully otherwise, FALSE + * The testSetNVRecordCRCOverride function overrides the CRC value of + * the selected non-volatile record and schedules it for writing. + * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT if invalid job is + * selected + * @details \b Inputs: none + * @details \b Outputs: ddCalibrationRecord, ddSystemGroup, + * ddServiceGroup, ddInstitutionalGroup, ddUsageInfoGroup + * @param job The job whose CRC needs to be overridden + * @param crc The CRC value to be set + * @return TRUE if the job was scheduled successfully otherwise FALSE *************************************************************************/ BOOL testSetNVRecordCRCOverride( U32 job, U16 crc ) {