Zephyr Project API
3.2.0
A Scalable Open Source RTOS
nvs.h
Go to the documentation of this file.
1
/* NVS: non volatile storage in flash
2
*
3
* Copyright (c) 2018 Laczen
4
*
5
* SPDX-License-Identifier: Apache-2.0
6
*/
7
#ifndef ZEPHYR_INCLUDE_FS_NVS_H_
8
#define ZEPHYR_INCLUDE_FS_NVS_H_
9
10
#include <
sys/types.h
>
11
#include <
zephyr/kernel.h
>
12
#include <
zephyr/device.h
>
13
#include <
zephyr/toolchain.h
>
14
15
#ifdef __cplusplus
16
extern
"C"
{
17
#endif
18
48
struct
nvs_fs
{
49
off_t
offset
;
50
uint32_t
ate_wra
;
51
uint32_t
data_wra
;
52
uint16_t
sector_size
;
53
uint16_t
sector_count
;
54
bool
ready
;
55
struct
k_mutex
nvs_lock
;
56
const
struct
device
*
flash_device
;
57
const
struct
flash_parameters
*
flash_parameters
;
58
#if CONFIG_NVS_LOOKUP_CACHE
59
uint32_t
lookup_cache[CONFIG_NVS_LOOKUP_CACHE_SIZE];
60
#endif
61
};
62
83
int
nvs_mount
(
struct
nvs_fs
*fs);
84
93
int
nvs_clear
(
struct
nvs_fs
*fs);
94
109
ssize_t
nvs_write
(
struct
nvs_fs
*fs,
uint16_t
id
,
const
void
*
data
,
size_t
len);
110
121
int
nvs_delete
(
struct
nvs_fs
*fs,
uint16_t
id
);
122
138
ssize_t
nvs_read
(
struct
nvs_fs
*fs,
uint16_t
id
,
void
*
data
,
size_t
len);
139
156
ssize_t
nvs_read_hist
(
struct
nvs_fs
*fs,
uint16_t
id
,
void
*
data
,
size_t
len,
uint16_t
cnt);
157
169
ssize_t
nvs_calc_free_space
(
struct
nvs_fs
*fs);
170
183
__deprecated
static
inline
int
nvs_init
(
struct
nvs_fs
*fs,
const
char
*dev_name)
184
{
185
fs->
flash_device
=
device_get_binding
(dev_name);
186
if
(fs->
flash_device
== NULL) {
187
return
-
ENODEV
;
188
}
189
190
return
nvs_mount
(fs);
191
}
192
197
#ifdef __cplusplus
198
}
199
#endif
200
201
#endif
/* ZEPHYR_INCLUDE_FS_NVS_H_ */
device.h
device_get_binding
const struct device * device_get_binding(const char *name)
Get a const struct device* from its name field.
nvs_read
ssize_t nvs_read(struct nvs_fs *fs, uint16_t id, void *data, size_t len)
nvs_read
nvs_write
ssize_t nvs_write(struct nvs_fs *fs, uint16_t id, const void *data, size_t len)
nvs_write
nvs_calc_free_space
ssize_t nvs_calc_free_space(struct nvs_fs *fs)
nvs_calc_free_space
nvs_clear
int nvs_clear(struct nvs_fs *fs)
nvs_clear
nvs_delete
int nvs_delete(struct nvs_fs *fs, uint16_t id)
nvs_delete
nvs_init
static int nvs_init(struct nvs_fs *fs, const char *dev_name)
nvs_init
Definition:
nvs.h:183
nvs_read_hist
ssize_t nvs_read_hist(struct nvs_fs *fs, uint16_t id, void *data, size_t len, uint16_t cnt)
nvs_read_hist
nvs_mount
int nvs_mount(struct nvs_fs *fs)
nvs_mount
ENODEV
#define ENODEV
Definition:
errno.h:58
kernel.h
Public kernel APIs.
types.h
ssize_t
__SIZE_TYPE__ ssize_t
Definition:
types.h:28
off_t
__INTPTR_TYPE__ off_t
Definition:
types.h:36
uint32_t
__UINT32_TYPE__ uint32_t
Definition:
stdint.h:90
uint16_t
__UINT16_TYPE__ uint16_t
Definition:
stdint.h:89
device
Runtime device structure (in ROM) per driver instance.
Definition:
device.h:435
flash_parameters
Definition:
flash.h:55
k_mutex
Definition:
kernel.h:2721
nvs_fs
Non-volatile Storage File system structure.
Definition:
nvs.h:48
nvs_fs::flash_device
const struct device * flash_device
Definition:
nvs.h:56
nvs_fs::sector_size
uint16_t sector_size
Definition:
nvs.h:52
nvs_fs::ready
bool ready
Definition:
nvs.h:54
nvs_fs::flash_parameters
const struct flash_parameters * flash_parameters
Definition:
nvs.h:57
nvs_fs::nvs_lock
struct k_mutex nvs_lock
Definition:
nvs.h:55
nvs_fs::offset
off_t offset
Definition:
nvs.h:49
nvs_fs::ate_wra
uint32_t ate_wra
Definition:
nvs.h:50
nvs_fs::sector_count
uint16_t sector_count
Definition:
nvs.h:53
nvs_fs::data_wra
uint32_t data_wra
Definition:
nvs.h:51
data
static fdata_t data[2]
Definition:
test_fifo_contexts.c:15
toolchain.h
Macros to abstract toolchain specific capabilities.
include
zephyr
fs
nvs.h
Generated on Tue Feb 28 2023 15:43:19 for Zephyr Project API by
1.9.2