Loading...
Searching...
No Matches
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
9#pragma once
10
58
59#include <stdint.h>
60
61#include "periph_cpu.h"
62#include "periph_conf.h"
63
64#ifdef __cplusplus
65extern "C" {
66#endif
67
68#ifndef EEPROM_RESERV_CPU_LOW
74#define EEPROM_RESERV_CPU_LOW (0U)
75#endif
76
77#ifndef EEPROM_RESERV_CPU_HI
83#define EEPROM_RESERV_CPU_HI (0U)
84#endif
85
86#ifndef EEPROM_RESERV_BOARD_LOW
92#define EEPROM_RESERV_BOARD_LOW (0U)
93#endif
94
95#ifndef EEPROM_RESERV_BOARD_HI
101#define EEPROM_RESERV_BOARD_HI (0U)
102#endif
103
107#if (EEPROM_SIZE > 0x1000000)
108#define EEPREG_PTR_LEN (4U)
109#elif (EEPROM_SIZE > 0x10000)
110#define EEPREG_PTR_LEN (3U)
111#elif (EEPROM_SIZE > 0x100)
112#define EEPREG_PTR_LEN (2U)
113#else
114#define EEPREG_PTR_LEN (1U)
115#endif
116
126typedef int (*eepreg_iter_cb_t)(char *name, void *arg);
127
146int eepreg_add(uint32_t *pos, const char *name, uint32_t len);
147
160int eepreg_read(uint32_t *pos, const char *name);
161
178int eepreg_write(uint32_t *pos, const char *name, uint32_t len);
179
195int eepreg_rm(const char *name);
196
216int eepreg_iter(eepreg_iter_cb_t cb, void *arg);
217
225int eepreg_check(void);
226
236int eepreg_reset(void);
237
251int eepreg_len(uint32_t *len, const char *name);
252
262int eepreg_free(uint32_t *len);
263
264#ifdef __cplusplus
265}
266#endif
267
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:126
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.