Zephyr Project API
3.7.0
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
#ifndef ZEPHYR_INCLUDE_DRIVERS_EEPROM_H_
17
#define ZEPHYR_INCLUDE_DRIVERS_EEPROM_H_
18
28
#include <
zephyr/types.h
>
29
#include <stddef.h>
30
#include <
sys/types.h
>
31
#include <
zephyr/device.h
>
32
33
#ifdef __cplusplus
34
extern
"C"
{
35
#endif
36
47
typedef
int (*eeprom_api_read)(
const
struct
device
*dev,
off_t
offset,
48
void
*
data
,
49
size_t
len);
50
55
typedef
int (*eeprom_api_write)(
const
struct
device
*dev,
off_t
offset,
56
const
void
*
data
,
size_t
len);
57
62
typedef
size_t
(*eeprom_api_size)(
const
struct
device
*dev);
63
64
__subsystem
struct
eeprom_driver_api {
65
eeprom_api_read read;
66
eeprom_api_write write;
67
eeprom_api_size size;
68
};
69
82
__syscall
int
eeprom_read
(
const
struct
device
*dev,
off_t
offset,
void
*
data
,
83
size_t
len);
84
85
static
inline
int
z_impl_eeprom_read(
const
struct
device
*dev,
off_t
offset,
86
void
*
data
,
size_t
len)
87
{
88
const
struct
eeprom_driver_api *api =
89
(
const
struct
eeprom_driver_api *)dev->
api
;
90
91
return
api->read(dev, offset,
data
, len);
92
}
93
104
__syscall
int
eeprom_write
(
const
struct
device
*dev,
off_t
offset,
105
const
void
*
data
,
106
size_t
len);
107
108
static
inline
int
z_impl_eeprom_write(
const
struct
device
*dev,
off_t
offset,
109
const
void
*
data
,
size_t
len)
110
{
111
const
struct
eeprom_driver_api *api =
112
(
const
struct
eeprom_driver_api *)dev->
api
;
113
114
return
api->write(dev, offset,
data
, len);
115
}
116
124
__syscall
size_t
eeprom_get_size
(
const
struct
device
*dev);
125
126
static
inline
size_t
z_impl_eeprom_get_size(
const
struct
device
*dev)
127
{
128
const
struct
eeprom_driver_api *api =
129
(
const
struct
eeprom_driver_api *)dev->
api
;
130
131
return
api->size(dev);
132
}
133
134
#ifdef __cplusplus
135
}
136
#endif
137
142
#include <zephyr/syscalls/eeprom.h>
143
144
#endif
/* ZEPHYR_INCLUDE_DRIVERS_EEPROM_H_ */
device.h
eeprom_write
int eeprom_write(const struct device *dev, off_t offset, const void *data, size_t len)
Write data to EEPROM.
eeprom_get_size
size_t eeprom_get_size(const struct device *dev)
Get the size of the EEPROM in bytes.
eeprom_read
int eeprom_read(const struct device *dev, off_t offset, void *data, size_t len)
Read data from EEPROM.
types.h
types.h
off_t
__INTPTR_TYPE__ off_t
Definition
types.h:36
size_t
Size of off_t must be equal or less than size of size_t
Definition
retained_mem.h:28
device
Runtime device structure (in ROM) per driver instance.
Definition
device.h:403
device::api
const void * api
Address of the API structure exposed by the device instance.
Definition
device.h:409
data
static fdata_t data[2]
Definition
test_fifo_contexts.c:15
include
zephyr
drivers
eeprom.h
Generated on Sun Sep 15 2024 17:01:29 for Zephyr Project API by
1.9.8