Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Relay Interface. More...

Data Structures

struct  relay_driver_api
 Relay driver class API. More...

Typedefs

typedef int(* relay_set_state_t) (const struct device *dev, bool on)
 Set the on/off state of the relay.
typedef int(* relay_get_state_t) (const struct device *dev, bool *on)
 Read back the on/off state of the relay.

Functions

int relay_set_state (const struct device *dev, bool on)
 Set the on/off state of the relay.
int relay_get_state (const struct device *dev, bool *on)
 Read back the last requested on/off state of the relay.

Detailed Description

Relay Interface.

Since
4.6
Version
0.1.0

The relay API exposes a hardware-agnostic on/off view of a single relay. A backend driver (for example the PWM or GPIO relay) implements relay_driver_api and hides all coil-drive details behind it.

Typedef Documentation

◆ relay_get_state_t

typedef int(* relay_get_state_t) (const struct device *dev, bool *on)

#include <zephyr/drivers/relay/relay.h>

Read back the on/off state of the relay.

◆ relay_set_state_t

typedef int(* relay_set_state_t) (const struct device *dev, bool on)

#include <zephyr/drivers/relay/relay.h>

Set the on/off state of the relay.

Function Documentation

◆ relay_get_state()

int relay_get_state ( const struct device * dev,
bool * on )

#include <zephyr/drivers/relay/relay.h>

Read back the last requested on/off state of the relay.

Parameters
devRelay device instance.
onOutput: true if the coil is energized, false if released.
Return values
0On success.
-ENOSYSIf the backend does not implement state read-back.
-errnoOther negative errno on failure.

◆ relay_set_state()

int relay_set_state ( const struct device * dev,
bool on )

#include <zephyr/drivers/relay/relay.h>

Set the on/off state of the relay.

Parameters
devRelay device instance.
ontrue to energize the coil, false to release it.
Return values
0On success.
-errnoNegative errno from the backend.