Renesas PTX1xxR IoT-Reader API Version 7.3.1
Renesas Software Stack for IoT-Reader Applications
Data Structures | Macros | Typedefs | Enumerations | Functions
Collaboration diagram for NVM:

Data Structures

struct  ptxFileHandle
 File Handle wrapper structure. More...
 
struct  ptxNvmRecord
 Nvm Record instance. It will be platform dependent. More...
 
struct  ptxNvm
 Main Nvm Component. More...
 

Macros

#define PTX_NVM_MAX_PATH_LEN   256U
 

Typedefs

typedef enum ptxNvm_FileMode ptxNvm_FileMode_t
 File access mode values used for file handling functions.
 
typedef struct ptxFileHandle ptxFileHandle_t
 File Handle wrapper structure.
 
typedef struct ptxNvmRecord ptxNvmRecord_t
 Nvm Record instance. It will be platform dependent.
 
typedef ptxStatus_t(* pptxNvm_Read_t) (struct ptxNvm *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord)
 Function pointer as this module is going to be delegated.
 
typedef ptxStatus_t(* pptxNvm_Write_t) (struct ptxNvm *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord)
 Function pointer as this module is going to be delegated.
 
typedef ptxStatus_t(* pptxNvm_CreateRecord_t) (struct ptxNvm *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord)
 Function pointer as this module is going to be delegated.
 
typedef ptxStatus_t(* pptxNvm_IsRecordCreated_t) (struct ptxNvm *nvm, ptxNvmRecord_t *nvmRecord)
 Function pointer as this module is going to be delegated.
 
typedef struct ptxNvm ptxNvm_t
 Main Nvm Component.
 

Enumerations

enum  ptxNvm_FileMode {
  ptxNvm_FileMode_None , ptxNvm_FileMode_Read , ptxNvm_FileMode_Write , ptxNvm_FileMode_Append ,
  ptxNvm_FileMode_ReadUpdate , ptxNvm_FileMode_WriteUpdate , ptxNvm_FileMode_AppendUpdate
}
 File access mode values used for file handling functions. More...
 

Functions

ptxStatus_t ptxNvm_Init (ptxNvm_t *nvm, uint32_t swId)
 Initialize the NVM.
 
ptxStatus_t ptxNvm_SetPath (ptxNvm_t *nvm, const char *nvmPath)
 Set the path for the NVM.
 
ptxStatus_t ptxNvm_DeInit (ptxNvm_t *nvm)
 De-Initialize the NVM.
 
ptxStatus_t ptxNvm_Read (ptxNvm_t *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord)
 It loads from NVM record to the provided buffer.
 
ptxStatus_t ptxNvm_Write (ptxNvm_t *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord)
 It writes to NVM record from the provided buffer.
 
ptxStatus_t ptxNvm_Write_And_Flush (ptxNvm_t *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord)
 Same as ptxNvm_Write but writes potentially OS-cached file content directly to the file.
 
ptxStatus_t ptxNvm_CreateRecord (ptxNvm_t *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord)
 It creates a record if it does not exist. It the Record already exists no action is performed.
 
ptxStatus_t ptxNvm_IsRecordCreated (ptxNvm_t *nvm, ptxNvmRecord_t *nvmRecord)
 It check if an nvm record already exists.
 
ptxStatus_t ptxNvm_FileOpen (ptxNvm_t *nvm, const char *fileNameID, ptxNvm_FileMode_t fileMode, uint8_t isBinary, ptxFileHandle_t *fileHandle)
 Wrapper for fopen operation. Opens the file with given parameters.
 
ptxStatus_t ptxNvm_FileRead (ptxNvm_t *nvm, ptxFileHandle_t *fileHandle, uint8_t *dataBlock, size_t *dataBlockSize)
 Wrapper for fread operation. Reads data from a file.
 
ptxStatus_t ptxNvm_FileWrite (ptxNvm_t *nvm, ptxFileHandle_t *fileHandle, uint8_t *dataBlock, size_t dataBlockSize)
 Wrapper for fwrite operation. Writes data to a file.
 
ptxStatus_t ptxNvm_FileClose (ptxNvm_t *nvm, ptxFileHandle_t *fileHandle)
 Wrapper for fclose operation. Closes the file stream and breaks all connections to a file.
 

Detailed Description

Macro Definition Documentation

◆ PTX_NVM_MAX_PATH_LEN

#define PTX_NVM_MAX_PATH_LEN   256U

Size of the buffer for the path of the file system.

Enumeration Type Documentation

◆ ptxNvm_FileMode

File access mode values used for file handling functions.

Enumerator
ptxNvm_FileMode_Read 

Open an existing file for input operations.

ptxNvm_FileMode_Write 

Create an empty file for output operations. Overwrite (discard) an existing file.

ptxNvm_FileMode_Append 

Open an existing file to append output to its end or create an empty file if no such file exists yet.

ptxNvm_FileMode_ReadUpdate 

Open an existing file for input and output operations.

ptxNvm_FileMode_WriteUpdate 

Like ptxNvm_FileMode_Write, but the file is open for output and input.

ptxNvm_FileMode_AppendUpdate 

Like ptxNvm_FileMode_AppendUpdate, but the file is open for output and input.

Function Documentation

◆ ptxNvm_CreateRecord()

ptxStatus_t ptxNvm_CreateRecord ( ptxNvm_t * nvm,
uint8_t * buffer,
size_t bufferLen,
ptxNvmRecord_t * nvmRecord )

It creates a record if it does not exist. It the Record already exists no action is performed.

