TI-OpenThread  1.08.03.09
LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  @file nvintf.h
4 
5  @brief Function pointer interface to the NV API
6 
7  Group: CMCU, LPC
8  Target Device: cc13x2_26x2
9 
10  ******************************************************************************
11 
12  Copyright (c) 2018-2021, Texas Instruments Incorporated
13  All rights reserved.
14 
15  Redistribution and use in source and binary forms, with or without
16  modification, are permitted provided that the following conditions
17  are met:
18 
19  * Redistributions of source code must retain the above copyright
20  notice, this list of conditions and the following disclaimer.
21 
22  * Redistributions in binary form must reproduce the above copyright
23  notice, this list of conditions and the following disclaimer in the
24  documentation and/or other materials provided with the distribution.
25 
26  * Neither the name of Texas Instruments Incorporated nor the names of
27  its contributors may be used to endorse or promote products derived
28  from this software without specific prior written permission.
29 
30  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
32  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
40  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 
42  ******************************************************************************
43 
44 
45  *****************************************************************************/
46 #ifndef NVINTF_H
47 #define NVINTF_H
48 
49 #include <stdbool.h>
50 #include <stdint.h>
51 #ifdef NV_LINUX
52 #include <stddef.h>
53 #endif
54 
55 #ifdef __cplusplus
56 extern "C"
57 {
58 #endif
59 
60 //*****************************************************************************
61 // Usage Overview
62 //*****************************************************************************
63 /*
64 This file implements a general NV API which can be used with NV drivers
65 designed to conform to this API. The API requires NV items to be described by
66 a three number ID contained in the NVINTF_itemID_t struct. System IDs are also
67 predefined but the user may use their own so long as they do not conflict.
68 Drivers using this interface are also required to return the defined status
69 codes.
70 
71 The particular driver is selected by loading a NVINTF_itemID_t struct with the
72 drivers function ptrs using the drivers public load function. Note that not all
73 of the function pointers are required to be populated so it is important to
74 check for null pointers before making a call. From this point on, NV calls are
75 made through the struct. The first call must be the .initNv() call.
76 If this call is successful, more NV calls can be made. A sample code block is
77 shown below:
78 
79 NVINTF_nvFuncts_t nvFps;
80 NVDRIVER_loadApiPtrs(&nvFps);
81 
82 nvFps.initNV(NULL);
83 // Do some Nv operations
84 nvFps.compactNv(NULL);
85 status = nvFps.readItem(id, 0, len, buf);
86 
87 */
88 
89 //*****************************************************************************
90 // Constants and definitions
91 //*****************************************************************************
92 
93 // NV system ID codes
94 #define NVINTF_SYSID_NVDRVR 0 // Refrain from use
95 #define NVINTF_SYSID_ZSTACK 1
96 #define NVINTF_SYSID_TIMAC 2
97 #define NVINTF_SYSID_REMOTI 3
98 #define NVINTF_SYSID_BLE 4
99 #define NVINTF_SYSID_6MESH 5
100 #define NVINTF_SYSID_TIOP 6
101 #define NVINTF_SYSID_APP 7
102 #define NVINTF_SYSID_WBMS 8
103 #define NVINTF_SYSID_BMESH 9
104 
105 // NV driver status codes
106 #define NVINTF_SUCCESS 0
107 #define NVINTF_FAILURE 1
108 #define NVINTF_CORRUPT 2
109 #define NVINTF_NOTREADY 3
110 #define NVINTF_BADPARAM 4
111 #define NVINTF_BADLENGTH 5
112 #define NVINTF_BADOFFSET 6
113 #define NVINTF_BADITEMID 7
114 #define NVINTF_BADSUBID 8
115 #define NVINTF_BADSYSID 9
116 #define NVINTF_NOTFOUND 10
117 #define NVINTF_LOWPOWER 11
118 #define NVINTF_BADVERSION 12
119 #define NVINTF_EXIST 13
120 
121 // doNext flag options
122 #define NVINTF_DOSTART 0x1 // starts new search
123 #define NVINTF_DOSYSID 0x2 // filters by sysID
124 #define NVINTF_DOITMID 0x4 // filters by itemID and sysID
125 #define NVINTF_DOANYID 0x8 // filters by validity
126 #define NVINTF_DOFIND 0x10 // no additional op
127 #define NVINTF_DOREAD 0x20 // reads item contents into buffer
128 #define NVINTF_DODELETE 0x40 // deletes found items
129 
130 //*****************************************************************************
131 // Typedefs
132 //*****************************************************************************
133 
137 typedef struct nvintf_itemid_t
138 {
140  uint8_t systemID;
142  uint16_t itemID;
144  uint16_t subID;
146 
147 // Proxy NV item used by doNext()
148 typedef struct nvintf_nvproxy_t
149 {
150  uint8_t sysid; // User inputs searchable sysID, API returns item sysID
151  uint16_t itemid; // User inputs searchable itemID, API returns item itemID
152  uint16_t subid; // API returns item subID here
153  void * buffer; // Item contents written here if requested
154  uint16_t len; // User inputs size of buffer, API returns item size
155  uint8_t flag; // User specifies requested operation by settings flags
157 
159 typedef uint8_t (*NVINTF_initNV)(void *param);
160 
162 typedef uint8_t (*NVINTF_compactNV)(uint16_t minBytes);
163 
165 typedef uint8_t (*NVINTF_createItem)(NVINTF_itemID_t id,
166  uint32_t length,
167  void *buffer );
168 
170 typedef uint8_t (*NVINTF_updateItem)(NVINTF_itemID_t id,
171  uint32_t length,
172  void *buffer );
173 
175 typedef uint8_t (*NVINTF_deleteItem)(NVINTF_itemID_t id);
176 
178 typedef uint8_t (*NVINTF_readItem)(NVINTF_itemID_t id,
179  uint16_t offset,
180  uint16_t length,
181  void *buffer );
182 
184 typedef uint8_t (*NVINTF_readContItem)(NVINTF_itemID_t id,
185  uint16_t offset,
186  uint16_t rlength,
187  void *rbuffer,
188  uint16_t clength,
189  uint16_t coffset,
190  void *cbuffer,
191  uint16_t *pSubId);
192 
194 typedef uint8_t (*NVINTF_writeItem)(NVINTF_itemID_t id,
195  uint16_t length,
196  void *buffer );
197 
199 typedef uint32_t (*NVINTF_getItemLen)(NVINTF_itemID_t id);
200 
202 typedef int32_t (*NVINTF_lockNV)(void);
203 
205 typedef void (*NVINTF_unlockNV)(int32_t);
206 
208 typedef uint8_t (*NVINTF_doNext)(NVINTF_nvProxy_t *nvProxy);
209 
211 typedef bool (*NVINTF_expectComp)(uint16_t length);
212 
214 typedef uint8_t (*NVINTF_eraseNV)(void);
215 
217 typedef uint32_t (*NVINTF_getFreeNV)(void);
218 
220 typedef struct nvintf_nvfuncts_t
221 {
223  NVINTF_initNV initNV;
225  NVINTF_compactNV compactNV;
227  NVINTF_createItem createItem;
229  NVINTF_updateItem updateItem;
231  NVINTF_deleteItem deleteItem;
233  NVINTF_readItem readItem;
235  NVINTF_readContItem readContItem;
237  NVINTF_writeItem writeItem;
239  NVINTF_getItemLen getItemLen;
241  NVINTF_doNext doNext;
243  NVINTF_lockNV lockNV;
245  NVINTF_unlockNV unlockNV;
247  NVINTF_expectComp expectComp;
249  NVINTF_eraseNV eraseNV;
251  NVINTF_getFreeNV getFreeNV;
253 
254 //*****************************************************************************
255 //*****************************************************************************
256 
257 #ifdef __cplusplus
258 }
259 #endif
260 
261 #endif /* NVINTF_H */
262 
uint8_t(* NVINTF_createItem)(NVINTF_itemID_t id, uint32_t length, void *buffer)
Function pointer definition for the NVINTF_createItem() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:165
Structure of NV API function pointers.
Definition: CC1352P_2_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:220
bool(* NVINTF_expectComp)(uint16_t length)
Function pointer definition for the NVINTF_expectComp() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:211
struct nvintf_nvproxy_t NVINTF_nvProxy_t
uint8_t(* NVINTF_eraseNV)(void)
Function pointer definition for the NVINTF_eraseNV() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:214
uint8_t(* NVINTF_deleteItem)(NVINTF_itemID_t id)
Function pointer definition for the NVINTF_deleteItem() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:175
uint8_t(* NVINTF_initNV)(void *param)
Function pointer definition for the NVINTF_initNV() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:159
uint8_t(* NVINTF_writeItem)(NVINTF_itemID_t id, uint16_t length, void *buffer)
Function pointer definition for the NVINTF_writeItem() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:194
uint32_t(* NVINTF_getItemLen)(NVINTF_itemID_t id)
Function pointer definition for the NVINTF_getItemLen() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:199
uint8_t(* NVINTF_readContItem)(NVINTF_itemID_t id, uint16_t offset, uint16_t rlength, void *rbuffer, uint16_t clength, uint16_t coffset, void *cbuffer, uint16_t *pSubId)
Function pointer definition for the NVINTF_readContItem() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:184
struct nvintf_nvfuncts_t NVINTF_nvFuncts_t
Structure of NV API function pointers.
uint16_t itemID
NV Item ID.
Definition: CC1352P_2_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:142
uint8_t(* NVINTF_updateItem)(NVINTF_itemID_t id, uint32_t length, void *buffer)
Function pointer definition for the NVINTF_updateItem() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:170
uint16_t subID
NV Item sub ID.
Definition: CC1352P_2_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:144
void(* NVINTF_unlockNV)(int32_t)
Function pointer definition for the NVINTF_unlockItem() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:205
Definition: CC1352P_2_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:148
uint8_t systemID
NV System ID - identifies system (ZStack, BLE, App, OAD...)
Definition: CC1352P_2_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:140
struct nvintf_itemid_t NVINTF_itemID_t
Definition: CC1352P_2_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:137
uint8_t(* NVINTF_compactNV)(uint16_t minBytes)
Function pointer definition for the NVINTF_compactNV() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:162
uint32_t(* NVINTF_getFreeNV)(void)
Function pointer definition for the NVINTF_getFreeNV() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:217
int32_t(* NVINTF_lockNV)(void)
Function pointer definition for the NVINTF_lockItem() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:202
uint8_t(* NVINTF_doNext)(NVINTF_nvProxy_t *nvProxy)
Function pointer definition for the NVINTF_doNext() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:208
uint8_t(* NVINTF_readItem)(NVINTF_itemID_t id, uint16_t offset, uint16_t length, void *buffer)
Function pointer definition for the NVINTF_readItem() function.
Definition: LP_CC1352P7_4/thread/doorlock_oad_secure/platform/nv/nvintf.h:178
© Copyright 1995-2021, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale