Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
emul_fuel_gauge.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Google LLC
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_DRIVERS_EMUL_FUEL_GAUGE_H_
14#define ZEPHYR_INCLUDE_DRIVERS_EMUL_FUEL_GAUGE_H_
15
16#include <stdint.h>
17#include <zephyr/drivers/emul.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
31
37__subsystem struct fuel_gauge_emul_driver_api {
38 int (*set_battery_charging)(const struct emul *emul, uint32_t uV, int uA);
39 int (*is_battery_cutoff)(const struct emul *emul, bool *cutoff);
40};
44
59__syscall int emul_fuel_gauge_set_battery_charging(const struct emul *target, uint32_t uV, int uA);
60static inline int z_impl_emul_fuel_gauge_set_battery_charging(const struct emul *target,
61 uint32_t uV, int uA)
62{
63 const struct fuel_gauge_emul_driver_api *backend_api =
64 (const struct fuel_gauge_emul_driver_api *)target->backend_api;
65
66 if (backend_api->set_battery_charging == 0) {
67 return -ENOTSUP;
68 }
69
70 return backend_api->set_battery_charging(target, uV, uA);
71}
72
82__syscall int emul_fuel_gauge_is_battery_cutoff(const struct emul *target, bool *cutoff);
83static inline int z_impl_emul_fuel_gauge_is_battery_cutoff(const struct emul *target, bool *cutoff)
84{
85 const struct fuel_gauge_emul_driver_api *backend_api =
86 (const struct fuel_gauge_emul_driver_api *)target->backend_api;
87
88 if (backend_api->is_battery_cutoff == 0) {
89 return -ENOTSUP;
90 }
91 return backend_api->is_battery_cutoff(target, cutoff);
92}
93
94#ifdef __cplusplus
95}
96#endif
97
98#include <zephyr/syscalls/emul_fuel_gauge.h>
99
103
104#endif /* ZEPHYR_INCLUDE_DRIVERS_EMUL_FUEL_GAUGE_H_*/
Public APIs for the device emulation framework.
Main header file for fuel gauge driver API.
int emul_fuel_gauge_set_battery_charging(const struct emul *target, uint32_t uV, int uA)
Set charging for fuel gauge associated battery.
int emul_fuel_gauge_is_battery_cutoff(const struct emul *target, bool *cutoff)
Check if the battery has been cut off.
#define ENOTSUP
Unsupported value.
Definition errno.h:115
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
An emulator instance - represents the target emulated device/peripheral that is interacted with throu...
Definition emul.h:88
const void * backend_api
Address of the API structure exposed by the emulator instance.
Definition emul.h:109