Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Comparator Interface

Comparator Interface . More...

Typedefs

typedef void(* comparator_callback_t) (const struct device *dev, void *user_data)
 Comparator callback template.
 

Enumerations

enum  comparator_trigger { COMPARATOR_TRIGGER_NONE = 0 , COMPARATOR_TRIGGER_RISING_EDGE , COMPARATOR_TRIGGER_FALLING_EDGE , COMPARATOR_TRIGGER_BOTH_EDGES }
 Comparator trigger enumerations. More...
 

Functions

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.
 
static int comparator_set_trigger_callback (const struct device *dev, comparator_callback_t callback, void *user_data)
 Set comparator's trigger callback.
 
int comparator_trigger_is_pending (const struct device *dev)
 Check if comparator's trigger is pending and clear it.
 

Detailed Description

Comparator Interface .

Since
4.0
Version
0.1.0

Typedef Documentation

◆ comparator_callback_t

typedef void(* comparator_callback_t) (const struct device *dev, void *user_data)

#include <zephyr/drivers/comparator.h>

Comparator callback template.

Enumeration Type Documentation

◆ comparator_trigger

#include <zephyr/drivers/comparator.h>

Comparator trigger enumerations.

Enumerator
COMPARATOR_TRIGGER_NONE 

No trigger.

COMPARATOR_TRIGGER_RISING_EDGE 

Trigger on rising edge of comparator output.

COMPARATOR_TRIGGER_FALLING_EDGE 

Trigger on falling edge of comparator output.

COMPARATOR_TRIGGER_BOTH_EDGES 

Trigger on both edges of comparator output.

Function Documentation

◆ comparator_get_output()

int comparator_get_output ( const struct device * dev)

#include <zephyr/drivers/comparator.h>

Get comparator's output state.

Parameters
devComparator device
Return values
1Output state is high
0Output state is low
-errnocode Failure

◆ comparator_set_trigger()

int comparator_set_trigger ( const struct device * dev,
enum comparator_trigger trigger )

#include <zephyr/drivers/comparator.h>

Set comparator's trigger.

Parameters
devComparator device
triggerTrigger for signal and callback
Return values
0Successful
-errnocode Failure

◆ comparator_set_trigger_callback()

static int comparator_set_trigger_callback ( const struct device * dev,
comparator_callback_t callback,
void * user_data )
inlinestatic

#include <zephyr/drivers/comparator.h>

Set comparator's trigger callback.

Parameters
devComparator device
callbackTrigger callback
user_dataUser data passed to callback
Return values
0Successful
-errnocode Failure
Note
Set callback to NULL to disable callback
Callback is called immediately if trigger is pending

◆ comparator_trigger_is_pending()

int comparator_trigger_is_pending ( const struct device * dev)

#include <zephyr/drivers/comparator.h>

Check if comparator's trigger is pending and clear it.

Parameters
devComparator device
Return values
1Trigger was pending
0Trigger was cleared
-errnocode Failure