7#ifndef ZEPHYR_INCLUDE_DRIVERS_COMPARATOR_H_
8#define ZEPHYR_INCLUDE_DRIVERS_COMPARATOR_H_
43typedef int (*comparator_api_get_output)(
const struct device *dev);
44typedef int (*comparator_api_set_trigger)(
const struct device *dev,
46typedef int (*comparator_api_set_trigger_callback)(
const struct device *dev,
49typedef int (*comparator_api_trigger_is_pending)(
const struct device *dev);
51__subsystem
struct comparator_driver_api {
52 comparator_api_get_output get_output;
53 comparator_api_set_trigger set_trigger;
54 comparator_api_set_trigger_callback set_trigger_callback;
55 comparator_api_trigger_is_pending trigger_is_pending;
71static inline int z_impl_comparator_get_output(
const struct device *dev)
73 const struct comparator_driver_api *api =
74 (
const struct comparator_driver_api *)dev->
api;
76 return api->get_output(dev);
91static inline int z_impl_comparator_set_trigger(
const struct device *dev,
94 const struct comparator_driver_api *api =
95 (
const struct comparator_driver_api *)dev->
api;
97 return api->set_trigger(dev, trigger);
117 const struct comparator_driver_api *api =
118 (
const struct comparator_driver_api *)dev->
api;
120 return api->set_trigger_callback(dev, callback, user_data);
134static inline int z_impl_comparator_trigger_is_pending(
const struct device *dev)
136 const struct comparator_driver_api *api =
137 (
const struct comparator_driver_api *)dev->
api;
139 return api->trigger_is_pending(dev);
148#include <zephyr/syscalls/comparator.h>
static int comparator_set_trigger_callback(const struct device *dev, comparator_callback_t callback, void *user_data)
Set comparator's trigger callback.
Definition comparator.h:113
int comparator_trigger_is_pending(const struct device *dev)
Check if comparator's trigger is pending and clear it.
void(* comparator_callback_t)(const struct device *dev, void *user_data)
Comparator callback template.
Definition comparator.h:39
int comparator_get_output(const struct device *dev)
Get comparator's output state.
int comparator_set_trigger(const struct device *dev, enum comparator_trigger trigger)
Set comparator's trigger.
comparator_trigger
Comparator trigger enumerations.
Definition comparator.h:27
@ COMPARATOR_TRIGGER_RISING_EDGE
Trigger on rising edge of comparator output.
Definition comparator.h:31
@ COMPARATOR_TRIGGER_BOTH_EDGES
Trigger on both edges of comparator output.
Definition comparator.h:35
@ COMPARATOR_TRIGGER_FALLING_EDGE
Trigger on falling edge of comparator output.
Definition comparator.h:33
@ COMPARATOR_TRIGGER_NONE
No trigger.
Definition comparator.h:29
Runtime device structure (in ROM) per driver instance.
Definition device.h:403
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:409