Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
charger.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Cirrus Logic, Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DRIVERS_CHARGER_H_
8#define ZEPHYR_INCLUDE_DRIVERS_CHARGER_H_
9
17#include <stdbool.h>
18#include <stddef.h>
19#include <stdint.h>
20
21#include <zephyr/device.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif /* __cplusplus */
26
49};
50
58
69};
70
85};
86
92 /* Fields have the format: */
93 /* CHARGER_PROPERTY_FIELD */
94 /* type property_field; */
95
99 bool present;
102};
103
110typedef int (*charger_get_property_t)(const struct device *dev, const charger_prop_t prop,
111 union charger_propval *val);
112
119typedef int (*charger_set_property_t)(const struct device *dev, const charger_prop_t prop,
120 const union charger_propval *val);
121
127__subsystem struct charger_driver_api {
130};
131
142__syscall int charger_get_prop(const struct device *dev, const charger_prop_t prop,
143 union charger_propval *val);
144
145static inline int z_impl_charger_get_prop(const struct device *dev, const charger_prop_t prop,
146 union charger_propval *val)
147{
148 const struct charger_driver_api *api = (const struct charger_driver_api *)dev->api;
149
150 return api->get_property(dev, prop, val);
151}
152
163__syscall int charger_set_prop(const struct device *dev, const charger_prop_t prop,
164 const union charger_propval *val);
165
166static inline int z_impl_charger_set_prop(const struct device *dev, const charger_prop_t prop,
167 const union charger_propval *val)
168{
169 const struct charger_driver_api *api = (const struct charger_driver_api *)dev->api;
170
171 return api->set_property(dev, prop, val);
172}
173
178#ifdef __cplusplus
179}
180#endif /* __cplusplus */
181
182#include <syscalls/charger.h>
183
184#endif /* ZEPHYR_INCLUDE_DRIVERS_CHARGER_H_ */
int charger_set_prop(const struct device *dev, const charger_prop_t prop, const union charger_propval *val)
Set a battery charger property.
int charger_get_prop(const struct device *dev, const charger_prop_t prop, union charger_propval *val)
Fetch a battery charger property.
int(* charger_get_property_t)(const struct device *dev, const charger_prop_t prop, union charger_propval *val)
Callback API for getting a charger property.
Definition: charger.h:110
int(* charger_set_property_t)(const struct device *dev, const charger_prop_t prop, const union charger_propval *val)
Callback API for setting a charger property.
Definition: charger.h:119
charger_status
Charging states.
Definition: charger.h:74
charger_property
Runtime Dynamic Battery Parameters.
Definition: charger.h:30
uint16_t charger_prop_t
A charger property's identifier.
Definition: charger.h:57
charger_online
External supply states.
Definition: charger.h:62
@ CHARGER_STATUS_FULL
The battery is full and the charging device will not attempt charging.
Definition: charger.h:84
@ CHARGER_STATUS_NOT_CHARGING
Charging device is not charging a battery.
Definition: charger.h:82
@ CHARGER_STATUS_DISCHARGING
Charging device is not able to charge a battery.
Definition: charger.h:80
@ CHARGER_STATUS_UNKNOWN
Charging device state is unknown.
Definition: charger.h:76
@ CHARGER_STATUS_CHARGING
Charging device is charging a battery.
Definition: charger.h:78
@ CHARGER_PROP_PRESENT
Reports whether or not a battery is present.
Definition: charger.h:36
@ CHARGER_PROP_ONLINE
Indicates if external supply is present for the charger.
Definition: charger.h:33
@ CHARGER_PROP_CUSTOM_BEGIN
Reserved to demark downstream custom properties - use this value as the actual value may change over ...
Definition: charger.h:46
@ CHARGER_PROP_COMMON_COUNT
Reserved to demark end of common charger properties.
Definition: charger.h:41
@ CHARGER_PROP_STATUS
Represents the charging status of the charger.
Definition: charger.h:39
@ CHARGER_PROP_MAX
Reserved to demark end of valid enum properties.
Definition: charger.h:48
@ CHARGER_ONLINE_FIXED
External supply is present and of fixed output.
Definition: charger.h:66
@ CHARGER_ONLINE_PROGRAMMABLE
External supply is present and of programmable output.
Definition: charger.h:68
@ CHARGER_ONLINE_OFFLINE
External supply not present.
Definition: charger.h:64
#define UINT16_MAX
Definition: stdint.h:28
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Charging device API.
Definition: charger.h:127
charger_set_property_t set_property
Definition: charger.h:129
charger_get_property_t get_property
Definition: charger.h:128
Runtime device structure (in ROM) per driver instance.
Definition: device.h:381
const void * api
Address of the API structure exposed by the device instance.
Definition: device.h:387
container for a charger_property value
Definition: charger.h:91
enum charger_status status
CHARGER_PROP_STATUS.
Definition: charger.h:101
enum charger_online online
CHARGER_PROP_ONLINE.
Definition: charger.h:97
bool present
CHARGER_PROP_PRESENT.
Definition: charger.h:99