drivers: led_gpio: minor tweaks
Two minor tweaks and a semantics change: - fix a whitespace nit - use gpio_pin_configure_dt() - turn the LED on in case the percentage is nonzero The last change patterns this driver after behavior in the Android lights HAL, which recommends analogous behavior when the user requests a color change in a non-RGB LED: Do your best here. [...] If you can only do on or off, 0 is off, anything else is on. https://source.android.com/reference/hal/structlight__state__t I think this behavior makes more sense. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
d6b50233ac
commit
5cb95c4ce6
1 changed files with 2 additions and 4 deletions
|
@ -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)
|
||||
{
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue