no-OS
Loading...
Searching...
No Matches
ltc3220.h
Go to the documentation of this file.
1/***************************************************************************/
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44#ifndef __LTC3220_H__
45#define __LTC3220_H__
46
47#include "no_os_i2c.h"
48#include "no_os_gpio.h"
49#include "no_os_util.h"
50
51/*ltc3220 register addresses*/
52#define LTC3220_REG_COMMAND 0x00
53#define LTC3220_REG_START_ULED 0x01 /*ULED1 */
54#define LTC3220_REG_END_ULED 0x12 /*ULED18*/
55#define LTC3220_REG_BLINK_GRAD 0x13
56
57/*command register (0x00) */
58#define LTC3220_COMMAND_QUICK_WRITE_MASK NO_OS_BIT(0)
59#define LTC3220_COMMAND_1P5X_MASK NO_OS_BIT(1)
60#define LTC3220_COMMAND_2X_MASK NO_OS_BIT(2)
61#define LTC3220_COMMAND_SHUTDOWN NO_OS_BIT(3)
62
63/* ULEDxx registers (0x01-0x12) */
64#define LTC3220_ULED_MODE_MASK NO_OS_GENMASK(7,6)
65#define LTC3220_ULED_CURRENT_MASK NO_OS_GENMASK(5,0)
66#define LTC3220_ULED_CURRENT_MAX_STEP 64
67
68/* Blink/Gradation (0x13) */
69#define LTC3220_BLINK_LONG_MASK NO_OS_BIT(4)
70#define LTC3220_BLINK_FAST_MASK NO_OS_BIT(3)
71#define LTC3220_GRAD_SPD_MASK NO_OS_GENMASK(2,1)
72#define LTC3220_GRAD_DIRECTION_MASK NO_OS_BIT(0)
73#define LTC3220_GRAD_MAX_SPD 3
74
75/* Reset timing */
76#define LTC3220_RESET_DELAY_USEC 1 /*20ns min */
77
79 LTC3220 = 0x1C,
80 LTC3220_1 = 0x1D
81};
82
89
96
97static const struct ltc3220_command_cfg command_reset;
98
103
104static const struct ltc3220_uled_cfg uled_reset;
105
110
111static const struct ltc3220_blink_cfg blink_reset;
112
114 uint8_t speed;
116};
117
118static const struct ltc3220_grad_cfg grad_reset;
119
122
124
125 /* Contains configuration of each ULED */
127
128 /* Contains configuration of device */
130
131 /* Blink mode configuration */
133
134 /* Gradation mode configuration */
136};
137
142
149int ltc3220_init(struct ltc3220_dev **device,
151
158
164int ltc3220_reset(struct ltc3220_dev *device);
165
173int ltc3220_reg_write(struct ltc3220_dev *device, uint8_t reg_addr,
174 uint8_t reg_data);
175
183int ltc3220_set_uled_mode(struct ltc3220_dev *device, uint8_t uled_number,
184 enum ltc3220_uled_mode mode);
185
193int ltc3220_set_uled_current(struct ltc3220_dev *device, uint8_t uled_number,
194 uint8_t current_level);
195
204int ltc3220_update_reg_uled(struct ltc3220_dev *device, uint8_t uled_number,
205 enum ltc3220_uled_mode mode, uint8_t current_level);
206
213int ltc3220_set_blink_fast(struct ltc3220_dev *device, bool is_fast_on);
214
221int ltc3220_set_blink_long(struct ltc3220_dev *device, bool is_long_period);
222
229int ltc3220_set_grad_speed(struct ltc3220_dev *device, uint8_t speed);
230
237int ltc3220_set_grad_increasing(struct ltc3220_dev *device, bool is_increasing);
238
249 bool is_blink_fast, bool is_blink_long, bool is_grad_inc,
250 uint8_t grad_speed);
251
258int ltc3220_set_quick_write(struct ltc3220_dev *device, bool is_quick_write);
259
266int ltc3220_set_cpo_1x(struct ltc3220_dev *device, bool is_force_cpo_1x);
267
274int ltc3220_set_cpo_1p5x(struct ltc3220_dev *device, bool is_force_cpo_1p5x);
275
282int ltc3220_set_cpo_2x(struct ltc3220_dev *device, bool is_force_cpo_2x);
283
290int ltc3220_set_shutdown(struct ltc3220_dev *device, bool is_shutdown);
291
292
302int ltc3220_update_reg_command(struct ltc3220_dev *device, bool is_shutdown,
303 bool is_force_cpo_2x, bool is_force_cpo_1p5x,
304 bool is_quick_write);
305
306#endif /*__LTC3220_H__*/
307
308#ifdef __cplusplus
309}
310#endif
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
#define LTC3220_REG_END_ULED
Definition ltc3220.h:54
int ltc3220_reg_write(struct ltc3220_dev *device, uint8_t reg_addr, uint8_t reg_data)
Writes to the selected register on the device.
Definition ltc3220.c:153
int ltc3220_set_grad_speed(struct ltc3220_dev *device, uint8_t speed)
Sets the configuration of the device's speed of gradation.
Definition ltc3220.c:333
int ltc3220_set_blink_long(struct ltc3220_dev *device, bool is_long_period)
Sets the configuration for blinking mode of ULEDs.
Definition ltc3220.c:289
int ltc3220_set_shutdown(struct ltc3220_dev *device, bool is_shutdown)
Sets the device to shutdown mode, while retaining the register configurations.
Definition ltc3220.c:473
int ltc3220_set_grad_increasing(struct ltc3220_dev *device, bool is_increasing)
Sets the configuration for the device's direction of gradation.
Definition ltc3220.c:311
int ltc3220_init(struct ltc3220_dev **device, struct ltc3220_init_param init_param)
Initializes the LTC3220 device structure.
Definition ltc3220.c:55
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.
Definition ltc3220.c:499
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.
Definition ltc3220.c:365
int ltc3220_set_blink_fast(struct ltc3220_dev *device, bool is_fast_on)
Sets the configuration for blinking mode of ULEDs.
Definition ltc3220.c:266
ltc3220_variant
Definition ltc3220.h:78
@ LTC3220
Definition ltc3220.h:79
@ LTC3220_1
Definition ltc3220.h:80
int ltc3220_set_quick_write(struct ltc3220_dev *device, bool is_quick_write)
Sets the configuration to perform a quick write to the device.
Definition ltc3220.c:384
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.
Definition ltc3220.c:428
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.
Definition ltc3220.c:229
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.
Definition ltc3220.c:200
int ltc3220_reset(struct ltc3220_dev *device)
Resets the device using the RST pin.
Definition ltc3220.c:122
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.
Definition ltc3220.c:406
ltc3220_uled_mode
Definition ltc3220.h:83
@ LTC3220_MODE_GRADATION
Definition ltc3220.h:86
@ LTC3220_MODE_GPO
Definition ltc3220.h:87
@ LTC3220_MODE_NORMAL
Definition ltc3220.h:84
@ LTC3220_MODE_BLINK
Definition ltc3220.h:85
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.
Definition ltc3220.c:174
int ltc3220_remove(struct ltc3220_dev *device)
Deallocates the resources for the device structure.
Definition ltc3220.c:91
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.
Definition ltc3220.c:450
Header file of GPIO Interface.
Header file of I2C Interface.
Header file of utility functions.
Definition ad9361_util.h:63
Definition ltc3220.h:90
bool is_shutdown
Definition ltc3220.h:94
bool is_force_cpo_1p5x
Definition ltc3220.h:92
bool is_quick_write
Definition ltc3220.h:91
bool is_force_cpo_2x
Definition ltc3220.h:93
Definition ltc3220.h:120
struct ltc3220_uled_cfg uleds[LTC3220_REG_END_ULED]
Definition ltc3220.h:126
struct no_os_gpio_desc * gpio_rst_desc
Definition ltc3220.h:123
struct no_os_i2c_desc * i2c_desc
Definition ltc3220.h:121
struct ltc3220_command_cfg command_config
Definition ltc3220.h:129
struct ltc3220_blink_cfg blink_config
Definition ltc3220.h:132
struct ltc3220_grad_cfg gradation_config
Definition ltc3220.h:135
Definition ltc3220.h:113
bool is_increasing
Definition ltc3220.h:115
uint8_t speed
Definition ltc3220.h:114
Definition ltc3220.h:138
struct no_os_i2c_init_param i2c_init_param
Definition ltc3220.h:139
struct no_os_gpio_init_param gpio_init_param
Definition ltc3220.h:140
Definition ltc3220.h:99
uint8_t current_level
Definition ltc3220.h:101
enum ltc3220_uled_mode mode
Definition ltc3220.h:100
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding I2C address descriptor.
Definition no_os_i2c.h:89
Structure holding the parameters for I2C initialization.
Definition no_os_i2c.h:52