Renesas PTX1xxR IoT-Reader API Version 7.3.1
Renesas Software Stack for IoT-Reader Applications
ptxNvm.h
Go to the documentation of this file.
1
43#ifndef PTXNVM_H_
44#define PTXNVM_H_
45
52/*
53 * ####################################################################################################################
54 * INCLUDES
55 * ####################################################################################################################
56 */
57
58#include "ptx_Status.h"
59#include <stddef.h>
60
61#ifdef __cplusplus
62extern "C" {
63#endif
64
65/*
66 * ####################################################################################################################
67 * DEFINES / TYPES
68 * ####################################################################################################################
69 */
70
71#define PTX_NVM_MAX_PATH_LEN 256U
86
95
99typedef struct ptxNvmRecord
100{
101 void *F;
102 char *NvmName;
103 size_t Length;
105
109struct ptxNvm;
110
114typedef ptxStatus_t (*pptxNvm_Read_t) (struct ptxNvm *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord);
115
119typedef ptxStatus_t (*pptxNvm_Write_t) (struct ptxNvm *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord);
120
124typedef ptxStatus_t (*pptxNvm_CreateRecord_t) (struct ptxNvm *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord);
125
129typedef ptxStatus_t (*pptxNvm_IsRecordCreated_t)(struct ptxNvm *nvm, ptxNvmRecord_t *nvmRecord);
130
134 struct ptxOsal;
135
157
158
159/*
160 * ####################################################################################################################
161 * API FUNCTIONS
162 * ####################################################################################################################
163 */
164
174ptxStatus_t ptxNvm_Init (ptxNvm_t *nvm, uint32_t swId);
175
185ptxStatus_t ptxNvm_SetPath (ptxNvm_t *nvm, const char *nvmPath);
186
196
208ptxStatus_t ptxNvm_Read (ptxNvm_t *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord);
209
221ptxStatus_t ptxNvm_Write (ptxNvm_t *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord);
222
238ptxStatus_t ptxNvm_Write_And_Flush (ptxNvm_t *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord);
239
251ptxStatus_t ptxNvm_CreateRecord (ptxNvm_t *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord);
252
263
264
265/*
266 * ####################################################################################################################
267 * HELPER FUNCTIONS.
268 * ####################################################################################################################
269 */
270
283ptxStatus_t ptxNvm_FileOpen(ptxNvm_t *nvm, const char *fileNameID, ptxNvm_FileMode_t fileMode, uint8_t isBinary, ptxFileHandle_t *fileHandle);
284
299ptxStatus_t ptxNvm_FileRead(ptxNvm_t *nvm, ptxFileHandle_t *fileHandle, uint8_t *dataBlock, size_t *dataBlockSize);
300
312ptxStatus_t ptxNvm_FileWrite(ptxNvm_t *nvm, ptxFileHandle_t *fileHandle, uint8_t *dataBlock, size_t dataBlockSize);
313
324
325#ifdef __cplusplus
326}
327#endif
328
331#endif /* Guard */
332
uint16_t ptxStatus_t
Status Type.
Definition ptx_Status.h:82
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.
ptxStatus_t ptxNvm_SetPath(ptxNvm_t *nvm, const char *nvmPath)
Set the path for the NVM.
enum ptxNvm_FileMode ptxNvm_FileMode_t
File access mode values used for file handling functions.
struct ptxNvm ptxNvm_t
Main Nvm Component.
ptxStatus_t(* pptxNvm_IsRecordCreated_t)(struct ptxNvm *nvm, ptxNvmRecord_t *nvmRecord)
Function pointer as this module is going to be delegated.
Definition ptxNvm.h:129
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.
Definition ptxNvm.h:114
ptxStatus_t ptxNvm_Init(ptxNvm_t *nvm, uint32_t swId)
Initialize the NVM.
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_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.
ptxNvm_FileMode
File access mode values used for file handling functions.
Definition ptxNvm.h:77
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.
Definition ptxNvm.h:124
ptxStatus_t ptxNvm_IsRecordCreated(ptxNvm_t *nvm, ptxNvmRecord_t *nvmRecord)
It check if an nvm record already exists.
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_Read(ptxNvm_t *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord)
It loads from NVM record to the provided buffer.
struct ptxFileHandle ptxFileHandle_t
File Handle wrapper structure.
#define PTX_NVM_MAX_PATH_LEN
Definition ptxNvm.h:71
struct ptxNvmRecord ptxNvmRecord_t
Nvm Record instance. It will be platform dependent.
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.
Definition ptxNvm.h:119
ptxStatus_t ptxNvm_DeInit(ptxNvm_t *nvm)
De-Initialize the NVM.
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_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_Write(ptxNvm_t *nvm, uint8_t *buffer, size_t bufferLen, ptxNvmRecord_t *nvmRecord)
It writes to NVM record from the provided buffer.
@ ptxNvm_FileMode_ReadUpdate
Definition ptxNvm.h:82
@ ptxNvm_FileMode_Append
Definition ptxNvm.h:81
@ ptxNvm_FileMode_AppendUpdate
Definition ptxNvm.h:84
@ ptxNvm_FileMode_Write
Definition ptxNvm.h:80
@ ptxNvm_FileMode_WriteUpdate
Definition ptxNvm.h:83
@ ptxNvm_FileMode_Read
Definition ptxNvm.h:79
File Handle wrapper structure.
Definition ptxNvm.h:91
ptxNvm_FileMode_t Mode
Definition ptxNvm.h:93
void * F
Definition ptxNvm.h:92
Main Nvm Component.
Definition ptxNvm.h:140
pptxNvm_Read_t ReadFn
Definition ptxNvm.h:152
uint8_t IsPathProvided
Definition ptxNvm.h:147
char Path[PTX_NVM_MAX_PATH_LEN]
Definition ptxNvm.h:146
uint32_t SwId
Definition ptxNvm.h:145
pptxNvm_CreateRecord_t CreateRecordFn
Definition ptxNvm.h:154
pptxNvm_IsRecordCreated_t IsRecordCreatedFn
Definition ptxNvm.h:155
char * prefix
Definition ptxNvm.h:144
pptxNvm_Write_t WriteFn
Definition ptxNvm.h:153
Nvm Record instance. It will be platform dependent.
Definition ptxNvm.h:100
void * F
Definition ptxNvm.h:101
char * NvmName
Definition ptxNvm.h:102
size_t Length
Definition ptxNvm.h:103