Index: NVDataMgmt.c =================================================================== diff -u -rcd1dbf44ebce97f61ad4a757d47449562ec366f0 -r547c33d5e13614b5e8de4739a45db7c3475721d1 --- NVDataMgmt.c (.../NVDataMgmt.c) (revision cd1dbf44ebce97f61ad4a757d47449562ec366f0) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision 547c33d5e13614b5e8de4739a45db7c3475721d1) @@ -20,6 +20,8 @@ #include // For memcpy #include "F021.h" + +#include "MsgQueues.h" #include "NVDataMgmt.h" #include "RTC.h" #include "system.h" @@ -81,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 { @@ -226,6 +230,9 @@ static BOOL calRecordIsValid = FALSE; ///< Flag indicates whether stored calibration record was found to be valid static volatile BOOL powerOffIsImminent = FALSE; ///< Power off warning has been signaled. Non-volatile memory operations should be completed ASAP and then ceased +// *** This declaration will cause a compiler error if CALIBRATION_DATA_T record size exceeds max message payload size. +U08 calRecordSizeAssertion[ ( sizeof( CALIBRATION_DATA_T ) <= MAX_MSG_PAYLOAD_SIZE ? 1 : -1 ) ]; + // Private functions static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestStart ( void ); @@ -367,7 +374,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 * @details Outputs: none @@ -389,6 +396,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: PersistentAlarm.c =================================================================== diff -u -r85db35aef9a57d1efc02bb3b42fc802b65aa3646 -r547c33d5e13614b5e8de4739a45db7c3475721d1 --- PersistentAlarm.c (.../PersistentAlarm.c) (revision 85db35aef9a57d1efc02bb3b42fc802b65aa3646) +++ PersistentAlarm.c (.../PersistentAlarm.c) (revision 547c33d5e13614b5e8de4739a45db7c3475721d1) @@ -89,9 +89,10 @@ * @param alarmIndex Persistent alarm index * @param isOutOfRange Flag indicates data out of range * @param data Data to be check for out of range + * @param limit Upper or lower limit that data exceeded * @return none *************************************************************************/ -void checkPersistentAlarm( PERSISTENT_ALARM_T const alarmIndex, BOOL const isOutOfRange, F32 const data ) +void checkPersistentAlarm( PERSISTENT_ALARM_T const alarmIndex, BOOL const isOutOfRange, F32 const data, F32 const limit ) { if ( alarmIndex < NUM_OF_PERSISTENT_ALARM ) { @@ -101,7 +102,7 @@ persistentAlarms[ alarmIndex ].inRangeCounter = 0; if ( persistentAlarms[ alarmIndex ].outOfRangeCounter > persistentAlarms[ alarmIndex ].persistentTriggerCount ) { - SET_ALARM_WITH_1_F32_DATA( persistentAlarms[ alarmIndex ].alarm, data ); + SET_ALARM_WITH_2_F32_DATA( persistentAlarms[ alarmIndex ].alarm, data, limit ); } } else Index: PersistentAlarm.h =================================================================== diff -u -r97f119050f52c01aa9346c80b706dfdbbda3ac9e -r547c33d5e13614b5e8de4739a45db7c3475721d1 --- PersistentAlarm.h (.../PersistentAlarm.h) (revision 97f119050f52c01aa9346c80b706dfdbbda3ac9e) +++ PersistentAlarm.h (.../PersistentAlarm.h) (revision 547c33d5e13614b5e8de4739a45db7c3475721d1) @@ -8,7 +8,7 @@ * @file PersistentAlarm.h * * @author (last) Quang Nguyen -* @date (last) 17-Aug-2020 +* @date (last) 02-Sep-2020 * * @author (original) Quang Nguyen * @date (original) 17-Aug-2020 @@ -34,6 +34,8 @@ typedef enum PersistentAlarm { #ifdef _HD_ + PERSISTENT_ALARM_BLOOD_FLOW_SIGNAL_STRENGTH, ///< Blood flow signal strength too low + PERSISTENT_ALARM_DIALYSATE_FLOW_SIGNAL_STRENGTH, ///< Dialysate flow signal strength too low PERSISTENT_ALARM_ARTERIAL_PRESSURE_LOW, ///< Arterial pressure too low during treatment PERSISTENT_ALARM_ARTERIAL_PRESSURE_HIGH, ///< Arterial pressure too high during treatment PERSISTENT_ALARM_VENOUS_PRESSURE_LOW, ///< Venous pressure too low during treatment @@ -45,14 +47,16 @@ PERSISTENT_ALARM_INLET_WATER_HIGH_CONDUCTIVITY, ///< Inlet water high conductivity persistent alarm PERSISTENT_ALARM_INLET_WATER_LOW_CONDUCTIVITY, ///< Inlet water low conductivity persistent alarm PERSISTENT_ALARM_RO_REJECTION_RATIO_OUT_OF_RANGE, ///< RO rejection ratio out of range persistent alarm + PERSISTENT_ALARM_INLET_WATER_LOW_PRESSURE, ///< Inlet water low pressure persistent alarm + PERSISTENT_ALARM_INLET_WATER_PRESSURE_FAULT, ///< Inlet water pressure fault persistent alarm #endif NUM_OF_PERSISTENT_ALARM ///< Number of persistent alarms } PERSISTENT_ALARM_T; // ********** public function prototypes ********** void initPersistentAlarm( PERSISTENT_ALARM_T alarmIndex, ALARM_ID_T alarm, BOOL isClearable, - F32 persistentClearCount, F32 persistentTriggerCount ); + U32 persistentClearCount, U32 persistentTriggerCount ); void checkPersistentAlarm( PERSISTENT_ALARM_T const alarmIndex, BOOL const isOutOfRange, F32 const data, F32 const limit ); /**@}*/