6.3.4 Using PDS in the Application
The following are the sequence of steps to use PDS in the application:
- Include
pds_interface.h
in the application - Create an instance of the structure
PdsFileMarks_t
and update the fields. The maximum size combining all the elements inPdsFileMarks_t
is 256 bytes. - Each instance of
PdsFileMarks_t
represents the data to be stored in one NVM row, which is 256 bytes. So, additional instances of thePdsFileMarks_t
structure are created when the size of all the elements exceeds 256 bytes. - Create a File ID for each instance of
PdsFileMarks_t
and append it in the enum listPdsFileItemIdx_t
available in filepds_interface.h
.Figure 6-4. PDS File IDs - Create array instances of the
structure
ItemMap_t
, according the number of elements to be stored. Ensure the elements have File ID in the MSB byte of the 16-bit data as shown in Figure 6-6. MacroDECLARE_ITEM()
shown in Figure 6-5 assigns appropriate value to theItemMap_t
structure and it is declared in thepds_interface.h
. The third parameter to the macro function is the element value and it has the File ID in the MSB. The macro function masks the File ID and assigns the element value to the structure element.Figure 6-5. Array of ItemMap Elements Figure 6-6. File ID Appended to Element List - Register each instance of the
PdsFileMarks_t
with the File ID and the instance name.Figure 6-7. FileMarks Structure Registration - Once registered, the application can use the PDS APIs with File ID and instance name. For more information on the PDS APIs, refer to the API document.