Index: firmware/App/Drivers/NVDriver.c =================================================================== diff -u -rf525d2be1e7038cacbe2bb34b8db3505cf26a350 -r63c3a65e681810f037718377c6ed5a28c897d0ca --- firmware/App/Drivers/NVDriver.c (.../NVDriver.c) (revision f525d2be1e7038cacbe2bb34b8db3505cf26a350) +++ firmware/App/Drivers/NVDriver.c (.../NVDriver.c) (revision 63c3a65e681810f037718377c6ed5a28c897d0ca) @@ -25,12 +25,22 @@ // ********** private definitions ********** // The clock frequency comes from HCLK_FREQ and it has to be rounded up to the nearest number -#define ROUNDED_HCLK_FREQ FLOAT_TO_INT_WITH_ROUND(HCLK_FREQ) ///< Rounded HCLK for EERPOM clock. -#define BANK7_SECTOR_0_31_ENABLE_BIT_MASK 0x0000000F ///< Bank7 sector 0 t0 31 enable mask. -#define BANK7_SECTOR_32_63_ENABLE_BIT_MASK 0x00000000 ///< Bank7 sector 32 to 63 enable mask. +#define ROUNDED_HCLK_FREQ FLOAT_TO_INT_WITH_ROUND(HCLK_FREQ) ///< Rounded HCLK for EERPOM clock. +#define BANK7_SECTOR_0_31_ENABLE_BIT_MASK 0x0000000F ///< Bank7 sector 0 t0 31 enable mask. +#define BANK7_SECTOR_32_63_ENABLE_BIT_MASK 0x00000000 ///< Bank7 sector 32 to 63 enable mask. -static BOOL getSectorStartAddress( U32* recordFlashAddress ); +// ********** private function prototypes ********** +static BOOL isSectorStartAddress( U32* recordFlashAddress ); + +/*********************************************************************//** + * @brief + * The initNVDriver function initializes the Non Volatile Memory Driver module. + * It configures and enables flash bank 7 and its EEPROM sectors. + * @details \b Inputs: none + * @details \b Outputs: none + * @return none + *************************************************************************/ void initNVDriver( void ) { // Initialize and activate flash bank 7 @@ -39,46 +49,97 @@ Fapi_enableEepromBankSectors( BANK7_SECTOR_0_31_ENABLE_BIT_MASK, BANK7_SECTOR_32_63_ENABLE_BIT_MASK ); } +/*********************************************************************//** + * @brief + * The eraseSector function erases a flash sector at the specified address. + * It validates the address and issues an erase command if valid. + * @details \b Inputs: none + * @details \b Outputs: none + * @param recordFlashAddress Flash address of the sector to erase + * @return none + *************************************************************************/ void eraseSector( U32* recordFlashAddress ) { - BOOL isFlashAddressValid = getSectorStartAddress( recordFlashAddress ); + BOOL isFlashAddressValid = isSectorStartAddress( recordFlashAddress ); if ( TRUE == isFlashAddressValid) { Fapi_issueAsyncCommandWithAddress( Fapi_EraseSector, recordFlashAddress ); } } +/*********************************************************************//** + * @brief + * The writeSector function programs data to a flash sector at the specified address. + * It validates the address and buffer before issuing the programming command. + * @details \b Inputs: none + * @details \b Outputs: none + * @param recordFlashAddress Flash address where data will be written + * @param bufferAddress Pointer to the data buffer to be written + * @param bufferSize Size of the buffer to be written + * @return none + *************************************************************************/ void writeSector( U32* recordFlashAddress, U08* bufferAddress, U32 bufferSize ) { // Create a copy only for validation U32 sectorStartAddress = *recordFlashAddress; - BOOL isFlashAddressValid = getSectorStartAddress( §orStartAddress ); + BOOL isFlashAddressValid = isSectorStartAddress( §orStartAddress ); if ( ( TRUE == isFlashAddressValid ) && ( NULL != bufferAddress ) && ( bufferSize > 0 ) ) { Fapi_issueProgrammingCommand( recordFlashAddress, bufferAddress, bufferSize, 0x00, 0, Fapi_DataOnly ); } } +/*********************************************************************//** + * @brief + * The readSector function reads data from a flash sector at the specified address. + * It validates the address and buffer before performing the read operation. + * @details \b Inputs: none + * @details \b Outputs: none + * @param recordFlashAddress Flash address to read from + * @param bufferAddress Pointer to the buffer where data will be stored + * @param bufferSize Size of the data to be read + * @return none + *************************************************************************/ void readSector( U32* recordFlashAddress, U32* bufferAddress, U32 bufferSize ) { // Create a copy only for validation U32 sectorStartAddress = *recordFlashAddress; - BOOL isFlashAddressValid = getSectorStartAddress( §orStartAddress ); + BOOL isFlashAddressValid = isSectorStartAddress( §orStartAddress ); if ( ( TRUE == isFlashAddressValid ) && ( NULL != bufferAddress ) && ( bufferSize > 0 ) ) { Fapi_doMarginRead( recordFlashAddress, bufferAddress, bufferSize, Fapi_NormalRead ); } } +/*********************************************************************//** + * @brief + * The isFlashReady function checks whether the flash FSM is ready. + * It returns the readiness status of the flash state machine. + * @details \b Inputs: none + * @details \b Outputs: none + * @return value indicating flash ready status (TRUE if ready, FALSE otherwise) + *************************************************************************/ BOOL isFlashReady( void ) { - return (Fapi_Status_FsmReady == FAPI_CHECK_FSM_READY_BUSY); + return ( Fapi_Status_FsmReady == FAPI_CHECK_FSM_READY_BUSY ); } -static BOOL getSectorStartAddress( U32* recordFlashAddress ) +/*********************************************************************//** + * @brief + * The isSectorStartAddress function validates and aligns a flash address + * to a sector start. It checks if the address falls within defined + * sectors and updates it accordingly. + * @details \b Inputs: none + * @details \b Outputs: none + * @param recordFlashAddress Pointer to the flash address to validate + * and update + * @return isFlashAddressValid indicating address validity (TRUE if valid, FALSE + * otherwise) + *************************************************************************/ +static BOOL isSectorStartAddress( U32* recordFlashAddress ) { BOOL isFlashAddressValid = TRUE; @@ -115,6 +176,5 @@ return isFlashAddressValid; } - /**@}*/ Index: firmware/App/Drivers/NVDriver.h =================================================================== diff -u -rb878faee61a0800b767d053ab3f65afb3790dacb -r63c3a65e681810f037718377c6ed5a28c897d0ca --- firmware/App/Drivers/NVDriver.h (.../NVDriver.h) (revision b878faee61a0800b767d053ab3f65afb3790dacb) +++ firmware/App/Drivers/NVDriver.h (.../NVDriver.h) (revision 63c3a65e681810f037718377c6ed5a28c897d0ca) @@ -19,52 +19,53 @@ /** * @defgroup NVDriver NVDriver - * @brief + * @brief Non Volatile Memory Driver module provides an abstraction layer for + * accessing Flash memory, ncluding initialization, sector erase, read, and write operations. * * @addtogroup NVDriver * @{ */ // ********** public definitions ********** -#define BANK7_SECTOR0_START_ADDRESS 0xF0200000 ///< Bank7 sector 0 start address. -#define BANK7_SECTOR0_END_ADDRESS 0xF0203FFF ///< Bank7 sector 0 end address. +#define BANK7_SECTOR0_START_ADDRESS 0xF0200000 ///< Bank7 sector 0 start address. +#define BANK7_SECTOR0_END_ADDRESS 0xF0203FFF ///< Bank7 sector 0 end address. -#define BANK7_SECTOR1_START_ADDRESS 0xF0204000 ///< Bank7 sector 1 start address. -#define BANK7_SECTOR1_END_ADDRESS 0xF0207FFF ///< Bank7 sector 1 end address. +#define BANK7_SECTOR1_START_ADDRESS 0xF0204000 ///< Bank7 sector 1 start address. +#define BANK7_SECTOR1_END_ADDRESS 0xF0207FFF ///< Bank7 sector 1 end address. -#define BANK7_SECTOR2_START_ADDRESS 0xF0208000 ///< Bank7 sector 2 start address. -#define BANK7_SECTOR2_END_ADDRESS 0xF020BFFF ///< Bank7 sector 2 end address. +#define BANK7_SECTOR2_START_ADDRESS 0xF0208000 ///< Bank7 sector 2 start address. +#define BANK7_SECTOR2_END_ADDRESS 0xF020BFFF ///< Bank7 sector 2 end address. -#define BANK7_SECTOR3_START_ADDRESS 0xF020C000 ///< Bank7 sector 3 start address. -#define BANK7_SECTOR3_END_ADDRESS 0xF020FFFF ///< Bank7 sector 3 end address. +#define BANK7_SECTOR3_START_ADDRESS 0xF020C000 ///< Bank7 sector 3 start address. +#define BANK7_SECTOR3_END_ADDRESS 0xF020FFFF ///< Bank7 sector 3 end address. /// NVDataMgmt memory operation modes enumeration. typedef enum NVDataMgmt_Operation { - NVDATAMGMT_NONE = 0, ///< Default mode to prevent any accidental ops. - NVDATAMGMT_WRITE, ///< Operation mode write. - NVDATAMGMT_READ, ///< Operation mode read. - NVDATAMGMT_ERASE_SECTOR, ///< Operation mode erase a sector (EEPROM). - NUM_OF_NVDATAMGMT_OPS_STATES ///< Total number of operation states. + NVDATAMGMT_NONE = 0, ///< Default mode to prevent any accidental ops. + NVDATAMGMT_WRITE, ///< Operation mode write. + NVDATAMGMT_READ, ///< Operation mode read. + NVDATAMGMT_ERASE_SECTOR, ///< Operation mode erase a sector (EEPROM). + NUM_OF_NVDATAMGMT_OPS_STATES ///< Total number of operation states. } NVDATAMGMT_OPERATION_STATE_T; /// NVDataMgmt records' jobs states typedef enum NVDataMgmt_Records_Jobs { - NVDATAMGMT_SYSTEM_RECORD = 0, ///< NVDataMgmt process write system record. - NVDATAMGMT_SERVICE_RECORD, ///< NVDataMgmt process service record. - NVDATAMGMT_CALIBRATION_RECORD, ///< NVDataMgmt process write calibration record. - NVDATAMGMT_INSTITUTIONAL_RECORD, ///< NVDataMgmt process institutional record. - NVDATAMGMT_USAGE_INFO_RECORD, ///< NVDataMgmt process usage info record. - NUM_OF_NVDATMGMT_RECORDS_JOBS ///< Number of NVDataMgmt records jobs. + NVDATAMGMT_SYSTEM_RECORD = 0, ///< NVDataMgmt process system record. + NVDATAMGMT_SERVICE_RECORD, ///< NVDataMgmt process service record. + NVDATAMGMT_CALIBRATION_RECORD, ///< NVDataMgmt process calibration record. + NVDATAMGMT_INSTITUTIONAL_RECORD, ///< NVDataMgmt process institutional record. + NVDATAMGMT_USAGE_INFO_RECORD, ///< NVDataMgmt process usage info record. + NUM_OF_NVDATMGMT_RECORDS_JOBS ///< Number of NVDataMgmt records jobs. } RECORD_JOBS_STATE_T; /// Process records job structure typedef struct { - NVDATAMGMT_OPERATION_STATE_T memoryOperation; ///< Memory operation. - RECORD_JOBS_STATE_T recordJob; ///< Record job (i.e sector 0). + NVDATAMGMT_OPERATION_STATE_T memoryOperation; ///< Memory operation. + RECORD_JOBS_STATE_T recordJob; ///< Record job (i.e sector 0). } PROCESS_RECORD_JOB_T; // ********** public function prototypes ********** Index: firmware/App/Services/NVMsgQ.c =================================================================== diff -u -r0face6417892ea9de28d146bf88d44a9f30cf2a4 -r63c3a65e681810f037718377c6ed5a28c897d0ca --- firmware/App/Services/NVMsgQ.c (.../NVMsgQ.c) (revision 0face6417892ea9de28d146bf88d44a9f30cf2a4) +++ firmware/App/Services/NVMsgQ.c (.../NVMsgQ.c) (revision 63c3a65e681810f037718377c6ed5a28c897d0ca) @@ -99,10 +99,8 @@ static U08 recordQueueFrontIndex; ///< Record queue front index. static U08 recordQueueCount; ///< Record queue count. static PROCESS_RECORD_JOB_T recordCurrentJob; ///< Record queue current job. - static NVDATAMGMT_RECORDS_READ_STATUS_T recordsReadStatus; ///< NVDataMgmt records read status. static BOOL isNewNVRecordAvailable; ///< Signal to indicate whether a new NVM data is available. - static RECORD_JOBS_STATE_T recordToPublish; ///< Record to publish (i.e. calibration, system) static RECORD_JOBS_STATE_T nvPublishRecordType; static SEND_RECORD_STATE_T nvMExecSendRecordState; ///< NVDataMgmt exec process record state. @@ -117,8 +115,6 @@ static U32 recordReceiveStartTime; ///< Time stamp the calibration/service was received. static U32 newRecordStartTimer; ///< New record availability start timer. - - // ********** private function prototypes ********** // Process record functions @@ -491,83 +487,8 @@ return recordsReadStatus; } -BOOL testDDGetNVRecord( MESSAGE_T *message ) -{ - BOOL result = FALSE; - RECORD_JOBS_STATE_T job; - // verify payload length - if ( 1 == message->hdr.payloadLen ) - { - job = ( RECORD_JOBS_STATE_T )message->payload[ 0 ]; -// job = getNVMRecordJobState( msgID ); - if ( ( job < NUM_OF_NVDATMGMT_RECORDS_JOBS ) && - ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) ) - { - isPublishRecordRequested[ job ] = TRUE; - recordToPublish = job; - result = TRUE; - } - - } - - return result; -} - -BOOL testDDSetNVSystemRecord( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // System record can be updated only in service mode - if ( DD_MODE_SERV == getCurrentOperationMode() ) - { - result = receiveDDRecord ( message ); - } - - return result; -} - -BOOL testDDSetNVServiceRecord( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // Service record can be updated only in service mode - if ( DD_MODE_SERV == getCurrentOperationMode() ) - { - result = receiveDDRecord ( message ); - } - - return result; -} - -BOOL testDDSetNVCalibrationRecord( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // Calibration record can be updated only in service mode - if ( DD_MODE_SERV == getCurrentOperationMode() ) - { - result = receiveDDRecord ( message ); - } - - return result; -} - -BOOL testDDSetNVInstitutionalRecord( MESSAGE_T *message ) -{ - BOOL result = FALSE; - result = receiveDDRecord ( message ); - return result; -} - -BOOL testDDSetNVUsageInfoRecord( MESSAGE_T *message ) -{ - BOOL result = FALSE; - result = receiveDDRecord ( message ); - return result; -} - /*********************************************************************//** * @brief * The sendDDCalibrationRecord function sends out the DD calibration @@ -843,4 +764,88 @@ return recordCurrentJob; } + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +BOOL testDDGetNVRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + RECORD_JOBS_STATE_T job; + + // verify payload length + if ( 1 == message->hdr.payloadLen ) + { + job = ( RECORD_JOBS_STATE_T )message->payload[ 0 ]; +// job = getNVMRecordJobState( msgID ); + + if ( ( job < NUM_OF_NVDATMGMT_RECORDS_JOBS ) && + ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) ) + { + isPublishRecordRequested[ job ] = TRUE; + recordToPublish = job; + result = TRUE; + } + + } + + return result; +} + +BOOL testDDSetNVSystemRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // System record can be updated only in service mode + if ( DD_MODE_SERV == getCurrentOperationMode() ) + { + result = receiveDDRecord ( message ); + } + + return result; +} + +BOOL testDDSetNVServiceRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Service record can be updated only in service mode + if ( DD_MODE_SERV == getCurrentOperationMode() ) + { + result = receiveDDRecord ( message ); + } + + return result; +} + +BOOL testDDSetNVCalibrationRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Calibration record can be updated only in service mode + if ( DD_MODE_SERV == getCurrentOperationMode() ) + { + result = receiveDDRecord ( message ); + } + + return result; +} + +BOOL testDDSetNVInstitutionalRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + result = receiveDDRecord ( message ); + return result; +} + +BOOL testDDSetNVUsageInfoRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + result = receiveDDRecord ( message ); + return result; +} + /**@}*/ Index: firmware/App/Services/NVMsgQ.h =================================================================== diff -u -r0face6417892ea9de28d146bf88d44a9f30cf2a4 -r63c3a65e681810f037718377c6ed5a28c897d0ca --- firmware/App/Services/NVMsgQ.h (.../NVMsgQ.h) (revision 0face6417892ea9de28d146bf88d44a9f30cf2a4) +++ firmware/App/Services/NVMsgQ.h (.../NVMsgQ.h) (revision 63c3a65e681810f037718377c6ed5a28c897d0ca) @@ -69,25 +69,22 @@ BOOL isRecordQueueEmpty( void ); BOOL isRecordQueueFull( void ); U32 getAvailableRecordQueueCount( void ); - BOOL enqueueEraseAndWriteSector( RECORD_JOBS_STATE_T job ); BOOL enqueuewriteAllRecords( void ); BOOL enqueueReadAllRecords( void ); +BOOL isNewCalibrationRecordAvailable( void ); +void updateNewNVRecordAvailableFlag( BOOL value ); +void updateRecordReadStatus( NVDATAMGMT_RECORDS_READ_STATUS_T status ); +void updateRecordStartTimer( U32 value ); +PROCESS_RECORD_JOB_T getCurrentProcessRecordJob ( void ); BOOL testDDGetNVRecord( MESSAGE_T *message ); BOOL testDDSetNVSystemRecord( MESSAGE_T *message ); BOOL testDDSetNVServiceRecord( MESSAGE_T *message ); BOOL testDDSetNVCalibrationRecord( MESSAGE_T *message ); BOOL testDDSetNVInstitutionalRecord( MESSAGE_T *message ); BOOL testDDSetNVUsageInfoRecord( MESSAGE_T *message ); -BOOL isNewCalibrationRecordAvailable( void ); -void updateNewNVRecordAvailableFlag( BOOL value ); -void updateRecordReadStatus( NVDATAMGMT_RECORDS_READ_STATUS_T status ); -void updateRecordStartTimer( U32 value ); - -PROCESS_RECORD_JOB_T getCurrentProcessRecordJob ( void ); - /**@}*/ #endif /* _NV_MSG_Q_H_ */ 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 ) { Index: firmware/App/Services/NVRecordsDD.h =================================================================== diff -u -r66b03c4d4724df628b4fd175567880f23eb35259 -r63c3a65e681810f037718377c6ed5a28c897d0ca --- firmware/App/Services/NVRecordsDD.h (.../NVRecordsDD.h) (revision 66b03c4d4724df628b4fd175567880f23eb35259) +++ firmware/App/Services/NVRecordsDD.h (.../NVRecordsDD.h) (revision 63c3a65e681810f037718377c6ed5a28c897d0ca) @@ -29,283 +29,288 @@ /** * @defgroup NVRecordsDD NVRecordsDD * @brief + * This module handles Non-Volatile data management including record + * validation, self-test execution, and update of system, service, + * usage, institutional, and calibration records. It ensures data + * integrity using CRC checks and updates invalid records with + * default values. * * @addtogroup NVRecordsDD * @{ */ // ********** public definitions ********** -#define MAX_TOP_LEVEL_PN_CHARS 10U ///< Max number of characters for top level part number. -#define MAX_TOP_LEVEL_SN_CHARS 20U ///< Max number of characters for top level serial number. -#define PRES_SENSORS_RESERVED_SPACE_COUNT 5 ///< Pressure sensors reserved space count. -#define FLOW_SENSROS_RESERVED_SPACE_COUNT 2 ///< Flow sensors reserved space count. -#define TEMP_SENSORS_RESERVED_SPACE_COUNT 2 ///< Temperature sensors reserved space count. -#define GENERIC_VOL_RESERVED_SPACE_COUNT 4 ///< Generic volumes reserved space count. -#define MAX_EEPROM_WRITE_BUFFER_BYTES 16U ///< Max allowed bytes for an EEPROM write (16 bytes). +#define MAX_TOP_LEVEL_PN_CHARS 10U ///< Max number of characters for top level part number. +#define MAX_TOP_LEVEL_SN_CHARS 20U ///< Max number of characters for top level serial number. +#define PRES_SENSORS_RESERVED_SPACE_COUNT 5 ///< Pressure sensors reserved space count. +#define FLOW_SENSROS_RESERVED_SPACE_COUNT 2 ///< Flow sensors reserved space count. +#define TEMP_SENSORS_RESERVED_SPACE_COUNT 2 ///< Temperature sensors reserved space count. +#define GENERIC_VOL_RESERVED_SPACE_COUNT 4 ///< Generic volumes reserved space count. +#define MAX_EEPROM_WRITE_BUFFER_BYTES 16U ///< Max allowed bytes for an EEPROM write (16 bytes). /// NVDataMgmt self-test states enumeration. typedef enum NVDataMgmt_Self_Test_States { - NVDATAMGMT_SELF_TEST_STATE_READ_RECORDS = 0, ///< Self test read records. - NVDATAMGMT_SELF_TEST_STATE_CHECK_CRC, ///< Self test check CRC. - NVDATAMGMT_SELF_TEST_STATE_COMPLETE, ///< Self test complete. - NUM_OF_NVDATAMGMT_SELF_TEST_STATES ///< Total number of self-test states. + NVDATAMGMT_SELF_TEST_STATE_READ_RECORDS = 0, ///< Self test read records. + NVDATAMGMT_SELF_TEST_STATE_CHECK_CRC, ///< Self test check CRC. + NVDATAMGMT_SELF_TEST_STATE_COMPLETE, ///< Self test complete. + NUM_OF_NVDATAMGMT_SELF_TEST_STATES ///< Total number of self-test states. } NVDATAMGMT_SELF_TEST_STATE_T; /// Process records specifications structure typedef struct { - U32 recordFlashAddress; ///< Jobs spec start address. - U32 sizeofRecord; ///< Jobs spec size of job. - U08* structAddressPtr; ///< Jobs structure address pointer. - U08* structCRCPtr; ///< Jobs structure CRC pointer. - DD_EVENT_ID_T nvEvent; ///< Jobs non-volatile DD event (i.e calibration, system). + U32 recordFlashAddress; ///< Jobs spec start address. + U32 sizeofRecord; ///< Jobs spec size of job. + U08* structAddressPtr; ///< Jobs structure address pointer. + U08* structCRCPtr; ///< Jobs structure CRC pointer. + DD_EVENT_ID_T nvEvent; ///< Jobs non-volatile DD event (i.e calibration, system). } PROCESS_RECORD_SPECS_T; /// DD available NV data to get typedef enum DD_nv_commands { - GET_CAL_PRESSURE_SENOSRS = 0, ///< Get pressure sensors calibration data. - GET_CAL_TEMP_SENSORS, ///< Get temperature sensors calibration data. - GET_CAL_CONCENTRATE_PUMPS_RECORD, ///< Get concentrate pumps calibration record. + GET_CAL_PRESSURE_SENOSRS = 0, ///< Get pressure sensors calibration data. + GET_CAL_TEMP_SENSORS, ///< Get temperature sensors calibration data. + GET_CAL_CONCENTRATE_PUMPS_RECORD, ///< Get concentrate pumps calibration record. GET_CAL_DIALYSATE_PUMPS_RECORD, - GET_CAL_ACID_CONCENTREATES, ///< Get acid concentrates calibration data. - GET_CAL_BICARB_CONCENTRATES, ///< Get bicarb concentrates calibration data. - GET_CAL_ACCEL_SENSORS, ///< Get accelerometers calibration data. - GET_CAL_FILL_CONDUCTIVITIES_RECORD, ///< Get fill conductivities record. + GET_CAL_ACID_CONCENTREATES, ///< Get acid concentrates calibration data. + GET_CAL_BICARB_CONCENTRATES, ///< Get bicarb concentrates calibration data. + GET_CAL_ACCEL_SENSORS, ///< Get accelerometers calibration data. + GET_CAL_FILL_CONDUCTIVITIES_RECORD, ///< Get fill conductivities record. GET_CAL_BLOOD_LEAK_SENSOR, - GET_SYS_RECORD, ///< Get system record. - GET_SRV_RECORD, ///< Get service record. - GET_INSTITUTIONAL_RECORD, ///< Get institutional record. - GET_USAGE_RECORD, ///< Get usage record. - NUM_OF_NV_DD_DATA ///< Number of non-volatile data. + GET_SYS_RECORD, ///< Get system record. + GET_SRV_RECORD, ///< Get service record. + GET_INSTITUTIONAL_RECORD, ///< Get institutional record. + GET_USAGE_RECORD, ///< Get usage record. + NUM_OF_NV_DD_DATA ///< Number of non-volatile data. } NV_DATA_T; /// DD acid concentrate enumeration. typedef enum DD_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_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_DD_ACID_CONCENTRATES_T; /// DD bicarb concentrate enumeration. typedef enum DD_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_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_DD_BICARB_CONCENTRATES_T; /// DD scheduled runs enumeration. typedef enum DD_scheduled_runs { - RUN_FLUSH = 0, ///< Flush run. - RUN_HEAT_DISINFECT, ///< Heat disinfect run. - NUM_OF_DD_SCHEDULED_RUNS ///< Number of DD scheduled runs. + RUN_FLUSH = 0, ///< Flush run. + RUN_HEAT_DISINFECT, ///< Heat disinfect run. + NUM_OF_DD_SCHEDULED_RUNS ///< Number of DD scheduled runs. } SCHEDULED_DD_RUNS_T; /// DD usage info items typedef enum DD_usage_items { - USAGE_INFO_RO_GEN_WATER = 0, ///< Usage info RO generated water. - USAGE_INFO_BASIC_FLUSH, ///< Usage info basic flush. - USAGE_INFO_HEAT_DIS, ///< Usage info heat disinfect complete. - USAGE_INFO_FILTER_FLUSH, ///< Usage info filter flush complete. - USAGE_INFO_HEAT_DIS_ACTIVE_COOL, ///< Usage info heat disinfect active cool complete. - NUM_OF_USAGE_INFO_ITEMS ///< Number of usage info items. + USAGE_INFO_RO_GEN_WATER = 0, ///< Usage info RO generated water. + USAGE_INFO_BASIC_FLUSH, ///< Usage info basic flush. + USAGE_INFO_HEAT_DIS, ///< Usage info heat disinfect complete. + USAGE_INFO_FILTER_FLUSH, ///< Usage info filter flush complete. + USAGE_INFO_HEAT_DIS_ACTIVE_COOL, ///< Usage info heat disinfect active cool complete. + NUM_OF_USAGE_INFO_ITEMS ///< Number of usage info items. } DD_USAGE_INFO_ITEMS_T; /// DD fill conductivity tests typedef enum DD_conductivity_ops { - FILL_COND_NORMAL_OP = 0, ///< Fill conductivity normal operation. - FILL_COND_ACID_TEST, ///< Fill conductivity acid test. - FILL_COND_BICARB_TEST, ///< Fill conductivity bicarb test. - NUM_OF_FILL_COND_TEST ///< Number of fill conductivity test. + FILL_COND_NORMAL_OP = 0, ///< Fill conductivity normal operation. + FILL_COND_ACID_TEST, ///< Fill conductivity acid test. + FILL_COND_BICARB_TEST, ///< Fill conductivity bicarb test. + NUM_OF_FILL_COND_TEST ///< Number of fill conductivity test. } DD_FILL_COND_OPS_T; #pragma pack(push, 1) /// Polynomial calibration structure typedef struct { - F32 fourthOrderCoeff; ///< Fourth order coefficient. - F32 thirdOrderCoeff; ///< Third order coefficient. - F32 secondOrderCoeff; ///< Second order coefficient. - F32 gain; ///< Gain. - F32 offset; ///< Offset. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC for the polynomial calibration payload. + F32 fourthOrderCoeff; ///< Fourth order coefficient. + F32 thirdOrderCoeff; ///< Third order coefficient. + F32 secondOrderCoeff; ///< Second order coefficient. + F32 gain; ///< Gain. + F32 offset; ///< Offset. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the polynomial calibration payload. } POLYNOMIAL_CAL_PAYLOAD_T; /// Pressure sensors calibration structure typedef struct { - POLYNOMIAL_CAL_PAYLOAD_T pressureSensors[ NUM_OF_PRESSURE_SENSORS ]; ///< Pressure sensors to calibrate. + POLYNOMIAL_CAL_PAYLOAD_T pressureSensors[ NUM_OF_PRESSURE_SENSORS ]; ///< Pressure sensors to calibrate. } DD_PRES_SENSORS_CAL_RECORD_T; /// Temperature sensors calibration structure typedef struct { - POLYNOMIAL_CAL_PAYLOAD_T tempSensors[ NUM_OF_TEMPERATURE_SENSORS ]; ///< Temperature sensors to calibrate. + POLYNOMIAL_CAL_PAYLOAD_T tempSensors[ NUM_OF_TEMPERATURE_SENSORS ]; ///< Temperature sensors to calibrate. } DD_TEMP_SENSORS_CAL_RECORD_T; /// DD concentrate pumps calibration record typedef struct { - POLYNOMIAL_CAL_PAYLOAD_T concentratePumps[ NUM_OF_CONCENTRATE_PUMPS ]; ///< DD concentrate pumps calibration data. + POLYNOMIAL_CAL_PAYLOAD_T concentratePumps[ NUM_OF_CONCENTRATE_PUMPS ]; ///< DD concentrate pumps calibration data. } DD_CONC_PUMPS_CAL_RECORD_T; /// DD dialysate pump calibration structure typedef struct { - float targetPumpSpeed[ NUM_OF_DIALYSATE_PUMPS ]; ///< Target Pump Speed - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC for the polynomial calibration payload. + float targetPumpSpeed[ NUM_OF_DIALYSATE_PUMPS ]; ///< Target Pump Speed + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the polynomial calibration payload. } DD_DIALYSATE_PUMP_DATA_T; /// DD dialysate pumps calibration record typedef struct { - DD_DIALYSATE_PUMP_DATA_T dialysatePump[ NUM_OF_DIALYSATE_PUMPS ]; ///< DD dialysate pumps calibration data. + DD_DIALYSATE_PUMP_DATA_T dialysatePump[ NUM_OF_DIALYSATE_PUMPS ]; ///< DD dialysate pumps calibration data. } DD_DIALYSATE_PUMPS_CAL_RECORD_T; /// DD acid concentrate typedef struct { - F32 acidConcMixRatio; ///< Acid concentrate mix ratio. - F32 acidFullBottleVolumeML; ///< Acid full bottle volume in milliliters. - F32 acidConductivityUSPerCM; ///< Acid conductivity in uS/cm. - F32 acidBottleTemperature; ///< Acid bottle temperature in C. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. + F32 acidConcMixRatio; ///< Acid concentrate mix ratio. + F32 acidFullBottleVolumeML; ///< Acid full bottle volume in milliliters. + F32 acidConductivityUSPerCM; ///< Acid conductivity in uS/cm. + F32 acidBottleTemperature; ///< Acid bottle temperature in C. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC. } DD_ACID_CONCENTRATE_T; /// DD bicarb concentrate typedef struct { - F32 bicarbConcMixRatio; ///< Bicarb concentrate mix ratio. - F32 bicarbStartVolumeML; ///< Bicarb start volume. - F32 bicarbConductivityUSPerCM; ///< Bicarb conductivity in uS/cm. - F32 bicarbBottleTemperature; ///< Bicarb bottle temperature in C. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. + F32 bicarbConcMixRatio; ///< Bicarb concentrate mix ratio. + F32 bicarbStartVolumeML; ///< Bicarb start volume. + F32 bicarbConductivityUSPerCM; ///< Bicarb conductivity in uS/cm. + F32 bicarbBottleTemperature; ///< Bicarb bottle temperature in C. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC. } DD_BICARB_CONCENTRATE_T; /// DD acid concentrates typedef struct { - DD_ACID_CONCENTRATE_T acidConcentrate[ NUM_OF_CAL_DATA_ACID_CONCENTRATES ]; ///< DD acid concentrates. + DD_ACID_CONCENTRATE_T acidConcentrate[ NUM_OF_CAL_DATA_ACID_CONCENTRATES ]; ///< DD acid concentrates. } DD_ACID_CONCENTRATES_RECORD_T; /// DD bicarb concentrates typedef struct { - DD_BICARB_CONCENTRATE_T bicarbConcentrate[ NUM_OF_CAL_DATA_BICARB_CONCENTRATES ]; ///< DD bicarb concentrates. + DD_BICARB_CONCENTRATE_T bicarbConcentrate[ NUM_OF_CAL_DATA_BICARB_CONCENTRATES ]; ///< DD bicarb concentrates. } DD_BICARB_CONCENTRATES_RECORD_T; /// HD accelerometer sensor calibration record typedef struct { - F32 accelXOffset; ///< DD accelerometer X axis offset. - F32 accelYOffset; ///< DD accelerometer Y axis offset. - F32 accelZOffset; ///< DD accelerometer Z axis offset. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC for the DD accelerometer sensor. + F32 accelXOffset; ///< DD accelerometer X axis offset. + F32 accelYOffset; ///< DD accelerometer Y axis offset. + F32 accelZOffset; ///< DD accelerometer Z axis offset. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the DD accelerometer sensor. } DD_ACCEL_SENSOR_CAL_RECORD_T; /// DD acid and bicarb fill conductivity values typedef struct { - F32 acidConduSPerCM; ///< Acid conductivity uS/cm. - F32 bicarbConduSPerCM; ///< Bicarb conductivity uS/cm. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC for the acid/bicarb fill conductivity values. + F32 acidConduSPerCM; ///< Acid conductivity uS/cm. + F32 bicarbConduSPerCM; ///< Bicarb conductivity uS/cm. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the acid/bicarb fill conductivity values. } DD_ACID_BICARB_FILL_COND_VALUES_T; /// DD acid and bicarb fill conductivity record typedef struct { - DD_ACID_BICARB_FILL_COND_VALUES_T fillCondValues[ NUM_OF_ACID_TYPE ][ NUM_OF_FILL_COND_TEST ]; ///< Acid and bicarb fill conductivity values. + DD_ACID_BICARB_FILL_COND_VALUES_T fillCondValues[ NUM_OF_ACID_TYPE ][ NUM_OF_FILL_COND_TEST ]; ///< Acid and bicarb fill conductivity values. } DD_CONCENTRATES_COND_CAL_RECORD_T; /// DD blood leak calibration structure typedef struct { - U16 setPoint; ///< Blood leak sensor set point. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC for the HD blood leak calibration payload. + U16 setPoint; ///< Blood leak sensor set point. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the HD blood leak calibration payload. } DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T; /// DD systems record structure typedef struct { - BOOL isROFeatured; ///< True : RO featured. False : RO de-featured. - BOOL isR0FeaturedBoostPump; ///< True : RO featured with boost pump. False : RO featured without the boost pump. - char topLevelPN[ MAX_TOP_LEVEL_PN_CHARS ]; ///< DD top level part number. - char topLevelSN[ MAX_TOP_LEVEL_SN_CHARS ]; ///< DD top level serial number. - U08 mfgLocation; ///< DD manufacturing location. - U32 mfgDate; ///< DD manufacturing date. - U16 crc; ///< CRC for the DD system record structure. + BOOL isROFeatured; ///< True : RO featured. False : RO de-featured. + BOOL isR0FeaturedBoostPump; ///< True : RO featured with boost pump. False : RO featured without the boost pump. + char topLevelPN[ MAX_TOP_LEVEL_PN_CHARS ]; ///< DD top level part number. + char topLevelSN[ MAX_TOP_LEVEL_SN_CHARS ]; ///< DD top level serial number. + U08 mfgLocation; ///< DD manufacturing location. + U32 mfgDate; ///< DD manufacturing date. + U16 crc; ///< CRC for the DD system record structure. } DD_SYSTEM_RECORD_T; /// DD service record structure typedef struct { - BOOL isHDFOnlineFluid; ///< True : HDF Online Fluid feature is available, False if not. - U32 waterRecovey; ///< Low : 0, Medium : 1, High : 2. - U08 serviceLoc; ///< DD service location. - U32 lastServiceEpochDate; ///< DD last service date in epoch. - U32 serviceIntervalSeconds; ///< DD service interval in seconds. - U32 lastResetTimeEpoch; ///< Last time the record was reset in epoch. - U16 crc; ///< CRC for the DD service record structure. + BOOL isHDFOnlineFluid; ///< True : HDF Online Fluid feature is available, False if not. + U32 waterRecovey; ///< Low : 0, Medium : 1, High : 2. + U08 serviceLoc; ///< DD service location. + U32 lastServiceEpochDate; ///< DD last service date in epoch. + U32 serviceIntervalSeconds; ///< DD service interval in seconds. + U32 lastResetTimeEpoch; ///< Last time the record was reset in epoch. + U16 crc; ///< CRC for the DD service record structure. } DD_SERVICE_RECORD_T; /// DD institutional record structure typedef struct { - U32 minDialysateFlowMLPM; ///< Min dialysate flow in mL/min. - U32 maxDialysateFlowMLPM; ///< Max dialysate flow in mL/min. - F32 minDialysateTempC; ///< Min dialysate temperature in C. - F32 maxDialysateTempC; ///< Max dialysate temperature in C. - F32 acidConcentrate; ///< acid concentrate - F32 bicarbCartridgeSizeG; ///< bicarbonate cartridge size in grams. - F32 minSodiumMEQL; ///< Min sodium in mEq/L - F32 maxSodiumMEQL; ///< Max sodium in mEq/L - F32 minBicarbonateMEQL; ///< Min bicarbonate in mEq/L - F32 maxBicarbonateMEQL; ///< Max bicarbonate in mEq/L - U32 minRORejectionRatioPCT; ///< Min RO rejection ratio in percent. - U32 disinfectionFrequency; ///< Disinfection days between cycles. - F32 disinfectionCycleTime; ///< Disinfection Cycle Time - F32 minInletWaterCondAlarmLimitUSPCM; ///< Min inlet water conductivity alarm limit in uS/cm. - F32 maxInletWaterCondAlarmLimitUSPCM; ///< Max inlet water conductivity alarm limit in uS/cm. - F32 acidConcentrateJugSizeL; ///< acid concentrate jug size in Liters - F32 minAcidAlarmLimitPCT; ///< Min acid alarm limit in percent. - F32 minBicarbAlarmLimitPCT; ///< Min bicarbonate alarm limit in percent. - U32 postTreatDrainOption; ///< Dialysate Post Treatment Drain Option  - U32 postTreatDryBicarbOption; ///< Dry Bicarbonate Post Treatment Option  - U32 calibrationTime; ///< Calibration time in epoch. - U16 crc; ///< CRC of the institutional record. + U32 minDialysateFlowMLPM; ///< Min dialysate flow in mL/min. + U32 maxDialysateFlowMLPM; ///< Max dialysate flow in mL/min. + F32 minDialysateTempC; ///< Min dialysate temperature in C. + F32 maxDialysateTempC; ///< Max dialysate temperature in C. + F32 acidConcentrate; ///< acid concentrate + F32 bicarbCartridgeSizeG; ///< bicarbonate cartridge size in grams. + F32 minSodiumMEQL; ///< Min sodium in mEq/L + F32 maxSodiumMEQL; ///< Max sodium in mEq/L + F32 minBicarbonateMEQL; ///< Min bicarbonate in mEq/L + F32 maxBicarbonateMEQL; ///< Max bicarbonate in mEq/L + U32 minRORejectionRatioPCT; ///< Min RO rejection ratio in percent. + U32 disinfectionFrequency; ///< Disinfection days between cycles. + F32 disinfectionCycleTime; ///< Disinfection Cycle Time + F32 minInletWaterCondAlarmLimitUSPCM; ///< Min inlet water conductivity alarm limit in uS/cm. + F32 maxInletWaterCondAlarmLimitUSPCM; ///< Max inlet water conductivity alarm limit in uS/cm. + F32 acidConcentrateJugSizeL; ///< acid concentrate jug size in Liters + F32 minAcidAlarmLimitPCT; ///< Min acid alarm limit in percent. + F32 minBicarbAlarmLimitPCT; ///< Min bicarbonate alarm limit in percent. + U32 postTreatDrainOption; ///< Dialysate Post Treatment Drain Option  + U32 postTreatDryBicarbOption; ///< Dry Bicarbonate Post Treatment Option  + U32 calibrationTime; ///< Calibration time in epoch. + U16 crc; ///< CRC of the institutional record. } DD_INSTITUTIONAL_RECORD_T; /// DD usage info structure. typedef struct { - F32 roWaterGenTotalL; ///< Total RO water generated in liters. (Cannot be reset) - F32 roWaterGenSinceLastServiceL; ///< RO water generated since last treatment in liters. - U32 lastBasicFlushCompleteDateEpoch; ///< Last basic flush complete date in epoch. - U32 lastHeatDisCompleteDateEpoch; ///< Last heat disinfect complete date in epoch. - U32 lastHeatActiveCoolCompleteDateEpoch; ///< Last heat disinfect active cool complete date in epoch. - U32 lastFilterFlushCompleteDateEpoch; ///< Last filter flush complete date in epoch. - U32 lastResetTimeEpoch; ///< Last time the record was reset in epoch. - U16 crc; ///< CRC for the DD usage info structure. + F32 roWaterGenTotalL; ///< Total RO water generated in liters. (Cannot be reset) + F32 roWaterGenSinceLastServiceL; ///< RO water generated since last treatment in liters. + U32 lastBasicFlushCompleteDateEpoch; ///< Last basic flush complete date in epoch. + U32 lastHeatDisCompleteDateEpoch; ///< Last heat disinfect complete date in epoch. + U32 lastHeatActiveCoolCompleteDateEpoch; ///< Last heat disinfect active cool complete date in epoch. + U32 lastFilterFlushCompleteDateEpoch; ///< Last filter flush complete date in epoch. + U32 lastResetTimeEpoch; ///< Last time the record was reset in epoch. + U16 crc; ///< CRC for the DD usage info structure. } DD_USAGE_INFO_RECORD_T; #pragma pack(pop) @@ -319,12 +324,11 @@ void benignPolynomialCalRecord( POLYNOMIAL_CAL_PAYLOAD_T* record ); BOOL setLastDisinfectDate( DD_USAGE_INFO_ITEMS_T disinfect, U32 epochTime ); BOOL setServiceTime( void ); -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 ); void updateNVSelfTestResult( SELF_TEST_STATUS_T result ); void updateNVSelfTestState( NVDATAMGMT_SELF_TEST_STATE_T state ); void updateSelfTestReadRecordsFlag ( BOOL value ); - BOOL testSetNVRecordCRCOverride( U32 job, U16 crc ); /**@}*/