Lines Matching +full:led +full:- +full:duty +full:- +full:cycle
4 * SPDX-License-Identifier: Apache-2.0
11 * @brief LP5569 LED controller
13 * The LP5569 is a 9-channel LED driver that communicates over I2C.
18 #include <zephyr/drivers/led.h>
37 /* PWM base Register for controlling the duty-cycle */
46 static int lp5569_led_set_brightness(const struct device *dev, uint32_t led, uint8_t brightness) in lp5569_led_set_brightness() argument
48 const struct lp5569_config *config = dev->config; in lp5569_led_set_brightness()
52 if (led >= LP5569_NUM_LEDS || brightness > 100) { in lp5569_led_set_brightness()
53 return -EINVAL; in lp5569_led_set_brightness()
56 /* Map 0-100 % to 0-255 pwm register value */ in lp5569_led_set_brightness()
59 ret = i2c_reg_write_byte_dt(&config->bus, LP5569_LED0_PWM + led, val); in lp5569_led_set_brightness()
61 LOG_ERR("LED reg update failed"); in lp5569_led_set_brightness()
68 static inline int lp5569_led_on(const struct device *dev, uint32_t led) in lp5569_led_on() argument
70 /* Set LED brightness to 100 % */ in lp5569_led_on()
71 return lp5569_led_set_brightness(dev, led, 100); in lp5569_led_on()
74 static inline int lp5569_led_off(const struct device *dev, uint32_t led) in lp5569_led_off() argument
76 /* Set LED brightness to 0 % */ in lp5569_led_off()
77 return lp5569_led_set_brightness(dev, led, 0); in lp5569_led_off()
83 const struct lp5569_config *config = dev->config; in lp5569_write_channels()
88 return -EINVAL; in lp5569_write_channels()
94 return i2c_write_dt(&config->bus, i2c_msg, i2c_len); in lp5569_write_channels()
99 const struct lp5569_config *config = dev->config; in lp5569_enable()
102 if (!i2c_is_ready_dt(&config->bus)) { in lp5569_enable()
104 return -ENODEV; in lp5569_enable()
108 if (config->enable_gpio.port) { in lp5569_enable()
109 if (!gpio_is_ready_dt(&config->enable_gpio)) { in lp5569_enable()
111 return -ENODEV; in lp5569_enable()
114 ret = gpio_pin_configure_dt(&config->enable_gpio, GPIO_OUTPUT_ACTIVE); in lp5569_enable()
124 ret = i2c_reg_write_byte_dt(&config->bus, LP5569_CONFIG, LP5569_CHIP_EN); in lp5569_enable()
130 ret = i2c_reg_write_byte_dt(&config->bus, LP5569_MISC, in lp5569_enable()
132 (config->cp_mode << LP5569_CP_MODE_SHIFT)); in lp5569_enable()
134 LOG_ERR("LED reg update failed"); in lp5569_enable()
148 LOG_INF("Init %s as PM_DEVICE_STATE_OFF", dev->name); in lp5569_init()
158 const struct lp5569_config *config = dev->config; in lp5569_pm_action()
172 ret = i2c_reg_update_byte_dt(&config->bus, LP5569_CONFIG, LP5569_CHIP_EN, 0); in lp5569_pm_action()
179 return -ENOTSUP; in lp5569_pm_action()
186 static DEVICE_API(led, lp5569_led_api) = {