Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
bbram.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Google Inc
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_DRIVERS_BBRAM_H
14#define ZEPHYR_INCLUDE_DRIVERS_BBRAM_H
15
16#include <errno.h>
17
18#include <zephyr/device.h>
19
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
35
40typedef int (*bbram_api_check_invalid_t)(const struct device *dev);
41
46typedef int (*bbram_api_check_standby_power_t)(const struct device *dev);
47
52typedef int (*bbram_api_check_power_t)(const struct device *dev);
53
58typedef int (*bbram_api_get_size_t)(const struct device *dev, size_t *size);
59
64typedef int (*bbram_api_read_t)(const struct device *dev, size_t offset, size_t size,
65 uint8_t *data);
66
71typedef int (*bbram_api_write_t)(const struct device *dev, size_t offset, size_t size,
72 const uint8_t *data);
73
103
106
116__syscall int bbram_check_invalid(const struct device *dev);
117
118static inline int z_impl_bbram_check_invalid(const struct device *dev)
119{
120 const struct bbram_driver_api *api = DEVICE_API_GET(bbram, dev);
121
122 if (!api->check_invalid) {
123 return -ENOTSUP;
124 }
125
126 return api->check_invalid(dev);
127}
128
137__syscall int bbram_check_standby_power(const struct device *dev);
138
139static inline int z_impl_bbram_check_standby_power(const struct device *dev)
140{
141 const struct bbram_driver_api *api = DEVICE_API_GET(bbram, dev);
142
143 if (!api->check_standby_power) {
144 return -ENOTSUP;
145 }
146
147 return api->check_standby_power(dev);
148}
149
159__syscall int bbram_check_power(const struct device *dev);
160
161static inline int z_impl_bbram_check_power(const struct device *dev)
162{
163 const struct bbram_driver_api *api = DEVICE_API_GET(bbram, dev);
164
165 if (!api->check_power) {
166 return -ENOTSUP;
167 }
168
169 return api->check_power(dev);
170}
171
179__syscall int bbram_get_size(const struct device *dev, size_t *size);
180
181static inline int z_impl_bbram_get_size(const struct device *dev, size_t *size)
182{
183 const struct bbram_driver_api *api = DEVICE_API_GET(bbram, dev);
184
185 if (!api->get_size) {
186 return -ENOTSUP;
187 }
188
189 return api->get_size(dev, size);
190}
191
201__syscall int bbram_read(const struct device *dev, size_t offset, size_t size,
202 uint8_t *data);
203
204static inline int z_impl_bbram_read(const struct device *dev, size_t offset,
205 size_t size, uint8_t *data)
206{
207 const struct bbram_driver_api *api = DEVICE_API_GET(bbram, dev);
208
209 if (!api->read) {
210 return -ENOTSUP;
211 }
212
213 return api->read(dev, offset, size, data);
214}
215
225__syscall int bbram_write(const struct device *dev, size_t offset, size_t size,
226 const uint8_t *data);
227
228static inline int z_impl_bbram_write(const struct device *dev, size_t offset,
229 size_t size, const uint8_t *data)
230{
231 const struct bbram_driver_api *api = DEVICE_API_GET(bbram, dev);
232
233 if (!api->write) {
234 return -ENOTSUP;
235 }
236
237 return api->write(dev, offset, size, data);
238}
239
249int bbram_emul_set_invalid(const struct device *dev, bool is_invalid);
250
260int bbram_emul_set_standby_power_state(const struct device *dev, bool failure);
261
271int bbram_emul_set_power_state(const struct device *dev, bool failure);
272
273#ifdef __cplusplus
274}
275#endif
276
280
281#include <zephyr/syscalls/bbram.h>
282
283#endif /* ZEPHYR_INCLUDE_DRIVERS_BBRAM_H */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1375
System error numbers.
int(* bbram_api_write_t)(const struct device *dev, size_t offset, size_t size, const uint8_t *data)
Callback API to write to BBRAM.
Definition bbram.h:71
int(* bbram_api_read_t)(const struct device *dev, size_t offset, size_t size, uint8_t *data)
Callback API to read from BBRAM See bbram_read() for argument description.
Definition bbram.h:64
int(* bbram_api_check_standby_power_t)(const struct device *dev)
Callback API to check for standby power failure See bbram_check_standby_power() for argument descript...
Definition bbram.h:46
int(* bbram_api_check_power_t)(const struct device *dev)
Callback API to check for V CC1 power failure See bbram_check_power() for argument description.
Definition bbram.h:52
int(* bbram_api_check_invalid_t)(const struct device *dev)
Callback API to check if the BBRAM is invalid See bbram_check_invalid() for argument description.
Definition bbram.h:40
int(* bbram_api_get_size_t)(const struct device *dev, size_t *size)
Callback API to get the size of the BBRAM See bbram_get_size() for argument description.
Definition bbram.h:58
int bbram_emul_set_standby_power_state(const struct device *dev, bool failure)
Set the emulated BBRAM driver's standby power state.
int bbram_write(const struct device *dev, size_t offset, size_t size, const uint8_t *data)
Write bytes to BBRAM.
int bbram_check_invalid(const struct device *dev)
Check if BBRAM is invalid.
int bbram_check_power(const struct device *dev)
Check for V CC1 power failure.
int bbram_check_standby_power(const struct device *dev)
Check for standby (Volt SBY) power failure.
int bbram_read(const struct device *dev, size_t offset, size_t size, uint8_t *data)
Read bytes from BBRAM.
int bbram_get_size(const struct device *dev, size_t *size)
Get the size of the BBRAM (in bytes).
int bbram_emul_set_power_state(const struct device *dev, bool failure)
Set the emulated BBRAM driver's power state.
int bbram_emul_set_invalid(const struct device *dev, bool is_invalid)
Set the emulated BBRAM driver's invalid state.
#define ENOTSUP
Unsupported value.
Definition errno.h:114
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
<span class="mlabel">Driver Operations</span> BBRAM driver operations
Definition bbram.h:77
bbram_api_check_invalid_t check_invalid
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition bbram.h:81
bbram_api_get_size_t get_size
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition bbram.h:93
bbram_api_check_standby_power_t check_standby_power
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition bbram.h:85
bbram_api_read_t read
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition bbram.h:97
bbram_api_check_power_t check_power
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition bbram.h:89
bbram_api_write_t write
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition bbram.h:101
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