Index: NVDataMgmt.c =================================================================== diff -u -rd63bda74880d0c3ffdd235e3ae67e68a1dc5f36b -r9e272cee788f7b0558d19973457856279f3605ea --- NVDataMgmt.c (.../NVDataMgmt.c) (revision d63bda74880d0c3ffdd235e3ae67e68a1dc5f36b) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision 9e272cee788f7b0558d19973457856279f3605ea) @@ -83,6 +83,8 @@ #define COMMAND_TIME_OUT 500U // time in ms ///< Timeout for an EEPROM or RTC command in ms +#define ERASE_CALIBRATION_KEY 0xD2C3B4A5 ///< 32-bit key required for clearing calibration data. + /// NVDataMgmt self-test states enumeration. typedef enum NVDataMgmt_Self_Test_States { @@ -353,10 +355,10 @@ /*********************************************************************//** * @brief - * The setCalibrationData updates the structure that holds the calibration data, - * calls another function to calculate the CRC for the provided data and - * calls another function to erase sector 0 and write the new manufacturing - * data. + * The setCalibrationData function updates the structure that holds the + * calibration data, calls another function to calculate the CRC for the + * provided data and calls another function to erase sector 0 and write + * the new manufacturing data. * @details * Inputs: calibrationRecord * Outputs: calibrationRecord @@ -377,7 +379,7 @@ /*********************************************************************//** * @brief - * The getCalibrationData returns the data in the structure that hold + * The getCalibrationData function returns the data in the structure that hold * calibration record to buffer that the caller has provided. * @details * Inputs: calibrationRecord @@ -400,6 +402,37 @@ /*********************************************************************//** * @brief + * The testResetCalibrationData function erases the calibration data. + * @details + * Inputs: calibrationRecord + * Outputs: none + * @param key a key is required to erase calibration data + * @return TRUE if calibration record valid + *************************************************************************/ +BOOL testResetCalibrationData( U32 key ) +{ + BOOL status = FALSE; + + // tester must be logged in + if ( TRUE == isTestingActivated() ) + { + // verify key + if ( ERASE_CALIBRATION_KEY == key ) + { + // erase calibration record + memset( (U08*)&calibrationRecord.calData, 0, sizeof(CALIBRATION_DATA_T) ); + // zero CRC so integrity check will fail unless calibration data set again + calibrationRecord.crc = 0; + // save erased calibration record + status = enqueueBank7Sector0Records(); + } + } + + return status; +} + +/*********************************************************************//** + * @brief * The setServiceDate updates the structure that holds the calibration data, * calls another function to calculate the CRC for the provided data if * there is enough queues available, it schedules a write to RTC RAM. Index: NVDataMgmt.h =================================================================== diff -u -r7ff7e715f7a15da5f4055b33e186d58cf96fe909 -r9e272cee788f7b0558d19973457856279f3605ea --- NVDataMgmt.h (.../NVDataMgmt.h) (revision 7ff7e715f7a15da5f4055b33e186d58cf96fe909) +++ NVDataMgmt.h (.../NVDataMgmt.h) (revision 9e272cee788f7b0558d19973457856279f3605ea) @@ -125,35 +125,28 @@ SELF_TEST_STATUS_T execNVDataMgmtSelfTest ( void ); BOOL setBootloaderFlag ( U32 flag ); - U32 getBootloaderFlag ( void ); BOOL setMfgData ( MFG_DATA_T data ); - BOOL getMfgData ( MFG_DATA_T* buffer ); BOOL setCalibrationData ( CALIBRATION_DATA_T data ); - BOOL getCalibrationData ( CALIBRATION_DATA_T* buffer ); +BOOL testResetCalibrationData( U32 key ); BOOL setServiceDate ( SERVICE_DATA_T data ); - BOOL getServiceDate ( SERVICE_DATA_T* buffer ); BOOL setTreatmentTime ( U32 hours ); - U32 getTreatmentTime ( void ); BOOL setWaterConsumption ( U32 liters ); - U32 getWaterConsumption ( void ); BOOL setDisinfectionDate ( DISINFECTION_DATE_T date ); - BOOL getDisinfectionDate ( DISINFECTION_DATE_T* buffer ); BOOL writeLogData ( LOG_DATA_T* data ); - BOOL readLogData ( READ_DATA_T* buffer, U32 length ); /**@}*/