Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
eeprom.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Vestas Wind Systems A/S
3 *
4 * Heavily based on drivers/flash.h which is:
5 * Copyright (c) 2017 Nordic Semiconductor ASA
6 * Copyright (c) 2016 Intel Corporation
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10
16
17#ifndef ZEPHYR_INCLUDE_DRIVERS_EEPROM_H_
18#define ZEPHYR_INCLUDE_DRIVERS_EEPROM_H_
19
28
29#include <zephyr/types.h>
30#include <stddef.h>
31#include <sys/types.h>
32#include <zephyr/device.h>
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
43
48typedef int (*eeprom_api_read)(const struct device *dev, off_t offset,
49 void *data,
50 size_t len);
51
56typedef int (*eeprom_api_write)(const struct device *dev, off_t offset,
57 const void *data, size_t len);
58
63typedef size_t (*eeprom_api_size)(const struct device *dev);
64
76
78
89__syscall int eeprom_read(const struct device *dev, off_t offset, void *data,
90 size_t len);
91
92static inline int z_impl_eeprom_read(const struct device *dev, off_t offset,
93 void *data, size_t len)
94{
95 return DEVICE_API_GET(eeprom, dev)->read(dev, offset, data, len);
96}
97
108__syscall int eeprom_write(const struct device *dev, off_t offset,
109 const void *data,
110 size_t len);
111
112static inline int z_impl_eeprom_write(const struct device *dev, off_t offset,
113 const void *data, size_t len)
114{
115 return DEVICE_API_GET(eeprom, dev)->write(dev, offset, data, len);
116}
117
125__syscall size_t eeprom_get_size(const struct device *dev);
126
127static inline size_t z_impl_eeprom_get_size(const struct device *dev)
128{
129 return DEVICE_API_GET(eeprom, dev)->size(dev);
130}
131
132#ifdef __cplusplus
133}
134#endif
135
139
140#include <zephyr/syscalls/eeprom.h>
141
142#endif /* ZEPHYR_INCLUDE_DRIVERS_EEPROM_H_ */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1425
int(* eeprom_api_read)(const struct device *dev, off_t offset, void *data, size_t len)
Callback API upon reading from the EEPROM.
Definition eeprom.h:48
size_t(* eeprom_api_size)(const struct device *dev)
Callback API upon getting the EEPROM size.
Definition eeprom.h:63
int(* eeprom_api_write)(const struct device *dev, off_t offset, const void *data, size_t len)
Callback API upon writing to the EEPROM.
Definition eeprom.h:56
int eeprom_write(const struct device *dev, off_t offset, const void *data, size_t len)
Write data to EEPROM.
size_t eeprom_get_size(const struct device *dev)
Get the size of the EEPROM in bytes.
int eeprom_read(const struct device *dev, off_t offset, void *data, size_t len)
Read data from EEPROM.
__INTPTR_TYPE__ off_t
Definition types.h:36
Size of off_t must be equal or less than size of size_t
Definition retained_mem.h:29
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
void * data
Address of the device instance private data.
Definition device.h:523
<span class="mlabel">Driver Operations</span> EEPROM driver operations
Definition eeprom.h:68
eeprom_api_read read
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition eeprom.h:70
eeprom_api_size size
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition eeprom.h:74
eeprom_api_write write
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition eeprom.h:72