Zephyr API Documentation 4.0.0-rc3
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
7#ifndef ZEPHYR_INCLUDE_DRIVERS_BBRAM_H
8#define ZEPHYR_INCLUDE_DRIVERS_BBRAM_H
9
10#include <errno.h>
11
12#include <zephyr/device.h>
13
21#ifdef __cplusplus
22extern "C" {
23#endif
24
31typedef int (*bbram_api_check_invalid_t)(const struct device *dev);
32
39typedef int (*bbram_api_check_standby_power_t)(const struct device *dev);
40
47typedef int (*bbram_api_check_power_t)(const struct device *dev);
48
55typedef int (*bbram_api_get_size_t)(const struct device *dev, size_t *size);
56
63typedef int (*bbram_api_read_t)(const struct device *dev, size_t offset, size_t size,
64 uint8_t *data);
65
72typedef int (*bbram_api_write_t)(const struct device *dev, size_t offset, size_t size,
73 const uint8_t *data);
74
83
93__syscall int bbram_check_invalid(const struct device *dev);
94
95static inline int z_impl_bbram_check_invalid(const struct device *dev)
96{
97 const struct bbram_driver_api *api =
98 (const struct bbram_driver_api *)dev->api;
99
100 if (!api->check_invalid) {
101 return -ENOTSUP;
102 }
103
104 return api->check_invalid(dev);
105}
106
115__syscall int bbram_check_standby_power(const struct device *dev);
116
117static inline int z_impl_bbram_check_standby_power(const struct device *dev)
118{
119 const struct bbram_driver_api *api =
120 (const struct bbram_driver_api *)dev->api;
121
122 if (!api->check_standby_power) {
123 return -ENOTSUP;
124 }
125
126 return api->check_standby_power(dev);
127}
128
138__syscall int bbram_check_power(const struct device *dev);
139
140static inline int z_impl_bbram_check_power(const struct device *dev)
141{
142 const struct bbram_driver_api *api =
143 (const struct bbram_driver_api *)dev->api;
144
145 if (!api->check_power) {
146 return -ENOTSUP;
147 }
148
149 return api->check_power(dev);
150}
151
159__syscall int bbram_get_size(const struct device *dev, size_t *size);
160
161static inline int z_impl_bbram_get_size(const struct device *dev, size_t *size)
162{
163 const struct bbram_driver_api *api =
164 (const struct bbram_driver_api *)dev->api;
165
166 if (!api->get_size) {
167 return -ENOTSUP;
168 }
169
170 return api->get_size(dev, size);
171}
172
182__syscall int bbram_read(const struct device *dev, size_t offset, size_t size,
183 uint8_t *data);
184
185static inline int z_impl_bbram_read(const struct device *dev, size_t offset,
186 size_t size, uint8_t *data)
187{
188 const struct bbram_driver_api *api =
189 (const struct bbram_driver_api *)dev->api;
190
191 if (!api->read) {
192 return -ENOTSUP;
193 }
194
195 return api->read(dev, offset, size, data);
196}
197
207__syscall int bbram_write(const struct device *dev, size_t offset, size_t size,
208 const uint8_t *data);
209
210static inline int z_impl_bbram_write(const struct device *dev, size_t offset,
211 size_t size, const uint8_t *data)
212{
213 const struct bbram_driver_api *api =
214 (const struct bbram_driver_api *)dev->api;
215
216 if (!api->write) {
217 return -ENOTSUP;
218 }
219
220 return api->write(dev, offset, size, data);
221}
222
232int bbram_emul_set_invalid(const struct device *dev, bool is_invalid);
233
243int bbram_emul_set_standby_power_state(const struct device *dev, bool failure);
244
254int bbram_emul_set_power_state(const struct device *dev, bool failure);
255
256#ifdef __cplusplus
257}
258#endif
259
264#include <zephyr/syscalls/bbram.h>
265
266#endif /* ZEPHYR_INCLUDE_DRIVERS_BBRAM_H */
System error numbers.
int bbram_emul_set_standby_power_state(const struct device *dev, bool failure)
Set the emulated BBRAM driver's standby power state.
int(* bbram_api_write_t)(const struct device *dev, size_t offset, size_t size, const uint8_t *data)
API template to write to BBRAM.
Definition bbram.h:72
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_api_read_t)(const struct device *dev, size_t offset, size_t size, uint8_t *data)
API template to read from BBRAM.
Definition bbram.h:63
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_api_check_standby_power_t)(const struct device *dev)
API template to check for standby power failure.
Definition bbram.h:39
int bbram_read(const struct device *dev, size_t offset, size_t size, uint8_t *data)
Read bytes from BBRAM.
int(* bbram_api_check_power_t)(const struct device *dev)
API template to check for V CC1 power failure.
Definition bbram.h:47
int bbram_get_size(const struct device *dev, size_t *size)
Get the size of the BBRAM (in bytes).
int(* bbram_api_check_invalid_t)(const struct device *dev)
API template to check if the BBRAM is invalid.
Definition bbram.h:31
int(* bbram_api_get_size_t)(const struct device *dev, size_t *size)
API template to check the size of the BBRAM.
Definition bbram.h:55
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
Definition bbram.h:75
bbram_api_check_invalid_t check_invalid
Definition bbram.h:76
bbram_api_get_size_t get_size
Definition bbram.h:79
bbram_api_check_standby_power_t check_standby_power
Definition bbram.h:77
bbram_api_read_t read
Definition bbram.h:80
bbram_api_check_power_t check_power
Definition bbram.h:78
bbram_api_write_t write
Definition bbram.h:81
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
void * data
Address of the device instance private data.
Definition device.h:422
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:418