Index: firmware/App/Controllers/BoostPump.c =================================================================== diff -u -r830213bc6dcc1a684610caf78c79d55f2cb41e93 -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Controllers/BoostPump.c (.../BoostPump.c) (revision 830213bc6dcc1a684610caf78c79d55f2cb41e93) +++ firmware/App/Controllers/BoostPump.c (.../BoostPump.c) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -18,7 +18,7 @@ #include "BoostPump.h" #include "Flow.h" #include "FPOperationModes.h" -//#include "NVDataMgmt.h" +//#include "NVMgmtDD.h" #include "Messaging.h" #include "MessageSupport.h" #include "PersistentAlarm.h" Index: firmware/App/Controllers/ConcentratePumps.h =================================================================== diff -u -rd210786d6c7d75bb0b4d9e18efc40a01d85123fe -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Controllers/ConcentratePumps.h (.../ConcentratePumps.h) (revision d210786d6c7d75bb0b4d9e18efc40a01d85123fe) +++ firmware/App/Controllers/ConcentratePumps.h (.../ConcentratePumps.h) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -19,7 +19,7 @@ #define __CONCENTRATE_PUMPS_H__ #include "DDCommon.h" -//#include "NVDataMgmt.h" +//#include "NVMgmtDD.h" /** * @defgroup ConcentratePumps ConcentratePumps Index: firmware/App/Controllers/DialysatePumps.c =================================================================== diff -u -rb2e7c9194acd84783d2bbad64c5720410493e199 -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Controllers/DialysatePumps.c (.../DialysatePumps.c) (revision b2e7c9194acd84783d2bbad64c5720410493e199) +++ firmware/App/Controllers/DialysatePumps.c (.../DialysatePumps.c) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -22,7 +22,7 @@ #include "FpgaDD.h" #include "MessageSupport.h" #include "Messaging.h" -//#include "NVDataMgmt.h" +//#include "NVMgmtDD.h" #include "OperationModes.h" #include "PersistentAlarm.h" #include "PIControllers.h" Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -rb37e7ab88f133b7ba7f9b604e4e164b2855b239e -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision b37e7ab88f133b7ba7f9b604e4e164b2855b239e) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -23,7 +23,7 @@ #include "Level.h" #include "MessageSupport.h" #include "Messaging.h" -//#include "NVDataMgmt.h" +//#include "NVMgmtDD.h" #include "OperationModes.h" #include "PersistentAlarm.h" #include "PIControllers.h" Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -ra2ebc68ef586c213fd6e5e56c61e4b1e8cbb749c -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision a2ebc68ef586c213fd6e5e56c61e4b1e8cbb749c) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -18,7 +18,7 @@ #include "Flow.h" #include "FPOperationModes.h" -//#include "NVDataMgmt.h" +//#include "NVMgmtDD.h" #include "Messaging.h" #include "MessageSupport.h" #include "PersistentAlarm.h" Index: firmware/App/Drivers/NVDriver.h =================================================================== diff -u -re17e1dc97bf8878056f1f7e4aa861c2448db52bc -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Drivers/NVDriver.h (.../NVDriver.h) (revision e17e1dc97bf8878056f1f7e4aa861c2448db52bc) +++ firmware/App/Drivers/NVDriver.h (.../NVDriver.h) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -43,29 +43,29 @@ /// Non Volatile Memory operation modes enumeration. typedef enum NVM_Operation { - NVM_NONE = 0, ///< Default mode to prevent any accidental ops. - NVM_OPERATION_WRITE, ///< Operation mode write. - NVM_OPERATION_READ, ///< Operation mode read. - NVM_OPERATION_ERASE, ///< Operation mode erase a sector (EEPROM). - NUM_OF_NVM_OPERATIONS ///< Total number of operation states. + NVM_OPERATION_NONE = 0, ///< Default mode to prevent any accidental ops. + NVM_OPERATION_WRITE, ///< Operation mode write. + NVM_OPERATION_READ, ///< Operation mode read. + NVM_OPERATION_ERASE, ///< Operation mode erase a sector. + NUM_OF_NVM_OPERATIONS ///< Total number of operation states. } NVM_OPERATION_T; /// NVM record type enumeration typedef enum NVM_Record_Type { - NVM_SYSTEM_RECORD = 0, ///< NVM process system record. - NVM_SERVICE_RECORD, ///< NVM process service record. - NVM_CALIBRATION_RECORD, ///< NVM process calibration record. - NVM_INSTITUTIONAL_RECORD, ///< NVM process institutional record. - NVM_USAGE_INFO_RECORD, ///< NVM process usage info record. - NUM_OF_NVM_RECORD_TYPES ///< Number of NVM records jobs. + NVM_SYSTEM_RECORD = 0, ///< NVM process system record. + NVM_SERVICE_RECORD, ///< NVM process service record. + NVM_CALIBRATION_RECORD, ///< NVM process calibration record. + NVM_INSTITUTIONAL_RECORD, ///< NVM process institutional record. + NVM_USAGE_INFO_RECORD, ///< NVM process usage info record. + NUM_OF_NVM_RECORD_TYPES ///< Number of NVM records jobs. } NVM_RECORD_TYPE_T; /// Process records job structure typedef struct { - NVM_OPERATION_T memoryOperation; ///< Memory operation. - NVM_RECORD_TYPE_T recordJob; ///< Record job (i.e sector 0). + NVM_OPERATION_T memoryOperation; ///< Memory operation. + NVM_RECORD_TYPE_T recordJob; ///< Record job (i.e sector 0). } PROCESS_RECORD_JOB_T; // ********** public function prototypes ********** Index: firmware/App/Drivers/TemperatureSensors.c =================================================================== diff -u -r50144ec3e96785cf76d5bfd22ee65029c82e732b -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Drivers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 50144ec3e96785cf76d5bfd22ee65029c82e732b) +++ firmware/App/Drivers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -20,7 +20,7 @@ #include "FpgaDD.h" #include "MessageSupport.h" #include "Messaging.h" -//#include "NVDataMgmt.h" +//#include "NVMgmtDD.h" #include "OperationModes.h" #include "PersistentAlarm.h" #include "TemperatureSensors.h" Index: firmware/App/Drivers/TemperatureSensors.h =================================================================== diff -u -r50144ec3e96785cf76d5bfd22ee65029c82e732b -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Drivers/TemperatureSensors.h (.../TemperatureSensors.h) (revision 50144ec3e96785cf76d5bfd22ee65029c82e732b) +++ firmware/App/Drivers/TemperatureSensors.h (.../TemperatureSensors.h) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -19,7 +19,7 @@ #define __TEMPERATURE_SENSORS_H__ #include "DDCommon.h" -//#include "NVDataMgmt.h" +//#include "NVMgmtDD.h" /** * @defgroup TemperatureSensors TemperatureSensors Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -re17e1dc97bf8878056f1f7e4aa861c2448db52bc -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision e17e1dc97bf8878056f1f7e4aa861c2448db52bc) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -24,7 +24,7 @@ //#include "Integrity.h" #include "Messaging.h" #include "ModeInitPOST.h" -//#include "NVDataMgmt.h" +//#include "NVMgmtDD.h" #include "OperationModes.h" #include "Pressure.h" #include "SafetyShutdown.h" Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r54f47e88c2aac4b18b089e52fd030888ad6ce916 -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 54f47e88c2aac4b18b089e52fd030888ad6ce916) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -25,7 +25,7 @@ #include "ModeGenDialysate.h" #include "MessageSupport.h" #include "Messaging.h" -//#include "NVDataMgmt.h" +//#include "NVMgmtDD.h" #include "OperationModes.h" #include "PermeateTank.h" #include "Pressure.h" Index: firmware/App/Services/NVMgmtDD.c =================================================================== diff -u -re17e1dc97bf8878056f1f7e4aa861c2448db52bc -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Services/NVMgmtDD.c (.../NVMgmtDD.c) (revision e17e1dc97bf8878056f1f7e4aa861c2448db52bc) +++ firmware/App/Services/NVMgmtDD.c (.../NVMgmtDD.c) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -29,54 +29,64 @@ /// EEPROM functions use the buffer length as the size of U32. So before send the length to any of FAPI functions, it should be divided by 4. #define EEPROM_OPS_SIZE_OF_CONVERTER 4 -#define COMMAND_TIME_OUT (1 * MS_PER_SECOND) ///< Timeout for an EEPROM or RTC command in ms. +#define COMMAND_TIME_OUT (1 * MS_PER_SECOND) ///< Timeout for an EEPROM in ms. /// NVM Exec states enumeration. typedef enum NVM_Exec_State { - NVM_EXEC_STATE_IDLE = 0, ///< Exec state Idle. - NVM_EXEC_STATE_WRITE_TO_EEPROM, ///< Exec state write to EEPROM. - NVM_EXEC_STATE_VERIFY_EEPROM_WRITE, ///< Exec state verify EEPROM write. - NVM_EXEC_STATE_READ_FROM_EEPROM, ///< Exec state read from EEPROM. - NVM_EXEC_STATE_ERASE_EEPROM, ///< Exec state erase EEPROM. - NUM_OF_NVM_EXEC_STATES ///< Total number of exec states. + NVM_EXEC_STATE_IDLE = 0, ///< Exec state Idle. + NVM_EXEC_STATE_WRITE, ///< Exec state write to EEPROM. + NVM_EXEC_STATE_VERIFY_WRITE, ///< Exec state verify EEPROM write. + NVM_EXEC_STATE_READ, ///< Exec state read from EEPROM. + NVM_EXEC_STATE_ERASE, ///< Exec state erase EEPROM. + NUM_OF_NVM_EXEC_STATES ///< Total number of exec states. } NVM_EXEC_STATE_T; /// NVM write record validity check states typedef enum NVM_Write_Record_Validity_Check { - NVM_RECORD_NOT_CHECKED = 0, ///< NVM (written) record not checked. - NVM_RECORD_VALID, ///< NVM record is valid. - NVM_RECORD_NOT_VALID, ///< NVM record is not valid. - NUM_OF_NVM_RECORD_VALIDITY_CHECK ///< Number of NVM validity check states. + NVM_RECORD_NOT_CHECKED = 0, ///< NVM (written) record not checked. + NVM_RECORD_VALID, ///< NVM record is valid. + NVM_RECORD_NOT_VALID, ///< NVM record is not valid. + NUM_OF_NVM_RECORD_VALIDITY_CHECK ///< Number of NVM validity check states. } NVM_RECORD_VALIDITY_CHECK_T; // ********** private data ********** -static NVM_EXEC_STATE_T nvmExecState; ///< NVM exec state variable. -static volatile BOOL powerOffIsImminent; ///< Power off warning has been signaled. Non-volatile memory operations should be completed ASAP and then ceased. -static NVM_RECORD_VALIDITY_CHECK_T writtenRecordStatus; ///< Record data write validity check. -static U32 currentTime; ///< Current time. -static U32 recordAddressOffset; ///< Record address offset. -static U08 writtenRecordCheckBuffer[ MAX_EEPROM_WRITE_BUFFER_BYTES ]; ///< Written record validity check buffer. +static NVM_EXEC_STATE_T nvmExecState; ///< NVM exec state variable. +static volatile BOOL powerOffIsImminent; ///< Power off warning has been signaled. Non-volatile memory operations should be completed ASAP and then ceased. +static NVM_RECORD_VALIDITY_CHECK_T writtenRecordStatus; ///< Record data write validity check. +static U32 currentTime; ///< Current time. +static U32 recordAddressOffset; ///< Record address offset. +static U08 writtenRecordCheckBuffer[ MAX_EEPROM_WRITE_BUFFER_BYTES ]; ///< Written record validity check buffer. // ********** private function prototypes ********** // Exec functions static NVM_EXEC_STATE_T handleExecIdleState( void ); static NVM_EXEC_STATE_T handleExecEraseState( void ); -static NVM_EXEC_STATE_T handleExecWriteToEEPROMState( void ); -static NVM_EXEC_STATE_T handleExecReadFromEEPROMState( void ); -static NVM_EXEC_STATE_T handleExecVerifyEEPROMWriteState( void ); +static NVM_EXEC_STATE_T handleExecWriteState( void ); +static NVM_EXEC_STATE_T handleExecReadState( void ); +static NVM_EXEC_STATE_T handleExecVerifyWriteState( void ); // Helper functions static BOOL didCommandTimeout( NVM_EXEC_STATE_T state ); +/*********************************************************************//** + * @brief + * The initNVMgmtDD function initializes the NV management module. + * It resets internal state variables, initializes driver, + * message queue, records, and enqueues read operations. + * @details \b Inputs: none + * @details \b Outputs: nvmExecState, powerOffIsImminent, + * currentTime, writtenRecordStatus, + * recordAddressOffset + * @return none + *************************************************************************/ void initNVMgmtDD( void ) { - nvmExecState = NVM_EXEC_STATE_IDLE; + nvmExecState = NVM_EXEC_STATE_IDLE; powerOffIsImminent = FALSE; - currentTime = 0; writtenRecordStatus = NVM_RECORD_NOT_CHECKED; recordAddressOffset = 0; @@ -92,7 +102,7 @@ * The signalPowerOffWarning signals this module that system power off is * imminent and any non-volatile data writes in progress should be wrapped * up quickly and any pending non-volatile data writes should not be started. - * @details Inputs: powerOffIsImminent + * @details Inputs: none * @details Outputs: powerOffIsImminent * @return none *************************************************************************/ @@ -103,9 +113,11 @@ /*********************************************************************//** * @brief - * The execNVM runs the NVM main tasks. - * @details Inputs: nvmExecState - * @details Outputs: nvmExecState + * The execNVM function executes the main NV management state machine. + * It handles different execution states for erase, write, read, and + * verification of NV memory operations. + * @details \b Inputs: nvmExecState + * @details \b Outputs: nvmExecState * @return none *************************************************************************/ void execNVM( void ) @@ -116,20 +128,20 @@ nvmExecState = handleExecIdleState(); break; - case NVM_EXEC_STATE_ERASE_EEPROM: + case NVM_EXEC_STATE_ERASE: nvmExecState = handleExecEraseState(); break; - case NVM_EXEC_STATE_WRITE_TO_EEPROM: - nvmExecState = handleExecWriteToEEPROMState(); + case NVM_EXEC_STATE_WRITE: + nvmExecState = handleExecWriteState(); break; - case NVM_EXEC_STATE_READ_FROM_EEPROM: - nvmExecState = handleExecReadFromEEPROMState(); + case NVM_EXEC_STATE_READ: + nvmExecState = handleExecReadState(); break; - case NVM_EXEC_STATE_VERIFY_EEPROM_WRITE: - nvmExecState = handleExecVerifyEEPROMWriteState(); + case NVM_EXEC_STATE_VERIFY_WRITE: + nvmExecState = handleExecVerifyWriteState(); break; default: @@ -140,22 +152,25 @@ } /*********************************************************************//** - * @brief - * The handleExecIdleState checks if the queue is empty and if it is not - * empty, it sets the state of the job. - * @details Inputs: powerOffIsImminent - * @details Outputs: none - * @return next state - *************************************************************************/ -static NVM_EXEC_STATE_T handleExecIdleState ( void ) +* @brief +* The handleExecIdleState function processes the idle state of the +* NVM execution state machine. It checks for pending record jobs and +* initiates erase, write, or read operations. +* @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT if invalid operation +* is encountered +* @details \b Inputs: powerOffIsImminent +* @details \b Outputs: recordAddressOffset, currentTime +* @return state next state of the state machine +*************************************************************************/ +static NVM_EXEC_STATE_T handleExecIdleState( void ) { NVM_EXEC_STATE_T state = NVM_EXEC_STATE_IDLE; - BOOL areQueuesNotEmpty = FALSE; + BOOL areQueuesNotEmpty = FALSE; NVM_OPERATION_T ops; U32 recordFlashAddress; U08* bufferAddress; PROCESS_RECORD_JOB_T recordCurrentJob; - NVM_RECORD_TYPE_T job; + NVM_RECORD_TYPE_T job; PROCESS_RECORD_SPECS_T jobSpecs; // If power off command has been issued, do not process any new jobs @@ -165,15 +180,15 @@ if ( ( FALSE == isRecordQueueEmpty() ) && ( TRUE == isFlashReady() ) ) { dequeueRecordJob(); - recordCurrentJob = getCurrentProcessRecordJob(); - job = recordCurrentJob.recordJob; + recordCurrentJob = getCurrentProcessRecordJob(); + job = recordCurrentJob.recordJob; jobSpecs = getProcessRecord( job ); // Set the record address offset to 0 since a job will just be started recordAddressOffset = 0; areQueuesNotEmpty = TRUE; ops = recordCurrentJob.memoryOperation; currentTime = getMSTimerCount(); - recordFlashAddress = jobSpecs.recordFlashAddress + recordAddressOffset; + recordFlashAddress = jobSpecs.recordFlashAddress + recordAddressOffset; bufferAddress = jobSpecs.structAddressPtr + recordAddressOffset; } } @@ -185,19 +200,19 @@ { case NVM_OPERATION_ERASE: eraseSector( (U32*)recordFlashAddress ); - state = NVM_EXEC_STATE_ERASE_EEPROM; + state = NVM_EXEC_STATE_ERASE; break; case NVM_OPERATION_WRITE: writeSector( (U32*)recordFlashAddress, (U08*)bufferAddress, MAX_EEPROM_WRITE_BUFFER_BYTES ); currentTime = getMSTimerCount(); - state = NVM_EXEC_STATE_WRITE_TO_EEPROM; + state = NVM_EXEC_STATE_WRITE; break; case NVM_OPERATION_READ: readSector( (U32*)recordFlashAddress, (U32*)bufferAddress, ( jobSpecs.sizeofRecord / EEPROM_OPS_SIZE_OF_CONVERTER ) ); currentTime = getMSTimerCount(); - state = NVM_EXEC_STATE_READ_FROM_EEPROM; + state = NVM_EXEC_STATE_READ; break; default: @@ -221,16 +236,18 @@ /*********************************************************************//** * @brief - * The handleExecEraseState issues an erase command to EEPROM on entry - * and if the erase was successful, it sets the state to Idle. - * @details Inputs: none - * @details Outputs: none - * @return next state + * The handleExecEraseState function handles the erase state of the + * NVM execution state machine. It issues an erase command to EEPROM on entry, + * waits for erase completion and if the erase was successful, + * it transitions back to idle when done or on timeout. + * @details \b Inputs: none + * @details \b Outputs: none + * @return state next state of the state machine *************************************************************************/ -static NVM_EXEC_STATE_T handleExecEraseState ( void ) +static NVM_EXEC_STATE_T handleExecEraseState( void ) { - NVM_EXEC_STATE_T state = NVM_EXEC_STATE_ERASE_EEPROM; - BOOL timeoutStatus = didCommandTimeout( state ); + NVM_EXEC_STATE_T state = NVM_EXEC_STATE_ERASE; + BOOL timeoutStatus = didCommandTimeout( state ); if ( TRUE == isFlashReady() || timeoutStatus == TRUE ) { @@ -242,39 +259,44 @@ /*********************************************************************//** * @brief - * The handleExecWriteToEEPROMState issues a write command to EEPROM and - * if the write was successful, it sets the state to Idle. - * @details Inputs: recordAddressOffset, writtenRecordCheckBuffer, + * The handleExecWriteState function handles the write state of + * the NVM execution state machine. It verifies written data and + * continues writing remaining data. if the write was successful, + * it sets the state to Idle. + * @details \b Inputs: recordAddressOffset, * writtenRecordStatus - * @details Outputs: recordAddressOffset, writtenRecordCheckBuffer, - * writtenRecordStatus - * @return next state of the state machine + * @details \b Outputs: recordAddressOffset, currentTime, + * writtenRecordCheckBuffer, writtenRecordStatus + * @return state next state of the state machine *************************************************************************/ -static NVM_EXEC_STATE_T handleExecWriteToEEPROMState ( void ) +static NVM_EXEC_STATE_T handleExecWriteState( void ) { - NVM_EXEC_STATE_T state = NVM_EXEC_STATE_WRITE_TO_EEPROM; - BOOL timeoutStatus = didCommandTimeout( state ); + NVM_EXEC_STATE_T state = NVM_EXEC_STATE_WRITE; + BOOL timeoutStatus = didCommandTimeout( state ); PROCESS_RECORD_JOB_T recordCurrentJob = getCurrentProcessRecordJob(); - NVM_RECORD_TYPE_T job = recordCurrentJob.recordJob; - PROCESS_RECORD_SPECS_T jobSpecs = getProcessRecord ( job ); + NVM_RECORD_TYPE_T job = recordCurrentJob.recordJob; + PROCESS_RECORD_SPECS_T jobSpecs = getProcessRecord( job ); // Check if the fapi has finished if ( TRUE == isFlashReady() ) { - // Check the integrity of data (the 16 bytes that were written to EEPROM should be read and be checked for each byte) + // Check the integrity of data (the 16 bytes that were written to + // EEPROM should be read and be checked for each byte) if ( writtenRecordStatus == NVM_RECORD_NOT_CHECKED ) { - currentTime = getMSTimerCount(); + currentTime = getMSTimerCount(); U32 recordFlashAddress = jobSpecs.recordFlashAddress + recordAddressOffset; - U32 maxBufferLength = MAX_EEPROM_WRITE_BUFFER_BYTES / EEPROM_OPS_SIZE_OF_CONVERTER; + U32 maxBufferLength = MAX_EEPROM_WRITE_BUFFER_BYTES / EEPROM_OPS_SIZE_OF_CONVERTER; // Clear the buffer from the previous content memset( writtenRecordCheckBuffer, 0, sizeof( writtenRecordCheckBuffer ) ); // Issue a FAPI read command but only the bytes that were written, so use maxBufferLength - readSector( (U32*)recordFlashAddress, (U32*)writtenRecordCheckBuffer, maxBufferLength ); + readSector( (U32*)recordFlashAddress, + (U32*)writtenRecordCheckBuffer, + maxBufferLength ); - state = NVM_EXEC_STATE_VERIFY_EEPROM_WRITE; + state = NVM_EXEC_STATE_VERIFY_WRITE; } else if ( writtenRecordStatus == NVM_RECORD_VALID ) { @@ -286,13 +308,12 @@ else { // Update the variables and issue the next write command - currentTime = getMSTimerCount(); + currentTime = getMSTimerCount(); recordAddressOffset += MAX_EEPROM_WRITE_BUFFER_BYTES; - U32 memoryPtr = jobSpecs.recordFlashAddress + recordAddressOffset; - U08* structPtr = jobSpecs.structAddressPtr + recordAddressOffset; + U32 memoryPtr = jobSpecs.recordFlashAddress + recordAddressOffset; + U08* structPtr = jobSpecs.structAddressPtr + recordAddressOffset; + writtenRecordStatus = NVM_RECORD_NOT_CHECKED; - writtenRecordStatus = NVM_RECORD_NOT_CHECKED; - // Issue the write command writeSector( (U32*)memoryPtr, structPtr, MAX_EEPROM_WRITE_BUFFER_BYTES ); } @@ -310,16 +331,17 @@ /*********************************************************************//** * @brief - * The handleExecReadFromEEPROMState issues a read command to EEPROM on entry - * and if the read was successful, it sets the state to Idle. - * @details Inputs: None - * @details Outputs: None - * @return next state + * The handleExecReadState function handles the read state of the NVM + * execution state machine. It waits for read completion and transitions + * to idle when done or on timeout. + * @details \b Inputs: none + * @details \b Outputs: none + * @return state next state of the state machine *************************************************************************/ -static NVM_EXEC_STATE_T handleExecReadFromEEPROMState ( void ) +static NVM_EXEC_STATE_T handleExecReadState( void ) { - NVM_EXEC_STATE_T state = NVM_EXEC_STATE_READ_FROM_EEPROM; - BOOL timeoutStatus = didCommandTimeout( state ); + NVM_EXEC_STATE_T state = NVM_EXEC_STATE_READ; + BOOL timeoutStatus = didCommandTimeout( state ); if ( ( TRUE == isFlashReady() ) || ( TRUE == timeoutStatus ) ) { @@ -331,21 +353,20 @@ /*********************************************************************//** * @brief - * The handleExecVerifyEEPROMWriteState checks all the bytes that were - * written to EEPROM to ensure they match the data in the NV memory. - * @details Inputs: recordAddressOffset, writtenRecordCheckBuffer, - * writtenRecordStatus - * @details Outputs: recordAddressOffset, writtenRecordCheckBuffer, - * writtenRecordStatus - * @return next state of the state machine + * The handleExecVerifyWriteState function verifies the data written to + * EEPROM by comparing it with the source data. It schedules a rewrite + * if mismatch is detected or continues the write process if valid. + * @details \b Inputs: recordAddressOffset,writtenRecordCheckBuffer + * @details \b Outputs: writtenRecordStatus + * @return state next state of the state machine *************************************************************************/ -static NVM_EXEC_STATE_T handleExecVerifyEEPROMWriteState ( void ) +static NVM_EXEC_STATE_T handleExecVerifyWriteState( void ) { - NVM_EXEC_STATE_T state = NVM_EXEC_STATE_VERIFY_EEPROM_WRITE; - BOOL timeoutStatus = didCommandTimeout( state ); + NVM_EXEC_STATE_T state = NVM_EXEC_STATE_VERIFY_WRITE; + BOOL timeoutStatus = didCommandTimeout( state ); PROCESS_RECORD_JOB_T recordCurrentJob = getCurrentProcessRecordJob(); - NVM_RECORD_TYPE_T job = recordCurrentJob.recordJob; - PROCESS_RECORD_SPECS_T jobSpecs = getProcessRecord ( job ); + NVM_RECORD_TYPE_T job = recordCurrentJob.recordJob; + PROCESS_RECORD_SPECS_T jobSpecs = getProcessRecord( job ); // Check if the flash is ready if ( TRUE == isFlashReady() ) @@ -374,7 +395,7 @@ // Record data is valid so far writtenRecordStatus = NVM_RECORD_VALID; // Go back write to EEPROM state to continue writing the record data - state = NVM_EXEC_STATE_WRITE_TO_EEPROM; + state = NVM_EXEC_STATE_WRITE; } } } @@ -385,11 +406,12 @@ /*********************************************************************//** * @brief * The resetNVMPOSTState function resets the NV data management POST - * state and enqueues all the NV records to be read again from the NV memory. - * @details Inputs: none - * @details Outputs: nvDataMgmtSelfTestState, nvDataMgmtSelfTestResult + * state and sets the self-test to start reading all the records. + * @details \b Inputs: none + * @details \b Outputs: none * @return none *************************************************************************/ + void resetNVMPOSTState( void ) { updateNVSelfTestResult( SELF_TEST_STATUS_IN_PROGRESS ); @@ -398,21 +420,79 @@ /*********************************************************************//** * @brief - * The didCommandTimedout checks whether the a command whether RTC RAM or - * EEPROM has timedout. If it has timedout, it sets the alarm and turns - * flag to TRUE. - * @details Inputs: none - * @details Outputs: alarm if command timed out - * @param state the state that the command timed out - * @return TRUE if a command timed out + * The execNVMProcessRecord function executes the NVM process record + * handler. + * @details \b Inputs: none + * @details \b Outputs: none + * @return none *************************************************************************/ -static BOOL didCommandTimeout ( NVM_EXEC_STATE_T state ) +void execNVMProcessRecord( void ) { + execNVMPSendReceiveRecord(); +} + +/*********************************************************************//** + * @brief + * The execNVMSelfTest function executes the NV management self-test + * handler. + * @details \b Inputs: none + * @details \b Outputs: none + * @return SELF_TEST_STATUS_T self-test result + *************************************************************************/ +SELF_TEST_STATUS_T execNVMSelfTest( void ) +{ + execNVMRecordsSelfTest(); +} + +/*********************************************************************//** + * @brief + * The getNVRecord2Driver function retrieves NV data by calling the + * record handler after validating input parameters. + * @details \b Inputs: none + * @details \b Outputs: none + * @param nvData The non-volatile data identifier + * @param bufferAddress Pointer to the buffer where data will be copied + * @param bufferLength Length of the provided buffer + * @param numOfSnsrs2Check Number of sensors to check + * @param nvAlarm Alarm to raise if data is invalid + * @return TRUE if the operation is successful otherwise FALSE + *************************************************************************/ +BOOL getNVRecord2Driver( NV_DATA_T nvData, U08* bufferAddress, U32 bufferLength, + U08 numOfSnsrs2Check, ALARM_ID_T nvAlarm ) +{ BOOL status = FALSE; + if ( ( nvData < NUM_OF_NV_DD_DATA ) && + ( NULL != bufferAddress ) && + ( bufferLength > 0U ) ) + { + status = getNVMRecord(nvData, bufferAddress, + bufferLength, numOfSnsrs2Check, nvAlarm); + } + + return status; +} + +/*********************************************************************//** + * @brief + * The didCommandTimeout function checks whether the command has timed + * out. If a timeout occurs, it sets an alarm and returns TRUE. + * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT if command timeout + * occurs + * @details \b Inputs: currentTime + * @details \b Outputs: none + * @param state The state in which the command timed out + * @return TRUE if a command timed out otherwise FALSE + *************************************************************************/ +static BOOL didCommandTimeout( NVM_EXEC_STATE_T state ) +{ + BOOL status = FALSE; + if ( TRUE == didTimeout( currentTime, COMMAND_TIME_OUT ) ) { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_NVM_OPS_TIMEOUT, ( U32 )state ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, + SW_FAULT_ID_NVM_OPS_TIMEOUT, + ( U32 )state ) status = TRUE; } Index: firmware/App/Services/NVMgmtDD.h =================================================================== diff -u -re17e1dc97bf8878056f1f7e4aa861c2448db52bc -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Services/NVMgmtDD.h (.../NVMgmtDD.h) (revision e17e1dc97bf8878056f1f7e4aa861c2448db52bc) +++ firmware/App/Services/NVMgmtDD.h (.../NVMgmtDD.h) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -33,6 +33,12 @@ void execNVM( void ); void resetNVMPOSTState( void ); +// Wrapper functions to other NVM files +void execNVMProcessRecord( void ); +SELF_TEST_STATUS_T execNVMSelfTest( void ); +BOOL getNVRecord2Driver( NV_DATA_T nvData, U08* bufferAddress, U32 bufferLength, + U08 numOfSnsrs2Check, ALARM_ID_T nvAlarm ); + /**@}*/ #endif /* _NV_MGMT_DD_H_ */ Index: firmware/App/Services/NVMsgQ.c =================================================================== diff -u -re17e1dc97bf8878056f1f7e4aa861c2448db52bc -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Services/NVMsgQ.c (.../NVMsgQ.c) (revision e17e1dc97bf8878056f1f7e4aa861c2448db52bc) +++ firmware/App/Services/NVMsgQ.c (.../NVMsgQ.c) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -31,7 +31,7 @@ // ********** private definitions ********** // Once a new calibration data is available the driver, sets a signal for the defined time. Once the time is out, it turns the signal off. -#define NEW_CAL_AVAILABLE_SIGNAL_TIMEOUT_MS (1 * MS_PER_SECOND) ///< New calibration available signal timeout in milliseconds.#define QUEUE_MAX_SIZE 20U ///< Max queue size. +#define NEW_CAL_AVAILABLE_SIGNAL_TIMEOUT_MS (1 * MS_PER_SECOND) ///< New calibration available signal timeout in milliseconds. #define QUEUE_MAX_SIZE 20U ///< Max queue size. #define QUEUE_START_INDEX 0U ///< Queue start index. #define MAX_JOB_DATA_SIZE_BYTES 32U ///< Max bytes per job (32 bytes). @@ -60,7 +60,7 @@ /// Memory operations structure. typedef struct { - NVM_OPERATION_T memoryOperation; ///< Memory operation. + NVM_OPERATION_T memoryOperation; ///< Memory operation. U32 recordFlashAddress; ///< Operation start address. U08 buffer[ MAX_JOB_DATA_SIZE_BYTES ]; ///< Buffer. U32 length; ///< Length of a buffer. @@ -89,13 +89,13 @@ static U08 recordQueueFrontIndex; ///< Record queue front index. static U08 recordQueueCount; ///< Record queue count. static PROCESS_RECORD_JOB_T recordCurrentJob; ///< Record queue current job. -static NVM_RECORDS_READ_STATUS_T recordsReadStatus; ///< NVM records read status. +static NVM_RECORDS_READ_STATUS_T recordsReadStatus; ///< NVM records read status. static BOOL isNewNVRecordAvailable; ///< Signal to indicate whether a new NVM data is available. -static NVM_RECORD_TYPE_T recordToPublish; ///< Record to publish (i.e. calibration, system) -static NVM_RECORD_TYPE_T nvPublishRecordType; +static NVM_RECORD_TYPE_T recordToPublish; ///< Record type which is being processed currently for sending +static NVM_RECORD_TYPE_T nvPublishRecordType; ///< Used to index over isPublishRecordRequested in the idle state static SEND_RECORD_STATE_T nvMExecSendRecordState; ///< NVM exec process record state. static RECEIVE_RECORD_STATE_T nvmExecReceiveRecordState; ///< NVM exec receive record state. -static NVM_RECORD_TYPE_T currentRxRecordType; +static NVM_RECORD_TYPE_T currentRxRecordType; ///< Record type which is being processed currently for receiving static BOOL isPublishRecordRequested[ NUM_OF_NVM_RECORD_TYPES ]; ///< Record state machine publish request flag. static U32 recordPublishMsgCount; ///< Record data publish message counter. static U32 recordPublishTotalMsgs; ///< Record data total number of messages to be sent. @@ -120,6 +120,22 @@ static MSG_ID_T getNVMRecordResponseMsgId (NVM_RECORD_TYPE_T job ); static void monitorNewCalSignal( void ); +/*********************************************************************//** + * @brief + * The initNVMsgQ function initializes the NV message queue and related + * state variables. It resets queue indices, counters, flags, and + * publishing states to default values. + * @details \b Inputs: none + * @details \b Outputs: recordUpdateAddress, recordQueueRearIndex, + * recordQueueFrontIndex, recordQueueCount, recordsReadStatus, + * isNewNVRecordAvailable, nvMExecSendRecordState, + * nvmExecReceiveRecordState, nvPublishRecordType, + * isPublishRecordRequested, newRecordStartTimer, + * recordPublishMsgCount, recordPublishTotalMsgs, + * recordSendDataIntervalCounter, previousRecordMessageNum, + * recordReceiveStartTime + * @return none + *************************************************************************/ void initNVMsgQ ( void ) { recordUpdateAddress = 0; @@ -148,17 +164,20 @@ recordReceiveStartTime = 0; } + /*********************************************************************//** * @brief - * The execNVMSendRecord runs the NVM send records related - * to tasks. - * @details Inputs: nvMExecSendRecordState, + * The execNVMPSendReceiveRecord function executes the NV record processing + * state machines. It handles send and receive operations and monitors + * for timeouts and calibration signals. + * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT if invalid send state + * @details \b Inputs: nvMExecSendRecordState, * nvmExecReceiveRecordState, recordReceiveStartTime - * @details Outputs: nvMExecSendRecordState, + * @details \b Outputs: nvMExecSendRecordState, * nvmExecReceiveRecordState * @return none *************************************************************************/ -void execNVMProcessRecord( void ) +void execNVMPSendReceiveRecord( void ) { switch ( nvMExecSendRecordState ) { @@ -197,13 +216,16 @@ /*********************************************************************//** * @brief - * The handleExecSendRecordIdleState handles the idle state of the - * exec cal state machine. - * @details Inputs: isPublishRecordRequested, recordPublishTotalMsgs, - * recordPublishMsgCount, recordSendDataIntervalCounter - * @details Outputs: isPublishRecordRequested, recordPublishTotalMsgs, - * recordPublishMsgCount, recordSendDataIntervalCounter - * @return next state of the state machine + * The handleExecSendRecordIdleState function handles the idle state of + * the exec send record state machine. It prepares record data for + * publishing when requested. + * @details \b Inputs: isPublishRecordRequested, + * nvPublishRecordType + * @details \b Outputs: isPublishRecordRequested, + * recordPublishTotalMsgs, recordPublishMsgCount, + * recordSendDataIntervalCounter, nvPublishRecordType, + * recordToPublish + * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleExecSendRecordIdleState( void ) { @@ -232,7 +254,7 @@ } nvPublishRecordType = ( NVM_RECORD_TYPE_T )( nvPublishRecordType + 1 ); - if(nvPublishRecordType >= NUM_OF_NVM_RECORD_TYPES) + if( nvPublishRecordType >= NUM_OF_NVM_RECORD_TYPES ) { nvPublishRecordType = NVM_SYSTEM_RECORD; } @@ -242,13 +264,15 @@ /*********************************************************************//** * @brief - * The handleExecSendRecordSendState handles the send nvm - * record state of the state machine. - * @details Inputs: dgCalibrationRecord, recordPublishTotalMsgs, - * recordPublishMsgCount, recordSendDataIntervalCounter - * @details Outputs: recordPublishTotalMsgs, recordPublishMsgCount, + * The handleExecSendRecordSendState function handles the send state of + * the exec send record state machine. It sends record data in chunks + * based on timing and message count. + * @details \b Inputs: recordPublishTotalMsgs, + * recordPublishMsgCount, recordSendDataIntervalCounter, + * recordToPublish + * @details \b Outputs: recordPublishMsgCount, * recordSendDataIntervalCounter - * @return next state of the state machine + * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleExecSendRecordSendState( void ) { @@ -296,11 +320,14 @@ /*********************************************************************//** * @brief - * The enqueueRecordJob function enqueues a new record job. - * @details Inputs: recordQueueRearIndex, queueCount, recordJobQueue - * @details Outputs: recordQueueRearIndex, queueCount, recordJobQueue - * @param ops: memory operation (i.e write, read) - * @param job: type of job (i.e write calibration data) + * The enqueueRecordJob function enqueues a new record job into the + * record queue. It updates the queue with the new job and advances + * the rear index. + * @details \b Inputs: recordQueueRearIndex, recordQueueCount + * @details \b Outputs: recordJobQueue, recordQueueRearIndex, + * recordQueueCount + * @param ops memory operation (i.e write, read) + * @param job type of job (i.e write calibration data) * @return none *************************************************************************/ void enqueueRecordJob( NVM_OPERATION_T ops, NVM_RECORD_TYPE_T job ) @@ -317,11 +344,13 @@ /*********************************************************************//** * @brief - * The dequeueRecordJob increments the front index counter and if it is - * equal to rear index, it sets it to -1, meaning that the queue is empty. - * @details Inputs: recordQueueFrontIndex, recordQueueCount, recordCurrentJob, + * The dequeueRecordJob function removes a record job from the queue. + * It updates the front index, retrieves the job, and updates the + * queue count. + * @details \b Inputs: recordQueueFrontIndex, recordQueueCount, * recordJobQueue - * @details Outputs: recordQueueFrontIndex, recordQueueCount, recordCurrentJob + * @details \b Outputs: recordQueueFrontIndex, recordQueueCount, + * recordCurrentJob * @return none *************************************************************************/ void dequeueRecordJob( void ) @@ -345,11 +374,11 @@ /*********************************************************************//** * @brief - * The isRecordQueueEmpty checks whether the queue is empty and if it is - * empty, it will return a false. - * @details Inputs: recordQueueCount - * @details Outputs: none - * @return TRUE if queue is not empty + * The isRecordQueueEmpty function checks whether the record queue is + * empty. It returns the status based on the queue count. + * @details \b Inputs: recordQueueCount + * @details \b Outputs: none + * @return TRUE if queue is empty otherwise FALSE *************************************************************************/ BOOL isRecordQueueEmpty( void ) { @@ -363,6 +392,14 @@ return isEmpty; } +/*********************************************************************//** + * @brief + * The isRecordQueueFull function checks whether the record queue is + * full based on the maximum queue size. + * @details \b Inputs: recordQueueCount + * @details \b Outputs: none + * @return TRUE if queue is full otherwise FALSE + *************************************************************************/ BOOL isRecordQueueFull( void ) { BOOL isFull = FALSE; @@ -377,25 +414,35 @@ /*********************************************************************//** * @brief - * The getAvailableRecordQueueCount returns the number of available record - * queues. - * @details Inputs: recordQueueCount - * @details Outputs: none + * The getAvailableRecordQueueCount function returns the number of + * available record queue slots based on the current queue count. + * @details \b Inputs: recordQueueCount + * @details \b Outputs: none * @return available record queues *************************************************************************/ + U32 getAvailableRecordQueueCount( void ) { return QUEUE_MAX_SIZE - recordQueueCount; } +/*********************************************************************//** + * @brief + * The enqueueEraseAndWriteSector function enqueues erase and write + * operations for the given record type. + * @details \b Inputs: none + * @details \b Outputs: none + * @param job Record type for which erase and write operations are scheduled + * @return TRUE if the operations were successfully enqueued otherwise FALSE + *************************************************************************/ BOOL enqueueEraseAndWriteSector( NVM_RECORD_TYPE_T job ) { BOOL status = FALSE; if ( getAvailableRecordQueueCount() >= MIN_JOBS_NEEDED_TO_WRITE_A_RECORD ) { // Service and Calibration record are stored in the same sector. - if( ( job == NVM_SERVICE_RECORD ) || ( job == NVM_CALIBRATION_RECORD ) ) + if ( ( job == NVM_SERVICE_RECORD ) || ( job == NVM_CALIBRATION_RECORD ) ) { enqueueRecordJob( NVM_OPERATION_ERASE, NVM_SERVICE_RECORD ); enqueueRecordJob( NVM_OPERATION_WRITE, NVM_SERVICE_RECORD ); @@ -413,6 +460,15 @@ return status; } +/*********************************************************************//** + * @brief + * The enqueuewriteAllRecords function enqueues erase and write + * operations for all records. It schedules jobs for all record types + * if sufficient queue space is available. + * @details \b Inputs: none + * @details \b Outputs: none + * @return TRUE if all operations were successfully enqueued otherwise FALSE + *************************************************************************/ BOOL enqueuewriteAllRecords( void ) { BOOL status = FALSE; @@ -441,10 +497,12 @@ /*********************************************************************//** * @brief - * The enqueueReadAllRecords enqueues the NV records to be read during POST. - * @details Inputs: none - * @details Outputs: recordsReadStatus - * @return none + * The enqueueReadAllRecords function enqueues all NV records to be read + * during POST. It schedules read jobs for all record types if sufficient + * queue space is available. + * @details \b Inputs: none + * @details \b Outputs: recordsReadStatus + * @return TRUE if records were successfully enqueued otherwise FALSE *************************************************************************/ BOOL enqueueReadAllRecords( void ) { @@ -469,29 +527,28 @@ /*********************************************************************//** * @brief - * The getNVRecordsReadStatus function returns the status of the NV POST. - * @details Inputs: none - * @details Outputs: none + * The getNVRecordsReadStatus function returns the current NV records + * read status of the POST process. + * @details \b Inputs: recordsReadStatus + * @details \b Outputs: none * @return recordsReadStatus *************************************************************************/ NVM_RECORDS_READ_STATUS_T getNVRecordsReadStatus( void ) { return recordsReadStatus; } - - /*********************************************************************//** * @brief - * The sendDDCalibrationRecord function sends out the DD calibration - * record. - * @details Inputs: none - * @details Outputs: DG calibration record msg constructed and queued - * @param msgId : Message Id for response record - * @param msgCurrNum: current payload number - * @param msgTotalNum: total number of payloads - * @param length: buffer length to be written - * @param recordAddress: start address of the calibration record + * The sendDDRecord function sends a DD record payload over communication. + * It prepares the payload and queues it for transmission. + * @details \b Inputs: none + * @details \b Outputs: none + * @param msgId Message Id for response record + * @param payloadCurrNum Current payload number + * @param payloadTotalNum Total number of payloads + * @param length Buffer length to be written + * @param recordAddress Start address of the record data * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ static BOOL sendDDRecord( MSG_ID_T msgId, U32 payloadCurrNum, U32 payloadTotalNum, @@ -511,6 +568,17 @@ return result; } +/*********************************************************************//** + * @brief + * The receiveDDRecord function processes a received DD record message. + * It extracts payload information and verifies the received data before + * saving it. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to received message structure + * @return TRUE if the record is successfully verified and saved, + * otherwise FALSE + *************************************************************************/ static BOOL receiveDDRecord( MESSAGE_T *message ) { BOOL status = FALSE; @@ -543,17 +611,19 @@ /*********************************************************************//** * @brief - * The verifyAndSaveReceivedRecord function receives the record that has been sent - * from Dialin and if the CRCs passed, it schedules a write to the NV data. - * @details Inputs: currentMessage, nvmExecReceiveRecordState, - * previousRecordMessageNum, totalMessages, previousRecordMessageNum, - * @details Outputs: nvmExecReceiveRecordState, recordReceiveStartTime, - * previousRecordMessageNum, recordUpdateAddress, recordUpdateAddress - * @param job: the job that has to be received and written (i.e. service record) - * @param currentMessage: current message number that is received from Dialin - * @param totalMessages: total number of messages from Dialin - * @param length: message length in bytes - * @param *addressPtr: address to the beginning of the calibration data from Dialin + * The verifyAndSaveReceivedRecord function receives the record sent + * from Dialin, assembles it, validates it using CRC, and schedules a + * write to NV memory if valid. + * @details \b Inputs: nvmExecReceiveRecordState, + * @details \b Outputs: nvmExecReceiveRecordState, + * recordReceiveStartTime, previousRecordMessageNum, + * recordUpdateAddress, currentRxRecordType, + * newRecordStartTimer, isNewNVRecordAvailable + * @param job The job that has to be received and written + * @param currentMessage Current message number received from Dialin + * @param totalMessages Total number of messages from Dialin + * @param length Message length in bytes + * @param addressPtr Address to the beginning of received data from Dialin * @return TRUE if the request was successfully registered *************************************************************************/ static BOOL verifyAndSaveReceivedRecord( NVM_RECORD_TYPE_T job, U32 currentMessage, @@ -562,17 +632,19 @@ BOOL status = TRUE; // If the calibration message number is the first message number and receive exec state is idle, switch to idle - if ( ( RECORD_DATA_FIRST_RECEIVING_MSG_NUM == currentMessage ) && ( NVM_RECEIVE_RECORD_STATE_IDLE == nvmExecReceiveRecordState ) ) + if ( ( RECORD_DATA_FIRST_RECEIVING_MSG_NUM == currentMessage ) && + ( NVM_RECEIVE_RECORD_STATE_IDLE == nvmExecReceiveRecordState ) ) { - nvmExecReceiveRecordState = NVM_RECEIVE_RECORD_STATE_RECEIVE; - currentRxRecordType = job; + nvmExecReceiveRecordState = NVM_RECEIVE_RECORD_STATE_RECEIVE; + currentRxRecordType = job; recordReceiveStartTime = getMSTimerCount(); previousRecordMessageNum = 0; recordUpdateAddress = 0; } // Check if there is still a message left to be received - if ( ( NVM_RECEIVE_RECORD_STATE_RECEIVE == nvmExecReceiveRecordState ) && ( currentMessage <= totalMessages ) ) + if ( ( NVM_RECEIVE_RECORD_STATE_RECEIVE == nvmExecReceiveRecordState ) && + ( currentMessage <= totalMessages ) ) { // Check if the current message is different from the previous message by 1 if ( RECORD_DATA_MAX_MESSAGE_DFFIRENCE == ( currentMessage - previousRecordMessageNum ) ) @@ -593,7 +665,8 @@ // and 0 everything out since we are done writing if ( currentMessage == totalMessages ) { - U16 calcCRC = crc16 ( tempRxSpec.structAddressPtr, tempRxSpec.sizeofRecord - sizeof(U16) ); + U16 calcCRC = crc16 ( tempRxSpec.structAddressPtr, + tempRxSpec.sizeofRecord - sizeof(U16) ); // Get the CRC of the structure without the last 16 bits which is the CRC as well as the padding values U16 recordCRC = *(U16*)tempRxSpec.structCRCPtr; @@ -640,11 +713,20 @@ return status; } +/*********************************************************************//** + * @brief + * The getNVMRecordJobState function maps the received message ID to + * the corresponding NV record job type. + * @details \b Inputs: none + * @details \b Outputs: none + * @param msgID Message ID received + * @return job corresponding NV record type + *************************************************************************/ static NVM_RECORD_TYPE_T getNVMRecordJobState( MSG_ID_T msgID ) { NVM_RECORD_TYPE_T job; - switch( msgID ) + switch ( msgID ) { case MSG_ID_DD_NVM_SET_CALIBRATION_RECORD: job = NVM_CALIBRATION_RECORD; @@ -667,14 +749,23 @@ break; default: - // Software Fault - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, ( U32 )msgID ) + // Do nothing for Invalid Input from Dialin break; } return job; } +/*********************************************************************//** + * @brief + * The getNVMRecordResponseMsgId function maps the NV record type to + * the corresponding response message ID. + * provided + * @details \b Inputs: none + * @details \b Outputs: none + * @param job NV record type + * @return msgID corresponding response message ID + *************************************************************************/ static MSG_ID_T getNVMRecordResponseMsgId( NVM_RECORD_TYPE_T job ) { MSG_ID_T msgID; @@ -702,8 +793,7 @@ break; default: - // Software fault - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, ( U32 )job ) + // Do nothing for Invalid Input from Dialin break; } @@ -713,60 +803,108 @@ /*********************************************************************//** * @brief * The monitorNewCalSignal function monitors the new calibration signal - * and if it on and time to on has elapsed, it turns it off. - * @details Inputs: isNewNVRecordAvailable - * @details Outputs: isNewNVRecordAvailable + * and clears it when the timeout has elapsed. + * @details \b Inputs: isNewNVRecordAvailable, + * newRecordStartTimer + * @details \b Outputs: isNewNVRecordAvailable * @return none *************************************************************************/ + static void monitorNewCalSignal( void ) { - if ( ( TRUE == didTimeout( newRecordStartTimer, NEW_CAL_AVAILABLE_SIGNAL_TIMEOUT_MS ) ) && ( TRUE == isNewNVRecordAvailable ) ) + if ( ( TRUE == didTimeout( newRecordStartTimer, NEW_CAL_AVAILABLE_SIGNAL_TIMEOUT_MS ) ) && + ( TRUE == isNewNVRecordAvailable ) ) { isNewNVRecordAvailable = FALSE; } } /*********************************************************************//** * @brief - * The isNewCalibrationRecordAvailable function returns the status of a - * new calibration availability. - * @details Inputs: none - * @details Outputs: none - * @return isNewNVRecordAvailable which is TRUE if new calibration is available, - * otherwise FALSE + * The isNewCalibrationRecordAvailable function returns the status of + * new calibration record availability. + * @details \b Inputs: isNewNVRecordAvailable + * @details \b Outputs: none + * @return isNewNVRecordAvailable which is TRUE if new calibration is + * available otherwise FALSE *************************************************************************/ BOOL isNewCalibrationRecordAvailable( void ) { return isNewNVRecordAvailable; } +/*********************************************************************//** + * @brief + * The updateNewNVRecordAvailableFlag function updates the flag + * indicating new NV record availability. + * @details \b Inputs: none + * @details \b Outputs: isNewNVRecordAvailable + * @param value Flag value to be updated + * @return none + *************************************************************************/ void updateNewNVRecordAvailableFlag( BOOL value ) { isNewNVRecordAvailable = value; } +/*********************************************************************//** + * @brief + * The updateRecordReadStatus function updates the NV records read + * status with the provided value. + * @details \b Inputs: none + * @details \b Outputs: recordsReadStatus + * @param status Record read status to be updated + * @return none + *************************************************************************/ void updateRecordReadStatus( NVM_RECORDS_READ_STATUS_T status ) { recordsReadStatus = status; } +/*********************************************************************//** + * @brief + * The updateRecordStartTimer function updates the record start timer + * with the provided value. + * @details \b Inputs: none + * @details \b Outputs: newRecordStartTimer + * @param value Timer value to be updated + * @return none + *************************************************************************/ void updateRecordStartTimer( U32 value ) { newRecordStartTimer = value; } +/*********************************************************************//** + * @brief + * The getCurrentProcessRecordJob function gets the current record job + * from the processing queue. + * @details \b Inputs: recordCurrentJob + * @details \b Outputs: none + * @return recordCurrentJob + *************************************************************************/ PROCESS_RECORD_JOB_T getCurrentProcessRecordJob ( void ) { return recordCurrentJob; } - /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ +/*********************************************************************//** + * @brief + * The testDDGetNVRecord function processes a request to publish an NV + * record. It validates the payload and sets the publish request flag + * for the selected record. + * @details \b Inputs: nvMExecSendRecordState + * @details \b Outputs: isPublishRecordRequested, + * recordToPublish + * @param message Pointer to the received message + * @return TRUE if the request is accepted otherwise FALSE + *************************************************************************/ BOOL testDDGetNVRecord( MESSAGE_T *message ) { BOOL result = FALSE; @@ -776,21 +914,31 @@ if ( 1 == message->hdr.payloadLen ) { job = ( NVM_RECORD_TYPE_T )message->payload[ 0 ]; -// job = getNVMRecordJobState( msgID ); + // Accept the request only if the send exec is in the idle state if ( ( job < NUM_OF_NVM_RECORD_TYPES ) && ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) ) { isPublishRecordRequested[ job ] = TRUE; - recordToPublish = job; - result = TRUE; + recordToPublish = job; + result = TRUE; } } return result; } +/*********************************************************************//** + * @brief + * The testDDSetNVSystemRecord function processes a request to update + * the system record. It allows updates only when the system is in + * service mode. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the record is successfully processed otherwise FALSE + *************************************************************************/ BOOL testDDSetNVSystemRecord( MESSAGE_T *message ) { BOOL result = FALSE; @@ -804,6 +952,16 @@ return result; } +/*********************************************************************//** + * @brief + * The testDDSetNVServiceRecord function processes a request to update + * the service record. It allows updates only when the system is in + * service mode. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the record is successfully processed otherwise FALSE + *************************************************************************/ BOOL testDDSetNVServiceRecord( MESSAGE_T *message ) { BOOL result = FALSE; @@ -817,6 +975,16 @@ return result; } +/*********************************************************************//** + * @brief + * The testDDSetNVCalibrationRecord function processes a request to + * update the calibration record. It allows updates only when the + * system is in service mode. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the record is successfully processed otherwise FALSE + *************************************************************************/ BOOL testDDSetNVCalibrationRecord( MESSAGE_T *message ) { BOOL result = FALSE; @@ -830,13 +998,31 @@ return result; } +/*********************************************************************//** + * @brief + * The testDDSetNVInstitutionalRecord function processes a request to + * update the institutional record. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the record is successfully processed otherwise FALSE + *************************************************************************/ BOOL testDDSetNVInstitutionalRecord( MESSAGE_T *message ) { BOOL result = FALSE; result = receiveDDRecord ( message ); return result; } +/*********************************************************************//** + * @brief + * The testDDSetNVUsageInfoRecord function processes a request to + * update the usage information record. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the record is successfully processed otherwise FALSE + *************************************************************************/ BOOL testDDSetNVUsageInfoRecord( MESSAGE_T *message ) { BOOL result = FALSE; Index: firmware/App/Services/NVMsgQ.h =================================================================== diff -u -re17e1dc97bf8878056f1f7e4aa861c2448db52bc -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Services/NVMsgQ.h (.../NVMsgQ.h) (revision e17e1dc97bf8878056f1f7e4aa861c2448db52bc) +++ firmware/App/Services/NVMsgQ.h (.../NVMsgQ.h) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -61,7 +61,7 @@ // ********** public function prototypes ********** void initNVMsgQ ( void ); -void execNVMProcessRecord( void ); +void execNVMPSendReceiveRecord( void ); // Record operations queue functions void enqueueRecordJob( NVM_OPERATION_T ops, NVM_RECORD_TYPE_T job ); Index: firmware/App/Services/NVRecordsDD.c =================================================================== diff -u -re17e1dc97bf8878056f1f7e4aa861c2448db52bc -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Services/NVRecordsDD.c (.../NVRecordsDD.c) (revision e17e1dc97bf8878056f1f7e4aa861c2448db52bc) +++ firmware/App/Services/NVRecordsDD.c (.../NVRecordsDD.c) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -139,14 +139,14 @@ // ********** private data ********** -// Temporary Record variable used only for receiving record before crc verification +/// Temporary Record variable used only for receiving record before crc verification static DD_SYSTEM_GROUP_T ddTempRxSystemGrp; ///< DD system group structure (including padding and final CRC). static DD_SERVICE_GROUP_T ddTempRxServiceGrp; ///< DD service group structure (including padding and final CRC). static DD_CALIBRATION_RECORD_T ddTempRxCalRecord; ///< DD calibration record structure (including padding and final CRC). static DD_INSTITUTIONAL_GROUP_T ddTempRxInstitGrp; ///< DD institutional group structure (including padding and final CRC). static DD_USAGE_INFO_GROUP_T ddTempRxUsageGrp; ///< DD usage info structure (including padding and final CRC). -// Temporary Process records specifications used only for receiving +/// Temporary Process records specifications used only for receiving static PROCESS_RECORD_SPECS_T tempRxRecords[ NUM_OF_NVM_RECORD_TYPES ] = { // Start address Size of the job Record structure pointer Record CRC pointer Event calibration record update {SYSTEM_RECORD_NV_MEM_START_ADDRESS, sizeof(DD_SYSTEM_GROUP_T), (U08*)&ddTempRxSystemGrp, (U08*)&ddTempRxSystemGrp.crc, DD_EVENT_SYSTEM_RECORD_UPDATE }, // NVM_SYSTEM_RECORD @@ -156,14 +156,14 @@ {USAGE_INFO_START_ADDRESS, sizeof(DD_USAGE_INFO_GROUP_T), (U08*)&ddTempRxUsageGrp, (U08*)&ddTempRxUsageGrp.crc, DD_EVENT_USAGE_INFO_UPDATE }, // NVM_USAGE_INFO_RECORD }; -// Main NVM Record variables +/// Main NVM Record variables static DD_SYSTEM_GROUP_T ddSystemGroup; ///< DD system group structure (including padding and final CRC). static DD_SERVICE_GROUP_T ddServiceGroup; ///< DD service group structure (including padding and final CRC). static DD_CALIBRATION_RECORD_T ddCalibrationRecord; ///< DD calibration record structure (including padding and final CRC). static DD_INSTITUTIONAL_GROUP_T ddInstitutionalGroup; ///< DD institutional group structure (including padding and final CRC). static DD_USAGE_INFO_GROUP_T ddUsageInfoGroup; ///< DD usage info structure (including padding and final CRC). -// Main Process records specifications +/// Main Process records specifications const PROCESS_RECORD_SPECS_T RECORDS_SPECS[ NUM_OF_NVM_RECORD_TYPES ] = { // Start address Size of the job Record structure pointer Record CRC pointer Event calibration record update {SYSTEM_RECORD_NV_MEM_START_ADDRESS, sizeof(DD_SYSTEM_GROUP_T), (U08*)&ddSystemGroup, (U08*)&ddSystemGroup.crc, DD_EVENT_SYSTEM_RECORD_UPDATE }, // NVM_SYSTEM_RECORD @@ -173,10 +173,10 @@ {USAGE_INFO_START_ADDRESS, sizeof(DD_USAGE_INFO_GROUP_T), (U08*)&ddUsageInfoGroup, (U08*)&ddUsageInfoGroup.crc, DD_EVENT_USAGE_INFO_UPDATE }, // NVM_USAGE_INFO_RECORD }; -static NVM_SELF_TEST_STATE_T nvmSelfTestState; ///< NVM self-test state variable. -static SELF_TEST_STATUS_T nvmSelfTestResult; ///< NVM self-test result. -static U32 usageWriteTries; ///< Usage write tries. -static BOOL isSelfTestReadRecordsDone; ///< Set to true when all the records are read +static NVM_SELF_TEST_STATE_T nvmSelfTestState; ///< NVM self-test state variable. +static SELF_TEST_STATUS_T nvmSelfTestResult; ///< NVM self-test result. +static U32 usageWriteTries; ///< Usage write tries. +static BOOL isSelfTestReadRecordsDone; ///< Set to true when all the records are read // ********** private function prototypes ********** @@ -217,7 +217,7 @@ /*********************************************************************//** * @brief - * The execNVMSelfTest function runs the NV data management + * The execNVMRecordsSelfTest 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 @@ -227,7 +227,7 @@ * nvmSelfTestResult * @return nvmSelfTestResult the result of self-test *************************************************************************/ -SELF_TEST_STATUS_T execNVMSelfTest ( void ) +SELF_TEST_STATUS_T execNVMRecordsSelfTest ( void ) { switch ( nvmSelfTestState ) { @@ -524,18 +524,19 @@ if ( calcCRC != recordCRC ) { // CRC did not pass so set all values to default -// ddInstitutionalGroup.ddInstitutionalRecord.minDialysateFlowMLPM = getU32DefaultTreatmentParamEdge( TREATMENT_PARAM_DIALYSATE_FLOW, TRUE ); -// ddInstitutionalGroup.ddInstitutionalRecord.maxDialysateFlowMLPM = getU32DefaultTreatmentParamEdge( TREATMENT_PARAM_DIALYSATE_FLOW, FALSE ); -// ddInstitutionalGroup.ddInstitutionalRecord.minDialysateTempC = getF32DefaultTreatmentParamEdge( TREATMENT_PARAM_DIALYSATE_TEMPERATURE, TRUE ); -// ddInstitutionalGroup.ddInstitutionalRecord.maxDialysateTempC = getF32DefaultTreatmentParamEdge( TREATMENT_PARAM_DIALYSATE_TEMPERATURE, FALSE ); -// ddInstitutionalGroup.ddInstitutionalRecord.acidConcentrate = getF32DefaultTreatmentParamEdge( TREATMENT_PARAM_ACID_CONCENTRATE, FALSE ); +// ddInstitutionalGroup.ddInstitutionalRecord.minDialysateFlowMLPM = getU32TreatmentParamLowerRangeLimit( TREATMENT_PARAM_DIALYSATE_FLOW ); +// ddInstitutionalGroup.ddInstitutionalRecord.maxDialysateFlowMLPM = getU32TreatmentParamUpperRangeLimit( TREATMENT_PARAM_DIALYSATE_FLOW ); +// ddInstitutionalGroup.ddInstitutionalRecord.minDialysateTempC = getF32TreatmentParamLowerRangeLimit( TREATMENT_PARAM_DIALYSATE_TEMPERATURE ); +// ddInstitutionalGroup.ddInstitutionalRecord.maxDialysateTempC = getF32TreatmentParamUpperRangeLimit( TREATMENT_PARAM_DIALYSATE_TEMPERATURE ); +// ddInstitutionalGroup.ddInstitutionalRecord.minAcidConcentrate = getU32TreatmentParamLowerRangeLimit( TREATMENT_PARAM_ACID_CONCENTRATE ); +// ddInstitutionalGroup.ddInstitutionalRecord.maxAcidConcentrate = getU32TreatmentParamUpperRangeLimit( TREATMENT_PARAM_ACID_CONCENTRATE ); +// ddInstitutionalGroup.ddInstitutionalRecord.minBicarbCartridgeSizeG = getU32TreatmentParamLowerRangeLimit( TREATMENT_PARAM_DRY_BICARB_CART_SIZE ); +// ddInstitutionalGroup.ddInstitutionalRecord.maxBicarbCartridgeSizeG = getU32TreatmentParamUpperRangeLimit( TREATMENT_PARAM_DRY_BICARB_CART_SIZE ); +// ddInstitutionalGroup.ddInstitutionalRecord.minSodiumMEQL = getU32TreatmentParamLowerRangeLimit( TREATMENT_PARAM_SODIUM ); +// ddInstitutionalGroup.ddInstitutionalRecord.maxSodiumMEQL = getU32TreatmentParamUpperRangeLimit( TREATMENT_PARAM_SODIUM ); +// ddInstitutionalGroup.ddInstitutionalRecord.minBicarbonateMEQL = getU32TreatmentParamLowerRangeLimit( TREATMENT_PARAM_BICARBONATE ); +// ddInstitutionalGroup.ddInstitutionalRecord.maxBicarbonateMEQL = getU32TreatmentParamUpperRangeLimit( TREATMENT_PARAM_BICARBONATE ); -// ddInstitutionalGroup.ddInstitutionalRecord.bicarbCartridgeSizeG = getF32DefaultTreatmentParamEdge( TREATMENT_PARAM_DIALYSATE_TEMPERATURE, FALSE ); -// ddInstitutionalGroup.ddInstitutionalRecord.minSodiumMEQL = getF32DefaultTreatmentParamEdge( TREATMENT_PARAM_DIALYSATE_TEMPERATURE, FALSE ); -// ddInstitutionalGroup.ddInstitutionalRecord.maxSodiumMEQL = getF32DefaultTreatmentParamEdge( TREATMENT_PARAM_DIALYSATE_TEMPERATURE, FALSE ); -// ddInstitutionalGroup.ddInstitutionalRecord.minBicarbonateMEQL = getF32DefaultTreatmentParamEdge( TREATMENT_PARAM_DIALYSATE_TEMPERATURE, FALSE ); -// ddInstitutionalGroup.ddInstitutionalRecord.maxBicarbonateMEQL = getF32DefaultTreatmentParamEdge( TREATMENT_PARAM_DIALYSATE_TEMPERATURE, FALSE ); - ddInstitutionalGroup.ddInstitutionalRecord.minRORejectionRatioPCT = DEFAULT_MAX_RO_REJECTION_RATIO_PCT; ddInstitutionalGroup.ddInstitutionalRecord.disinfectionFrequency = DEFAULT_NUM_OF_DISINFECTION_FREQUENCY; ddInstitutionalGroup.ddInstitutionalRecord.disinfectionCycleTime = DEFAULT_NUM_OF_DISINFECTION_CYCLE_TIME; @@ -977,7 +978,7 @@ /*********************************************************************//** * @brief - * The getNVRecord2Driver function copies the requested non-volatile + * The getNVMRecord function copies the requested non-volatile * 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 @@ -992,7 +993,7 @@ * if the data is not valid * @return TRUE if the non-volatile data is valid otherwise FALSE *************************************************************************/ -BOOL getNVRecord2Driver( NV_DATA_T nvData, U08* bufferAddress, U32 bufferLength, +BOOL getNVMRecord( NV_DATA_T nvData, U08* bufferAddress, U32 bufferLength, U08 numOfSnsrs2Check, ALARM_ID_T nvAlarm ) { U08 i; Index: firmware/App/Services/NVRecordsDD.h =================================================================== diff -u -re17e1dc97bf8878056f1f7e4aa861c2448db52bc -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Services/NVRecordsDD.h (.../NVRecordsDD.h) (revision e17e1dc97bf8878056f1f7e4aa861c2448db52bc) +++ firmware/App/Services/NVRecordsDD.h (.../NVRecordsDD.h) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -52,20 +52,20 @@ /// NVM self-test states enumeration. typedef enum NVM_Self_Test_States { - NVM_SELF_TEST_STATE_READ_RECORDS = 0, ///< Self test read records. - NVM_SELF_TEST_STATE_CHECK_CRC, ///< Self test check CRC. - NVM_SELF_TEST_STATE_COMPLETE, ///< Self test complete. - NUM_OF_NVM_SELF_TEST_STATES ///< Total number of self-test states. + NVM_SELF_TEST_STATE_READ_RECORDS = 0, ///< Self test read records. + NVM_SELF_TEST_STATE_CHECK_CRC, ///< Self test check CRC. + NVM_SELF_TEST_STATE_COMPLETE, ///< Self test complete. + NUM_OF_NVM_SELF_TEST_STATES ///< Total number of self-test states. } NVM_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 @@ -257,12 +257,14 @@ 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 minAcidConcentrate; ///< Min acid concentrate + U32 maxAcidConcentrate; ///< Max acid concentrate + U32 minBicarbCartridgeSizeG; ///< Min bicarbonate cartridge size in grams. + U32 maxBicarbCartridgeSizeG; ///< Max bicarbonate cartridge size in grams. + U32 minSodiumMEQL; ///< Min sodium in mEq/L + U32 maxSodiumMEQL; ///< Max sodium in mEq/L + U32 minBicarbonateMEQL; ///< Min bicarbonate in mEq/L + U32 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 @@ -295,13 +297,15 @@ // ********** public function prototypes ********** void initNVRecordsDD( void ); -SELF_TEST_STATUS_T execNVMSelfTest ( void ); +SELF_TEST_STATUS_T execNVMRecordsSelfTest ( void ); PROCESS_RECORD_SPECS_T getProcessRecord( NVM_RECORD_TYPE_T job ); PROCESS_RECORD_SPECS_T getTemporaryRxRecord( NVM_RECORD_TYPE_T job ); 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, +U32 getMinRORejectionRatioInInstitRecordPCT( void ); +F32 getMinInletWaterConductivityLimitInstitRecordUSPCM( void ); +BOOL getNVMRecord( NV_DATA_T nvData, U08* bufferAddress, U32 bufferLength, U08 numOfSnsrs2Check, ALARM_ID_T nvAlarm ); void updateNVSelfTestResult( SELF_TEST_STATUS_T result ); void updateNVSelfTestState( NVM_SELF_TEST_STATE_T state ); Index: firmware/App/Tasks/TaskBG.c =================================================================== diff -u -r830213bc6dcc1a684610caf78c79d55f2cb41e93 -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Tasks/TaskBG.c (.../TaskBG.c) (revision 830213bc6dcc1a684610caf78c79d55f2cb41e93) +++ firmware/App/Tasks/TaskBG.c (.../TaskBG.c) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -17,7 +17,7 @@ #include "gio.h" -//#include "NVDataMgmt.h" +//#include "NVMgmtDD.h" #include "TaskTimer.h" #include "WatchdogMgmt.h" @@ -45,7 +45,7 @@ execWatchdogMgmt(); // Manage Non-volatile data manager - //execNVDataMgmt(); + //execNVM(); } } Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -re17e1dc97bf8878056f1f7e4aa861c2448db52bc -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision e17e1dc97bf8878056f1f7e4aa861c2448db52bc) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -25,6 +25,7 @@ #include "Heaters.h" #include "FPOperationModes.h" #include "Messaging.h" +//#include "NVMgmtDD.h" #include "OperationModes.h" #include "PermeateTank.h" #include "RinsePump.h" Index: firmware/source/sys_main.c =================================================================== diff -u -r89c8709e3b27648926fbb20f25c9a67cbeb99adc -r9a14f69c0f0de343b5664b20753142b50bc4e093 --- firmware/source/sys_main.c (.../sys_main.c) (revision 89c8709e3b27648926fbb20f25c9a67cbeb99adc) +++ firmware/source/sys_main.c (.../sys_main.c) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) @@ -87,6 +87,7 @@ #include "ModeGenPermeate.h" #include "ModePreGenPermeate.h" #include "MsgQueues.h" +#include "NVMgmtDD.h" #include "OperationModes.h" #include "PermeateTank.h" #include "Pressure.h" @@ -189,6 +190,7 @@ initWatchdogMgmt(); initInterrupts(); initFPGADD(); + initNVMgmtDD(); initPressure(); initConductivity(); initValves();