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)
88static inline int z_impl_comparator_set_trigger(
const struct device *dev,
111 return DEVICE_API_GET(comparator, dev)->set_trigger_callback(dev, callback, user_data);
125static inline int z_impl_comparator_trigger_is_pending(
const struct device *dev)
136#include <zephyr/syscalls/comparator.h>
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1221
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:107
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:411