Parameters
[in]nvmPointer to an initialized NVM component structure.
[in]bufferAllocated buffer as content of new record.
[in]bufferLenNumber of bytes to write.
[in]nvmRecordPointer to handle of the nvmRecord in that wants to be written.
Returns
Status. Operation successful means that either the record been successfully created

◆ ptxNvm_DeInit()

ptxStatus_t ptxNvm_DeInit ( ptxNvm_t * nvm)

De-Initialize the NVM.

Parameters
[in]nvmPointer to a initialized NVM component structure.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxNvm_FileClose()

ptxStatus_t ptxNvm_FileClose ( ptxNvm_t * nvm,
ptxFileHandle_t * fileHandle )

Wrapper for fclose operation. Closes the file stream and breaks all connections to a file.

Parameters
[in]nvmPointer to an initialized NVM component structure.
[in]fileHandlePointer to the opened file handle structure.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxNvm_FileOpen()

ptxStatus_t ptxNvm_FileOpen ( ptxNvm_t * nvm,
const char * fileNameID,
ptxNvm_FileMode_t fileMode,
uint8_t isBinary,
ptxFileHandle_t * fileHandle )

Wrapper for fopen operation. Opens the file with given parameters.

Parameters
[in]nvmPointer to an initialized NVM component structure.
[in]fileNameIDThe name of the file to open.
[in]fileModeFile access mode.
[in]isBinarySet to 1 if the file is in binary format. Otherwise 0.
[in]fileHandlePointer to the opened file handle structure.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxNvm_FileRead()

ptxStatus_t ptxNvm_FileRead ( ptxNvm_t * nvm,
ptxFileHandle_t * fileHandle,
uint8_t * dataBlock,
size_t * dataBlockSize )

Wrapper for fread operation. Reads data from a file.

Parameters
[in]nvmPointer to an initialized NVM component structure.
[in]fileHandlePointer to the opened file handle structure.
[out]dataBlockData buffer to receive data from file.
[in,out]dataBlockSizeThe number of data bytes to read. If the operation is successful, this parameter value does not change. If an error occurs, this parameter might be set to 0. If the end of a file is reached and not all data could be read out (as requested per this parameter value), the value of this parameter is set to the count of data that was actually read from a file stream.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxNvm_FileWrite()

ptxStatus_t ptxNvm_FileWrite ( ptxNvm_t * nvm,
ptxFileHandle_t * fileHandle,
uint8_t * dataBlock,
size_t dataBlockSize )

Wrapper for fwrite operation. Writes data to a file.

Parameters
[in]nvmPointer to an initialized NVM component structure.
[in]fileHandlePointer to the opened file handle structure.
[out]dataBlockData buffer holding the data to write.
[in]dataBlockSizeThe number of data bytes to write.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxNvm_Init()

ptxStatus_t ptxNvm_Init ( ptxNvm_t * nvm,
uint32_t swId )

Initialize the NVM.

Parameters
[in]nvmPointer to a non-initialized NVM component structure.
[in]swIdswId used for matching between sw version and NVM version.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxNvm_IsRecordCreated()

ptxStatus_t ptxNvm_IsRecordCreated ( ptxNvm_t * nvm,
ptxNvmRecord_t * nvmRecord )

It check if an nvm record already exists.

Parameters
[in]nvmPointer to an initialized NVM component structure.
[in]nvmRecordPointer to handle of the nvmRecord.
Returns
Status. Operation successful means that the record already exists

◆ ptxNvm_Read()

ptxStatus_t ptxNvm_Read ( ptxNvm_t * nvm,
uint8_t * buffer,
size_t bufferLen,
ptxNvmRecord_t * nvmRecord )

It loads from NVM record to the provided buffer.

Parameters
[in]nvmPointer to an initialized NVM component structure.
[in]bufferAllocated buffer where data is going to be filled in.
[in]bufferLenNumber of bytes to read.
[in]nvmRecordPointer to handle of the nvmRecord in that wants to be loaded.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxNvm_SetPath()

ptxStatus_t ptxNvm_SetPath ( ptxNvm_t * nvm,
const char * nvmPath )

Set the path for the NVM.

Parameters
[in]nvmPointer to an allocated NVM component structure.
[in]nvmPathPath where NVM is located (in case of File System).
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxNvm_Write()

ptxStatus_t ptxNvm_Write ( ptxNvm_t * nvm,
uint8_t * buffer,
size_t bufferLen,
ptxNvmRecord_t * nvmRecord )

It writes to NVM record from the provided buffer.

Parameters
[in]nvmPointer to an initialized NVM component structure.
[in]bufferAllocated buffer to write to NVM.
[in,out]bufferLenNumber of bytes to write.
[in]nvmRecordPointer to handle of the nvmRecord in that wants to be written.
Returns
Status. Operation successful means that all the bytes have been written to NVM

◆ ptxNvm_Write_And_Flush()

ptxStatus_t ptxNvm_Write_And_Flush ( ptxNvm_t * nvm,
uint8_t * buffer,
size_t bufferLen,
ptxNvmRecord_t * nvmRecord )

Same as ptxNvm_Write but writes potentially OS-cached file content directly to the file.

Attention: Due to the flush-operation, this function works slower than ptxNvm_Write, therefore it should only be used in environments where timing is not critical (e.g. Realtime-Logging during debugging.

Parameters
[in]nvmPointer to an initialized NVM component structure.
[in]bufferAllocated buffer to write to NVM.
[in,out]bufferLenNumber of bytes to write.
[in]nvmRecordPointer to handle of the nvmRecord in that wants to be written.
Returns
Status. Operation successful means that all the bytes have been written to NVM