Index: firmware/App/Services/NVMsgQ.c =================================================================== diff -u -r1e809a81cb8831f5aa5938bd333cc374920d5b87 -r45b03b9f23005c05fc75f69416595a155e250cbe --- firmware/App/Services/NVMsgQ.c (.../NVMsgQ.c) (revision 1e809a81cb8831f5aa5938bd333cc374920d5b87) +++ firmware/App/Services/NVMsgQ.c (.../NVMsgQ.c) (revision 45b03b9f23005c05fc75f69416595a155e250cbe) @@ -15,7 +15,12 @@ #include // For memcpy #include // For ceilf function +#include "Common.h" #include "NVMsgQ.h" +#include "NVRecordsDD.h" +#include "TaskGeneral.h" +#include "Timers.h" +#include "Utilities.h" // For crc calculation #define QUEUE_MAX_SIZE 20U ///< Max queue size. #define QUEUE_START_INDEX 0U ///< Queue start index. @@ -37,13 +42,6 @@ U32 length; ///< Length of a buffer. } MEMORY_OPS_T; -/// Process records job structure -typedef struct -{ - NVDATAMGMT_OPERATION_STATE_T memoryOperation; ///< Memory operation. - RECORD_JOBS_STATE_T recordJob; ///< Record job (i.e sector 0). -} PROCESS_RECORD_JOB_T; - /// NVDataMgmt process records states typedef enum NVDataMgmt_Process_Records_States { @@ -66,8 +64,6 @@ static U08 recordQueueCount; ///< Record queue count. static PROCESS_RECORD_JOB_T recordCurrentJob; ///< Record queue current job. -static U32 recordAddressOffset; ///< Record address offset. -static MEMORY_OPS_T currentJob; ///< Current job. static NVDATAMGMT_RECORDS_READ_STATUS_T recordsReadStatus; ///< NVDataMgmt records read status. static BOOL isNewCalAvailable; ///< Signal to indicate whether a new calibration data is available. @@ -95,7 +91,6 @@ recordQueueRearIndex = QUEUE_START_INDEX; recordQueueFrontIndex = QUEUE_START_INDEX; recordQueueCount = 0; - recordAddressOffset = 0; recordsReadStatus = NVDATAMGMT_RECORDS_NOT_STARTED; isNewCalAvailable = FALSE; @@ -180,7 +175,7 @@ hasPublishRecordBeenRequested = FALSE; // Get the record specifications to find the size of the job - PROCESS_RECORD_SPECS_T recordSpec = RECORDS_SPECS [ recordToPublish ]; + PROCESS_RECORD_SPECS_T recordSpec = getProcessRecord( recordToPublish ); // Calculate the total number of messages required to be sent using ceilf function. This function rounds up the // value and its result is converted to U32. @@ -218,15 +213,15 @@ if ( ++calSendDataIntervalCounter >= CAL_DATA_SEND_INTERVAL_COUNT ) { // Set to default cal data payload length - U32 length = NUM_OF_BYTES_PER_CAL_PAYLOAD; +// U32 length = NUM_OF_BYTES_PER_CAL_PAYLOAD; - PROCESS_RECORD_SPECS_T recordSpec = RECORDS_SPECS [ recordToPublish ]; + PROCESS_RECORD_SPECS_T recordSpec = getProcessRecord( recordToPublish ); U08* startPtr = recordSpec.structAddressPtr; // If this is the last calibration data payload, calculate the remainder of the bytes to send if ( ( calPublishMessageCount + 1 ) == calPublishTotalMessages ) { - length = recordSpec.sizeofJob - ( calPublishMessageCount * NUM_OF_BYTES_PER_CAL_PAYLOAD ); +// length = recordSpec.sizeofJob - ( calPublishMessageCount * NUM_OF_BYTES_PER_CAL_PAYLOAD ); } // Find the new location of the pointer which is the start of the calibration payload to be sent @@ -236,28 +231,28 @@ { case NVDATAMGMT_CALIBRATION_RECORD: // Pass the information to the CAN bus - sendDGCalibrationRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); +// sendDGCalibrationRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); break; case NVDATAMGMT_SYSTEM_RECORD: // Pass the information to the CAN bus - sendDGSystemRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); +// sendDGSystemRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); break; case NVDATAMGMT_SERVICE_RECORD: // Pass the information to the CAN bus - sendDGServiceRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); +// sendDGServiceRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); break; #ifndef _RELEASE_ case NVDATAMGMT_SW_CONFIG_RECORD: - sendDGSWConfigRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); +// sendDGSWConfigRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); break; #endif case NVDATAMGMT_USAGE_INFO_RECORD: - sendDGUsageInfoRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); +// sendDGUsageInfoRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); break; default: @@ -328,42 +323,6 @@ /*********************************************************************//** * @brief - * The areResourcesAvailableForNextJob checks whether the resources such as - * semaphore for RTC is available prior to dequeuing the job to be processed. - * @details Inputs: recordQueueFrontIndex - * @details Outputs: none - * @return TRUE if the resources are available otherwise, FALSE - *************************************************************************/ -BOOL areResourcesAvailableForNextJob( void ) -{ - U32 tempIndex; - PROCESS_RECORD_JOB_T tempJob; - BOOL status = FALSE; - - // Initialize the structure per CppCheck run - tempJob.memoryOperation = NVDATAMGMT_NONE; - tempJob.recordJob = NVDATAMGMT_CALIBRATION_RECORD; - - _disable_IRQ(); - tempIndex = recordQueueFrontIndex; - - if ( FALSE == isRecordQueueEmpty() ) - { - tempJob = recordJobQueue[ tempIndex ]; - } - _enable_IRQ(); - - if ( TRUE == isFlashReady() ) - { - status = TRUE; - } - - - return status; -} - -/*********************************************************************//** - * @brief * The isRecordQueueEmpty checks whether the queue is empty and if it is * empty, it will return a false. * @details Inputs: recordQueueCount @@ -382,6 +341,18 @@ return isEmpty; } +BOOL isRecordQueueFull( void ) +{ + BOOL isFull = FALSE; + + if ( recordQueueCount >= ( QUEUE_MAX_SIZE - 1 ) ) + { + isFull = TRUE; + } + + return isFull; +} + /*********************************************************************//** * @brief * The getAvailableRecordQueueCount returns the number of available record @@ -516,7 +487,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[ job ]; + PROCESS_RECORD_SPECS_T recordSpec = getProcessRecord( job ); U08* ptr = recordSpec.structAddressPtr; // Offset the pointer to length that we should start writing from @@ -603,3 +574,23 @@ { return isNewCalAvailable; } + +void updateNewCalAvailableFlag( BOOL value ) +{ + isNewCalAvailable = value; +} + +void updateRecordReadStatus( NVDATAMGMT_RECORDS_READ_STATUS_T status ) +{ + recordsReadStatus = status; +} + +void updateCalStartTimer( U32 value ) +{ + newCalStartTimer = value; +} + +PROCESS_RECORD_JOB_T getCurrentProcessRecordJob ( void ) +{ + return recordCurrentJob; +}