Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
emul_bbram.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 Google LLC
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6#ifndef INCLUDE_ZEPHYR_DRIVERS_EMUL_BBRAM_H_
7#define INCLUDE_ZEPHYR_DRIVERS_EMUL_BBRAM_H_
8
10
11#include <stdint.h>
12
26__subsystem struct emul_bbram_driver_api {
28 int (*set_data)(const struct emul *target, size_t offset, size_t count,
29 const uint8_t *data);
31 int (*get_data)(const struct emul *target, size_t offset, size_t count, uint8_t *data);
32};
33
49static inline int emul_bbram_backend_set_data(const struct emul *target, size_t offset,
50 size_t count, const uint8_t *data)
51{
52 if (target == NULL || target->backend_api == NULL) {
53 return -ENOTSUP;
54 }
55
56 struct emul_bbram_driver_api *api = (struct emul_bbram_driver_api *)target->backend_api;
57
58 if (api->set_data == NULL) {
59 return -ENOTSUP;
60 }
61
62 return api->set_data(target, offset, count, data);
63}
64
76static inline int emul_bbram_backend_get_data(const struct emul *target, size_t offset,
77 size_t count, uint8_t *data)
78{
79 if (target == NULL || target->backend_api == NULL) {
80 return -ENOTSUP;
81 }
82
83 struct emul_bbram_driver_api *api = (struct emul_bbram_driver_api *)target->backend_api;
84
85 if (api->get_data == NULL) {
86 return -ENOTSUP;
87 }
88
89 return api->get_data(target, offset, count, data);
90}
91
96#endif /* INCLUDE_ZEPHYR_DRIVERS_EMUL_BBRAM_H_ */
ZTEST_BMEM int count
Definition main.c:33
static int emul_bbram_backend_get_data(const struct emul *target, size_t offset, size_t count, uint8_t *data)
Get the expected data in the bbram region.
Definition emul_bbram.h:76
static int emul_bbram_backend_set_data(const struct emul *target, size_t offset, size_t count, const uint8_t *data)
Set the expected data in the bbram region.
Definition emul_bbram.h:49
#define ENOTSUP
Unsupported value.
Definition errno.h:114
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
An emulator instance - represents the target emulated device/peripheral that is interacted with throu...
Definition emul.h:80
const void * backend_api
Address of the API structure exposed by the emulator instance.
Definition emul.h:100
static fdata_t data[2]
Definition test_fifo_contexts.c:15