no-OS
Loading...
Searching...
No Matches
ltc3220.h File Reference

Header file of LTC3220 Driver. More...

#include "no_os_i2c.h"
#include "no_os_gpio.h"
#include "no_os_util.h"
Include dependency graph for ltc3220.h:

Classes

struct  ltc3220_command_cfg
 
struct  ltc3220_uled_cfg
 
struct  ltc3220_blink_cfg
 
struct  ltc3220_grad_cfg
 
struct  ltc3220_dev
 
struct  ltc3220_init_param
 

Macros

#define __LTC3220_H__
 
#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
 
#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)
 
#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
 
#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
 
#define LTC3220_RESET_DELAY_USEC   1 /*20ns min */
 

Enumerations

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
}
 

Functions

int ltc3220_init (struct ltc3220_dev **device, struct ltc3220_init_param init_param)
 Initializes the LTC3220 device structure.
 
int ltc3220_remove (struct ltc3220_dev *device)
 Deallocates the resources for the device structure.
 
int ltc3220_reset (struct ltc3220_dev *device)
 Resets the device using the RST pin.
 
int ltc3220_reg_write (struct ltc3220_dev *device, uint8_t reg_addr, uint8_t reg_data)
 Writes to the selected register on the device.
 
int ltc3220_set_uled_mode (struct ltc3220_dev *device, uint8_t uled_number, enum ltc3220_uled_mode mode)
 Sets the selected ULED register's operating mode.
 
int ltc3220_set_uled_current (struct ltc3220_dev *device, uint8_t uled_number, uint8_t current_level)
 Sets the selected ULED register's current strength.
 
int ltc3220_update_reg_uled (struct ltc3220_dev *device, uint8_t uled_number, enum ltc3220_uled_mode mode, uint8_t current_level)
 Updates the configuration set on the device's ULED based on the config.
 
int ltc3220_set_blink_fast (struct ltc3220_dev *device, bool is_fast_on)
 Sets the configuration for blinking mode of ULEDs.
 
int ltc3220_set_blink_long (struct ltc3220_dev *device, bool is_long_period)
 Sets the configuration for blinking mode of ULEDs.
 
int ltc3220_set_grad_speed (struct ltc3220_dev *device, uint8_t speed)
 Sets the configuration of the device's speed of gradation.
 
int ltc3220_set_grad_increasing (struct ltc3220_dev *device, bool is_increasing)
 Sets the configuration for the device's direction of gradation.
 
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)
 Updates the configuration set on the device's Blink/Gradation based on the config.
 
int ltc3220_set_quick_write (struct ltc3220_dev *device, bool is_quick_write)
 Sets the configuration to perform a quick write to the device.
 
int ltc3220_set_cpo_1x (struct ltc3220_dev *device, bool is_force_cpo_1x)
 Sets the device's charge pump to output 1x of operating voltage.
 
int ltc3220_set_cpo_1p5x (struct ltc3220_dev *device, bool is_force_cpo_1p5x)
 Sets the device's charge pump to output 1.5x of operating voltage.
 
int ltc3220_set_cpo_2x (struct ltc3220_dev *device, bool is_force_cpo_2x)
 Sets the device's charge pump to output 2x of operating voltage.
 
int ltc3220_set_shutdown (struct ltc3220_dev *device, bool is_shutdown)
 Sets the device to shutdown mode, while retaining the register configurations.
 
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)
 Updates the configuration set on the.
 

Detailed Description

Header file of LTC3220 Driver.

Author
Jan Carlo Roleda (Janca.nosp@m.rlo..nosp@m.roled.nosp@m.a@an.nosp@m.alog..nosp@m.com)

