Lines Matching +full:blue +full:- +full:output +full:- +full:current

4  * SPDX-License-Identifier: Apache-2.0
13 * The LP5562 is a 4-channel LED driver that communicates over I2C. The four
14 * channels are expected to be connected to a red, green, blue and white LED.
23 * - Set the brightness.
24 * - Fade the brightness over time.
25 * - Loop parts of the program or the whole program.
26 * - Add delays.
27 * - Synchronize between the engines.
86 /* Output current limits in 0.1 mA */
119 * with a red, a green, a blue and a white LED. Since the data sheet's
189 * @retval -EINVAL If an invalid channel is given.
208 return -EINVAL; in lp5562_get_pwm_reg()
221 * @retval -EINVAL If a source is given that is not a valid engine.
237 return -EINVAL; in lp5562_get_engine_ram_base_addr()
253 * @retval -EINVAL If a source is given that is not a valid engine.
269 return -EINVAL; in lp5562_get_engine_reg_shift()
320 * @retval -EIO If the underlying I2C call fails.
326 const struct lp5562_config *config = dev->config; in lp5562_set_led_source()
328 if (i2c_reg_update_byte_dt(&config->bus, LP5562_LED_MAP, in lp5562_set_led_source()
332 return -EIO; in lp5562_set_led_source()
346 * @retval -EIO If the underlying I2C call fails.
352 const struct lp5562_config *config = dev->config; in lp5562_get_led_source()
355 if (i2c_reg_read_byte_dt(&config->bus, LP5562_LED_MAP, &led_map)) { in lp5562_get_led_source()
356 return -EIO; in lp5562_get_led_source()
378 const struct lp5562_config *config = dev->config; in lp5562_is_engine_executing()
387 if (i2c_reg_read_byte_dt(&config->bus, LP5562_ENABLE, &enabled)) { in lp5562_is_engine_executing()
408 * @retval -ENODEV If all engines are busy.
425 return -ENODEV; in lp5562_get_available_engine()
437 * @retval -EIO If the underlying I2C call fails.
443 const struct lp5562_config *config = dev->config; in lp5562_set_engine_reg()
452 if (i2c_reg_update_byte_dt(&config->bus, reg, LP5562_MASK << shift, in lp5562_set_engine_reg()
454 return -EIO; in lp5562_set_engine_reg()
468 * @retval -EIO If the underlying I2C call fails.
485 * @retval -EIO If the underlying I2C call fails.
511 * @retval -EIO If the underlying I2C call fails.
517 return -EIO; in lp5562_start_program_exec()
531 * @retval -EIO If the underlying I2C call fails.
537 return -EIO; in lp5562_stop_program_exec()
554 * @retval -EINVAL If the given command index is out of range or an invalid
556 * @retval -EIO If the underlying I2C call fails.
564 const struct lp5562_config *config = dev->config; in lp5562_program_command()
569 return -EINVAL; in lp5562_program_command()
578 if (i2c_reg_write_byte_dt(&config->bus, in lp5562_program_command()
582 return -EIO; in lp5562_program_command()
585 if (i2c_reg_write_byte_dt(&config->bus, in lp5562_program_command()
589 return -EIO; in lp5562_program_command()
604 * @retval -EINVAL If the passed arguments are invalid or out of range.
605 * @retval -EIO If the underlying I2C call fails.
612 struct lp5562_data *data = dev->data; in lp5562_program_set_brightness()
613 struct led_data *dev_data = &data->dev_data; in lp5562_program_set_brightness()
616 if ((brightness < dev_data->min_brightness) || in lp5562_program_set_brightness()
617 (brightness > dev_data->max_brightness)) { in lp5562_program_set_brightness()
618 return -EINVAL; in lp5562_program_set_brightness()
621 val = (brightness * 0xFF) / dev_data->max_brightness; in lp5562_program_set_brightness()
638 * @param fade_dir Direction of the ramp (in-/decrease brightness).
641 * @retval -EINVAL If the passed arguments are invalid or out of range.
642 * @retval -EIO If the underlying I2C call fails.
651 struct lp5562_data *data = dev->data; in lp5562_program_ramp()
652 struct led_data *dev_data = &data->dev_data; in lp5562_program_ramp()
655 if ((time_per_step < dev_data->min_period) || in lp5562_program_ramp()
656 (time_per_step > dev_data->max_period)) { in lp5562_program_ramp()
657 return -EINVAL; in lp5562_program_ramp()
677 * @retval -EINVAL If the passed arguments are invalid or out of range.
678 * @retval -EIO If the underlying I2C call fails.
703 * @retval -EINVAL If the given command index is out of range or an invalid
705 * @retval -EIO If the underlying I2C call fails.
717 * We know that the current program executes a blinking pattern
720 * - set_brightness high
721 * - wait on_delay
722 * - set_brightness low
723 * - wait off_delay
724 * - return to start
734 * @retval -EINVAL If the engine ID or brightness is out of range.
735 * @retval -EIO If the underlying I2C call fails.
771 struct lp5562_data *data = dev->data; in lp5562_led_blink()
772 struct led_data *dev_data = &data->dev_data; in lp5562_led_blink()
778 * Read current "led" source setting. This is to check in lp5562_led_blink()
806 dev_data->max_brightness); in lp5562_led_blink()
817 dev_data->min_brightness); in lp5562_led_blink()
844 const struct lp5562_config *config = dev->config; in lp5562_led_set_brightness()
845 struct lp5562_data *data = dev->data; in lp5562_led_set_brightness()
846 struct led_data *dev_data = &data->dev_data; in lp5562_led_set_brightness()
851 if ((value < dev_data->min_brightness) || in lp5562_led_set_brightness()
852 (value > dev_data->max_brightness)) { in lp5562_led_set_brightness()
853 return -EINVAL; in lp5562_led_set_brightness()
877 val = (value * 0xFF) / dev_data->max_brightness; in lp5562_led_set_brightness()
884 if (i2c_reg_write_byte_dt(&config->bus, reg, val)) { in lp5562_led_set_brightness()
886 return -EIO; in lp5562_led_set_brightness()
894 struct lp5562_data *data = dev->data; in lp5562_led_on()
895 struct led_data *dev_data = &data->dev_data; in lp5562_led_on()
897 return lp5562_led_set_brightness(dev, led, dev_data->max_brightness); in lp5562_led_on()
902 struct lp5562_data *data = dev->data; in lp5562_led_off()
903 struct led_data *dev_data = &data->dev_data; in lp5562_led_off()
920 return lp5562_led_set_brightness(dev, led, dev_data->min_brightness); in lp5562_led_off()
925 const struct lp5562_config *config = dev->config; in lp5562_led_update_current()
929 config->b_current, in lp5562_led_update_current()
930 config->g_current, in lp5562_led_update_current()
931 config->r_current }; in lp5562_led_update_current()
933 ret = i2c_write_dt(&config->bus, tx_buf, sizeof(tx_buf)); in lp5562_led_update_current()
935 ret = i2c_reg_write_byte_dt(&config->bus, LP5562_W_CURRENT, config->w_current); in lp5562_led_update_current()
943 const struct lp5562_config *config = dev->config; in lp5562_enable()
944 const struct gpio_dt_spec *enable_gpio = &config->enable_gpio; in lp5562_enable()
948 if (enable_gpio->port != NULL) { in lp5562_enable()
951 LOG_ERR("%s: failed to set enable GPIO 1", dev->name); in lp5562_enable()
964 err = i2c_reg_write_byte_dt(&config->bus, LP5562_RESET, 0xFF); in lp5562_enable()
966 LOG_ERR("%s: failed to soft-reset device", dev->name); in lp5562_enable()
972 err = i2c_reg_update_byte_dt(&config->bus, LP5562_ENABLE, LP5562_ENABLE_CHIP_EN_MASK, in lp5562_enable()
975 LOG_ERR("%s: failed to set EN Bit in ENABLE register", dev->name); in lp5562_enable()
986 const struct lp5562_config *config = dev->config; in lp5562_disable()
987 const struct gpio_dt_spec *enable_gpio = &config->enable_gpio; in lp5562_disable()
991 err = i2c_reg_update_byte_dt(&config->bus, LP5562_ENABLE, LP5562_ENABLE_CHIP_EN_MASK, in lp5562_disable()
994 LOG_ERR("%s: failed to clear EN Bit in ENABLE register", dev->name); in lp5562_disable()
998 /* if gpio control is enabled, we can de-assert EN_GPIO now */ in lp5562_disable()
999 if (enable_gpio->port != NULL) { in lp5562_disable()
1002 LOG_ERR("%s: failed to set enable GPIO to 0", dev->name); in lp5562_disable()
1012 const struct lp5562_config *config = dev->config; in lp5562_led_init()
1013 struct lp5562_data *data = dev->data; in lp5562_led_init()
1014 struct led_data *dev_data = &data->dev_data; in lp5562_led_init()
1015 const struct gpio_dt_spec *enable_gpio = &config->enable_gpio; in lp5562_led_init()
1018 if (enable_gpio->port != NULL) { in lp5562_led_init()
1020 return -ENODEV; in lp5562_led_init()
1029 if (!device_is_ready(config->bus.bus)) { in lp5562_led_init()
1031 return -ENODEV; in lp5562_led_init()
1040 dev_data->min_period = LP5562_MIN_BLINK_PERIOD; in lp5562_led_init()
1041 dev_data->max_period = LP5562_MAX_BLINK_PERIOD; in lp5562_led_init()
1042 dev_data->min_brightness = LP5562_MIN_BRIGHTNESS; in lp5562_led_init()
1043 dev_data->max_brightness = LP5562_MAX_BRIGHTNESS; in lp5562_led_init()
1047 LOG_ERR("Setting current setting LP5562 LED chip failed."); in lp5562_led_init()
1051 if (i2c_reg_write_byte_dt(&config->bus, LP5562_CONFIG, in lp5562_led_init()
1055 return -EIO; in lp5562_led_init()
1058 if (i2c_reg_write_byte_dt(&config->bus, LP5562_OP_MODE, 0x00)) { in lp5562_led_init()
1060 return -EIO; in lp5562_led_init()
1063 if (i2c_reg_write_byte_dt(&config->bus, LP5562_LED_MAP, 0x00)) { in lp5562_led_init()
1065 return -EIO; in lp5562_led_init()
1087 return -ENOTSUP; in lp5562_pm_action()
1094 "Red channel current must be between 0 and 25.5 mA."); \
1096 "Green channel current must be between 0 and 25.5 mA."); \
1098 "Blue channel current must be between 0 and 25.5 mA."); \
1100 "White channel current must be between 0 and 25.5 mA."); \