Index: firmware/App/Services/NVMgmtDD.c =================================================================== diff -u -r9a14f69c0f0de343b5664b20753142b50bc4e093 -r6d1ea33dbe56d63b13802cacd09c263a5ee7e6e0 --- firmware/App/Services/NVMgmtDD.c (.../NVMgmtDD.c) (revision 9a14f69c0f0de343b5664b20753142b50bc4e093) +++ firmware/App/Services/NVMgmtDD.c (.../NVMgmtDD.c) (revision 6d1ea33dbe56d63b13802cacd09c263a5ee7e6e0) @@ -15,8 +15,9 @@ #include // For memcpy #include "Common.h" #include "NVDriver.h" +#include "NVJobQ.h" #include "NVMgmtDD.h" -#include "NVMsgQ.h" +#include "NVMessaging.h" #include "NVRecordsDD.h" #include "Timers.h" @@ -35,10 +36,10 @@ typedef enum NVM_Exec_State { NVM_EXEC_STATE_IDLE = 0, ///< Exec state Idle. - NVM_EXEC_STATE_WRITE, ///< Exec state write to EEPROM. - NVM_EXEC_STATE_VERIFY_WRITE, ///< Exec state verify EEPROM write. - NVM_EXEC_STATE_READ, ///< Exec state read from EEPROM. - NVM_EXEC_STATE_ERASE, ///< Exec state erase EEPROM. + NVM_EXEC_STATE_WRITE, ///< Exec state write to EEPROM. + NVM_EXEC_STATE_VERIFY_WRITE, ///< Exec state verify EEPROM write. + NVM_EXEC_STATE_READ, ///< Exec state read from EEPROM. + NVM_EXEC_STATE_ERASE, ///< Exec state erase EEPROM. NUM_OF_NVM_EXEC_STATES ///< Total number of exec states. } NVM_EXEC_STATE_T; @@ -92,7 +93,8 @@ recordAddressOffset = 0; initNVDriver(); - initNVMsgQ(); + initNVJobQ(); + initNVMessaging(); initNVRecordsDD(); enqueueReadAllRecords(); } @@ -152,6 +154,89 @@ } /*********************************************************************//** + * @brief + * The resetNVMPOSTState function resets the NV data management POST + * state and sets the self-test to start reading all the records. + * @details \b Inputs: none + * @details \b Outputs: none + * @return none + *************************************************************************/ + +void resetNVMPOSTState( void ) +{ + updateNVSelfTestResult( SELF_TEST_STATUS_IN_PROGRESS ); + updateNVSelfTestState( NVM_SELF_TEST_STATE_READ_RECORDS ); +} + +/*********************************************************************//** + * @brief + * The isNewCalibrationRecordAvailable function returns the status of + * new calibration record availability. + * @details \b Inputs: none + * @details \b Outputs: none + * @return TRUE if new calibration is available otherwise FALSE + *************************************************************************/ +BOOL isNewCalibrationRecordAvailable( void ) +{ + return getNewCalRecordAvalability(); +} + +/*********************************************************************//** + * @brief + * The getNVRecord2Driver function retrieves NV data by calling the + * record handler after validating input parameters. + * @details \b Inputs: none + * @details \b Outputs: none + * @param nvData The non-volatile data identifier + * @param bufferAddress Pointer to the buffer where data will be copied + * @param bufferLength Length of the provided buffer + * @param numOfSnsrs2Check Number of sensors to check + * @param nvAlarm Alarm to raise if data is invalid + * @return TRUE if the operation is successful otherwise FALSE + *************************************************************************/ +BOOL getNVRecord2Driver( NV_DATA_T nvData, U08* bufferAddress, U32 bufferLength, + U08 numOfSnsrs2Check, ALARM_ID_T nvAlarm ) +{ + BOOL status = FALSE; + + if ( ( nvData < NUM_OF_NV_DD_DATA ) && + ( NULL != bufferAddress ) && + ( bufferLength > 0U ) ) + { + status = getNVMRecord(nvData, bufferAddress, + bufferLength, numOfSnsrs2Check, nvAlarm); + } + + return status; +} + +/*********************************************************************//** + * @brief + * The execNVMProcessRecord function executes the NVM process record + * handler. + * @details \b Inputs: none + * @details \b Outputs: none + * @return none + *************************************************************************/ +void execNVMProcessRecord( void ) +{ + execNVMPSendReceiveRecord(); +} + +/*********************************************************************//** + * @brief + * The execNVMSelfTest function executes the NV management self-test + * handler. + * @details \b Inputs: none + * @details \b Outputs: none + * @return SELF_TEST_STATUS_T self-test result + *************************************************************************/ +SELF_TEST_STATUS_T execNVMSelfTest( void ) +{ + return execNVMRecordsSelfTest(); +} + +/*********************************************************************//** * @brief * The handleExecIdleState function processes the idle state of the * NVM execution state machine. It checks for pending record jobs and @@ -403,78 +488,10 @@ return state; } -/*********************************************************************//** - * @brief - * The resetNVMPOSTState function resets the NV data management POST - * state and sets the self-test to start reading all the records. - * @details \b Inputs: none - * @details \b Outputs: none - * @return none - *************************************************************************/ -void resetNVMPOSTState( void ) -{ - updateNVSelfTestResult( SELF_TEST_STATUS_IN_PROGRESS ); - updateNVSelfTestState( NVM_SELF_TEST_STATE_READ_RECORDS ); -} /*********************************************************************//** * @brief - * The execNVMProcessRecord function executes the NVM process record - * handler. - * @details \b Inputs: none - * @details \b Outputs: none - * @return none - *************************************************************************/ -void execNVMProcessRecord( void ) -{ - execNVMPSendReceiveRecord(); -} - -/*********************************************************************//** - * @brief - * The execNVMSelfTest function executes the NV management self-test - * handler. - * @details \b Inputs: none - * @details \b Outputs: none - * @return SELF_TEST_STATUS_T self-test result - *************************************************************************/ -SELF_TEST_STATUS_T execNVMSelfTest( void ) -{ - execNVMRecordsSelfTest(); -} - -/*********************************************************************//** - * @brief - * The getNVRecord2Driver function retrieves NV data by calling the - * record handler after validating input parameters. - * @details \b Inputs: none - * @details \b Outputs: none - * @param nvData The non-volatile data identifier - * @param bufferAddress Pointer to the buffer where data will be copied - * @param bufferLength Length of the provided buffer - * @param numOfSnsrs2Check Number of sensors to check - * @param nvAlarm Alarm to raise if data is invalid - * @return TRUE if the operation is successful otherwise FALSE - *************************************************************************/ -BOOL getNVRecord2Driver( NV_DATA_T nvData, U08* bufferAddress, U32 bufferLength, - U08 numOfSnsrs2Check, ALARM_ID_T nvAlarm ) -{ - BOOL status = FALSE; - - if ( ( nvData < NUM_OF_NV_DD_DATA ) && - ( NULL != bufferAddress ) && - ( bufferLength > 0U ) ) - { - status = getNVMRecord(nvData, bufferAddress, - bufferLength, numOfSnsrs2Check, nvAlarm); - } - - return status; -} - -/*********************************************************************//** - * @brief * The didCommandTimeout function checks whether the command has timed * out. If a timeout occurs, it sets an alarm and returns TRUE. * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT if command timeout