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
65__subsystem struct eeprom_driver_api {
66 eeprom_api_read read;
67 eeprom_api_write write;
68 eeprom_api_size size;
69};
70
72
83__syscall int eeprom_read(const struct device *dev, off_t offset, void *data,
84 size_t len);
85
86static inline int z_impl_eeprom_read(const struct device *dev, off_t offset,
87 void *data, size_t len)
88{
89 return DEVICE_API_GET(eeprom, dev)->read(dev, offset, data, len);
90}
91
102__syscall int eeprom_write(const struct device *dev, off_t offset,
103 const void *data,
104 size_t len);
105
106static inline int z_impl_eeprom_write(const struct device *dev, off_t offset,
107 const void *data, size_t len)
108{
109 return DEVICE_API_GET(eeprom, dev)->write(dev, offset, data, len);
110}
111
119__syscall size_t eeprom_get_size(const struct device *dev);
120
121static inline size_t z_impl_eeprom_get_size(const struct device *dev)
122{
123 return DEVICE_API_GET(eeprom, dev)->size(dev);
124}
125
126#ifdef __cplusplus
127}
128#endif
129
133
134#include <zephyr/syscalls/eeprom.h>
135
136#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:1375
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