eepreg.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2018 Acutam Automation, LLC
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
56 #include <stdint.h>
57 
58 #include "periph_cpu.h"
59 #include "periph_conf.h"
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 #ifndef EEPROM_RESERV_CPU_LOW
71 #define EEPROM_RESERV_CPU_LOW (0U)
72 #endif
73 
74 #ifndef EEPROM_RESERV_CPU_HI
80 #define EEPROM_RESERV_CPU_HI (0U)
81 #endif
82 
83 #ifndef EEPROM_RESERV_BOARD_LOW
89 #define EEPROM_RESERV_BOARD_LOW (0U)
90 #endif
91 
92 #ifndef EEPROM_RESERV_BOARD_HI
98 #define EEPROM_RESERV_BOARD_HI (0U)
99 #endif
100 
104 #if (EEPROM_SIZE > 0x1000000)
105 #define EEPREG_PTR_LEN (4U)
106 #elif (EEPROM_SIZE > 0x10000)
107 #define EEPREG_PTR_LEN (3U)
108 #elif (EEPROM_SIZE > 0x100)
109 #define EEPREG_PTR_LEN (2U)
110 #else
111 #define EEPREG_PTR_LEN (1U)
112 #endif
113 
123 typedef int (*eepreg_iter_cb_t)(char *name, void *arg);
124 
143 int eepreg_add(uint32_t *pos, const char *name, uint32_t len);
144 
157 int eepreg_read(uint32_t *pos, const char *name);
158 
175 int eepreg_write(uint32_t *pos, const char *name, uint32_t len);
176 
192 int eepreg_rm(const char *name);
193 
213 int eepreg_iter(eepreg_iter_cb_t cb, void *arg);
214 
222 int eepreg_check(void);
223 
233 int eepreg_reset(void);
234 
248 int eepreg_len(uint32_t *len, const char *name);
249 
259 int eepreg_free(uint32_t *len);
260 
261 #ifdef __cplusplus
262 }
263 #endif
264 
int eepreg_rm(const char *name)
Remove entry from EEPROM registry and free space.
int eepreg_read(uint32_t *pos, const char *name)
Read position meta-data from EEPROM registry.
int eepreg_len(uint32_t *len, const char *name)
Calculate data length from meta-data in EEPROM registry.
int eepreg_reset(void)
Clear existing 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_iter_cb_t)(char *name, void *arg)
Signature of callback for iterating over entries in EEPROM registry.
Definition: eepreg.h:123
int eepreg_check(void)
Check for the presence of meta-data registry.
int eepreg_write(uint32_t *pos, const char *name, uint32_t len)
Write meta-data to EEPROM registry.
int eepreg_free(uint32_t *len)
Calculate length of remaining EEPROM free space.
int eepreg_iter(eepreg_iter_cb_t cb, void *arg)
Iterate over meta-data entries in EEPROM registry.