Zephyr API Documentation
2.7.0-rc2
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 <kernel.h>
12
#include <device.h>
13
14
#ifdef __cplusplus
15
extern
"C"
{
16
#endif
17
47
struct
nvs_fs
{
48
off_t
offset
;
/* filesystem offset in flash */
49
uint32_t
ate_wra
;
/* next alloc table entry write address */
50
uint32_t
data_wra
;
/* next data write address */
51
uint16_t
sector_size
;
/* filesystem is divided into sectors,
52
* sector size should be multiple of pagesize
53
*/
54
uint16_t
sector_count
;
/* amount of sectors in the filesystem */
55
bool
ready
;
/* is the filesystem initialized ? */
56
57
struct
k_mutex
nvs_lock
;
58
const
struct
device
*
flash_device
;
59
const
struct
flash_parameters
*
flash_parameters
;
60
};
61
83
int
nvs_init
(
struct
nvs_fs
*fs,
const
char
*dev_name);
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,
157
uint16_t
cnt);
158
171
ssize_t
nvs_calc_free_space
(
struct
nvs_fs
*fs);
172
177
#ifdef __cplusplus
178
}
179
#endif
180
181
#endif
/* ZEPHYR_INCLUDE_FS_NVS_H_ */
nvs_init
int nvs_init(struct nvs_fs *fs, const char *dev_name)
nvs_init
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_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
types.h
ssize_t
__SIZE_TYPE__ ssize_t
Definition:
types.h:28
uint32_t
__UINT32_TYPE__ uint32_t
Definition:
stdint.h:60
uint16_t
__UINT16_TYPE__ uint16_t
Definition:
stdint.h:59
device
Runtime device structure (in ROM) per driver instance.
Definition:
device.h:367
flash_parameters
Definition:
flash.h:55
k_mutex
Definition:
kernel.h:2680
nvs_fs
Non-volatile Storage File system structure.
Definition:
nvs.h:47
nvs_fs::flash_device
const struct device * flash_device
Definition:
nvs.h:58
nvs_fs::sector_size
uint16_t sector_size
Definition:
nvs.h:51
nvs_fs::ready
bool ready
Definition:
nvs.h:55
nvs_fs::flash_parameters
const struct flash_parameters * flash_parameters
Definition:
nvs.h:59
nvs_fs::nvs_lock
struct k_mutex nvs_lock
Definition:
nvs.h:57
nvs_fs::offset
off_t offset
Definition:
nvs.h:48
nvs_fs::ate_wra
uint32_t ate_wra
Definition:
nvs.h:49
nvs_fs::sector_count
uint16_t sector_count
Definition:
nvs.h:54
nvs_fs::data_wra
uint32_t data_wra
Definition:
nvs.h:50
data
static fdata_t data[2]
Definition:
test_fifo_contexts.c:15
include
fs
nvs.h
Generated on Sun Oct 9 2022 09:21:56 for Zephyr API Documentation by
1.9.4