Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
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
26
#include <
zephyr/types.h
>
27
#include <stddef.h>
28
#include <
sys/types.h
>
29
#include <device.h>
30
31
#ifdef __cplusplus
32
extern
"C"
{
33
#endif
34
35
typedef
int (*
eeprom_api_read
)(
const
struct
device
*dev, off_t offset,
36
void
*
data
,
37
size_t
len);
38
typedef
int (*
eeprom_api_write
)(
const
struct
device
*dev, off_t offset,
39
const
void
*
data
,
size_t
len);
40
typedef
size_t (*
eeprom_api_size
)(
const
struct
device
*dev);
41
42
__subsystem
struct
eeprom_driver_api
{
43
eeprom_api_read
read
;
44
eeprom_api_write
write
;
45
eeprom_api_size
size
;
46
};
47
58
__syscall
int
eeprom_read
(
const
struct
device
*dev, off_t offset,
void
*
data
,
59
size_t
len);
60
61
static
inline
int
z_impl_eeprom_read(
const
struct
device
*dev, off_t offset,
62
void
*
data
,
size_t
len)
63
{
64
const
struct
eeprom_driver_api
*api =
65
(
const
struct
eeprom_driver_api
*)dev->
api
;
66
67
return
api->
read
(dev, offset,
data
, len);
68
}
69
80
__syscall
int
eeprom_write
(
const
struct
device
*dev, off_t offset,
81
const
void
*
data
,
82
size_t
len);
83
84
static
inline
int
z_impl_eeprom_write(
const
struct
device
*dev, off_t offset,
85
const
void
*
data
,
size_t
len)
86
{
87
const
struct
eeprom_driver_api
*api =
88
(
const
struct
eeprom_driver_api
*)dev->
api
;
89
90
return
api->
write
(dev, offset,
data
, len);
91
}
92
100
__syscall
size_t
eeprom_get_size
(
const
struct
device
*dev);
101
102
static
inline
size_t
z_impl_eeprom_get_size(
const
struct
device
*dev)
103
{
104
const
struct
eeprom_driver_api
*api =
105
(
const
struct
eeprom_driver_api
*)dev->
api
;
106
107
return
api->
size
(dev);
108
}
109
110
#ifdef __cplusplus
111
}
112
#endif
113
118
#include <syscalls/eeprom.h>
119
120
#endif
/* ZEPHYR_INCLUDE_DRIVERS_EEPROM_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.
eeprom_api_read
int(* eeprom_api_read)(const struct device *dev, off_t offset, void *data, size_t len)
Definition:
eeprom.h:35
eeprom_api_size
size_t(* eeprom_api_size)(const struct device *dev)
Definition:
eeprom.h:40
eeprom_api_write
int(* eeprom_api_write)(const struct device *dev, off_t offset, const void *data, size_t len)
Definition:
eeprom.h:38
types.h
types.h
device
Runtime device structure (in ROM) per driver instance.
Definition:
device.h:367
device::api
const void * api
Definition:
device.h:373
eeprom_driver_api
Definition:
eeprom.h:42
eeprom_driver_api::read
eeprom_api_read read
Definition:
eeprom.h:43
eeprom_driver_api::size
eeprom_api_size size
Definition:
eeprom.h:45
eeprom_driver_api::write
eeprom_api_write write
Definition:
eeprom.h:44
data
static fdata_t data[2]
Definition:
test_fifo_contexts.c:15
include
drivers
eeprom.h
Generated on Sun Oct 9 2022 09:21:56 for Zephyr API Documentation by
1.9.4