eepreg.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Acutam Automation, LLC
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
57 #ifndef EEPREG_H
58 #define EEPREG_H
59 
60 #include <stdint.h>
61 
62 #include "periph_cpu.h"
63 #include "periph_conf.h"
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 #ifndef EEPROM_RESERV_CPU_LOW
70 
75 #define EEPROM_RESERV_CPU_LOW (0U)
76 #endif
77 
78 #ifndef EEPROM_RESERV_CPU_HI
79 
84 #define EEPROM_RESERV_CPU_HI (0U)
85 #endif
86 
87 #ifndef EEPROM_RESERV_BOARD_LOW
88 
93 #define EEPROM_RESERV_BOARD_LOW (0U)
94 #endif
95 
96 #ifndef EEPROM_RESERV_BOARD_HI
97 
102 #define EEPROM_RESERV_BOARD_HI (0U)
103 #endif
104 
108 #if (EEPROM_SIZE > 0x1000000)
109 #define EEPREG_PTR_LEN (4U)
110 #elif (EEPROM_SIZE > 0x10000)
111 #define EEPREG_PTR_LEN (3U)
112 #elif (EEPROM_SIZE > 0x100)
113 #define EEPREG_PTR_LEN (2U)
114 #else
115 #define EEPREG_PTR_LEN (1U)
116 #endif
117 
127 typedef int (*eepreg_iter_cb_t)(char *name, void *arg);
128 
147 int eepreg_add(uint32_t *pos, const char *name, uint32_t len);
148 
161 int eepreg_read(uint32_t *pos, const char *name);
162 
179 int eepreg_write(uint32_t *pos, const char *name, uint32_t len);
180 
196 int eepreg_rm(const char *name);
197 
217 int eepreg_iter(eepreg_iter_cb_t cb, void *arg);
218 
226 int eepreg_check(void);
227 
237 int eepreg_reset(void);
238 
252 int eepreg_len(uint32_t *len, const char *name);
253 
263 int eepreg_free(uint32_t *len);
264 
265 #ifdef __cplusplus
266 }
267 #endif
268 
271 #endif /* EEPREG_H */
int(* eepreg_iter_cb_t)(char *name, void *arg)
Signature of callback for iterating over entries in EEPROM registry.
Definition: eepreg.h:127
int eepreg_write(uint32_t *pos, const char *name, uint32_t len)
Write meta-data to EEPROM registry.
int eepreg_iter(eepreg_iter_cb_t cb, void *arg)
Iterate over meta-data entries in EEPROM registry.
int eepreg_read(uint32_t *pos, const char *name)
Read position meta-data from EEPROM registry.
int eepreg_check(void)
Check for the presence of meta-data registry.
int eepreg_add(uint32_t *pos, const char *name, uint32_t len)
Load or write meta-data in EEPROM registry.
int eepreg_len(uint32_t *len, const char *name)
Calculate data length from meta-data in EEPROM registry.
int eepreg_free(uint32_t *len)
Calculate length of remaining EEPROM free space.
int eepreg_reset(void)
Clear existing meta-data registry.
int eepreg_rm(const char *name)
Remove entry from EEPROM registry and free space.