TI-OpenThread  1.08.06.06
CC1352P_4_LAUNCHXL/thread/cli_ftd/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: cc13xx_cc26xx
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 #define NVINTF_SYSID_SIDWK 10
105 #define NVINTF_SYSID_WISUN 11
106 
107 // NV driver status codes
108 #define NVINTF_SUCCESS 0
109 #define NVINTF_FAILURE 1
110 #define NVINTF_CORRUPT 2
111 #define NVINTF_NOTREADY 3
112 #define NVINTF_BADPARAM 4
113 #define NVINTF_BADLENGTH 5
114 #define NVINTF_BADOFFSET 6
115 #define NVINTF_BADITEMID 7
116 #define NVINTF_BADSUBID 8
117 #define NVINTF_BADSYSID 9
118 #define NVINTF_NOTFOUND 10
119 #define NVINTF_LOWPOWER 11
120 #define NVINTF_BADVERSION 12
121 #define NVINTF_EXIST 13
122 
123 // doNext flag options
124 #define NVINTF_DOSTART 0x1 // starts new search
125 #define NVINTF_DOSYSID 0x2 // filters by sysID
126 #define NVINTF_DOITMID 0x4 // filters by itemID and sysID
127 #define NVINTF_DOANYID 0x8 // filters by validity
128 #define NVINTF_DOFIND 0x10 // no additional op
129 #define NVINTF_DOREAD 0x20 // reads item contents into buffer
130 #define NVINTF_DODELETE 0x40 // deletes found items
131 
132 //*****************************************************************************
133 // Typedefs
134 //*****************************************************************************
135 
139 typedef struct nvintf_itemid_t
140 {
142  uint8_t systemID;
144  uint16_t itemID;
146  uint16_t subID;
148 
149 // Proxy NV item used by doNext()
150 typedef struct nvintf_nvproxy_t
151 {
152  uint8_t sysid; // User inputs searchable sysID, API returns item sysID
153  uint16_t itemid; // User inputs searchable itemID, API returns item itemID
154  uint16_t subid; // API returns item subID here
155  void * buffer; // Item contents written here if requested
156  uint16_t len; // User inputs size of buffer, API returns item size
157  uint8_t flag; // User specifies requested operation by settings flags
159 
161 typedef uint8_t (*NVINTF_initNV)(void *param);
162 
164 typedef uint8_t (*NVINTF_compactNV)(uint16_t minBytes);
165 
167 typedef uint8_t (*NVINTF_createItem)(NVINTF_itemID_t id,
168  uint32_t length,
169  void *buffer );
170 
172 typedef uint8_t (*NVINTF_updateItem)(NVINTF_itemID_t id,
173  uint32_t length,
174  void *buffer );
175 
177 typedef uint8_t (*NVINTF_deleteItem)(NVINTF_itemID_t id);
178 
180 typedef uint8_t (*NVINTF_readItem)(NVINTF_itemID_t id,
181  uint16_t offset,
182  uint16_t length,
183  void *buffer );
184 
186 typedef uint8_t (*NVINTF_readContItem)(NVINTF_itemID_t id,
187  uint16_t offset,
188  uint16_t rlength,
189  void *rbuffer,
190  uint16_t clength,
191  uint16_t coffset,
192  void *cbuffer,
193  uint16_t *pSubId);
194 
196 typedef uint8_t (*NVINTF_writeItem)(NVINTF_itemID_t id,
197  uint16_t length,
198  void *buffer );
199 
201 typedef uint32_t (*NVINTF_getItemLen)(NVINTF_itemID_t id);
202 
204 typedef int32_t (*NVINTF_lockNV)(void);
205 
207 typedef void (*NVINTF_unlockNV)(int32_t);
208 
210 typedef uint8_t (*NVINTF_doNext)(NVINTF_nvProxy_t *nvProxy);
211 
213 typedef bool (*NVINTF_expectComp)(uint16_t length);
214 
216 typedef uint8_t (*NVINTF_eraseNV)(void);
217 
219 typedef uint32_t (*NVINTF_getFreeNV)(void);
220 
222 typedef struct nvintf_nvfuncts_t
223 {
225  NVINTF_initNV initNV;
227  NVINTF_compactNV compactNV;
229  NVINTF_createItem createItem;
231  NVINTF_updateItem updateItem;
233  NVINTF_deleteItem deleteItem;
235  NVINTF_readItem readItem;
237  NVINTF_readContItem readContItem;
239  NVINTF_writeItem writeItem;
241  NVINTF_getItemLen getItemLen;
243  NVINTF_doNext doNext;
245  NVINTF_lockNV lockNV;
247  NVINTF_unlockNV unlockNV;
249  NVINTF_expectComp expectComp;
251  NVINTF_eraseNV eraseNV;
253  NVINTF_getFreeNV getFreeNV;
255 
256 //*****************************************************************************
257 //*****************************************************************************
258 
259 #ifdef __cplusplus
260 }
261 #endif
262 
263 #endif /* NVINTF_H */
264 
Structure of NV API function pointers.
Definition: CC1352P_2_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:222
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: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:186
uint8_t(* NVINTF_deleteItem)(NVINTF_itemID_t id)
Function pointer definition for the NVINTF_deleteItem() function.
Definition: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:177
struct nvintf_nvfuncts_t NVINTF_nvFuncts_t
Structure of NV API function pointers.
uint8_t(* NVINTF_initNV)(void *param)
Function pointer definition for the NVINTF_initNV() function.
Definition: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:161
int32_t(* NVINTF_lockNV)(void)
Function pointer definition for the NVINTF_lockItem() function.
Definition: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:204
uint8_t(* NVINTF_doNext)(NVINTF_nvProxy_t *nvProxy)
Function pointer definition for the NVINTF_doNext() function.
Definition: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:210
uint16_t itemID
NV Item ID.
Definition: CC1352P_2_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:144
uint8_t(* NVINTF_createItem)(NVINTF_itemID_t id, uint32_t length, void *buffer)
Function pointer definition for the NVINTF_createItem() function.
Definition: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:167
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: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:180
struct nvintf_nvproxy_t NVINTF_nvProxy_t
uint16_t subID
NV Item sub ID.
Definition: CC1352P_2_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:146
uint32_t(* NVINTF_getFreeNV)(void)
Function pointer definition for the NVINTF_getFreeNV() function.
Definition: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:219
uint32_t(* NVINTF_getItemLen)(NVINTF_itemID_t id)
Function pointer definition for the NVINTF_getItemLen() function.
Definition: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:201
uint8_t(* NVINTF_writeItem)(NVINTF_itemID_t id, uint16_t length, void *buffer)
Function pointer definition for the NVINTF_writeItem() function.
Definition: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:196
uint8_t(* NVINTF_compactNV)(uint16_t minBytes)
Function pointer definition for the NVINTF_compactNV() function.
Definition: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:164
struct nvintf_itemid_t NVINTF_itemID_t
Definition: CC1352P_2_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:150
uint8_t systemID
NV System ID - identifies system (ZStack, BLE, App, OAD...)
Definition: CC1352P_2_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:142
Definition: CC1352P_2_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:139
uint8_t(* NVINTF_updateItem)(NVINTF_itemID_t id, uint32_t length, void *buffer)
Function pointer definition for the NVINTF_updateItem() function.
Definition: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:172
uint8_t(* NVINTF_eraseNV)(void)
Function pointer definition for the NVINTF_eraseNV() function.
Definition: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:216
void(* NVINTF_unlockNV)(int32_t)
Function pointer definition for the NVINTF_unlockItem() function.
Definition: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:207
bool(* NVINTF_expectComp)(uint16_t length)
Function pointer definition for the NVINTF_expectComp() function.
Definition: CC1352P_4_LAUNCHXL/thread/cli_ftd/platform/nv/nvintf.h:213
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale