|
Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
|
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. | |
Relay Interface.
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.
#include <zephyr/drivers/relay/relay.h>
Read back the on/off state of the relay.
#include <zephyr/drivers/relay/relay.h>
Set the on/off state of the relay.
#include <zephyr/drivers/relay/relay.h>
Read back the last requested on/off state of the relay.
| dev | Relay device instance. |
| on | Output: true if the coil is energized, false if released. |
| 0 | On success. |
| -ENOSYS | If the backend does not implement state read-back. |
| -errno | Other negative errno on failure. |
#include <zephyr/drivers/relay/relay.h>
Set the on/off state of the relay.
| dev | Relay device instance. |
| on | true to energize the coil, false to release it. |
| 0 | On success. |
| -errno | Negative errno from the backend. |