Index: NVDataMgmt.c =================================================================== diff -u -ree4a1386feff846854f3ec80593f129b1ac2af43 -r63224e051e2c46221bd5fa8505da344d4294b307 --- NVDataMgmt.c (.../NVDataMgmt.c) (revision ee4a1386feff846854f3ec80593f129b1ac2af43) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision 63224e051e2c46221bd5fa8505da344d4294b307) @@ -38,58 +38,59 @@ // Private defines -#define QUEUE_MAX_SIZE 20U ///< Max queue size. -#define QUEUE_START_INDEX 0U ///< Queue start index. -#define MIN_JOBS_NEEDED_FOR_DATA_LOG 3U ///< Min queue required for data log (3). -#define MIN_JOBS_NEEDED_FOR_SECTOR_0 4U ///< Min queue count needed to write all (4) records back in sector 0. +#define QUEUE_MAX_SIZE 20U ///< Max queue size. +#define QUEUE_START_INDEX 0U ///< Queue start index. +#define MIN_JOBS_NEEDED_FOR_DATA_LOG 3U ///< Min queue required for data log (3). +#define MIN_JOBS_NEEDED_FOR_SECTOR_0 4U ///< Min queue count needed to write all (4) records back in sector 0. // The clock frequency comes from HCLK_FREQ and it has to be rounded up to the nearest number -#define ROUNDED_HCLK_FREQ FLOAT_TO_INT_WITH_ROUND(HCLK_FREQ) ///< Rounded HCLK for EERPOM clock. -#define BANK7_SECTOR_0_31_ENABLE_BIT_MASK 0x0000000F ///< Bank7 sector 0 t0 31 enable mask. -#define BANK7_SECTOR_32_63_ENABLE_BIT_MASK 0x00000000 ///< Bank7 sector 32 to 63 enable mask. +#define ROUNDED_HCLK_FREQ FLOAT_TO_INT_WITH_ROUND(HCLK_FREQ) ///< Rounded HCLK for EERPOM clock. +#define BANK7_SECTOR_0_31_ENABLE_BIT_MASK 0x0000000F ///< Bank7 sector 0 t0 31 enable mask. +#define BANK7_SECTOR_32_63_ENABLE_BIT_MASK 0x00000000 ///< Bank7 sector 32 to 63 enable mask. -#define BANK7_SECTOR0_START_ADDRESS 0xF0200000 ///< Bank7 sector 0 start address. -#define BANK7_SECTOR0_END_ADDRESS 0xF0203FFF ///< Bank7 sector 0 end address. +#define BANK7_SECTOR0_START_ADDRESS 0xF0200000 ///< Bank7 sector 0 start address. +#define BANK7_SECTOR0_END_ADDRESS 0xF0203FFF ///< Bank7 sector 0 end address. -#define BANK7_SECTOR1_START_ADDRESS 0xF0204000 ///< Bank7 sector 1 start address. -#define BANK7_SECTOR1_END_ADDRESS 0xF0207FFF ///< Bank7 sector 1 end address. +#define BANK7_SECTOR1_START_ADDRESS 0xF0204000 ///< Bank7 sector 1 start address. +#define BANK7_SECTOR1_END_ADDRESS 0xF0207FFF ///< Bank7 sector 1 end address. -#define BANK7_SECTOR2_START_ADDRESS 0xF0208000 ///< Bank7 sector 2 start address. -#define BANK7_SECTOR2_END_ADDRESS 0xF020BFFF ///< Bank7 sector 2 end address. +#define BANK7_SECTOR2_START_ADDRESS 0xF0208000 ///< Bank7 sector 2 start address. +#define BANK7_SECTOR2_END_ADDRESS 0xF020BFFF ///< Bank7 sector 2 end address. -#define BANK7_SECTOR3_START_ADDRESS 0xF020C000 ///< Bank7 sector 3 start address. -#define BANK7_SECTOR3_END_ADDRESS 0xF020FFFF ///< Bank7 sector 3 end address. +#define BANK7_SECTOR3_START_ADDRESS 0xF020C000 ///< Bank7 sector 3 start address. +#define BANK7_SECTOR3_END_ADDRESS 0xF020FFFF ///< Bank7 sector 3 end address. -#define MAX_EEPROM_WRITE_BUFFER_BYTES 16U ///< Max allowed bytes for an EEPROM write (16 bytes). -#define MAX_RTC_RAM_OPS_BUFFER_BYTES 64U ///< Max target RTC RAM operations (read/write) bytes. +#define MAX_EEPROM_WRITE_BUFFER_BYTES 16U ///< Max allowed bytes for an EEPROM write (16 bytes). +#define MAX_RTC_RAM_OPS_BUFFER_BYTES 64U ///< Max target RTC RAM operations (read/write) bytes. -#define MAX_JOB_DATA_SIZE_BYTES 32U ///< Max bytes per job (32 bytes). -#define LOG_DATA_START_INDEX 0U ///< Log data start index. -#define MAX_NUM_OF_SECTORS_FOR_LOG_DATA 3U ///< Max number of sector (3 sectors). -#define MAX_LOG_DATA_PER_SECTOR (((BANK7_SECTOR1_END_ADDRESS + 1) - \ +#define MAX_JOB_DATA_SIZE_BYTES 32U ///< Max bytes per job (32 bytes). +#define LOG_DATA_START_INDEX 0U ///< Log data start index. +#define MAX_NUM_OF_SECTORS_FOR_LOG_DATA 3U ///< Max number of sector (3 sectors). +#define MAX_LOG_DATA_PER_SECTOR (((BANK7_SECTOR1_END_ADDRESS + 1) - \ BANK7_SECTOR1_START_ADDRESS) / MAX_JOB_DATA_SIZE_BYTES) ///< Max log data per sector (512 for now). -#define MAX_NUM_OF_EVENTS_IN_SECTOR3 (MAX_NUM_OF_SECTORS_FOR_LOG_DATA * MAX_LOG_DATA_PER_SECTOR) ///< Max number of accumulated logs in sector 3 (1536). -#define MAX_NUM_OF_EVENTS_IN_SECTOR2 ((MAX_NUM_OF_SECTORS_FOR_LOG_DATA - 1) * MAX_LOG_DATA_PER_SECTOR) ///< Max number of accumulated logs in sector 2 (1024). -#define MAX_NUM_OF_EVENTS_IN_SECTOR1 ((MAX_NUM_OF_SECTORS_FOR_LOG_DATA - 2) * MAX_LOG_DATA_PER_SECTOR) ///< Max number of accumulated logs in sector 1 (512). +#define MAX_NUM_OF_EVENTS_IN_SECTOR3 (MAX_NUM_OF_SECTORS_FOR_LOG_DATA * MAX_LOG_DATA_PER_SECTOR) ///< Max number of accumulated logs in sector 3 (1536). +#define MAX_NUM_OF_EVENTS_IN_SECTOR2 ((MAX_NUM_OF_SECTORS_FOR_LOG_DATA - 1) * MAX_LOG_DATA_PER_SECTOR) ///< Max number of accumulated logs in sector 2 (1024). +#define MAX_NUM_OF_EVENTS_IN_SECTOR1 ((MAX_NUM_OF_SECTORS_FOR_LOG_DATA - 2) * MAX_LOG_DATA_PER_SECTOR) ///< Max number of accumulated logs in sector 1 (512). // Data addresses and length in RTC RAM -#define LOG_RECORD_START_ADDRESS 0x00000000 // 0 ///< Log record start address in RTC RAM (0). -#define HD_TREATMENT_TIME_ADDRESS 0x00000010 // 16 ///< HD treatment time start address in RTC RAM (16). -#define DG_CONSUMED_WATER_ADDRESS 0x00000020 // 32 ///< DG water consumption start address in RTC RAM (32). -#define SERVICE_RECORD_START_ADDRESS 0x00000030 // 48 ///< Service date record start address in RTC RAM (HD/DG) (48). -#define DG_SCHEDULED_RUNS_START_ADDRESS (SERVICE_RECORD_START_ADDRESS + sizeof(DG_SERVICE_GROUP_T)) ///< DG scheduled runs start address in RTC RAM. +#define LOG_RECORD_START_ADDRESS 0x00000000 // 0 ///< Log record start address in RTC RAM (0). +#define HD_TREATMENT_TIME_ADDRESS 0x00000010 // 16 ///< HD treatment time start address in RTC RAM (16). +#define DG_CONSUMED_WATER_ADDRESS 0x00000020 // 32 ///< DG water consumption start address in RTC RAM (32). +#define SERVICE_RECORD_START_ADDRESS 0x00000030 // 48 ///< Service date record start address in RTC RAM (HD/DG) (48). +#define DG_SCHEDULED_RUNS_START_ADDRESS (SERVICE_RECORD_START_ADDRESS + sizeof(DG_SERVICE_GROUP_T)) ///< DG scheduled runs start address in RTC RAM. #define COMMAND_TIME_OUT 500U ///< Timeout for an EEPROM or RTC command in ms. /// EEPROM functions use the buffer length as the size of U32. So before send the length to any of FAPI functions, it should be divide by 4. #define EEPROM_OPS_SIZE_OF_CONVERTER 4 // ********** Calibration data defines ********** #define NUM_OF_BYTES_PER_CAL_PAYLOAD 150U ///< Number of bytes per calibration payload. -#define CAL_DATA_SEND_INTERVAL_COUNT ( MS_PER_SECOND / ( 5 * TASK_GENERAL_INTERVAL ) ) ///< Calibration data send time interval in counts. -#define RECORD_DATA_RECEIVE_TIMEOUT_MS ( 4 * MS_PER_SECOND ) ///< Record data receive all the data packets timeout in ms. +#define CAL_DATA_SEND_INTERVAL_COUNT (MS_PER_SECOND / (5 * TASK_GENERAL_INTERVAL)) ///< Calibration data send time interval in counts. +#define RECORD_DATA_RECEIVE_TIMEOUT_MS (4 * MS_PER_SECOND) ///< Record data receive all the data packets timeout in ms. #define RECORD_DATA_MAX_MESSAGE_DFFIRENCE 1 ///< Calibration data receive message different from the previous message. #define RECORD_DATA_FIRST_RECEIVING_MSG_NUM 1 ///< Calibration data first receiving message number. -#define SYSTEM_DATA_NV_MEM_START_ADDRESS BANK7_SECTOR0_START_ADDRESS + 2048 ///< System record storage start address in NV memory. +#define SYSTEM_RECORD_NV_MEM_START_ADDRESS BANK7_SECTOR0_START_ADDRESS ///< System record storage start address in NV memory. +#define CAL_RECORD_NV_MEM_START_ADDRESS BANK7_SECTOR0_START_ADDRESS + 4096 ///< Calibration record storage start address in NV memory. #define RECORD_BYTE_SIZE(r) (sizeof(r) + sizeof(U16)) ///< Record byte size macro. // Padding length calculation: (DG struct size % bytes to write(16) == 0 ? 0 : (DG struct size / bytes to write(16)) + 1) * bytes to write(16) @@ -376,10 +377,10 @@ static DG_USAGE_INFO_GROUP_T dgUsageInfoGroup; ///< DG usage info structure (including padding and final CRC). // Process records specifications const PROCESS_RECORD_SPECS_T RECORDS_SPECS [ NUM_OF_NVDATMGMT_RECORDS_JOBS ] = { - {BANK7_SECTOR0_START_ADDRESS, sizeof(DG_CALIBRATION_RECORD_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(DG_CALIBRATION_RECORD_T), (U08*)&dgCalibrationRecord, (U08*)&(dgCalibrationRecord.crc)}, // NVDATAMGMT_CALIBRATION_RECORD - {SYSTEM_DATA_NV_MEM_START_ADDRESS, sizeof(DG_SYSTEM_GROUP_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(DG_SYSTEM_GROUP_T), (U08*)&dgSystemGroup, (U08*)&dgSystemGroup.crc}, // NVDATAMGMT_SYSTEM_RECORD - {SERVICE_RECORD_START_ADDRESS, sizeof(DG_SERVICE_GROUP_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&dgServiceGroup, (U08*)&dgServiceGroup.crc}, // NVDATAMGMT_PROCESS_LAST_SERVICE_RECORD - {DG_SCHEDULED_RUNS_START_ADDRESS, sizeof(DG_SCHEDULED_RUNS_GROUP_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&dgScheduledRunsGroup, (U08*)&dgScheduledRunsGroup.crc} // NVDATAMGMT_SCHEDULER_RECORD + {CAL_RECORD_NV_MEM_START_ADDRESS, sizeof(DG_CALIBRATION_RECORD_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(DG_CALIBRATION_RECORD_T), (U08*)&dgCalibrationRecord, (U08*)&(dgCalibrationRecord.crc)}, // NVDATAMGMT_CALIBRATION_RECORD + {SYSTEM_RECORD_NV_MEM_START_ADDRESS, sizeof(DG_SYSTEM_GROUP_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(DG_SYSTEM_GROUP_T), (U08*)&dgSystemGroup, (U08*)&dgSystemGroup.crc}, // NVDATAMGMT_SYSTEM_RECORD + {SERVICE_RECORD_START_ADDRESS, sizeof(DG_SERVICE_GROUP_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&dgServiceGroup, (U08*)&dgServiceGroup.crc}, // NVDATAMGMT_SERVICE_RECORD + {DG_SCHEDULED_RUNS_START_ADDRESS, sizeof(DG_SCHEDULED_RUNS_GROUP_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&dgScheduledRunsGroup, (U08*)&dgScheduledRunsGroup.crc} // NVDATAMGMT_SCHEDULER_RECORD }; #endif #ifdef _HD_ @@ -389,9 +390,9 @@ static HD_USAGE_INFO_GROUP_T hdUsageInfoGroup; ///< HD usage info group structure (including padding and final CRC). // Process records specifications const PROCESS_RECORD_SPECS_T RECORDS_SPECS [ NUM_OF_NVDATMGMT_RECORDS_JOBS ] = { - {BANK7_SECTOR0_START_ADDRESS, sizeof(HD_CALIBRATION_RECORD_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(HD_CALIBRATION_RECORD_T), (U08*)&hdCalibrationRecord, (U08*)&hdCalibrationRecord.crc}, // NVDATAMGMT_CALIBRATION_RECORD - {SYSTEM_DATA_NV_MEM_START_ADDRESS, sizeof(HD_SYSTEM_GROUP_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(HD_SYSTEM_GROUP_T), (U08*)&hdSystemGroup, (U08*)&hdSystemGroup.crc}, // NVDATAMGMT_SYSTEM_RECORD - {SERVICE_RECORD_START_ADDRESS, sizeof(HD_SERVICE_GROUP_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&hdServiceGroup, (U08*)&hdServiceGroup.crc}, // NVDATAMGMT_PROCESS_LAST_SERVICE_RECORD + {CAL_RECORD_NV_MEM_START_ADDRESS, sizeof(HD_CALIBRATION_RECORD_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(HD_CALIBRATION_RECORD_T), (U08*)&hdCalibrationRecord, (U08*)&hdCalibrationRecord.crc}, // NVDATAMGMT_CALIBRATION_RECORD + {SYSTEM_RECORD_NV_MEM_START_ADDRESS, sizeof(HD_SYSTEM_GROUP_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(HD_SYSTEM_GROUP_T), (U08*)&hdSystemGroup, (U08*)&hdSystemGroup.crc}, // NVDATAMGMT_SYSTEM_RECORD + {SERVICE_RECORD_START_ADDRESS, sizeof(HD_SERVICE_GROUP_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&hdServiceGroup, (U08*)&hdServiceGroup.crc}, // NVDATAMGMT_PROCESS_LAST_SERVICE_RECORD }; #endif static RECORD_JOBS_STATE_T recordToPublish; ///< Record to publish (i.e. calibration, system) @@ -427,7 +428,7 @@ static U32 currentTime = 0; ///< Current time. static volatile BOOL powerOffIsImminent = FALSE; ///< Power off warning has been signaled. Non-volatile memory operations should be completed ASAP and then ceased. -static U32 tempTest; //TODO remove +static U32 tempTest; //TODO remove for operations time measurements // Private functions static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestStart ( void ); @@ -508,16 +509,18 @@ /*********************************************************************//** * @brief * The initNVDataMgmt function initializes the module. - * @details Inputs: NVDataMgmtSelfTestState, NVDataMgmtExecState, - * NVDataMgmtSelfTestResult, queueRearIndex, queueFrontIndex, queueCount, - * recordUpdateAddress, recordQueueRearIndex, recordQueueFrontIndex, - * recordQueueCount, recordAddressOffset, writtenRecordStatus, - * hasPublishRecordBeenRequested - * @details Outputs: NVDataMgmtSelfTestState, NVDataMgmtExecState, - * NVDataMgmtSelfTestResult, queueRearIndex, queueFrontIndex, queueCount, - * recordUpdateAddress, recordQueueRearIndex, recordQueueFrontIndex, - * recordQueueCount, recordAddressOffset, writtenRecordStatus, - * hasPublishRecordBeenRequested + * @details Inputs: nvDataMgmtSelfTestState, nvDataMgmtExecState, + * nvDataMgmtSelfTestResult, nvDataMgmtExecProcessRecordState, + * nvDataMgmtExecReceiveRecordState, queueRearIndex, queueFrontIndex, + * queueFrontIndex, queueCount, recordUpdateAddress, recordQueueRearIndex, + * recordQueueFrontIndex, recordQueueCount, recordAddressOffset, + * writtenRecordStatus, hasPublishRecordBeenRequested + * @details Outputs: nvDataMgmtSelfTestState, nvDataMgmtExecState, + * nvDataMgmtSelfTestResult, nvDataMgmtExecProcessRecordState, + * nvDataMgmtExecReceiveRecordState, queueRearIndex, queueFrontIndex, + * queueFrontIndex, queueCount, recordUpdateAddress, recordQueueRearIndex, + * recordQueueFrontIndex, recordQueueCount, recordAddressOffset, + * writtenRecordStatus, hasPublishRecordBeenRequested * @return none *************************************************************************/ void initNVDataMgmt( void ) @@ -548,8 +551,8 @@ /*********************************************************************//** * @brief * 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. + * 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 Outputs: powerOffIsImminent * @return none @@ -562,8 +565,8 @@ /*********************************************************************//** * @brief * The execNVDataMgmt runs the NVDataMgmt main tasks. - * @details Inputs: NVDataMgmtExecState - * @details Outputs: NVDataMgmtExecState + * @details Inputs: nvDataMgmtExecState + * @details Outputs: nvDataMgmtExecState * @return none *************************************************************************/ void execNVDataMgmt( void ) @@ -620,9 +623,9 @@ /*********************************************************************//** * @brief * The execNVDataMgmtSelfTest runs the NVDataMgmt POST during the self-test. - * @details Inputs: NVDataMgmtSelfTestState - * @details Outputs: NVDataMgmtSelfTestState - * @return NVDataMgmtSelfTestResult the result of self-test + * @details Inputs: nvDataMgmtSelfTestState, nvDataMgmtSelfTestResult + * @details Outputs: nvDataMgmtSelfTestState + * @return nvDataMgmtSelfTestResult the result of self-test *************************************************************************/ SELF_TEST_STATUS_T execNVDataMgmtSelfTest ( void ) { @@ -688,7 +691,7 @@ * The execNVDataMgmtProcessRecord runs the NVDataMgmt send records related * to tasks. * @details Inputs: nvDataMgmtExecProcessRecordState, - * nvDataMgmtExecReceiveRecordState + * nvDataMgmtExecReceiveRecordState, recordReceiveStartTime * @details Outputs: nvDataMgmtExecProcessRecordState, * nvDataMgmtExecReceiveRecordState * @return none @@ -716,6 +719,8 @@ } // Check if the exec receive records is not idle + // This section checks the status of the asynchronous state machine that receives + // data from Dialin. if ( nvDataMgmtExecReceiveRecordState != NVDATAMGMT_RECEIVE_RECORD_IDLE ) { // Check if the data receiving process has timed out. The exec receive record @@ -757,8 +762,10 @@ * @brief * The setCalibrationRecord function writes the calibration record that * is received from Dialin into the calibration structure. - * @details Inputs: none - * @details Outputs: none + * @details Inputs: nvDataMgmtExecReceiveRecordState, recordUpdateAddress + * recordReceiveStartTime, previousCalMessageNum + * @details Outputs: nvDataMgmtExecReceiveRecordState, recordUpdateAddress + * recordReceiveStartTime, previousCalMessageNum * @param currentMessage: current message number that is received from * Dialin * @param totalMessages: total number of messages from Dialin @@ -775,9 +782,9 @@ if ( RECORD_DATA_FIRST_RECEIVING_MSG_NUM == currentMessage && nvDataMgmtExecReceiveRecordState == NVDATAMGMT_RECEIVE_RECORD_IDLE ) { nvDataMgmtExecReceiveRecordState = NVDATAMGMT_RECEIVE_RECORD_RECEIVE; - recordReceiveStartTime = getMSTimerCount(); - previousCalMessageNum = 0; - recordUpdateAddress = 0; + recordReceiveStartTime = getMSTimerCount(); + previousCalMessageNum = 0; + recordUpdateAddress = 0; } // Check if there is still a message left to be received @@ -835,10 +842,11 @@ /*********************************************************************//** * @brief - * The getSystemRecord function sets the system state machine - * to read and publish system record. - * @details Inputs: hasPublishRecordBeenRequested, NVDataMgmtExecCalState - * @details Outputs: hasPublishRecordBeenRequested + * The getSystemRecord function sets the system state machine to read + * and publish system record. + * @details Inputs: hasPublishRecordBeenRequested, recordToPublish + * nvDataMgmtExecProcessRecordState + * @details Outputs: hasPublishRecordBeenRequested, recordToPublish * @return TRUE if the request was successfully registered *************************************************************************/ BOOL getSystemRecord( void ) @@ -858,16 +866,18 @@ /*********************************************************************//** * @brief - * The setSystemRecord function writes the system record that - * is received from Dialin into the system structure. - * @details Inputs: none - * @details Outputs: none + * The setSystemRecord function writes the system record that is received + * from Dialin into the system structure. + * @details Inputs: nvDataMgmtExecReceiveRecordState, recordUpdateAddress + * recordReceiveStartTime, previousCalMessageNum + * @details Outputs: nvDataMgmtExecReceiveRecordState, recordUpdateAddress + * recordReceiveStartTime, previousCalMessageNum * @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 + * @param *addressPtr: address to the beginning of the calibration data + * from Dialin * @return TRUE if the request was successfully registered *************************************************************************/ BOOL setSystemRecord( U32 currentMessage, U32 totalMessages, U32 length, U08 *addressPtr ) @@ -938,10 +948,11 @@ /*********************************************************************//** * @brief - * The getServiceRecord function sets the system state machine - * to read and publish service record. - * @details Inputs: hasPublishRecordBeenRequested, NVDataMgmtExecCalState - * @details Outputs: hasPublishRecordBeenRequested + * The getServiceRecord function sets the system state machine to read + * and publish service record. + * @details Inputs: hasPublishRecordBeenRequested, recordToPublish + * hasPublishRecordBeenRequested + * @details Outputs: hasPublishRecordBeenRequested, recordToPublish * @return TRUE if the request was successfully registered *************************************************************************/ BOOL getServiceRecord( void ) @@ -963,14 +974,16 @@ * @brief * The setServiceRecord function writes the service record that * is received from Dialin into the service structure. - * @details Inputs: none - * @details Outputs: none + * @details Inputs: nvDataMgmtExecReceiveRecordState, recordUpdateAddress + * recordReceiveStartTime, previousCalMessageNum + * @details Outputs: nvDataMgmtExecReceiveRecordState, recordUpdateAddress + * recordReceiveStartTime, previousCalMessageNum * @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 service data data from - * Dialin + * @param *addressPtr: address to the beginning of the calibration data + * from Dialin * @return TRUE if the request was successfully registered *************************************************************************/ BOOL setServiceRecord( U32 currentMessage, U32 totalMessages, U32 length, U08 *addressPtr ) @@ -1043,8 +1056,8 @@ * @brief * The getScheduledRunsRecord function sets the system state machine * to read and publish the scheduled runs record. - * @details Inputs: hasPublishRecordBeenRequested, NVDataMgmtExecCalState, - * recordToPublish + * @details Inputs: hasPublishRecordBeenRequested, recordToPublish + * hasPublishRecordBeenRequested * @details Outputs: hasPublishRecordBeenRequested, recordToPublish * @return TRUE if the request was successfully registered *************************************************************************/ @@ -1067,14 +1080,16 @@ * @brief * The setScheduledRunsRecord function writes the scheduled runs record that * is received from Dialin into the scheduled runs structure. - * @details Inputs: none - * @details Outputs: none + * @details Inputs: nvDataMgmtExecReceiveRecordState, recordUpdateAddress + * recordReceiveStartTime, previousCalMessageNum + * @details Outputs: nvDataMgmtExecReceiveRecordState, recordUpdateAddress + * recordReceiveStartTime, previousCalMessageNum * @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 scheduled runs data from - * Dialin + * @param *addressPtr: address to the beginning of the calibration data + * from Dialin * @return TRUE if the request was successfully registered *************************************************************************/ BOOL setScheduledRunsRecord( U32 currentMessage, U32 totalMessages, U32 length, U08 *addressPtr ) @@ -1165,7 +1180,6 @@ * @details Outputs: none * @return DG flow sensors calibration record *************************************************************************/ - DG_FLOW_SENSORS_CAL_RECORD_T getDGFlowSensorsCalibrationRecord( void ) { return dgCalibrationRecord.dgCalibrationGroups.flowSensorsCalRecord; @@ -1376,12 +1390,12 @@ /*********************************************************************//** * @brief - * The getDGScheduledRunRecord function returns the DG scheduled runs record. + * The getDGScheduledRunsRecord function returns the DG scheduled runs record. * @details Inputs: none * @details Outputs: none * @return DG scheduled runs record *************************************************************************/ -DG_SCHEDULED_RUN_RECORD_T getDGScheduledRunRecord( void ) +DG_SCHEDULED_RUN_RECORD_T getDGScheduledRunsRecord( void ) { return dgScheduledRunsGroup.dgScheduledRun; } @@ -1651,7 +1665,6 @@ { NVDATAMGMT_SELF_TEST_STATE_T state = NVDATAMGMT_SELF_TEST_STATE_START; - if ( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmReady ) { PROCESS_RECORD_SPECS_T specs = RECORDS_SPECS [ NVDATAMGMT_CALIBRATION_RECORD ]; @@ -1729,7 +1742,7 @@ * @brief * The handleSelfTestReadServiceRecord reads the service record from RTC * RAM. - * @details Inputs: currentTime, serviceRecord + * @details Inputs: currentTime * @details Outputs: currentTime * @return next state *************************************************************************/ @@ -1868,6 +1881,7 @@ // If the RAM is in Idle, read the log records if ( getRTCRAMStatus() == RTC_RAM_STATUS_IDLE || timeoutStatus == TRUE ) { + // TODO enable the logs //U32 len = sizeof(MFG_RECORD_T) / sizeof(U32); //U32 *addr = (U32*)&mfgRecord; @@ -1886,10 +1900,8 @@ * @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, - * logRecord, mfgRecord, calibrationRecord, calibrationRecord, serviceRecord, - * NVDataMgmtSelfTestResult - * @details Outputs: nvDataMgmtSelfTestResult + * @details Inputs: nvDataMgmtSelfTestResult + * @details Outputs: none * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestCheckCRC ( void ) @@ -1935,15 +1947,16 @@ /*********************************************************************//** * @brief * The handleExecWaitForPostState waits for POST to be completed. - * @details Inputs: NVDataMgmtSelfTestState + * @details Inputs: nvDataMgmtSelfTestState * @details Outputs: none * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecWaitForPostState ( void ) { NVDATAMGMT_EXEC_STATE_T state = NVDATAMGMT_EXEC_STATE_WAIT_FOR_POST; - //if ( NVDataMgmtSelfTestState == NVDATAMGMT_SELF_TEST_STATE_COMPLETE ) + // TODO enable this line + //if ( nvDataMgmtSelfTestState == NVDATAMGMT_SELF_TEST_STATE_COMPLETE ) { state = NVDATAMGMT_EXEC_STATE_IDLE; } @@ -1955,8 +1968,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 - * @details Outputs: currentJob + * @details Inputs: powerOffIsImminent + * @details Outputs: none * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecIdleState ( void ) @@ -1970,7 +1983,7 @@ U32 maxBufferLength; BOOL areQueuesNotEmpty = FALSE; - // If poweroff command has been issued, do not process any new jobs + // If power off command has been issued, do not process any new jobs if ( powerOffIsImminent != TRUE ) { // If the record processing queue is not empty, process the queues @@ -2000,7 +2013,7 @@ maxBufferLength = jobSpecs.maxReadBufferSize; } } - //TODO add the log queue later. + // TODO add the log queue later. } // Check if a queue job is available @@ -2093,10 +2106,11 @@ // Update the variables and issue the next write command currentTime = getMSTimerCount(); recordAddressOffset += jobSpecs.maxWriteBufferSize; - U32 memoryPtr = jobSpecs.startAddress + recordAddressOffset; + U32 memoryPtr = jobSpecs.startAddress + recordAddressOffset; U08* structPtr = jobSpecs.structAddressPtr + recordAddressOffset; writtenRecordStatus = NVDATAMGMT_RECORD_NOT_CHECKED; + // Issue the write command Fapi_issueProgrammingCommand ( (U32*)memoryPtr, structPtr, jobSpecs.maxWriteBufferSize, 0x00, 0, Fapi_DataOnly ); } @@ -2117,8 +2131,10 @@ * @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 - * @details Outputs: recordAddressOffset + * @details Inputs: recordAddressOffset, writtenRecordCheckBuffer, + * writtenRecordStatus + * @details Outputs: recordAddressOffset, writtenRecordCheckBuffer, + * writtenRecordStatus * @return next state of the state machine *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecVerifyEEPROMWriteState ( void ) @@ -2165,11 +2181,11 @@ } /*********************************************************************//** - * @brief handleExecReadFromEEPROMState + * @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: currentJob - * @details Outputs: currentJob + * @details Inputs: currentJob, activeQueue + * @details Outputs: currentJob, activeQueue * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecReadFromEEPROMState ( void ) @@ -2219,8 +2235,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 - * @details Outputs: none + * @details Inputs: currentTime, writtenRecordStatus, recordAddressOffset + * @details Outputs: currentTime, writtenRecordStatus, recordAddressOffset * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecWriteToRAMState ( void ) @@ -2291,8 +2307,8 @@ * @brief * The handleExecVerifyRTCWriteState checks all the bytes that were * written to RTC RAM to ensure they match the data in the NV memory. - * @details Inputs: recordAddressOffset - * @details Outputs: recordAddressOffset + * @details Inputs: recordAddressOffset, writtenRecordStatus + * @details Outputs: recordAddressOffset, writtenRecordStatus * @return next state of the state machine *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecVerifyRTCWriteState( void ) @@ -2307,6 +2323,7 @@ { U32 i; U08* bufferPtr = jobSpecs.structAddressPtr + recordAddressOffset; + // Create a temporary buffer with the size of maximum RTC write U08 tempBufferToCheckData [ MAX_RTC_RAM_OPS_BUFFER_BYTES ]; getDataFromRAM( tempBufferToCheckData, jobSpecs.maxWriteBufferSize ); @@ -2383,7 +2400,7 @@ * @brief * The handleExecProcessRecordIdleState handles the idle state of the * exec cal state machine. - * @details Inputs: hasPublishRecordBeenRequested,calPublishTotalMessages, + * @details Inputs: hasPublishRecordBeenRequested, calPublishTotalMessages, * calPublishMessageCount, calSendDataIntervalCounter * @details Outputs: hasPublishRecordBeenRequested, calPublishTotalMessages, * calPublishMessageCount, calSendDataIntervalCounter @@ -2492,7 +2509,6 @@ break; default: - //Ignore break; } @@ -2947,7 +2963,7 @@ * @brief * The isDGCalibrationRecordValid function calls other functions to check * the validity of DG calibration record. - * @details Inputs: none + * @details Inputs: dgCalibrationRecord * @details Outputs: none * @return TRUE if the DG calibration record is valid otherwise FALSE *************************************************************************/ @@ -3864,8 +3880,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 - * @details Outputs: queueFrontIndex, queueCount + * @details Inputs: queueFrontIndex, queueCount, recordJobQueue + * @details Outputs: queueFrontIndex, queueCount, recordJobQueue * @param ops: memory operation (i.e write, read) * @param location: memory location which are either EEPROM or RTC RAM * @param job: type of job (i.e write calibration data) Index: NVDataMgmt.h =================================================================== diff -u -r5d12a10f75c6655992acb911af4bf339b2eb955b -r63224e051e2c46221bd5fa8505da344d4294b307 --- NVDataMgmt.h (.../NVDataMgmt.h) (revision 5d12a10f75c6655992acb911af4bf339b2eb955b) +++ NVDataMgmt.h (.../NVDataMgmt.h) (revision 63224e051e2c46221bd5fa8505da344d4294b307) @@ -59,25 +59,24 @@ } NVDATAMGMT_READ_STATUS_T; #pragma pack(push, 1) - /// Read data status structure. typedef struct get_data { - NVDATAMGMT_READ_STATUS_T status; ///< Read data status - U08* externalBuffer; ///< External buffer address + NVDATAMGMT_READ_STATUS_T status; ///< Read data status. + U08* externalBuffer; ///< External buffer address. } READ_DATA_T; /// Log data structure. typedef struct { - U32 epochTime; ///< Log data time in epoch - U32 eventCode; ///< Log data event code - U32 subCode; ///< Log data sub code - F32 data1; ///< Log data 1 - F32 data2; ///< Log data 2 - F32 data3; ///< Log data 3 - F32 data4; ///< Log data 4 - F32 data5; ///< Log data 5 + U32 epochTime; ///< Log data time in epoch. + U32 eventCode; ///< Log data event code. + U32 subCode; ///< Log data sub code. + F32 data1; ///< Log data 1. + F32 data2; ///< Log data 2. + F32 data3; ///< Log data 3. + F32 data4; ///< Log data 4. + F32 data5; ///< Log data 5. } LOG_DATA_T; #pragma pack(pop) @@ -122,7 +121,9 @@ DG_ACCELEROMETER_SENSOR_CAL_RECORD_T getDGAccelerometerSensorCalibrationRecord( void ); DG_SYSTEM_RECORD_T getDGSystemRecord( void ); DG_SERVICE_RECORD_T getDGServiceRecord( void ); -DG_SCHEDULED_RUN_RECORD_T getDGScheduledRunRecord( void ); +DG_SCHEDULED_RUN_RECORD_T getDGScheduledRunsRecord( void ); +BOOL setWaterConsumption ( U32 liters ); +U32 getWaterConsumption ( void ); #endif #ifdef _HD_ HD_PUMPS_CAL_RECORD_T getHDPumpsCalibrationRecord( void ); @@ -135,15 +136,9 @@ HD_ACCELEROMETER_SENSOR_CAL_RECORD_T getHDAccelerometerSensorCalibrationRecord( void ); HD_SYSTEM_RECORD_T getHDSystemRecord( void ); HD_SERVICE_RECORD_T getHDServiceRecord( void ); +BOOL setTreatmentTime ( U32 hours ); +U32 getTreatmentTime ( void ); #endif -#ifdef _HD_ -BOOL setTreatmentTime ( U32 hours ); -U32 getTreatmentTime ( void ); -#endif -#ifdef _DG_ -BOOL setWaterConsumption ( U32 liters ); -U32 getWaterConsumption ( void ); -#endif BOOL writeLogData ( LOG_DATA_T* data ); BOOL readLogData ( READ_DATA_T* buffer, U32 length );