Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions drivers/led/led_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ struct led_gpio_config {
const struct gpio_dt_spec *led;
};


static int led_gpio_set_brightness(const struct device *dev, uint32_t led, uint8_t value)
{

Expand All @@ -37,7 +36,7 @@ static int led_gpio_set_brightness(const struct device *dev, uint32_t led, uint8

led_gpio = &config->led[led];

return gpio_pin_set(led_gpio->port, led_gpio->pin, (value >= 50));
return gpio_pin_set(led_gpio->port, led_gpio->pin, value > 0);
}

static int led_gpio_on(const struct device *dev, uint32_t led)
Expand All @@ -64,8 +63,7 @@ static int led_gpio_init(const struct device *dev)
const struct gpio_dt_spec *led = &config->led[i];

if (device_is_ready(led->port)) {
err = gpio_pin_configure(led->port, led->pin,
led->dt_flags | GPIO_OUTPUT_INACTIVE);
err = gpio_pin_configure_dt(led, GPIO_OUTPUT_INACTIVE);

if (err) {
LOG_ERR("Cannot configure GPIO (err %d)", err);
Expand Down
4 changes: 4 additions & 0 deletions include/drivers/led.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ static inline int z_impl_led_get_info(const struct device *dev, uint32_t led,
* 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 @p value is nonzero, and off
* if @p value is zero.
*
* @param dev LED device
* @param led LED number
* @param value Brightness value to set in percent
Expand Down