Copyright 2025(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ __LTC3220_H__

#define __LTC3220_H__

◆ LTC3220_BLINK_FAST_MASK

#define LTC3220_BLINK_FAST_MASK   NO_OS_BIT(3)

◆ LTC3220_BLINK_LONG_MASK

#define LTC3220_BLINK_LONG_MASK   NO_OS_BIT(4)

◆ LTC3220_COMMAND_1P5X_MASK

#define LTC3220_COMMAND_1P5X_MASK   NO_OS_BIT(1)

◆ LTC3220_COMMAND_2X_MASK

#define LTC3220_COMMAND_2X_MASK   NO_OS_BIT(2)

◆ LTC3220_COMMAND_QUICK_WRITE_MASK

#define LTC3220_COMMAND_QUICK_WRITE_MASK   NO_OS_BIT(0)

◆ LTC3220_COMMAND_SHUTDOWN

#define LTC3220_COMMAND_SHUTDOWN   NO_OS_BIT(3)

◆ LTC3220_GRAD_DIRECTION_MASK

#define LTC3220_GRAD_DIRECTION_MASK   NO_OS_BIT(0)

◆ LTC3220_GRAD_MAX_SPD

#define LTC3220_GRAD_MAX_SPD   3

◆ LTC3220_GRAD_SPD_MASK

#define LTC3220_GRAD_SPD_MASK   NO_OS_GENMASK(2,1)

◆ LTC3220_REG_BLINK_GRAD

#define LTC3220_REG_BLINK_GRAD   0x13

◆ LTC3220_REG_COMMAND

#define LTC3220_REG_COMMAND   0x00

◆ LTC3220_REG_END_ULED

#define LTC3220_REG_END_ULED   0x12 /*ULED18*/

◆ LTC3220_REG_START_ULED

#define LTC3220_REG_START_ULED   0x01 /*ULED1 */

◆ LTC3220_RESET_DELAY_USEC

#define LTC3220_RESET_DELAY_USEC   1 /*20ns min */

◆ LTC3220_ULED_CURRENT_MASK

#define LTC3220_ULED_CURRENT_MASK   NO_OS_GENMASK(5,0)

◆ LTC3220_ULED_CURRENT_MAX_STEP

#define LTC3220_ULED_CURRENT_MAX_STEP   64

◆ LTC3220_ULED_MODE_MASK

#define LTC3220_ULED_MODE_MASK   NO_OS_GENMASK(7,6)

Enumeration Type Documentation

◆ ltc3220_uled_mode

Enumerator
LTC3220_MODE_NORMAL 
LTC3220_MODE_BLINK 
LTC3220_MODE_GRADATION 
LTC3220_MODE_GPO 

◆ ltc3220_variant

Enumerator
LTC3220 
LTC3220_1 

Function Documentation

◆ ltc3220_init()

int ltc3220_init ( struct ltc3220_dev ** device,
struct ltc3220_init_param init_param )

Initializes the LTC3220 device structure.

Parameters
device- The device structure to initialize.
init_param- The initialization parameters.
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_reg_write()

int ltc3220_reg_write ( struct ltc3220_dev * device,
uint8_t reg_addr,
uint8_t reg_data )

Writes to the selected register on the device.

Parameters
device- The device structure.
reg_addr- The register sub-address.
reg_data- The data to write into the register (8-bits wide)
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_remove()

int ltc3220_remove ( struct ltc3220_dev * device)

Deallocates the resources for the device structure.

Parameters
device- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_reset()

int ltc3220_reset ( struct ltc3220_dev * device)

Resets the device using the RST pin.

Parameters
device- the device structure.
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_set_blink_fast()

int ltc3220_set_blink_fast ( struct ltc3220_dev * device,
bool is_fast_on )

Sets the configuration for blinking mode of ULEDs.

Parameters
device- The device structure.
is_fast_on- Sets whether blinking should turn on fast (0.156s) or not (0.625s)
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_set_blink_long()

int ltc3220_set_blink_long ( struct ltc3220_dev * device,
bool is_long_period )

Sets the configuration for blinking mode of ULEDs.

Parameters
device- The device structure.
is_long_period- Sets whether blinking should have a shorter (1.25s) or longer (2.5s) period
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_set_cpo_1p5x()

int ltc3220_set_cpo_1p5x ( struct ltc3220_dev * device,
bool is_force_cpo_1p5x )

Sets the device's charge pump to output 1.5x of operating voltage.

Parameters
device- The device structure.
is_force_cpo_1p5x- Sets the device's to use 1.5x voltage.
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_set_cpo_1x()

int ltc3220_set_cpo_1x ( struct ltc3220_dev * device,
bool is_force_cpo_1x )

Sets the device's charge pump to output 1x of operating voltage.

Parameters
device- The device structure.
is_force_cpo_1x- Sets the device's to use 1x voltage.
Returns
0 in case of success, negative error code otherwise.
Parameters
device- The device structure.
is_force_cpo_1x- Set if the device's is to use 1x voltage.
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_set_cpo_2x()

int ltc3220_set_cpo_2x ( struct ltc3220_dev * device,
bool is_force_cpo_2x )

Sets the device's charge pump to output 2x of operating voltage.

Parameters
device- The device structure.
is_force_cpo_2x- Sets the device's to use 2x voltage.
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_set_grad_increasing()

int ltc3220_set_grad_increasing ( struct ltc3220_dev * device,
bool is_increasing )

Sets the configuration for the device's direction of gradation.

Parameters
device- The device structure.
is_increasing- Set for increasing gradation, unset if decreasing gradation.
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_set_grad_speed()

int ltc3220_set_grad_speed ( struct ltc3220_dev * device,
uint8_t speed )

Sets the configuration of the device's speed of gradation.

Parameters
device- The device structure.
speed- Sets the speed of gradation, with slowest speed at max setting (3). Set to 0 to disable gradation.
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_set_quick_write()

int ltc3220_set_quick_write ( struct ltc3220_dev * device,
bool is_quick_write )

Sets the configuration to perform a quick write to the device.

Parameters
device- The device structure.
is_quick_write- Set for quick write operation. This copies the configuration set on ULED1 to all other ULED registers.
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_set_shutdown()

int ltc3220_set_shutdown ( struct ltc3220_dev * device,
bool is_shutdown )

Sets the device to shutdown mode, while retaining the register configurations.

Parameters
device- The device structure.
is_shutdown- Signals the device to shutdown.
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_set_uled_current()

int ltc3220_set_uled_current ( struct ltc3220_dev * device,
uint8_t uled_number,
uint8_t current_level )

Sets the selected ULED register's current strength.

Parameters
device- The device structure.
uled_number- The ULED to select (1-indexed).
current_level- The current strength from 0 to 20mA to set on the corresponding ULED pin (64 levels)
Returns
0 in case of success, negative error code otherwise.
Parameters
device- The device structure.
uled_number- The ULED to select (1-indexed).
current_level- The current strength from 0 to 20mA to set on the corresponding ULED pin (64 levels)

◆ ltc3220_set_uled_mode()

int ltc3220_set_uled_mode ( struct ltc3220_dev * device,
uint8_t uled_number,
enum ltc3220_uled_mode mode )

Sets the selected ULED register's operating mode.

Parameters
device- The device structure.
uled_number- The ULED to select (1-indexed).
mode- The mode to set the ULED to.
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_update_reg_blink_grad()

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 )

Updates the configuration set on the device's Blink/Gradation based on the config.

Parameters
device- The device's structure.
is_blink_fast- Sets whether blinking should turn on fast (0.156s) or not (0.625s)
is_blink_long- Sets whether blinking should have a shorter (1.25s) or longer (2.5s) period
is_grad_inc- Set for increasing gradation, unset if decreasing gradation.
grad_speed- Sets the speed of gradation, with slowest speed at max setting (3). Set to 0 to disable gradation.
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_update_reg_command()

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 )

Updates the configuration set on the.

Parameters
device- The device's structure.
is_shutdown- Signals the device to shutdown.
is_force_cpo_1p5x- Sets the device's to use 1.5x voltage.
is_force_cpo_2x- Sets the device's to use 2x voltage.
is_quick_write- Set for quick write operation. This copies the configuration set on ULED1 to all other ULED registers.
Returns
0 in case of success, negative error code otherwise.

◆ ltc3220_update_reg_uled()

int ltc3220_update_reg_uled ( struct ltc3220_dev * device,
uint8_t uled_number,
enum ltc3220_uled_mode mode,
uint8_t current_level )

Updates the configuration set on the device's ULED based on the config.

Parameters
device- The device structure.
uled_number- The ULED to select (1-indexed).
mode- The mode to set the ULED to.
current_level- The current strength from 0 to 20mA to set on the corresponding ULED pin (64 levels)
Returns
0 in case of success, negative error code otherwise.

Updates the configuration set on the device's ULED based on the config.

Parameters
device- The device structure.
uled_number- The ULED to select (1-indexed).
mode- The mode to set the ULED to.
current_level- The current strength from 0 to 20mA to set on the corresponding ULED pin (64 levels)
Returns
0 in case of success, negative error code otherwise.