Index: NVDataMgmt.c =================================================================== diff -u -r8ef8c24e291a523ad58f39ab99b2a9129b64bbcd -reee3415dea5c6e05d5de9d3e3d916de6e1146e0e --- NVDataMgmt.c (.../NVDataMgmt.c) (revision 8ef8c24e291a523ad58f39ab99b2a9129b64bbcd) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision eee3415dea5c6e05d5de9d3e3d916de6e1146e0e) @@ -380,7 +380,7 @@ static DG_SCHEDULED_RUNS_GROUP_T dgScheduledRunsGroup; ///< DG scheduled run structure (including padding and final CRC). 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 ] = { +const PROCESS_RECORD_SPECS_T RECORDS_SPECS[ NUM_OF_NVDATMGMT_RECORDS_JOBS ] = { {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 @@ -514,13 +514,7 @@ /*********************************************************************//** * @brief * The initNVDataMgmt function initializes the module. - * @details Inputs: nvDataMgmtSelfTestState, nvDataMgmtExecState, - * nvDataMgmtSelfTestResult, nvDataMgmtExecProcessRecordState, - * nvDataMgmtExecReceiveRecordState, queueRearIndex, queueFrontIndex, - * queueFrontIndex, queueCount, recordUpdateAddress, recordQueueRearIndex, - * recordQueueFrontIndex, recordQueueCount, recordAddressOffset, - * writtenRecordStatus, hasPublishRecordBeenRequested, isNewCalAvailable, - * newCalStartTimer + * @details Inputs: none * @details Outputs: nvDataMgmtSelfTestState, nvDataMgmtExecState, * nvDataMgmtSelfTestResult, nvDataMgmtExecProcessRecordState, * nvDataMgmtExecReceiveRecordState, queueRearIndex, queueFrontIndex, @@ -627,9 +621,6 @@ nvDataMgmtExecState = NVDATAMGMT_EXEC_STATE_IDLE; break; } - - // Check the calibration signal - monitorNewCalSignal(); } /*********************************************************************//** @@ -744,6 +735,9 @@ nvDataMgmtExecReceiveRecordState = NVDATAMGMT_RECEIVE_RECORD_IDLE; } } + + // Check the calibration signal + monitorNewCalSignal(); } /*********************************************************************//** @@ -791,7 +785,7 @@ 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 && nvDataMgmtExecReceiveRecordState == NVDATAMGMT_RECEIVE_RECORD_IDLE ) + if ( ( RECORD_DATA_FIRST_RECEIVING_MSG_NUM == currentMessage ) && ( nvDataMgmtExecReceiveRecordState == NVDATAMGMT_RECEIVE_RECORD_IDLE ) ) { nvDataMgmtExecReceiveRecordState = NVDATAMGMT_RECEIVE_RECORD_RECEIVE; recordReceiveStartTime = getMSTimerCount(); @@ -806,7 +800,7 @@ if ( RECORD_DATA_MAX_MESSAGE_DFFIRENCE == ( currentMessage - previousCalMessageNum ) ) { // Define a pointer that points to the DG calibration record - PROCESS_RECORD_SPECS_T recordSpec = RECORDS_SPECS [ NVDATAMGMT_CALIBRATION_RECORD ]; + PROCESS_RECORD_SPECS_T recordSpec = RECORDS_SPECS[ NVDATAMGMT_CALIBRATION_RECORD ]; U08* ptr = recordSpec.structAddressPtr; // Offset the pointer to length that we should start writing from @@ -819,7 +813,7 @@ // and 0 everything out since we are done writing if ( currentMessage == totalMessages ) { - U16 calcCRC = crc16 ( recordSpec.structAddressPtr, recordSpec.sizeofJob - sizeof(U16) ); + U16 calcCRC = crc16( recordSpec.structAddressPtr, recordSpec.sizeofJob - sizeof(U16) ); U16 recordCRC = *(U16*)recordSpec.structCRCPtr; if ( calcCRC != recordCRC ) @@ -835,12 +829,11 @@ BOOL scheduleStatus = enqueueSector0Records(); // Signal that there is a new calibration record available. - isNewCalAvailable = TRUE; newCalStartTimer = getMSTimerCount(); - - // Done with receiving data, go back to idle - nvDataMgmtExecReceiveRecordState = NVDATAMGMT_RECEIVE_RECORD_IDLE; + isNewCalAvailable = TRUE; } + // Done with receiving data, go back to idle + nvDataMgmtExecReceiveRecordState = NVDATAMGMT_RECEIVE_RECORD_IDLE; } else { @@ -851,6 +844,11 @@ previousCalMessageNum = currentMessage; } } + else + { + status = FALSE; + nvDataMgmtExecReceiveRecordState = NVDATAMGMT_RECEIVE_RECORD_IDLE; + } } return status;