Index: NVJobQ.c =================================================================== diff -u -r760b430c92a9f4667ac8328b47ba80b4f0e71d31 -rebf3ea1b1f09cb5a21abde6f6106c9213df5afff --- NVJobQ.c (.../NVJobQ.c) (revision 760b430c92a9f4667ac8328b47ba80b4f0e71d31) +++ NVJobQ.c (.../NVJobQ.c) (revision ebf3ea1b1f09cb5a21abde6f6106c9213df5afff) @@ -24,11 +24,8 @@ // ********** private definitions ********** -// Once a new calibration data is available the driver, sets a signal for the defined time. Once the time is out, it turns the signal off. - #define QUEUE_MAX_SIZE 20U ///< Max queue size. #define QUEUE_START_INDEX 0U ///< Queue start index. -#define MAX_JOB_DATA_SIZE_BYTES 32U ///< Max bytes per job (32 bytes). /// DD institutional values structure. typedef struct @@ -50,7 +47,7 @@ /*********************************************************************//** * @brief - * The initNVJobQ function initializes the NV message queue and related + * The initNVJobQ function initializes the NV job queue and related * state variables. * @details \b Inputs: none * @details \b Outputs: recordQueueRearIndex, @@ -307,7 +304,7 @@ * @details \b Outputs: none * @return recordCurrentJob *************************************************************************/ -PROCESS_RECORD_JOB_T getCurrentProcessRecordJob ( void ) +PROCESS_RECORD_JOB_T getCurrentProcessRecordJob( void ) { return recordCurrentJob; } Index: NVJobQ.h =================================================================== diff -u -r9884f14392bb6ef52d10d09acb8c359684b522bb -rebf3ea1b1f09cb5a21abde6f6106c9213df5afff --- NVJobQ.h (.../NVJobQ.h) (revision 9884f14392bb6ef52d10d09acb8c359684b522bb) +++ NVJobQ.h (.../NVJobQ.h) (revision ebf3ea1b1f09cb5a21abde6f6106c9213df5afff) @@ -60,7 +60,7 @@ BOOL enqueuewriteAllRecords( void ); BOOL enqueueReadAllRecords( void ); void updateRecordReadStatus( NVM_RECORDS_READ_STATUS_T status ); -PROCESS_RECORD_JOB_T getCurrentProcessRecordJob ( void ); +PROCESS_RECORD_JOB_T getCurrentProcessRecordJob( void ); /**@}*/ Index: NVMsgQ.c =================================================================== diff -u --- NVMsgQ.c (revision 0) +++ NVMsgQ.c (revision ebf3ea1b1f09cb5a21abde6f6106c9213df5afff) @@ -0,0 +1,170 @@ +/************************************************************************** +* +* Copyright (c) 2026-2027 Diality Inc. - All Rights Reserved. +* +* THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +* WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +* +* @file NVMsgQ.c +* +* @author (original) Arpita Srivastava +* @date (original) 6-Aug-2026 +* +***************************************************************************/ + +#include "Common.h" +#include "NVMsgQ.h" + +/** + * @addtogroup NVMsgQ + * @{ + */ + +// ********** private definitions ********** + +#define QUEUE_MAX_SIZE 20U ///< Max queue size. +#define QUEUE_START_INDEX 0U ///< Queue start index. + +static NVM_MSG_REQUEST_Q_T requestQueue[ QUEUE_MAX_SIZE ]; ///< Request queue jobs. +static U08 requestQueueRearIndex; ///< Request queue rear index. +static U08 requestQueueFrontIndex; ///< Request queue front index. +static U08 requestQueueCount; ///< Request queue count. +static NVM_MSG_REQUEST_Q_T currentNVMsgRequest; ///< Request queue current job. + +// ********** private data ********** + +/*********************************************************************//** + * @brief + * The initNVMsgQ function initializes the NV message queue and related + * state variables. + * @details \b Inputs: none + * @details \b Outputs: requestQueueRearIndex, requestQueueFrontIndex, + * requestQueueCount, + * @return none + *************************************************************************/ +void initNVMsgQ ( void ) +{ + requestQueueRearIndex = QUEUE_START_INDEX; + requestQueueFrontIndex = QUEUE_START_INDEX; + requestQueueCount = 0; +} + +/*********************************************************************//** + * @brief + * The enqueueNVMsgRequest function enqueues an NV message request + * into the request queue and updates the queue indices and count. + * @details \b Inputs: requestQueueRearIndex, + * requestQueueCount + * @details \b Outputs: requestQueue, + * requestQueueRearIndex, requestQueueCount + * @param request NV message request to be queued + * @return none + *************************************************************************/ +void enqueueNVMsgRequest( NVM_MSG_REQUEST_Q_T request ) +{ + requestQueue[ requestQueueRearIndex ] = request; + + requestQueueCount++; + requestQueueRearIndex = INC_WRAP( requestQueueRearIndex, 0, QUEUE_MAX_SIZE - 1 ); +} + +/*********************************************************************//** + * @brief + * The dequeueNVMsgRequest function removes a record job from the queue. + * It updates the front index, retrieves the job, and updates the + * queue count. + * @details \b Inputs: requestQueueFrontIndex, requestQueueCount, + * requestQueue + * @details \b Outputs: requestQueueFrontIndex, requestQueueCount, + * currentNVMsgRequest + * @return none + *************************************************************************/ +void dequeueNVMsgRequest( void ) +{ + U32 tempIndex; + + _disable_IRQ(); + tempIndex = requestQueueFrontIndex; + + if ( FALSE == isNVMsgRequestQueueEmpty() ) + { + requestQueueFrontIndex = INC_WRAP( requestQueueFrontIndex, 0, QUEUE_MAX_SIZE - 1 ); + currentNVMsgRequest = requestQueue[ tempIndex ]; + } + if ( requestQueueCount > 0 ) + { + requestQueueCount--; + } + _enable_IRQ(); +} + +/*********************************************************************//** + * @brief + * The isNVMsgRequestQueueEmpty function checks whether the record queue is + * empty. It returns the status based on the queue count. + * @details \b Inputs: requestQueueCount + * @details \b Outputs: none + * @return TRUE if queue is empty otherwise FALSE + *************************************************************************/ +BOOL isNVMsgRequestQueueEmpty( void ) +{ + BOOL isEmpty = TRUE; + + if ( requestQueueCount > 0 ) + { + isEmpty = FALSE; + } + + return isEmpty; +} + +/*********************************************************************//** + * @brief + * The isNVMsgRequestQueueFull function checks whether the record queue is + * full based on the maximum queue size. + * @details \b Inputs: requestQueueCount + * @details \b Outputs: none + * @return TRUE if queue is full otherwise FALSE + *************************************************************************/ +BOOL isNVMsgRequestQueueFull( void ) +{ + BOOL isFull = FALSE; + + if ( requestQueueCount >= ( QUEUE_MAX_SIZE - 1 ) ) + { + isFull = TRUE; + } + + return isFull; +} + +/*********************************************************************//** + * @brief + * The getAvailableNVMsgRequestQueueCount function returns the number of + * available record queue slots based on the current queue count. + * @details \b Inputs: requestQueueCount + * @details \b Outputs: none + * @return available record queues + *************************************************************************/ + +U32 getAvailableNVMsgRequestQueueCount( void ) +{ + return QUEUE_MAX_SIZE - requestQueueCount; +} + +/*********************************************************************//** + * @brief + * The getCurrentNVMsgRequest function gets the current message request + * from the processing queue. + * @details \b Inputs: currentNVMsgRequest + * @details \b Outputs: none + * @return currentNVMsgRequest + *************************************************************************/ +NVM_MSG_REQUEST_Q_T getCurrentNVMsgRequest( void ) +{ + return currentNVMsgRequest; +} + +// ********** private function prototypes ********** + +/**@}*/ Index: NVMsgQ.h =================================================================== diff -u --- NVMsgQ.h (revision 0) +++ NVMsgQ.h (revision ebf3ea1b1f09cb5a21abde6f6106c9213df5afff) @@ -0,0 +1,62 @@ +/************************************************************************** +* +* Copyright (c) 2026-2027 Diality Inc. - All Rights Reserved. +* +* THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +* WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +* +* @file NVMsgQ.h +* +* @author (original) Arpita Srivastava +* @date (original) 6-Aug-2026 +* +***************************************************************************/ + +#ifndef _NV_MSG_Q_H_ +#define _NV_MSG_Q_H_ + +#ifdef _DD_ +#include "NVRecordsDD.h" +#endif + +/** + * @defgroup NVMsgQ NVMsgQ + * @brief This module manages the NV record message queue. It provides interfaces + * to enqueue, dequeue, and monitor UI requests to get or set records. + * + * @addtogroup NVMsgQ + * @{ + */ + +// ********** public definitions ********** + +/// NVM Message Request Type +typedef enum +{ + NVM_MSG_GET_RECORD_REQUEST = 0, ///< Request to Get the NVM Record + NVM_MSG_SET_RECORD_REQUEST, ///< Request to Set the NVM Record + NUM_OF_NVM_MSG_REQUEST +} NVM_MSG_REQUEST_TYPE_T; + +/// NVM Message Queue Structure +typedef struct +{ + NVM_MSG_REQUEST_TYPE_T requestType; ///< Type of Request Received from UI + NV_DATA_T recordType; ///< Type of Record for which Request was received + BOOL isIndexed; ///< TRUE if this record is indexed + U32 idx; ///< Index value received with the request +} NVM_MSG_REQUEST_Q_T; + +// ********** public function prototypes ********** + +void initNVMsgQ( void ); +void enqueueNVMsgRequest( NVM_MSG_REQUEST_Q_T request ); +void dequeueNVMsgRequest( void ); +BOOL isNVMsgRequestQueueEmpty( void ); +BOOL isNVMsgRequestQueueFull( void ); +U32 getAvailableNVMsgRequestQueueCount( void ); +NVM_MSG_REQUEST_Q_T getCurrentNVMsgRequest( void ); + +/**@}*/ + +#endif /* _NV_MSG_Q_H_ */