45 lines
931 B
C
45 lines
931 B
C
|
|
#ifndef BLINKY_DRIVERS_PMIC_IP5306_H_
|
||
|
|
#define BLINKY_DRIVERS_PMIC_IP5306_H_
|
||
|
|
|
||
|
|
#include <errno.h>
|
||
|
|
#include <stdbool.h>
|
||
|
|
|
||
|
|
#include <zephyr/device.h>
|
||
|
|
|
||
|
|
struct ip5306_status {
|
||
|
|
bool charging;
|
||
|
|
bool full;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct ip5306_driver_api {
|
||
|
|
int (*init)(const struct device *dev);
|
||
|
|
int (*get_status)(const struct device *dev, struct ip5306_status *status);
|
||
|
|
};
|
||
|
|
|
||
|
|
static inline int ip5306_init(const struct device *dev)
|
||
|
|
{
|
||
|
|
const struct ip5306_driver_api *api =
|
||
|
|
(const struct ip5306_driver_api *)dev->api;
|
||
|
|
|
||
|
|
if ((api == NULL) || (api->init == NULL)) {
|
||
|
|
return -ENOSYS;
|
||
|
|
}
|
||
|
|
|
||
|
|
return api->init(dev);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline int ip5306_get_status(const struct device *dev,
|
||
|
|
struct ip5306_status *status)
|
||
|
|
{
|
||
|
|
const struct ip5306_driver_api *api =
|
||
|
|
(const struct ip5306_driver_api *)dev->api;
|
||
|
|
|
||
|
|
if ((api == NULL) || (api->get_status == NULL)) {
|
||
|
|
return -ENOSYS;
|
||
|
|
}
|
||
|
|
|
||
|
|
return api->get_status(dev, status);
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif /* BLINKY_DRIVERS_PMIC_IP5306_H_ */
|