-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathEEPROM.h
58 lines (45 loc) · 1.19 KB
/
EEPROM.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Copyright (c) 2025 Purva Yeshi <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <zephyr/kernel.h>
#include <zephyr/fs/nvs.h>
#include <zephyr/device.h>
#include <zephyr/drivers/flash.h>
#include <zephyr/storage/flash_map.h>
#include <string.h>
#include <stdio.h>
#include <zephyr/sys/reboot.h>
namespace arduino {
class ZephyrEEPROM {
public:
/* Constructor */
ZephyrEEPROM() = default;
/* Initialize the NVS storage (mounts the NVS file system) */
int nvs_init(void);
/*
* Write data to NVS
*
* Parameters:
* - id: Unique identifier for the data
* - data: Pointer to the data to write
* - data_len: Length of the data to write
*/
int write_data(uint16_t id, const void *data, size_t data_len);
/*
* Read data from NVS
*
* Parameters:
* - id: Unique identifier for the data
* - data: Pointer to buffer where the data will be read into
* - max_len: Maximum length of data to read
*/
int read_data(uint16_t id, void *data, size_t max_len);
private:
/* NVS file system structure used for managing flash memory */
struct nvs_fs fs;
};
}
extern arduino::ZephyrEEPROM EEPROM;