Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
|
LED Interface . More...
Data Structures | |
struct | led_info |
LED information structure. More... | |
struct | led_driver_api |
LED driver API. More... | |
struct | led_dt_spec |
Container for an LED information specified in devicetree. More... | |
Macros | |
#define | LED_DT_SPEC_GET(node_id) |
Static initializer for a struct led_dt_spec. | |
#define | LED_DT_SPEC_GET_OR(node_id, default_value) |
Like LED_DT_SPEC_GET(), with a fallback value if the node does not exist. | |
Typedefs | |
typedef int(* | led_api_blink) (const struct device *dev, uint32_t led, uint32_t delay_on, uint32_t delay_off) |
Callback API for blinking an LED. | |
typedef int(* | led_api_get_info) (const struct device *dev, uint32_t led, const struct led_info **info) |
Optional API callback to get LED information. | |
typedef int(* | led_api_set_brightness) (const struct device *dev, uint32_t led, uint8_t value) |
Callback API for setting brightness of an LED. | |
typedef int(* | led_api_set_color) (const struct device *dev, uint32_t led, uint8_t num_colors, const uint8_t *color) |
Optional API callback to set the colors of a LED. | |
typedef int(* | led_api_on) (const struct device *dev, uint32_t led) |
Callback API for turning on an LED. | |
typedef int(* | led_api_off) (const struct device *dev, uint32_t led) |
Callback API for turning off an LED. | |
typedef int(* | led_api_write_channels) (const struct device *dev, uint32_t start_channel, uint32_t num_channels, const uint8_t *buf) |
Callback API for writing a strip of LED channels. | |
Functions | |
int | led_blink (const struct device *dev, uint32_t led, uint32_t delay_on, uint32_t delay_off) |
Blink an LED. | |
int | led_get_info (const struct device *dev, uint32_t led, const struct led_info **info) |
Get LED information. | |
int | led_set_brightness (const struct device *dev, uint32_t led, uint8_t value) |
Set LED brightness. | |
int | led_write_channels (const struct device *dev, uint32_t start_channel, uint32_t num_channels, const uint8_t *buf) |
Write/update a strip of LED channels. | |
int | led_set_channel (const struct device *dev, uint32_t channel, uint8_t value) |
Set a single LED channel. | |
int | led_set_color (const struct device *dev, uint32_t led, uint8_t num_colors, const uint8_t *color) |
Set LED color. | |
int | led_on (const struct device *dev, uint32_t led) |
Turn on an LED. | |
int | led_off (const struct device *dev, uint32_t led) |
Turn off an LED. | |
static int | led_set_brightness_dt (const struct led_dt_spec *spec, uint8_t value) |
Set LED brightness from a led_dt_spec. | |
static int | led_on_dt (const struct led_dt_spec *spec) |
Turn on an LED from a struct led_dt_spec. | |
static int | led_off_dt (const struct led_dt_spec *spec) |
Turn off an LED from a struct led_dt_spec. | |
static bool | led_is_ready_dt (const struct led_dt_spec *spec) |
Validate that the LED device is ready. | |
LED Interface .
#define LED_DT_SPEC_GET | ( | node_id | ) |
#include <zephyr/drivers/led.h>
Static initializer for a struct led_dt_spec.
This returns a static initializer for a struct led_dt_spec given a devicetree node identifier.
Example devicetree fragment:
Example usage:
The device (dev) must still be checked for readiness, e.g. using device_is_ready().
node_id | Devicetree node identifier. |
#define LED_DT_SPEC_GET_OR | ( | node_id, | |
default_value ) |
#include <zephyr/drivers/led.h>
Like LED_DT_SPEC_GET(), with a fallback value if the node does not exist.
node_id | Devicetree node identifier. |
typedef int(* led_api_blink) (const struct device *dev, uint32_t led, uint32_t delay_on, uint32_t delay_off) |
#include <zephyr/drivers/led.h>
Callback API for blinking an LED.
typedef int(* led_api_get_info) (const struct device *dev, uint32_t led, const struct led_info **info) |
#include <zephyr/drivers/led.h>
Optional API callback to get LED information.
#include <zephyr/drivers/led.h>
Callback API for turning off an LED.
#include <zephyr/drivers/led.h>
Callback API for turning on an LED.
#include <zephyr/drivers/led.h>
Callback API for setting brightness of an LED.
typedef int(* led_api_set_color) (const struct device *dev, uint32_t led, uint8_t num_colors, const uint8_t *color) |
#include <zephyr/drivers/led.h>
Optional API callback to set the colors of a LED.
typedef int(* led_api_write_channels) (const struct device *dev, uint32_t start_channel, uint32_t num_channels, const uint8_t *buf) |
#include <zephyr/drivers/led.h>
Callback API for writing a strip of LED channels.
#include <zephyr/drivers/led.h>
Blink an LED.
This optional routine starts blinking a LED forever with the given time period.
dev | LED device |
led | LED number |
delay_on | Time period (in milliseconds) an LED should be ON |
delay_off | Time period (in milliseconds) an LED should be OFF |
#include <zephyr/drivers/led.h>
Get LED information.
This optional routine provides information about a LED.
dev | LED device |
led | LED number |
info | Pointer to a pointer filled with LED information |
|
inlinestatic |
#include <zephyr/drivers/led.h>
Validate that the LED device is ready.
spec | LED specification from devicetree. |
true | If the LED device is ready for use. |
false | If the LED device is not ready for use. |
#include <zephyr/drivers/led.h>
Turn off an LED.
This routine turns off an LED
dev | LED device |
led | LED number |
|
inlinestatic |
#include <zephyr/drivers/led.h>
Turn off an LED from a struct led_dt_spec.
spec | LED device specification from devicetree. |
#include <zephyr/drivers/led.h>
Turn on an LED.
This routine turns on an LED
dev | LED device |
led | LED number |
|
inlinestatic |
#include <zephyr/drivers/led.h>
Turn on an LED from a struct led_dt_spec.
spec | LED device specification from devicetree. |
#include <zephyr/drivers/led.h>
Set LED brightness.
This optional routine sets the brightness of a LED to the given value. Calling this function after led_blink() won't affect blinking.
LEDs which can only be turned on or off may provide this function. These should simply turn the LED on if value
is nonzero, and off if value
is zero.
dev | LED device |
led | LED number |
value | Brightness value to set in percent |
|
inlinestatic |
#include <zephyr/drivers/led.h>
Set LED brightness from a led_dt_spec.
spec | LED device specification from devicetree. |
value | Brightness value to set in percent. |
#include <zephyr/drivers/led.h>
Set a single LED channel.
This optional routine sets a single LED channel to the given value.
Calling this function after led_blink() won't affect blinking.
dev | LED device |
channel | Absolute channel number (i.e. not relative to a LED) |
value | Value to configure the channel with |
int led_set_color | ( | const struct device * | dev, |
uint32_t | led, | ||
uint8_t | num_colors, | ||
const uint8_t * | color ) |
#include <zephyr/drivers/led.h>
Set LED color.
This routine configures all the color channels of a LED with the given color array.
Calling this function after led_blink() won't affect blinking.
dev | LED device |
led | LED number |
num_colors | Number of colors in the array. |
color | Array of colors. It must be ordered following the color mapping of the LED controller. See the color_mapping member in struct led_info. |
int led_write_channels | ( | const struct device * | dev, |
uint32_t | start_channel, | ||
uint32_t | num_channels, | ||
const uint8_t * | buf ) |
#include <zephyr/drivers/led.h>
Write/update a strip of LED channels.
This optional routine writes a strip of LED channels to the given array of levels. Therefore it can be used to configure several LEDs at the same time.
Calling this function after led_blink() won't affect blinking.
dev | LED device |
start_channel | Absolute number (i.e. not relative to a LED) of the first channel to update. |
num_channels | The number of channels to write/update. |
buf | array of values to configure the channels with. num_channels entries must be provided. |