From 126eb263ef8abf15cc1465001dfb86d74eed68ec Mon Sep 17 00:00:00 2001 From: "Roleda, Jan carlo" Date: Tue, 28 Oct 2025 09:36:49 +0800 Subject: [PATCH 1/4] drivers: led: ltc3220: add driver support for LTC3220 Added implementation for writing to LTC3220 device registers Signed-off-by: Jan Carlo Roleda --- drivers/led/ltc3220/ltc3220.c | 525 ++++++++++++++++++++++++++++++++++ drivers/led/ltc3220/ltc3220.h | 310 ++++++++++++++++++++ 2 files changed, 835 insertions(+) create mode 100644 drivers/led/ltc3220/ltc3220.c create mode 100644 drivers/led/ltc3220/ltc3220.h diff --git a/drivers/led/ltc3220/ltc3220.c b/drivers/led/ltc3220/ltc3220.c new file mode 100644 index 00000000000..4a05a9e31d2 --- /dev/null +++ b/drivers/led/ltc3220/ltc3220.c @@ -0,0 +1,525 @@ +/***************************************************************************//** + * @file ltc3220.c + * @brief Implementation of LTC3220 Driver + * @author Jan Carlo Roleda (Jancarlo.roleda@analog.com) +******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * - Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * - The use of this software may or may not infringe the patent rights + * of one or more patent holders. This license does not release you + * from the requirement that you obtain separate licenses from these + * patent holders to use this software. + * - Use of the software either in source or binary form, must be run + * on or directly connected to an Analog Devices Inc. component. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#include +#include +#include +#include +#include "ltc3220.h" +#include "no_os_i2c.h" +#include "no_os_util.h" +#include "no_os_delay.h" + +/***************************************************************************//** + * @brief Initializes the LTC3220 device structure. + * @param device - The device structure to initialize. + * @param init_param - The initialization parameters. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_init(struct ltc3220_dev **device, + struct ltc3220_init_param init_param) +{ + struct ltc3220_dev *dev; + int ret; + + dev = (struct ltc3220_dev *)no_os_calloc(1, sizeof(*dev)); + if (!dev) + return -ENOMEM; + + ret = no_os_i2c_init(&dev->i2c_desc, &init_param.i2c_init_param); + if (ret) + goto ltc3220_init_err; + + ret = no_os_gpio_get(&dev->gpio_rst_desc, &init_param.gpio_init_param); + if (ret) + goto ltc3220_init_err; + + ret = no_os_gpio_direction_output(dev->gpio_rst_desc, NO_OS_GPIO_HIGH); + if (ret) + goto ltc3220_init_err; + + *device = dev; + + return 0; + +ltc3220_init_err: + ltc3220_remove(dev); + return ret; +} + +/***************************************************************************//** + * @brief Deallocates the resources for the device structure. + * @param device - The device structure. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_remove(struct ltc3220_dev *device) +{ + int ret; + + if (!device) + return -ENODEV; + + if (device->i2c_desc) { + ret = no_os_i2c_remove(device->i2c_desc); + if (ret) + return ret; + device->i2c_desc = NULL; + } + + if (device->gpio_rst_desc) { + ret = no_os_gpio_remove(device->gpio_rst_desc); + if (ret) + return ret; + device->gpio_rst_desc = NULL; + } + + no_os_free(device); + + return 0; +} + +/***************************************************************************//** + * @brief Resets the device using the RST pin + * @param device - the device structure. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_reset(struct ltc3220_dev *device) +{ + int ret; + + ret = no_os_gpio_direction_output(device->gpio_rst_desc, NO_OS_GPIO_LOW); + if (ret) + return ret; + + no_os_udelay(LTC3220_RESET_DELAY_USEC); /* at least 20ns */ + + ret = no_os_gpio_set_value(device->gpio_rst_desc, NO_OS_GPIO_HIGH); + if (ret) + return ret; + + device->blink_config = blink_reset; + device->command_config = command_reset; + device->gradation_config = grad_reset; + + for (int i = 0; i < LTC3220_REG_END_ULED; i++) + device->uleds[i] = uled_reset; + + return 0; +} + +/***************************************************************************//** + * @brief Writes to the selected register on the device. + * @param device - The device structure. + * @param reg_addr - The register sub-address. + * @param reg_data - The data to write into the register (8-bits wide) + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_reg_write(struct ltc3220_dev *device, uint8_t reg_addr, + uint8_t reg_data) +{ + uint8_t data_buffer[2] = {0}; + + if (reg_addr > LTC3220_REG_BLINK_GRAD) + return -EINVAL; + + data_buffer[0] = reg_addr; + data_buffer[1] = reg_data; + + return no_os_i2c_write(device->i2c_desc, data_buffer, 2, 1); +} + +/***************************************************************************//** + * @brief Sets the selected ULED register's operating mode + * @param device - The device structure. + * @param uled_number - The ULED to select (1-indexed). + * @param mode - The mode to set the ULED to. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_set_uled_mode(struct ltc3220_dev *device, uint8_t uled_number, + enum ltc3220_uled_mode mode) +{ + int ret; + + if (uled_number > LTC3220_REG_END_ULED) + return -EINVAL; + + ret = ltc3220_update_reg_uled(device, uled_number, mode, + device->uleds[uled_number - 1].current_level); + if (ret) + return ret; + + device->uleds[uled_number - 1].mode = mode; + + return 0; +} + +/***************************************************************************//** + * @brief Sets the selected ULED register's current strength + * @param device - The device structure. + * @param uled_number - The ULED to select (1-indexed). + * @param current_level - The current strength from 0 to 20mA to set on the + * corresponding ULED pin (64 levels) +*******************************************************************************/ +int ltc3220_set_uled_current(struct ltc3220_dev *device, uint8_t uled_number, + uint8_t current_level) +{ + int ret; + + if (uled_number > LTC3220_REG_END_ULED) + return -EINVAL; + + ret = ltc3220_update_reg_uled(device, uled_number, + device->uleds[uled_number - 1].mode, current_level); + if (ret) + return ret; + + device->uleds[uled_number - 1].current_level = current_level; + + return 0; +} + +/***************************************************************************//** + * @brief Updates the configuration set on the ULED based on the device's + * config + * @param device - The device structure. + * @param uled_number - The ULED to select (1-indexed). + * @param mode - The mode to set the ULED to. + * @param current_level - The current strength from 0 to 20mA to set on the + * corresponding ULED pin (64 levels) + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_update_reg_uled(struct ltc3220_dev *device, uint8_t uled_number, + enum ltc3220_uled_mode mode, uint8_t current_level) +{ + uint8_t data, quick_mode, quick_current; + + if (uled_number > LTC3220_REG_END_ULED) + return -EINVAL; + + /* Copy config of ULED1 to all other ULEDs */ + if (device->command_config.is_quick_write + && uled_number == LTC3220_REG_START_ULED) { + + quick_mode = device->uleds[0].mode; + quick_current = device->uleds[0].current_level; + + for (int uled = LTC3220_REG_START_ULED; + uled < LTC3220_REG_END_ULED; + uled++) { + device->uleds[uled].mode = quick_mode; + device->uleds[uled].current_level = quick_current; + } + } + + data = no_os_field_prep(LTC3220_ULED_MODE_MASK, mode) | + no_os_field_prep(LTC3220_ULED_CURRENT_MASK, current_level); + + return ltc3220_reg_write(device, uled_number, data); +} + +/***************************************************************************//** + * @brief Sets the configuration for blinking mode of ULEDs. + * @param device - The device structure. + * @param is_fast_on - Sets whether blinking should turn on fast (0.156s) + * or not (0.625s) + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_set_blink_fast(struct ltc3220_dev *device, bool is_fast_on) +{ + int ret; + + ret = ltc3220_update_reg_blink_grad(device, is_fast_on, + device->blink_config.is_long_period, + device->gradation_config.is_increasing, + device->gradation_config.speed); + if (ret) + return ret; + + device->blink_config.is_fast_on = is_fast_on; + + return 0; +} + +/***************************************************************************//** + * @brief Sets the configuration for blinking mode of ULEDs. + * @param device - The device structure. + * @param is_long_period - Sets whether blinking should have a shorter (1.25s) + * or longer (2.5s) period + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_set_blink_long(struct ltc3220_dev *device, bool is_long_period) +{ + int ret; + + ret = ltc3220_update_reg_blink_grad(device, device->blink_config.is_fast_on, + is_long_period, device->gradation_config.is_increasing, + device->gradation_config.speed); + if (ret) + return ret; + + device->blink_config.is_long_period = is_long_period; + + return 0; +} + +/***************************************************************************//** + * @brief Sets the configuration for the device's direction of gradation + * @param device - The device structure. + * @param is_increasing - Set for increasing gradation, unset if + * decreasing gradation. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_set_grad_increasing(struct ltc3220_dev *device, bool is_increasing) +{ + int ret; + + ret = ltc3220_update_reg_blink_grad(device, device->blink_config.is_fast_on, + device->blink_config.is_long_period, + is_increasing, device->gradation_config.speed); + if (ret) + return ret; + + device->gradation_config.is_increasing = is_increasing; + + return 0; +} + +/***************************************************************************//** + * @brief Sets the configuration of the device's speed of gradation + * @param device - The device structure. + * @param speed - Sets the speed of gradation, with slowest speed at + * max setting (3). Set to 0 to disable gradation. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_set_grad_speed(struct ltc3220_dev *device, uint8_t speed) +{ + int ret; + + if (speed > LTC3220_GRAD_MAX_SPD) + return -EINVAL; + + ret = ltc3220_update_reg_blink_grad(device, device->blink_config.is_fast_on, + device->blink_config.is_long_period, + device->gradation_config.is_increasing, speed); + if (ret) + return ret; + + device->gradation_config.speed = speed; + + return 0; +} + +/***************************************************************************//** + * @brief Updates the configuration set on the device's Blink/Gradation + * based on the config + * @param device - The device's structure. + * @param is_blink_fast - Sets whether blinking should turn on fast (0.156s) + * or not (0.625s) + * @param is_blink_long - Sets whether blinking should have a shorter (1.25s) + * or longer (2.5s) period + * @param is_grad_inc - Set for increasing gradation, unset if decreasing + * gradation. + * @param grad_speed - Sets the speed of gradation, with slowest speed at + * max setting (3). Set to 0 to disable gradation. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_update_reg_blink_grad(struct ltc3220_dev *device, + bool is_blink_fast, bool is_blink_long, bool is_grad_inc, + uint8_t grad_speed) +{ + uint8_t data = no_os_field_prep(LTC3220_BLINK_LONG_MASK, is_blink_long) | + no_os_field_prep(LTC3220_BLINK_FAST_MASK, is_blink_fast) | + no_os_field_prep(LTC3220_GRAD_SPD_MASK, grad_speed) | + no_os_field_prep(LTC3220_GRAD_DIRECTION_MASK, is_grad_inc); + + return ltc3220_reg_write(device, LTC3220_REG_BLINK_GRAD, data); +} + +/***************************************************************************//** + * @brief Sets the configuration to perform a quick write to the device + * @param device - The device structure. + * @param is_quick_write - Set for quick write operation. This copies the + * configuration set on ULED1 to all other ULED registers. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_set_quick_write(struct ltc3220_dev *device, bool is_quick_write) +{ + int ret; + + ret = ltc3220_update_reg_command(device, device->command_config.is_shutdown, + device->command_config.is_force_cpo_2x, + device->command_config.is_force_cpo_1p5x, + is_quick_write); + if (ret) + return ret; + + device->command_config.is_quick_write = is_quick_write; + + return 0; +} + +/***************************************************************************//** + * @brief Sets the device's charge pump to output 1x of operating voltage + * @param device - The device structure. + * @param is_force_cpo_1x - Set if the device's is to use 1x voltage. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_set_cpo_1x(struct ltc3220_dev *device, bool is_force_cpo_1x) +{ + int ret; + + ret = ltc3220_update_reg_command(device, device->command_config.is_shutdown, + is_force_cpo_1x, is_force_cpo_1x, + device->command_config.is_quick_write); + if (ret) + return ret; + + device->command_config.is_force_cpo_1p5x = is_force_cpo_1x; + device->command_config.is_force_cpo_2x = is_force_cpo_1x; + + return 0; +} + +/***************************************************************************//** + * @brief Sets the device's charge pump to output 1.5x of operating voltage + * @param device - The device structure. + * @param is_force_cpo_1p5x - Sets the device's to use 1.5x voltage. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_set_cpo_1p5x(struct ltc3220_dev *device, bool is_force_cpo_1p5x) +{ + int ret; + + ret = ltc3220_update_reg_command(device, device->command_config.is_shutdown, + false, is_force_cpo_1p5x, + device->command_config.is_quick_write); + if (ret) + return ret; + + device->command_config.is_force_cpo_1p5x = is_force_cpo_1p5x; + device->command_config.is_force_cpo_2x = false; + + return 0; +} + +/***************************************************************************//** + * @brief Sets the device's charge pump to output 2x of operating voltage + * @param device - The device structure. + * @param is_force_cpo_2x - Sets the device's to use 2x voltage. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_set_cpo_2x(struct ltc3220_dev *device, bool is_force_cpo_2x) +{ + int ret; + + ret = ltc3220_update_reg_command(device, device->command_config.is_shutdown, + is_force_cpo_2x, false, + device->command_config.is_quick_write); + if (ret) + return ret; + + device->command_config.is_force_cpo_1p5x = false; + device->command_config.is_force_cpo_2x = is_force_cpo_2x; + + return 0; +} + +/***************************************************************************//** + * @brief Sets the device to shutdown mode, while retaining the register + * configurations + * @param device - The device structure. + * @param is_shutdown - Signals the device to shutdown. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_set_shutdown(struct ltc3220_dev *device, bool is_shutdown) +{ + int ret; + + ret = ltc3220_update_reg_command(device, is_shutdown, + device->command_config.is_force_cpo_2x, + device->command_config.is_force_cpo_1p5x, + device->command_config.is_quick_write); + if (ret) + return ret; + + device->command_config.is_shutdown = is_shutdown; + + return 0; +} + +/***************************************************************************//** + * @brief Updates the configuration set on the + * @param device - The device's structure. + * @param is_shutdown - Signals the device to shutdown. + * @param is_force_cpo_1p5x - Sets the device's to use 1.5x voltage. + * @param is_force_cpo_2x - Sets the device's to use 2x voltage. + * @param is_quick_write - Set for quick write operation. This copies the + * configuration set on ULED1 to all other ULED registers. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_update_reg_command(struct ltc3220_dev *device, bool is_shutdown, + bool is_force_cpo_2x, bool is_force_cpo_1p5x, + bool is_quick_write) +{ + uint8_t data, quick_mode, quick_current; + int ret; + + data = no_os_field_prep(LTC3220_COMMAND_SHUTDOWN, is_shutdown) | + no_os_field_prep(LTC3220_COMMAND_1P5X_MASK, is_force_cpo_1p5x) | + no_os_field_prep(LTC3220_COMMAND_2X_MASK, is_force_cpo_2x) | + no_os_field_prep(LTC3220_COMMAND_QUICK_WRITE_MASK, is_quick_write); + + ret = ltc3220_reg_write(device, LTC3220_REG_COMMAND, data); + if (ret) + return ret; + + /* Copy config of ULED1 to all other ULEDs */ + if (is_quick_write) { + quick_mode = device->uleds[0].mode; + quick_current = device->uleds[0].current_level; + for (int uled = LTC3220_REG_START_ULED; + uled < LTC3220_REG_END_ULED; + uled++) { + device->uleds[uled].mode = quick_mode; + device->uleds[uled].current_level = quick_current; + } + } + + return 0; +} diff --git a/drivers/led/ltc3220/ltc3220.h b/drivers/led/ltc3220/ltc3220.h new file mode 100644 index 00000000000..3fb730e8121 --- /dev/null +++ b/drivers/led/ltc3220/ltc3220.h @@ -0,0 +1,310 @@ +/***************************************************************************//** + * @file ltc3220.c + * @brief Implementation of LTC3220 Driver + * @author Jan Carlo Roleda (Jancarlo.roleda@analog.com) +******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * - Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * - The use of this software may or may not infringe the patent rights + * of one or more patent holders. This license does not release you + * from the requirement that you obtain separate licenses from these + * patent holders to use this software. + * - Use of the software either in source or binary form, must be run + * on or directly connected to an Analog Devices Inc. component. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __LTC3220_H__ +#define __LTC3220_H__ + +#include "no_os_i2c.h" +#include "no_os_gpio.h" +#include "no_os_util.h" + +/*ltc3220 register addresses*/ +#define LTC3220_REG_COMMAND 0x00 +#define LTC3220_REG_START_ULED 0x01 /*ULED1 */ +#define LTC3220_REG_END_ULED 0x12 /*ULED18*/ +#define LTC3220_REG_BLINK_GRAD 0x13 + +/*command register (0x00) */ +#define LTC3220_COMMAND_QUICK_WRITE_MASK NO_OS_BIT(0) +#define LTC3220_COMMAND_1P5X_MASK NO_OS_BIT(1) +#define LTC3220_COMMAND_2X_MASK NO_OS_BIT(2) +#define LTC3220_COMMAND_SHUTDOWN NO_OS_BIT(3) + +/* ULEDxx registers (0x01-0x12) */ +#define LTC3220_ULED_MODE_MASK NO_OS_GENMASK(7,6) +#define LTC3220_ULED_CURRENT_MASK NO_OS_GENMASK(5,0) +#define LTC3220_ULED_CURRENT_MAX_STEP 64 + +/* Blink/Gradation (0x13) */ +#define LTC3220_BLINK_LONG_MASK NO_OS_BIT(4) +#define LTC3220_BLINK_FAST_MASK NO_OS_BIT(3) +#define LTC3220_GRAD_SPD_MASK NO_OS_GENMASK(2,1) +#define LTC3220_GRAD_DIRECTION_MASK NO_OS_BIT(0) +#define LTC3220_GRAD_MAX_SPD 3 + +/* Reset timing */ +#define LTC3220_RESET_DELAY_USEC 1 /*20ns min */ + +enum ltc3220_variant { + LTC3220 = 0x1C, + LTC3220_1 = 0x1D +}; + +enum ltc3220_uled_mode { + LTC3220_MODE_NORMAL = 0, + LTC3220_MODE_BLINK, + LTC3220_MODE_GRADATION, + LTC3220_MODE_GPO +}; + +struct ltc3220_command_cfg { + bool is_quick_write; + bool is_force_cpo_1p5x; + bool is_force_cpo_2x; + bool is_shutdown; +}; + +static const struct ltc3220_command_cfg command_reset; + +struct ltc3220_uled_cfg { + enum ltc3220_uled_mode mode; + uint8_t current_level; +}; + +static const struct ltc3220_uled_cfg uled_reset; + +struct ltc3220_blink_cfg { + bool is_fast_on; + bool is_long_period; +}; + +static const struct ltc3220_blink_cfg blink_reset; + +struct ltc3220_grad_cfg { + uint8_t speed; + bool is_increasing; +}; + +static const struct ltc3220_grad_cfg grad_reset; + +struct ltc3220_dev { + struct no_os_i2c_desc *i2c_desc; + + struct no_os_gpio_desc *gpio_rst_desc; + + /* Contains configuration of each ULED */ + struct ltc3220_uled_cfg uleds[LTC3220_REG_END_ULED]; + + /* Contains configuration of device */ + struct ltc3220_command_cfg command_config; + + /* Blink mode configuration */ + struct ltc3220_blink_cfg blink_config; + + /* Gradation mode configuration */ + struct ltc3220_grad_cfg gradation_config; +}; + +struct ltc3220_init_param { + struct no_os_i2c_init_param i2c_init_param; + struct no_os_gpio_init_param gpio_init_param; /* for device reset */ +}; + +/** + * @brief Initializes the LTC3220 device structure. + * @param device - The device structure to initialize. + * @param init_param - The initialization parameters. + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_init(struct ltc3220_dev **device, + struct ltc3220_init_param init_param); + +/** + * @brief Deallocates the resources for the device structure. + * @param device - The device structure. + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_remove(struct ltc3220_dev *device); + +/** + * @brief Resets the device using the RST pin + * @param device - the device structure. + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_reset(struct ltc3220_dev *device); + +/** + * @brief Writes to the selected register on the device. + * @param device - The device structure. + * @param reg_addr - The register sub-address. + * @param reg_data - The data to write into the register (8-bits wide) + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_reg_write(struct ltc3220_dev *device, uint8_t reg_addr, + uint8_t reg_data); + +/** + * @brief Sets the selected ULED register's operating mode + * @param device - The device structure. + * @param uled_number - The ULED to select (1-indexed). + * @param mode - The mode to set the ULED to. + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_set_uled_mode(struct ltc3220_dev *device, uint8_t uled_number, + enum ltc3220_uled_mode mode); + +/** + * @brief Sets the selected ULED register's current strength + * @param device - The device structure. + * @param uled_number - The ULED to select (1-indexed). + * @param current_level - The current strength from 0 to 20mA to set on the corresponding ULED pin (64 levels) + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_set_uled_current(struct ltc3220_dev *device, uint8_t uled_number, + uint8_t current_level); + +/** + * @brief Updates the configuration set on the device's ULED based on the config + * @param device - The device structure. + * @param uled_number - The ULED to select (1-indexed). + * @param mode - The mode to set the ULED to. + * @param current_level - The current strength from 0 to 20mA to set on the corresponding ULED pin (64 levels) + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_update_reg_uled(struct ltc3220_dev *device, uint8_t uled_number, + enum ltc3220_uled_mode mode, uint8_t current_level); + +/** + * @brief Sets the configuration for blinking mode of ULEDs. + * @param device - The device structure. + * @param is_fast_on - Sets whether blinking should turn on fast (0.156s) or not (0.625s) + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_set_blink_fast(struct ltc3220_dev *device, bool is_fast_on); + +/** + * @brief Sets the configuration for blinking mode of ULEDs. + * @param device - The device structure. + * @param is_long_period - Sets whether blinking should have a shorter (1.25s) or longer (2.5s) period + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_set_blink_long(struct ltc3220_dev *device, bool is_long_period); + +/** + * @brief Sets the configuration of the device's speed of gradation + * @param device - The device structure. + * @param speed - Sets the speed of gradation, with slowest speed at max setting (3). Set to 0 to disable gradation. + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_set_grad_speed(struct ltc3220_dev *device, uint8_t speed); + +/** + * @brief Sets the configuration for the device's direction of gradation + * @param device - The device structure. + * @param is_increasing - Set for increasing gradation, unset if decreasing gradation. + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_set_grad_increasing(struct ltc3220_dev *device, bool is_increasing); + +/** + * @brief Updates the configuration set on the device's Blink/Gradation based on the config + * @param device - The device's structure. + * @param is_blink_fast - Sets whether blinking should turn on fast (0.156s) or not (0.625s) + * @param is_blink_long - Sets whether blinking should have a shorter (1.25s) or longer (2.5s) period + * @param is_grad_inc - Set for increasing gradation, unset if decreasing gradation. + * @param grad_speed - Sets the speed of gradation, with slowest speed at max setting (3). Set to 0 to disable gradation. + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_update_reg_blink_grad(struct ltc3220_dev *device, + bool is_blink_fast, bool is_blink_long, bool is_grad_inc, + uint8_t grad_speed); + +/** + * @brief Sets the configuration to perform a quick write to the device + * @param device - The device structure. + * @param is_quick_write - Set for quick write operation. This copies the configuration set on ULED1 to all other ULED registers. + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_set_quick_write(struct ltc3220_dev *device, bool is_quick_write); + +/** + * @brief Sets the device's charge pump to output 1x of operating voltage + * @param device - The device structure. + * @param is_force_cpo_1x - Sets the device's to use 1x voltage. + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_set_cpo_1x(struct ltc3220_dev *device, bool is_force_cpo_1x); + +/** + * @brief Sets the device's charge pump to output 1.5x of operating voltage + * @param device - The device structure. + * @param is_force_cpo_1p5x - Sets the device's to use 1.5x voltage. + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_set_cpo_1p5x(struct ltc3220_dev *device, bool is_force_cpo_1p5x); + +/** + * @brief Sets the device's charge pump to output 2x of operating voltage + * @param device - The device structure. + * @param is_force_cpo_2x - Sets the device's to use 2x voltage. + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_set_cpo_2x(struct ltc3220_dev *device, bool is_force_cpo_2x); + +/** + * @brief Sets the device to shutdown mode, while retaining the register configurations + * @param device - The device structure. + * @param is_shutdown - Signals the device to shutdown. + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_set_shutdown(struct ltc3220_dev *device, bool is_shutdown); + + +/** + * @brief Updates the configuration set on the + * @param device - The device's structure. + * @param is_shutdown - Signals the device to shutdown. + * @param is_force_cpo_1p5x - Sets the device's to use 1.5x voltage. + * @param is_force_cpo_2x - Sets the device's to use 2x voltage. + * @param is_quick_write - Set for quick write operation. This copies the configuration set on ULED1 to all other ULED registers. + * @return 0 in case of success, negative error code otherwise. + */ +int ltc3220_update_reg_command(struct ltc3220_dev *device, bool is_shutdown, + bool is_force_cpo_2x, bool is_force_cpo_1p5x, + bool is_quick_write); + +#endif /*__LTC3220_H__*/ + +#ifdef __cplusplus +} +#endif From 7d29b27da8eb3e4c5d6cfd03269e1ae44c3e2a63 Mon Sep 17 00:00:00 2001 From: "Roleda, Jan carlo" Date: Tue, 28 Oct 2025 09:39:49 +0800 Subject: [PATCH 2/4] projects: led: ltc3220: add project for LTC3220 Created LTC3220 project example for Maxim platform Includes tests for the different features of the LTC3220 Signed-off-by: Jan Carlo Roleda --- projects/ltc3220/makefile | 11 + projects/ltc3220/src.mk | 28 ++ projects/ltc3220/src/common/common_data.c | 55 ++++ projects/ltc3220/src/common/common_data.h | 43 +++ .../src/examples/dummy/dummy_example.c | 291 ++++++++++++++++++ .../src/examples/dummy/dummy_example.h | 74 +++++ projects/ltc3220/src/platform/maxim/main.c | 47 +++ .../ltc3220/src/platform/maxim/parameters.c | 42 +++ .../ltc3220/src/platform/maxim/parameters.h | 69 +++++ .../src/platform/maxim/platform_src.mk | 15 + 10 files changed, 675 insertions(+) create mode 100644 projects/ltc3220/makefile create mode 100644 projects/ltc3220/src.mk create mode 100644 projects/ltc3220/src/common/common_data.c create mode 100644 projects/ltc3220/src/common/common_data.h create mode 100644 projects/ltc3220/src/examples/dummy/dummy_example.c create mode 100644 projects/ltc3220/src/examples/dummy/dummy_example.h create mode 100644 projects/ltc3220/src/platform/maxim/main.c create mode 100644 projects/ltc3220/src/platform/maxim/parameters.c create mode 100644 projects/ltc3220/src/platform/maxim/parameters.h create mode 100644 projects/ltc3220/src/platform/maxim/platform_src.mk diff --git a/projects/ltc3220/makefile b/projects/ltc3220/makefile new file mode 100644 index 00000000000..3008473602a --- /dev/null +++ b/projects/ltc3220/makefile @@ -0,0 +1,11 @@ +EXAMPLE ?= dummy + +PLATFORM ?= maxim + +include ../../tools/scripts/generic_variables.mk + +include ../../tools/scripts/examples.mk + +include src.mk + +include ../../tools/scripts/generic.mk diff --git a/projects/ltc3220/src.mk b/projects/ltc3220/src.mk new file mode 100644 index 00000000000..09ba9bda725 --- /dev/null +++ b/projects/ltc3220/src.mk @@ -0,0 +1,28 @@ +INCS += $(INCLUDE)/no_os_error.h \ + $(INCLUDE)/no_os_gpio.h \ + $(INCLUDE)/no_os_irq.h \ + $(INCLUDE)/no_os_list.h \ + $(INCLUDE)/no_os_uart.h \ + $(INCLUDE)/no_os_lf256fifo.h\ + $(INCLUDE)/no_os_dma.h \ + $(INCLUDE)/no_os_init.h \ + $(INCLUDE)/no_os_util.h \ + $(INCLUDE)/no_os_i2c.h \ + $(INCLUDE)/no_os_mutex.h \ + $(INCLUDE)/no_os_alloc.h \ + $(INCLUDE)/no_os_delay.h + +SRCS += $(DRIVERS)/api/no_os_gpio.c \ + $(DRIVERS)/api/no_os_irq.c \ + $(NO-OS)/util/no_os_list.c \ + $(DRIVERS)/api/no_os_uart.c \ + $(NO-OS)/util/no_os_lf256fifo.c \ + $(DRIVERS)/api/no_os_dma.c \ + $(DRIVERS)/api/no_os_i2c.c \ + $(NO-OS)/util/no_os_util.c \ + $(NO-OS)/util/no_os_mutex.c \ + $(NO-OS)/util/no_os_alloc.c + + +INCS += $(DRIVERS)/led/ltc3220/ltc3220.h +SRCS += $(DRIVERS)/led/ltc3220/ltc3220.c diff --git a/projects/ltc3220/src/common/common_data.c b/projects/ltc3220/src/common/common_data.c new file mode 100644 index 00000000000..a9ddbfe8870 --- /dev/null +++ b/projects/ltc3220/src/common/common_data.c @@ -0,0 +1,55 @@ +/***************************************************************************//** + * @file common_data.c + * @brief Defines common data to be used by LTC3220 examples. + * @author Jan Carlo Roleda (jancarlo.roleda@analog.com) +******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#include "common_data.h" + +const struct no_os_i2c_init_param iip = { + .device_id = I2C_DEVICE_ID, + .max_speed_hz = 400000, + .slave_address = DEV_I2C_ADDRESS, + .platform_ops = I2C_OPS, + .extra = <c3220_i2c_extra, +}; + +const struct no_os_gpio_init_param gip = { + .port = GPIO_RST_PIN_PORT, + .number = GPIO_RST_PIN_NUM, + .pull = NO_OS_PULL_NONE, + .platform_ops = GPIO_OPS, + .extra = <c3220_gpio_extra, +}; + +struct ltc3220_init_param ltc3220_user_init = { + .i2c_init_param = iip, + .gpio_init_param = gip, +}; diff --git a/projects/ltc3220/src/common/common_data.h b/projects/ltc3220/src/common/common_data.h new file mode 100644 index 00000000000..61384236b30 --- /dev/null +++ b/projects/ltc3220/src/common/common_data.h @@ -0,0 +1,43 @@ +/***************************************************************************//** + * @file common_data.h + * @brief Defines common data to be used by LTC3220 examples. + * @author Jan Carlo Roleda (jancarlo.roleda@analog.com) +******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ +#ifndef __COMMON_DATA_H__ +#define __COMMON_DATA_H__ + +#include "parameters.h" +#include "ltc3220.h" + +extern const struct no_os_i2c_init_param iip; +extern const struct no_os_gpio_init_param gip; +extern struct ltc3220_init_param ltc3220_user_init; + +#endif /* __COMMON_DATA_H__ */ diff --git a/projects/ltc3220/src/examples/dummy/dummy_example.c b/projects/ltc3220/src/examples/dummy/dummy_example.c new file mode 100644 index 00000000000..1134af16d9d --- /dev/null +++ b/projects/ltc3220/src/examples/dummy/dummy_example.c @@ -0,0 +1,291 @@ +/***************************************************************************//** + * @file dummy_example.c + * @brief exmaple program for Maxim platfom of LTC3220 project. + * @author Jan Carlo Roleda (jancarlo.roleda@analog.com) +******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#include "common_data.h" +#include "ltc3220.h" +#include "no_os_delay.h" +#include "dummy_example.h" + +/***************************************************************************//** + * @brief Dummy example main execution. + * + * @return ret - Result of the example execution. If working correctly, will + * execute continuously the while(1) loop and will not return. +*******************************************************************************/ +int example_main() +{ + struct ltc3220_dev *ltc3220; + int ret; + + ret = ltc3220_init(<c3220, ltc3220_user_init); + if (ret) + goto error; + + while (true) { + /* reset operations */ + ret = ltc3220_reset(ltc3220); + if (ret) + goto error_ltc3220; + + /* regular light mode */ + ltc3220_test_led_singles(ltc3220, LTC3220_MODE_NORMAL); + + no_os_mdelay(3000); + + ret = ltc3220_reset(ltc3220); + if (ret) + goto error_ltc3220; + + /* blinking (fast) */ + ltc3220_set_blink_fast(ltc3220, true); + ltc3220_set_blink_long(ltc3220, false); + ltc3220_test_led_singles(ltc3220, LTC3220_MODE_BLINK); + + no_os_mdelay(3000); + + ret = ltc3220_reset(ltc3220); + if (ret) + goto error_ltc3220; + + /* blinking (slow) */ + ltc3220_set_blink_fast(ltc3220, false); + ltc3220_set_blink_long(ltc3220, true); + ltc3220_test_led_singles(ltc3220, LTC3220_MODE_BLINK); + + no_os_mdelay(3000); + + ret = ltc3220_reset(ltc3220); + if (ret) + goto error_ltc3220; + + /* check if voltage output is ~4.6v */ + ltc3220_set_cpo_1p5x(ltc3220, true); + + + /* gradation (increasing) */ + ltc3220_set_grad_increasing(ltc3220, true); + ltc3220_set_grad_speed(ltc3220, LTC3220_GRAD_MAX_SPD); + ltc3220_test_led_singles(ltc3220, LTC3220_MODE_GRADATION); + + no_os_mdelay(3000); + + ret = ltc3220_reset(ltc3220); + if (ret) + goto error_ltc3220; + + /* gradation (decreasing) */ + ltc3220_set_grad_increasing(ltc3220, false); + ltc3220_set_grad_speed(ltc3220, LTC3220_GRAD_MAX_SPD); + ltc3220_test_led_singles(ltc3220, LTC3220_MODE_GRADATION); + + no_os_mdelay(3000); + + ret = ltc3220_reset(ltc3220); + if (ret) + goto error_ltc3220; + + /* gradation (disabled) = normal mode */ + ltc3220_set_grad_speed(ltc3220, 0); + ltc3220_test_led_singles(ltc3220, LTC3220_MODE_GRADATION); + + no_os_mdelay(3000); + + ret = ltc3220_reset(ltc3220); + if (ret) + goto error_ltc3220; + + /* using different modes on the device */ + ltc3220_set_blink_fast(ltc3220, true); + ltc3220_set_grad_speed(ltc3220, LTC3220_GRAD_MAX_SPD); + ltc3220_test_led_singles_alt_modes(ltc3220); + + no_os_mdelay(3000); + + ret = ltc3220_reset(ltc3220); + if (ret) + goto error_ltc3220; + + /* check if voltage output is ~5.1v */ + ltc3220_set_cpo_2x(ltc3220, true); + + /* use parallel and single commands on LEDs */ + ltc3220_set_blink_fast(ltc3220, true); + ltc3220_set_blink_long(ltc3220, true); + ltc3220_test_led_quick_write_with_indiv(ltc3220, LTC3220_MODE_BLINK); + + no_os_mdelay(3000); + + ret = ltc3220_reset(ltc3220); + if (ret) + goto error_ltc3220; + + /* set alternating and shutdown, restore after 5s */ + ltc3220_set_cpo_2x(ltc3220, true); + ltc3220_set_blink_fast(ltc3220, true); + ltc3220_set_grad_speed(ltc3220, LTC3220_GRAD_MAX_SPD); + ltc3220_test_led_singles_alt_modes(ltc3220); + ltc3220_set_shutdown(ltc3220, true); + + no_os_mdelay(5000); + + ltc3220_set_shutdown(ltc3220, false); + + no_os_mdelay(5000); + } + +error_ltc3220: + ltc3220_remove(ltc3220); + +error: + return -1; +} + +/***************************************************************************//** + * @brief individual LED control for all 18 LEDs + * @param ltc3220 - The device structure. + * @param mode - the mode to set all the LEDs to. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_test_led_singles(struct ltc3220_dev *ltc3220, + enum ltc3220_uled_mode mode) +{ + uint8_t power = 1; + int ret; + ret = ltc3220_set_quick_write(ltc3220, false); + if (ret) + return ret; + for (int i = LTC3220_REG_START_ULED; + i <= LTC3220_REG_END_ULED; + i++) { + ret = ltc3220_set_uled_mode(ltc3220, i, mode); + if (ret) + return ret; + ltc3220_set_uled_current(ltc3220, i, power * i); + if (ret) + return ret; + no_os_mdelay(1500); + } + + return 0; +} + +/***************************************************************************//** + * @brief individual LED control with alternating modes for all 18 LEDs + * @param ltc3220 - the device structure. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_test_led_singles_alt_modes(struct ltc3220_dev *ltc3220) +{ + uint8_t power = 1; + int ret; + ret = ltc3220_set_quick_write(ltc3220, false); + if (ret) + return ret; + for (int i = LTC3220_REG_START_ULED; + i <= LTC3220_REG_END_ULED; + i++) { + /* cycle between the 4 modes of operation*/ + ret = ltc3220_set_uled_mode(ltc3220, i, i % 4); + if (ret) + return ret; + ltc3220_set_uled_current(ltc3220, i, power * i); + if (ret) + return ret; + no_os_mdelay(1500); + } + + return 0; +} + +/***************************************************************************//** + * @brief Parallel and Serial LED control. + * LED 2 to 9 are set to serial, then LED1 is set to display on all LEDs. + * After some delay LED 9 to 18 will change mode in serial write. + * @param ltc3220 - the device structure. + * @param mode - the mode to set the individual LEDs + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_test_led_quick_write_with_indiv(struct ltc3220_dev *ltc3220, + enum ltc3220_uled_mode mode) +{ + uint8_t power = 1; + int ret; + ret = ltc3220_set_quick_write(ltc3220, true); + if (ret) + return ret; + + for (int i = LTC3220_REG_START_ULED + 1; + i <= LTC3220_REG_END_ULED / 2; + i++) { + ret = ltc3220_set_uled_mode(ltc3220, i, mode); + if (ret) + return ret; + ret = ltc3220_set_uled_current(ltc3220, i, power * i); + if (ret) + return ret; + + no_os_mdelay(1500); + } + + ret = ltc3220_set_uled_mode(ltc3220, 1, LTC3220_MODE_NORMAL); + ret = ltc3220_set_uled_current(ltc3220, 1, 1); + if (ret) + return ret; + + no_os_mdelay(3000); + + for (int i = LTC3220_REG_END_ULED / 2; + i <= LTC3220_REG_END_ULED; + i++) { + ret = ltc3220_set_uled_mode(ltc3220, i, mode); + if (ret) + return ret; + ret = ltc3220_set_uled_current(ltc3220, i, power * i); + if (ret) + return ret; + + no_os_mdelay(1500); + } + + ret = ltc3220_set_quick_write(ltc3220, false); + if (ret) + return ret; + + ret = ltc3220_set_uled_current(ltc3220, LTC3220_REG_START_ULED, 0); + if (ret) + return ret; + + no_os_mdelay(3000); + + return 0; +} diff --git a/projects/ltc3220/src/examples/dummy/dummy_example.h b/projects/ltc3220/src/examples/dummy/dummy_example.h new file mode 100644 index 00000000000..50e0eb1c0e7 --- /dev/null +++ b/projects/ltc3220/src/examples/dummy/dummy_example.h @@ -0,0 +1,74 @@ +/***************************************************************************//** + * @file dummy_example.h + * @brief Header file for example program of LTC3220 project. + * @author Jan Carlo Roleda (jancarlo.roleda@analog.com) +******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#ifndef __LTC3220_DUMMY_EXAMPLE_TESTS__ +#define __LTC3220_DUMMY_EXAMPLE_TESTS__ + +#include "ltc3220.h" + +/***************************************************************************//** + * @brief Dummy example main execution. + * + * @return ret - Result of the example execution. If working correctly, will + * execute continuously the while(1) loop and will not return. +*******************************************************************************/ +int example_main(); + +/***************************************************************************//** + * @brief individual LED control for all 18 LEDs + * @param ltc3220 - The device structure. + * @param mode - the mode to set all the LEDs to. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_test_led_singles(struct ltc3220_dev *ltc3220, + enum ltc3220_uled_mode mode); + +/***************************************************************************//** + * @brief individual LED control with alternating modes for all 18 LEDs + * @param ltc3220 - the device structure. + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_test_led_singles_alt_modes(struct ltc3220_dev *ltc3220); + +/***************************************************************************//** + * @brief Parallel and Serial LED control. + * LED 2 to 9 are set to serial, then LED1 is set to display on all LEDs. + * After some delay LED 9 to 18 will change mode in serial write. + * @param ltc3220 - the device structure. + * @param mode - the mode to set the individual LEDs + * @return 0 in case of success, negative error code otherwise. +*******************************************************************************/ +int ltc3220_test_led_quick_write_with_indiv(struct ltc3220_dev *ltc3220, + enum ltc3220_uled_mode mode); + +#endif /* __LTC3220_DUMMY_EXAMPLE_TESTS__ */ diff --git a/projects/ltc3220/src/platform/maxim/main.c b/projects/ltc3220/src/platform/maxim/main.c new file mode 100644 index 00000000000..7c4a5107b1a --- /dev/null +++ b/projects/ltc3220/src/platform/maxim/main.c @@ -0,0 +1,47 @@ +/***************************************************************************//** + * @file main.c + * @brief Main file for Maxim platfom of LTC3220 project. + * @author Jan Carlo Roleda (jancarlo.roleda@analog.com) +******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#include "parameters.h" +#include "common_data.h" + +int example_main(); + +/***************************************************************************//** + * @brief Main function execution for Maxim platform. + * + * @return ret - Result of the enabled examples execution. +*******************************************************************************/ +int main() +{ + return example_main(); +} diff --git a/projects/ltc3220/src/platform/maxim/parameters.c b/projects/ltc3220/src/platform/maxim/parameters.c new file mode 100644 index 00000000000..df31ce0c05e --- /dev/null +++ b/projects/ltc3220/src/platform/maxim/parameters.c @@ -0,0 +1,42 @@ +/***************************************************************************//** + * @file parameters.c + * @brief Definition of Maxim platform data used by LTC3220 project + * @author Jan Carlo Roleda (jancarlo.roleda@analog.com) +******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#include "parameters.h" + +struct max_i2c_init_param ltc3220_i2c_extra = { + .vssel = MXC_GPIO_VSSEL_VDDIOH +}; + +struct max_gpio_init_param ltc3220_gpio_extra = { + .vssel = MXC_GPIO_VSSEL_VDDIOH, +}; diff --git a/projects/ltc3220/src/platform/maxim/parameters.h b/projects/ltc3220/src/platform/maxim/parameters.h new file mode 100644 index 00000000000..2a73f4bd9e2 --- /dev/null +++ b/projects/ltc3220/src/platform/maxim/parameters.h @@ -0,0 +1,69 @@ +/***************************************************************************//** + * @file parameters.c + * @brief Definition header of Maxim platform data used by LTC3220 project + * @author Jan Carlo Roleda (jancarlo.roleda@analog.com) +******************************************************************************** + * Copyright 2025(c) Analog Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of Analog Devices, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ +#ifndef __PARAMETERS_H__ +#define __PARAMETERS_H__ + +#include "maxim_i2c.h" +#include "maxim_gpio.h" + +#ifdef DEVICE_VARIANT_1 +#define DEV_I2C_ADDRESS 0x1D +#else +#define DEV_I2C_ADDRESS 0x1C +#endif + +#if (TARGET_NUM == 32650) || (TARGET_NUM == 78000) +#define I2C_DEVICE_ID 1 +#elif (TARGET_NUM == 32655) +#define I2C_DEVICE_ID 2 +#elif (TARGET_NUM == 32665) || (TARGET_NUM == 32660) || (TARGET_NUM == 32690) +#define I2C_DEVICE_ID 0 +#endif + +#define I2C_OPS &max_i2c_ops + +#define GPIO_OPS &max_gpio_ops + +#if (TARGET_NUM == 32690) +#define GPIO_RST_PIN_NUM 14 +#define GPIO_RST_PIN_PORT 0 +#elif (TARGET_NUM == 32655) +#define GPIO_RST_PIN_NUM 9 +#define GPIO_RST_PIN_PORT 1 +#endif + +extern struct max_gpio_init_param ltc3220_gpio_extra; + +extern struct max_i2c_init_param ltc3220_i2c_extra; + +#endif /* __PARAMETERS_H__ */ diff --git a/projects/ltc3220/src/platform/maxim/platform_src.mk b/projects/ltc3220/src/platform/maxim/platform_src.mk new file mode 100644 index 00000000000..8ca254f923c --- /dev/null +++ b/projects/ltc3220/src/platform/maxim/platform_src.mk @@ -0,0 +1,15 @@ +INCS += $(PLATFORM_DRIVERS)/maxim_gpio.h \ + $(PLATFORM_DRIVERS)/maxim_i2c.h \ + $(PLATFORM_DRIVERS)/maxim_irq.h \ + $(PLATFORM_DRIVERS)/../common/maxim_dma.h \ + $(PLATFORM_DRIVERS)/maxim_uart.h \ + $(PLATFORM_DRIVERS)/maxim_uart_stdio.h + +SRCS += $(PLATFORM_DRIVERS)/maxim_delay.c \ + $(PLATFORM_DRIVERS)/maxim_gpio.c \ + $(PLATFORM_DRIVERS)/maxim_i2c.c \ + $(PLATFORM_DRIVERS)/../common/maxim_dma.c\ + $(PLATFORM_DRIVERS)/maxim_init.c \ + $(PLATFORM_DRIVERS)/maxim_irq.c \ + $(PLATFORM_DRIVERS)/maxim_uart.c \ + $(PLATFORM_DRIVERS)/maxim_uart_stdio.c From 3804edd9c4c54a2e3dfbdd9a4669564735ed9c01 Mon Sep 17 00:00:00 2001 From: "Roleda, Jan carlo" Date: Tue, 28 Oct 2025 09:40:15 +0800 Subject: [PATCH 3/4] drivers: led: ltc3220: add README Documentation for LTC3220 Added driver documentation for LTC3220 LED driver Signed-off-by: Jan Carlo Roleda --- doc/sphinx/source/drivers/led/ltc3220.rst | 1 + drivers/led/ltc3220/README.rst | 123 ++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 doc/sphinx/source/drivers/led/ltc3220.rst create mode 100644 drivers/led/ltc3220/README.rst diff --git a/doc/sphinx/source/drivers/led/ltc3220.rst b/doc/sphinx/source/drivers/led/ltc3220.rst new file mode 100644 index 00000000000..5d16822e8e7 --- /dev/null +++ b/doc/sphinx/source/drivers/led/ltc3220.rst @@ -0,0 +1 @@ +.. include:: ../../../../../drivers/led/ltc3220/README.rst \ No newline at end of file diff --git a/drivers/led/ltc3220/README.rst b/drivers/led/ltc3220/README.rst new file mode 100644 index 00000000000..a3ef0e947dd --- /dev/null +++ b/drivers/led/ltc3220/README.rst @@ -0,0 +1,123 @@ +LTC3220 no-OS driver +==================== + +.. no-os-doxygen:: + +Supported Devices +----------------- + +`LTC3220 `_ + +Overview +-------- + +The LTC3220 is a highly integrated multi-display LED drivers. +These parts contain a high efficiency, low noise charge pump to provide power +to up to eighteen universal LED current sources. The LED currents are set by +an internal precision current reference. Independent dimming, on/off, +blinking and gradation control for all universal current sources is achieved +via the I2C serial interface. 6-bit linear DACs are available to adjust +brightness levels independently for each universal LED current source. + +The LTC3220 charge pump optimizes efficiency based on the voltage +across the LED current sources. The part powers up in 1x mode and +will automatically switch to boost mode whenever any enabled LED current source +begins to enter dropout. The first dropout switches the parts into 1.5x mode +and a subsequent dropout switches the LTC3220 into 2x mode. The parts reset to +1x mode whenever a data bit is updated via the I2C port. + +There are two I2C addresses available. The LTC3220 I2C address is 0011100 +and the LTC3220-1 I2C address is 0011101. The I2C address is the only difference +between the LTC3220 and LTC3220-1. + +Applications +------------ + +* Video Phones with QVGA+ Displays +* Keypad Lighting +* General/Miscellaneous Lighting + +LTC3220 Device Configuration +---------------------------- + +Driver Initialization +--------------------- + +In order to be able to use the device, you will have to provide the support for +the communication protocol (SPI) as mentioned above. + +The first API to be called is **ltc3220_init**. Make sure that it returns 0, +which means that the driver was initialized correctly. + +After successful initialization, it is recommended to perform a device reset by +calling **ltc3220_reset** in order to put the device in a known initial state, +where all the registers on the device are reset to 0. + +ULED Configuration +------------------ + +Each of the 18 LEDs are individually configurable to a specific mode +of operation and adjustable current output, using a 6-bit DAC +to provide 64 levels of resolution from 0mA to 20mA. + +The supported modes of operation are: + +1. Normal - provides a current output for an LED attached to its pins. +2. Blinking - performs a blinking operation with configurable period and + rise time in the Blink Configuration +3. Gradation - performs a gradation to gradually adjust the current provided + to the output, configurable to rising or falling and adjusting its ramp time + and period. +4. General Purpouse Output (GPO) - Configures the output to run in current + limited mode or as a strong pull-down output if the output current is 0mA. + +The ULED registers can be updated by using **ltc3220_set_uled_mode** and +**ltc3220_set_uled_current**, or together in the respective ULEDs' register via +**ltc3220_update_reg_uled**, where the 2 upper bits written correspond to the +mode of operation, and the 6 lower bits are for the DAC. + +If the device command register has quick write set, writing a mode and current +output level on ULED1 will perform a parallel write to all ULED outputs. + +Device Command Configuration +---------------------------- + +The device can be forced to operate on a specific charge pump configuration, be +written to in parallel through ULED1, and be shutdown while maintaining the +latest device configuration registers. This can be set individually via +**ltc3220_set_quick_write**, **ltc3220_set_cpo_1x**, **ltc3220_set_cpo_1p5x**, +**ltc3220_set_cpo_2x**, **ltc3220_set_shutdown**, or directly to the register +via **ltc3220_update_reg_command**, where the 4 lower bits of the register +corresponds to the above set configurations, according to the +device's datasheet. + +Blink Configuration +------------------- + +The blinking mode of operation for ULED outputs can be configured to have a +longer blinking period and a faster rise time in current. These can be +configured with **ltc3220_set_blink_fast** and **ltc3220_set_blink_long**, or +together in the Blink and Gradation Configuration register via +**ltc3220_update_reg_blink_grad**. Note that this also configures +the gradation configuration as they share the same configuration register. + +Gradation Configuration +----------------------- + +The gradation mode of operation for ULED outputs can be configured to increase +or decrease in brightness by gradually adjusting the current output based on an +internal counter. This counter resets to its maximum when set to decreasing, and +resets to its minimum when set to increasing. This can be set by using +**ltc3220_set_grad_increasing**. + +Note that in increasing gradation, the counter remains at its maximum if another +LED is set to gradation mode. The newly set LED will immediately appear with its +maximum current and will not rise towards it. + +The ramp time and period of gradation is also configurable from disabling +gradation to a ramp time of 0.96s to 0.24s and a period of 1.25s to 0.313s, +set by using **ltc3220_set_grad_speed**. + +Alternatively these can be set together in the Blink and Gradation Configuration +register via **ltc3220_update_reg_blink_grad**. Note that this also configures +the blink configuration as they share the same configuration register. From 2442b737a78ae6e32be67e73c06bf2cc94f8808d Mon Sep 17 00:00:00 2001 From: "Roleda, Jan carlo" Date: Tue, 28 Oct 2025 09:41:04 +0800 Subject: [PATCH 4/4] projects: led: ltc3220: add README documentation for LTC3220 Added project documentation for LTC3220 Driver Example Signed-off-by: Jan Carlo Roleda --- doc/sphinx/source/projects/led/ltc3220.rst | 1 + doc/sphinx/source/projects_doc.rst | 10 +- projects/ltc3220/README.rst | 147 +++++++++++++++++++++ 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 doc/sphinx/source/projects/led/ltc3220.rst create mode 100644 projects/ltc3220/README.rst diff --git a/doc/sphinx/source/projects/led/ltc3220.rst b/doc/sphinx/source/projects/led/ltc3220.rst new file mode 100644 index 00000000000..42386db2465 --- /dev/null +++ b/doc/sphinx/source/projects/led/ltc3220.rst @@ -0,0 +1 @@ +.. include:: ../../../../../projects/ltc3220/README.rst diff --git a/doc/sphinx/source/projects_doc.rst b/doc/sphinx/source/projects_doc.rst index 01730a1ce08..c312ba56d87 100644 --- a/doc/sphinx/source/projects_doc.rst +++ b/doc/sphinx/source/projects_doc.rst @@ -98,4 +98,12 @@ GYROSCOPES :maxdepth: 1 :glob: - projects/gyroscope/* \ No newline at end of file + projects/gyroscope/* + +LED +=== +.. toctree:: + :maxdepth: 1 + :glob: + + projects/led/* diff --git a/projects/ltc3220/README.rst b/projects/ltc3220/README.rst new file mode 100644 index 00000000000..a4cc03ec5be --- /dev/null +++ b/projects/ltc3220/README.rst @@ -0,0 +1,147 @@ +Evaluating the LTC3220 +====================== + + +Supported Evaluation Boards +--------------------------- + +* DC1265A-A (LTC3220) +* DC1265A-B (LTC3220-1) + + +Overview +-------- + +The LTC3220/LTC3220-1 are highly integrated multi-display LED drivers. +These parts contain a high efficiency, low noise charge pump to provide power +to up to eighteen universal LED current sources.The LED currents are set by an +internal precision current reference. Independent dimming, on/off, blinking and +gradation control for all universal current sources are achieved via the +I2C serial interface. 6-bit linear DACs are available to adjust brightness +levels independently for each universal LED current source. + +The LTC3220/LTC3220-1 charge pump optimizes efficiency based on the voltage +across the LED current sources. The part powers up in 1x mode and will +automatically switch to boost mode whenever any enabled LED current source +begins to enter dropout. The first dropout switches the parts into 1.5x mode +and a subsequent dropout switches the LTC3220/LTC3220-1 into 2x mode. + +The LTC3220 maintains an I2C address of 0x1C. Its LTC3220-1 maintains an address +of 0x1D. There is no other difference between the two apart from this. + +Power Supply Requirements +------------------------- + +A seperate power supply capable of providing 3V, up to 400mA is required for +the device's maximum capabilities. The logic signals used for the I2C protocol +uses 3.3V via the controller as a logic high reference. + +**Pin Description**: + ++-----+-----------+-------------------------------------------+ +| Pin | Name | Description | ++-----+-----------+-------------------------------------------+ +| 1 | ULED1 | Current Source Output 1 | ++-----+-----------+-------------------------------------------+ +| 2 | ULED2 | Current Source Output 2 | ++-----+-----------+-------------------------------------------+ +| 3 | ULED3 | Current Source Output 3 | ++-----+-----------+-------------------------------------------+ +| 4 | ULED4 | Current Source Output 4 | ++-----+-----------+-------------------------------------------+ +| 5 | ULED5 | Current Source Output 5 | ++-----+-----------+-------------------------------------------+ +| 6 | ULED6 | Current Source Output 6 | ++-----+-----------+-------------------------------------------+ +| 7 | ULED7 | Current Source Output 7 | ++-----+-----------+-------------------------------------------+ +| 8 | ULED8 | Current Source Output 8 | ++-----+-----------+-------------------------------------------+ +| 9 | ULED9 | Current Source Output 9 | ++-----+-----------+-------------------------------------------+ +| 10 | V_CC | Digital I/O Supply Voltage | ++-----+-----------+-------------------------------------------+ +| 11 | SCL | I2C Clock Input | ++-----+-----------+-------------------------------------------+ +| 12 | SDA | I2C Data Input | ++-----+-----------+-------------------------------------------+ +| 13 | ULED10 | Current Source Output 10 | ++-----+-----------+-------------------------------------------+ +| 14 | ULED11 | Current Source Output 11 | ++-----+-----------+-------------------------------------------+ +| 15 | ULED12 | Current Source Output 12 | ++-----+-----------+-------------------------------------------+ +| 16 | ULED13 | Current Source Output 13 | ++-----+-----------+-------------------------------------------+ +| 17 | ULED14 | Current Source Output 14 | ++-----+-----------+-------------------------------------------+ +| 18 | ULED15 | Current Source Output 15 | ++-----+-----------+-------------------------------------------+ +| 19 | ULED16 | Current Source Output 16 | ++-----+-----------+-------------------------------------------+ +| 20 | ULED17 | Current Source Output 17 | ++-----+-----------+-------------------------------------------+ +| 21 | ULED18 | Current Source Output 18 | ++-----+-----------+-------------------------------------------+ +| 24 | V_IN | Supply Voltage | ++-----+-----------+-------------------------------------------+ +| 25 | RST | Active Low Reset Input | ++-----+-----------+-------------------------------------------+ +| 28 | CPO | Charge Pump Output | ++-----+-----------+-------------------------------------------+ +| 29 | GND | Ground Pad | ++-----+-----------+-------------------------------------------+ + +No-OS Build Setup +----------------- + +Please refer to the Analog Wiki: https://wiki.analog.com/resources/no-os/build + + +No-OS Supported Platforms +------------------------- + +The initialization data used in the examples is taken out from: +`Project Common Data Path `_ + +The macros used in Common data are defined in platfor-specific files found in: +`Project Platform Configuration Path `_ + +Maxim Platform +-------------- + +**Used Hardware** + +* `DC1265A-A `_ +* `MAX32690 `_ + +**Connections**: + ++----------+-----------------------+ +| LTC3220 | MAX32655 Pinouts | ++----------+-----------------------+ +| V_IN | Power Supply | ++----------+-----------------------+ +| V_CC | 3v3 | ++----------+-----------------------+ +| GND | GND | ++----------+-----------------------+ +| I2C_SCL | P2_8 | ++----------+-----------------------+ +| I2C_SDA | P2_7 | ++----------+-----------------------+ +| RST | P0_14 | ++----------+-----------------------+ + +** Build Command ** + +.. code-block:: bash + + # to delete current build + make reset + + #to build project + make TARGET=max32690 + + # to flash the code to the controller + make TARGET=max32690 run