Index: NVDataMgmt.c =================================================================== diff -u -re32c7f4d6ffd2047d271e428ebd2d92e0e5d2402 -r4b13eff164ec468e415fff197ed8af3b85504df0 --- NVDataMgmt.c (.../NVDataMgmt.c) (revision e32c7f4d6ffd2047d271e428ebd2d92e0e5d2402) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision 4b13eff164ec468e415fff197ed8af3b85504df0) @@ -8,7 +8,7 @@ * @file NVDataMgmt.c * * @author (last) Sean Nash -* @date (last) 10-Sep-2020 +* @date (last) 24-Sep-2020 * * @author (original) Dara Navaei * @date (original) 12-Feb-2020 @@ -278,10 +278,9 @@ /*********************************************************************//** * @brief * The initNVDataMgmt function initializes the module. - * @details - * Inputs: NVDataMgmtSelfTestState, NVDataMgmtExecState, NVDataMgmtSelfTestResult, + * @details Inputs: NVDataMgmtSelfTestState, NVDataMgmtExecState, NVDataMgmtSelfTestResult, * queueRearIndex, queueFrontIndex, queueCount - * Outputs: NVDataMgmtSelfTestState, NVDataMgmtExecState, NVDataMgmtSelfTestResult, + * @details Outputs: NVDataMgmtSelfTestState, NVDataMgmtExecState, NVDataMgmtSelfTestResult, * queueRearIndex, queueFrontIndex, queueCount * @return none *************************************************************************/ @@ -302,9 +301,8 @@ * 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: none - * Outputs: powerOffIsImminent + * @details Inputs: none + * @details Outputs: powerOffIsImminent * @return none *************************************************************************/ void signalPowerOffWarning( void ) @@ -318,9 +316,8 @@ * 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: mfgRecord - * Outputs: mfgRecord + * @details Inputs: mfgRecord + * @details Outputs: mfgRecord * @return TRUE is the enqueue was successfully scheduled *************************************************************************/ BOOL setMfgData ( MFG_DATA_T data ) @@ -335,9 +332,8 @@ * @brief * The getMfgData returns the data in the structure that holds manufacturing * record to buffer that the caller has provided. - * @details - * Inputs: mfgRecord - * Outputs: none + * @details Inputs: mfgRecord + * @details Outputs: none * @param buffer address of manufacturing data buffer * @return TRUE if the buffer pointer was not null and the copy was successful *************************************************************************/ @@ -356,13 +352,12 @@ /*********************************************************************//** * @brief - * 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 + * 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. + * @details Inputs: calibrationRecord + * @details Outputs: calibrationRecord * @param data calibration data structure * @return TRUE if updating was successfully scheduled *************************************************************************/ @@ -382,9 +377,8 @@ * @brief * The getCalibrationData function returns the data in the structure that hold * calibration record to buffer that the caller has provided. - * @details - * Inputs: calibrationRecord - * Outputs: none + * @details Inputs: calibrationRecord + * @details Outputs: none * @param buffer address of calibration data buffer * @return TRUE if calibration record valid *************************************************************************/ @@ -438,9 +432,8 @@ * 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. - * @details - * Inputs: serviceRecord - * Outputs: serviceRecord + * @details Inputs: serviceRecord + * @details Outputs: serviceRecord * @param data service data buffer * @return TRUE if the queue had enough space to schedule the job *************************************************************************/ @@ -464,9 +457,8 @@ * @brief * The getServiceDate returns the data in the structure that holds service * date to buffer that the caller has provided. - * @details - * Inputs: serviceRecord - * Outputs: none + * @details Inputs: serviceRecord + * @details Outputs: none * @param buffer address of service data buffer * @return TRUE if the buffer address was not null *************************************************************************/ @@ -487,9 +479,8 @@ * @brief * The writeLogData checks if the queue is not full and if it is not, it calls * enqueue to schedule a job for writing the log data. - * @details - * Inputs: logRecord - * Outputs: none + * @details Inputs: logRecord + * @details Outputs: none * @param data address of log data buffer * @return TRUE if the queue is not full and if the log header is not corrupted *************************************************************************/ @@ -511,9 +502,8 @@ * @brief * The readLogData checks if the queue is not full and if it is not, it calls * enqueue to schedule a job for writing the log data. - * @details - * Inputs: none - * Outputs: none + * @details Inputs: none + * @details Outputs: none * @param buffer address of read data buffer * @param length length of the data log * @return TRUE if there are enough queues available for the job @@ -536,9 +526,8 @@ * @brief * The setTreatmentTime sets a queue job to write the treatment time in * the specified RAM address. - * @details - * Inputs: treatmentTimeRecord - * Outputs: treatmentTimeRecord + * @details Inputs: treatmentTimeRecord + * @details Outputs: treatmentTimeRecord * @param hours treatmet time in hours * @return TRUE if the queue was not full so the job was scheduled successfully *************************************************************************/ @@ -562,8 +551,7 @@ * @brief * The getTreatmentTime returns the total number treatment hours of the * HD device. - * @details - * Inputs: none + * @details Inputs: none * Output: none * @return treatment time as U32 *************************************************************************/ @@ -576,9 +564,8 @@ * @brief * The setWaterConsumption sets a queue job to write the amount of water * that has been consumed in DG. - * @details - * Inputs: waterConsumptionRecord - * Outputs: waterConsumptionRecord + * @details Inputs: waterConsumptionRecord + * @details Outputs: waterConsumptionRecord * @param liters consumed water is liters * @return TRUE if queue is not full *************************************************************************/ @@ -601,9 +588,8 @@ /*********************************************************************//** * @brief * The getWaterConsumption returns the amount of consumed water. - * @details - * Inputs: none - * Outputs: none + * @details Inputs: none + * @details Outputs: none * @return water consumption as a U32 *************************************************************************/ U32 getWaterConsumption ( void ) @@ -616,9 +602,8 @@ * The setDisinfectionDate gets the last disinfection date, calculates the * CRC for it and if the queue is not full, it schedules a write to RTC RAM * to store the last date. - * @details - * Inputs: lastDisinfectionRecord - * Outputs: lastDisinfectionRecord + * @details Inputs: lastDisinfectionRecord + * @details Outputs: lastDisinfectionRecord * @param date disinfection date buffer * @return TRUE if the queue was not full *************************************************************************/ @@ -642,9 +627,8 @@ * @brief * The getDisinfectionDate populates the provided buffer with the last * disinfection date. - * @details - * Inputs: lastDisinfectionRecord - * Outputs: none + * @details Inputs: lastDisinfectionRecord + * @details Outputs: none * @param buffer address of disinfection date buffer * @return TRUE if the buffer address was not null *************************************************************************/ @@ -664,9 +648,8 @@ /*********************************************************************//** * @brief * The execNVDataMgmtSelfTest runs the NVDataMgmt POST during the self-test. - * @details - * Inputs: NVDataMgmtSelfTestState - * Outputs: NVDataMgmtSelfTestState, alarm if there was a software fault + * @details Inputs: NVDataMgmtSelfTestState + * @details Outputs: NVDataMgmtSelfTestState, alarm if there was a software fault * @return NVDataMgmtSelfTestResult the result of self-test *************************************************************************/ SELF_TEST_STATUS_T execNVDataMgmtSelfTest ( void ) @@ -752,9 +735,8 @@ /*********************************************************************//** * @brief * The setBootloaderFlag sets the bootloader flag to RTC RAM. - * @details - * Inputs: none - * Outputs: none + * @details Inputs: none + * @details Outputs: none * @param flag the bootloader flag * @return TRUE if the queue was not full *************************************************************************/ @@ -775,9 +757,8 @@ /*********************************************************************//** * @brief * The getBootloaderFlag gets the bootloader flag from RTC RAM. - * @details - * Inputs: none - * Outputs: none + * @details Inputs: none + * @details Outputs: none * @return bootloader flag as a U32 *************************************************************************/ U32 getBootloaderFlag( void ) @@ -788,9 +769,8 @@ /*********************************************************************//** * @brief * The execNVDataMgmt runs the NVDataMgmt main tasks. - * @details - * Inputs: NVDataMgmtExecState - * Outputs: NVDataMgmtExecState, alarm if exec state was invalid + * @details Inputs: NVDataMgmtExecState + * @details Outputs: NVDataMgmtExecState, alarm if exec state was invalid * @return none *************************************************************************/ void execNVDataMgmt( void ) @@ -850,9 +830,8 @@ /*********************************************************************//** * @brief * The handleSelfTestStart enables the EEPROM bank sectors. - * @details - * Inputs: currentTime - * Outputs: currentTime + * @details Inputs: currentTime + * @details Outputs: currentTime * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestStart ( void ) @@ -871,9 +850,8 @@ * @brief * The handleSelfTestEnableEEPROM waits for EEPROM to return with ready from * enabling the EEPROM command. - * @details - * Inputs: currentTime - * Outputs: currentTime + * @details Inputs: currentTime + * @details Outputs: currentTime * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestEnableEEPROM ( void ) @@ -900,9 +878,8 @@ * @brief * The handleSelfTestReadBootloaderFlag reads the bootloader flag * from RTC RAM. - * @details - * Inputs: currentTime, bootloaderFlag - * Outputs: currentTime + * @details Inputs: currentTime, bootloaderFlag + * @details Outputs: currentTime * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadBootloaderFlag ( void ) @@ -940,9 +917,8 @@ * @brief * The handleSelfTestReadHDTreatmentTime reads the HD treatment time * from RTC RAM. - * @details - * Inputs: currentTime, treatmentTimeRecord - * Outputs: currentTime + * @details Inputs: currentTime, treatmentTimeRecord + * @details Outputs: currentTime * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadHDTreatmentTime ( void ) @@ -970,9 +946,8 @@ * @brief * The handleSelfTestReadDGWaterConsumption reads the DG water consumption * from RTC RAM. - * @details - * Inputs: currentTime, waterConsumptionRecord - * Outputs: currentTime + * @details Inputs: currentTime, waterConsumptionRecord + * @details Outputs: currentTime * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadDGWaterConsumption ( void ) @@ -998,9 +973,8 @@ /*********************************************************************//** * @brief * The handleSelfTestReadLogRecord reads the log record from RTC RAM. - * @details - * Inputs: currentTime, logRecord, mfgRecord - * Outputs: currentTime + * @details Inputs: currentTime, logRecord, mfgRecord + * @details Outputs: currentTime * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadLogRecord ( void ) @@ -1029,9 +1003,8 @@ * @brief * The handleSelfTestReadMfgRecords reads the manufacturing record from * EEPROM. - * @details - * Inputs: currentTime, calibrationRecord - * Outputs: currentTime + * @details Inputs: currentTime, calibrationRecord + * @details Outputs: currentTime * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadMfgRecord ( void ) @@ -1056,9 +1029,8 @@ * @brief * The handleSelfTestReadCalibrationRecord reads the calibration record * from EEPROM. - * @details - * Inputs: currentTime - * Outputs: currentTime + * @details Inputs: currentTime + * @details Outputs: currentTime * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadCalibrationRecord ( void ) @@ -1085,9 +1057,8 @@ * @brief * The handleSelfTestReadServiceRecord reads the service dates from RTC * RAM. - * @details - * Inputs: currentTime, serviceRecord - * Outputs: currentTime + * @details Inputs: currentTime, serviceRecord + * @details Outputs: currentTime * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadServiceRecord ( void ) @@ -1113,9 +1084,8 @@ * @brief * The handleSelfTestReadLastDisinfectionDate reads the last disinfection date * from RTC RAM. - * @details - * Inputs: lastDisinfectionRecord - * Outputs: none + * @details Inputs: lastDisinfectionRecord + * @details Outputs: none * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadLastDisinfectionDate ( void ) @@ -1137,11 +1107,10 @@ * @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: treatmentTimeRecord, waterConsumptionRecord, lastDisinfectionRecord, + * @details Inputs: treatmentTimeRecord, waterConsumptionRecord, lastDisinfectionRecord, * logRecord, mfgRecord, calibrationRecord, calibrationRecord, serviceRecord, * NVDataMgmtSelfTestResult - * Outputs: NVDataMgmtSelfTestResult, alarm if any of the CRC checks failed + * @details Outputs: NVDataMgmtSelfTestResult, alarm if any of the CRC checks failed * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestCheckCRC ( void ) @@ -1240,9 +1209,8 @@ /*********************************************************************//** * @brief * The handleExecWaitForPostState waits for POST to be completed. - * @details - * Inputs: NVDataMgmtSelfTestState - * Outputs: none + * @details Inputs: NVDataMgmtSelfTestState + * @details Outputs: none * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecWaitForPostState ( void ) @@ -1261,9 +1229,8 @@ * @brief * The handleExecIdleState checks if the queue is empty and if it is not * empty, it sets the state of the job. - * @details - * Inputs: currentJob, currentTime - * Outputs: currentJob + * @details Inputs: currentJob, currentTime + * @details Outputs: currentJob * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecIdleState ( void ) @@ -1329,9 +1296,8 @@ * @brief * The handleExecWriteToEEPROMState issues a write command to EEPROM on entry * and if the write was successful, it sets the state to Idle. - * @details - * Inputs: none - * Outputs: none + * @details Inputs: none + * @details Outputs: none * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecWriteToEEPROMState ( void ) @@ -1351,9 +1317,8 @@ * @brief handleExecReadFromEEPROMState * The handleExecReadFromEEPROMState issues a read command to EEPROM on entry * and if the read was successful, it sets the state to Idle. - * @details - * Inputs: currentJob - * Outputs: currentJob + * @details Inputs: currentJob + * @details Outputs: currentJob * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecReadFromEEPROMState ( void ) @@ -1374,9 +1339,8 @@ * @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 - * Outputs: none + * @details Inputs: none + * @details Outputs: none * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecEraseState ( void ) @@ -1397,9 +1361,8 @@ * The handleExecWriteToRAMState issues a write command to RTC RAM if the * RAM was ready, and if the RAM got back to Idle after the write command, * it sets the state to Idle. - * @details - * Inputs: none - * Outputs: none + * @details Inputs: none + * @details Outputs: none * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecWriteToRAMState ( void ) @@ -1421,9 +1384,8 @@ * RAM was ready, and if the RAM got back to Idle after the read command, * it calls another function to read the data back from RTC RAM and * it sets the state to Idle. - * @details - * Inputs: currentJob - * Outputs: currentJob + * @details Inputs: currentJob + * @details Outputs: currentJob * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecReadFromRAMState ( void ) @@ -1449,9 +1411,8 @@ * read or write. The function then checks for the length of the buffer and if * it is greater than the specified max buffer, it breaks the operation into * multiple jobs. - * @details - * Inputs: jobQueue, queueCount, queueRearIndex - * Outputs: jobQueue, queueCount, queueRearIndex + * @details Inputs: jobQueue, queueCount, queueRearIndex + * @details Outputs: jobQueue, queueCount, queueRearIndex * @param ops type of operation (i.e. write to EEPROM) * @param location location of operation (i.e. RTC RAM) * @param startAddress start address of operation @@ -1493,9 +1454,8 @@ * is at edge of the any of the sectors and if yes, it will update the log * header accordingly. If the write is not at the edge, it will prepare a * normal write to EEPROM job. - * @details - * Inputs: logRecord - * Outputs: logRecord + * @details Inputs: logRecord + * @details Outputs: logRecord * @param data address of data buffer * @return address of the next write as a U32 *************************************************************************/ @@ -1546,9 +1506,8 @@ * @brief * The prepareReadLogJobAndGetStartAddress prepares a read from the specified * address of the EEPROM. - * @details - * Inputs: logRecord - * Outputs: logRecord + * @details Inputs: logRecord + * @details Outputs: logRecord * @return address of the next read as a U32 *************************************************************************/ static U32 prepareReadLogJobAndGetStartAddress ( void ) @@ -1590,9 +1549,8 @@ * is at the beginning of the next sector, it schedules and erase first and then * it schedules the write jobs. The function breaks the write to EEPROM jobs to * 16 bytes at the time. - * @details - * Inputs: none - * Outputs: none + * @details Inputs: none + * @details Outputs: none * @param ops type of operation (i.e. write to EEPROM) * @param location location of operation (i.e. RTC RAM) * @param startAddress start address of operation @@ -1663,9 +1621,8 @@ * @brief * The dequeue 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: queueFrontIndex, queueCount - * Outputs: queueFrontIndex, queueCount + * @details Inputs: queueFrontIndex, queueCount + * @details Outputs: queueFrontIndex, queueCount * @return none *************************************************************************/ static void dequeue ( void ) @@ -1690,9 +1647,8 @@ * @brief * The isQueueEmpty checks whether the queue is empty and if it is empty, * it will return a false. - * @details - * Inputs: queueCount - * Outputs: none + * @details Inputs: queueCount + * @details Outputs: none * @return TRUE if queue is not empty *************************************************************************/ static BOOL isQueueEmpty ( void ) @@ -1711,9 +1667,8 @@ * @brief * The isQueueFull checks whether the queue is full and if it is full, * it will return a true. - * @details - * Inputs: queueCount - * Outputs: none + * @details Inputs: queueCount + * @details Outputs: none * @return TRUE is queue is full *************************************************************************/ static BOOL isQueueFull ( void ) @@ -1731,9 +1686,8 @@ /*********************************************************************//** * @brief * The getAvailableQueueCount returns the number of available queues left. - * @details - * Inputs: queueCount - * Outputs: none + * @details Inputs: queueCount + * @details Outputs: none * @return available queue counts as a U32 *************************************************************************/ static U32 getAvailableQueueCount ( void ) @@ -1747,9 +1701,8 @@ * queues for erasing and setting the records. If there are enough queues, * it schedules an erase job and then schdules jobs to write all the records * back to Bank 7 Sector 0. - * @details - * Inputs: mfgRecord, calibrationRecord - * Outputs: none + * @details Inputs: mfgRecord, calibrationRecord + * @details Outputs: none * @return TRUE if there are enough queue jobs available *************************************************************************/ static BOOL enqueueBank7Sector0Records( void ) @@ -1774,9 +1727,8 @@ * 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 - * Outputs: alarm if command timed out + * @details Inputs: none + * @details Outputs: alarm if command timed out * @param alarm alarm ID * @param state the state that the command timed out * @return TRUE if a command timed out @@ -1803,9 +1755,8 @@ * @brief * The eraseDataLogSectors checks whether there are enough queues available * and if there are, it schedules 3 erases to erase sectors 1,2, and 3. - * @details - * Inputs: none - * Outputs: non + * @details Inputs: none + * @details Outputs: non * @return TRUE if there are enough queues available *************************************************************************/ static BOOL eraseDataLogSectors ( void )