ledring2  2.1.0.0
ledring2.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef LEDRING2_H
29 #define LEDRING2_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
38 
60 #define LEDRING2_REG_CHIP_EN 0x0000
61 #define LEDRING2_REG_DEV_INITIAL 0x0001
62 #define LEDRING2_REG_DEV_CONFIG1 0x0002
63 #define LEDRING2_REG_DEV_CONFIG2 0x0003
64 #define LEDRING2_REG_DEV_CONFIG3 0x0004
65 #define LEDRING2_REG_GLOBAL_BRI 0x0005
66 #define LEDRING2_REG_GROUP0_BRI 0x0006
67 #define LEDRING2_REG_GROUP1_BRI 0x0007
68 #define LEDRING2_REG_GROUP2_BRI 0x0008
69 #define LEDRING2_REG_R_CURRENT_SET 0x0009
70 #define LEDRING2_REG_G_CURRENT_SET 0x000A
71 #define LEDRING2_REG_B_CURRENT_SET 0x000B
72 #define LEDRING2_REG_DOT_GRP_SEL0 0x000C
73 #define LEDRING2_REG_DOT_GRP_SEL1 0x000D
74 #define LEDRING2_REG_DOT_GRP_SEL2 0x000E
75 #define LEDRING2_REG_DOT_GRP_SEL3 0x000F
76 #define LEDRING2_REG_DOT_GRP_SEL4 0x0010
77 #define LEDRING2_REG_DOT_GRP_SEL5 0x0011
78 #define LEDRING2_REG_DOT_GRP_SEL6 0x0012
79 #define LEDRING2_REG_DOT_GRP_SEL7 0x0013
80 #define LEDRING2_REG_DOT_GRP_SEL8 0x0014
81 #define LEDRING2_REG_DOT_GRP_SEL9 0x0015
82 #define LEDRING2_REG_DOT_ONOFF0 0x0043
83 #define LEDRING2_REG_DOT_ONOFF1 0x0044
84 #define LEDRING2_REG_DOT_ONOFF2 0x0045
85 #define LEDRING2_REG_DOT_ONOFF3 0x0046
86 #define LEDRING2_REG_DOT_ONOFF4 0x0047
87 #define LEDRING2_REG_DOT_ONOFF5 0x0048
88 #define LEDRING2_REG_FAULT_STATE 0x0064
89 #define LEDRING2_REG_DOT_LOD0 0x0065
90 #define LEDRING2_REG_DOT_LOD1 0x0066
91 #define LEDRING2_REG_DOT_LOD2 0x0067
92 #define LEDRING2_REG_DOT_LOD3 0x0068
93 #define LEDRING2_REG_DOT_LOD4 0x0069
94 #define LEDRING2_REG_DOT_LOD5 0x006A
95 #define LEDRING2_REG_DOT_LSD0 0x0086
96 #define LEDRING2_REG_DOT_LSD1 0x0087
97 #define LEDRING2_REG_DOT_LSD2 0x0088
98 #define LEDRING2_REG_DOT_LSD3 0x0089
99 #define LEDRING2_REG_DOT_LSD4 0x008A
100 #define LEDRING2_REG_DOT_LSD5 0x008B
101 #define LEDRING2_REG_LOD_CLEAR 0x00A7
102 #define LEDRING2_REG_LSD_CLEAR 0x00A8
103 #define LEDRING2_REG_RESET 0x00A9
104 #define LEDRING2_REG_DC0 0x0100
105 #define LEDRING2_REG_DC1 0x0101
106 #define LEDRING2_REG_DC2 0x0102
107 #define LEDRING2_REG_DC3 0x0103
108 #define LEDRING2_REG_DC4 0x0104
109 #define LEDRING2_REG_DC5 0x0105
110 #define LEDRING2_REG_DC6 0x0106
111 #define LEDRING2_REG_DC7 0x0107
112 #define LEDRING2_REG_DC8 0x0108
113 #define LEDRING2_REG_DC9 0x0109
114 #define LEDRING2_REG_DC10 0x010A
115 #define LEDRING2_REG_DC11 0x010B
116 #define LEDRING2_REG_DC12 0x010C
117 #define LEDRING2_REG_DC13 0x010D
118 #define LEDRING2_REG_DC14 0x010E
119 #define LEDRING2_REG_DC15 0x010F
120 #define LEDRING2_REG_DC16 0x0110
121 #define LEDRING2_REG_DC17 0x0111
122 #define LEDRING2_REG_DC18 0x0112
123 #define LEDRING2_REG_DC19 0x0113
124 #define LEDRING2_REG_DC20 0x0114
125 #define LEDRING2_REG_DC21 0x0115
126 #define LEDRING2_REG_DC22 0x0116
127 #define LEDRING2_REG_DC23 0x0117
128 #define LEDRING2_REG_DC24 0x0118
129 #define LEDRING2_REG_DC25 0x0119
130 #define LEDRING2_REG_DC26 0x011A
131 #define LEDRING2_REG_DC27 0x011B
132 #define LEDRING2_REG_DC28 0x011C
133 #define LEDRING2_REG_DC29 0x011D
134 #define LEDRING2_REG_DC30 0x011E
135 #define LEDRING2_REG_DC31 0x011F
136 #define LEDRING2_REG_DC32 0x0120
137 #define LEDRING2_REG_DC33 0x0121
138 #define LEDRING2_REG_DC34 0x0122
139 #define LEDRING2_REG_DC35 0x0123
140 #define LEDRING2_REG_PWM_BRI0 0x0200
141 #define LEDRING2_REG_PWM_BRI1 0x0201
142 #define LEDRING2_REG_PWM_BRI2 0x0202
143 #define LEDRING2_REG_PWM_BRI3 0x0203
144 #define LEDRING2_REG_PWM_BRI4 0x0204
145 #define LEDRING2_REG_PWM_BRI5 0x0205
146 #define LEDRING2_REG_PWM_BRI6 0x0206
147 #define LEDRING2_REG_PWM_BRI7 0x0207
148 #define LEDRING2_REG_PWM_BRI8 0x0208
149 #define LEDRING2_REG_PWM_BRI9 0x0209
150 #define LEDRING2_REG_PWM_BRI10 0x020A
151 #define LEDRING2_REG_PWM_BRI11 0x020B
152 #define LEDRING2_REG_PWM_BRI12 0x020C
153 #define LEDRING2_REG_PWM_BRI13 0x020D
154 #define LEDRING2_REG_PWM_BRI14 0x020E
155 #define LEDRING2_REG_PWM_BRI15 0x020F
156 #define LEDRING2_REG_PWM_BRI16 0x0210
157 #define LEDRING2_REG_PWM_BRI17 0x0211
158 #define LEDRING2_REG_PWM_BRI18 0x0212
159 #define LEDRING2_REG_PWM_BRI19 0x0213
160 #define LEDRING2_REG_PWM_BRI20 0x0214
161 #define LEDRING2_REG_PWM_BRI21 0x0215
162 #define LEDRING2_REG_PWM_BRI22 0x0216
163 #define LEDRING2_REG_PWM_BRI23 0x0217
164 #define LEDRING2_REG_PWM_BRI24 0x0218
165 #define LEDRING2_REG_PWM_BRI25 0x0219
166 #define LEDRING2_REG_PWM_BRI26 0x021A
167 #define LEDRING2_REG_PWM_BRI27 0x021B
168 #define LEDRING2_REG_PWM_BRI28 0x021C
169 #define LEDRING2_REG_PWM_BRI29 0x021D
170 #define LEDRING2_REG_PWM_BRI30 0x021E
171 #define LEDRING2_REG_PWM_BRI31 0x021F
172 #define LEDRING2_REG_PWM_BRI32 0x0220
173 #define LEDRING2_REG_PWM_BRI33 0x0221
174 #define LEDRING2_REG_PWM_BRI34 0x0222
175 #define LEDRING2_REG_PWM_BRI35 0x0223
176 #define LEDRING2_REG_PWM_BRI36 0x0224
177 #define LEDRING2_REG_PWM_BRI37 0x0225
178 #define LEDRING2_REG_PWM_BRI38 0x0226
179 #define LEDRING2_REG_PWM_BRI39 0x0227
180 #define LEDRING2_REG_PWM_BRI40 0x0228
181 #define LEDRING2_REG_PWM_BRI41 0x0229
182 #define LEDRING2_REG_PWM_BRI42 0x022A
183 #define LEDRING2_REG_PWM_BRI43 0x022B
184 #define LEDRING2_REG_PWM_BRI44 0x022C
185 #define LEDRING2_REG_PWM_BRI45 0x022D
186 #define LEDRING2_REG_PWM_BRI46 0x022E
187 #define LEDRING2_REG_PWM_BRI47 0x022F
188 #define LEDRING2_REG_PWM_BRI48 0x0230
189 #define LEDRING2_REG_PWM_BRI49 0x0231
190 #define LEDRING2_REG_PWM_BRI50 0x0232
191 #define LEDRING2_REG_PWM_BRI51 0x0233
192 #define LEDRING2_REG_PWM_BRI52 0x0234
193 #define LEDRING2_REG_PWM_BRI53 0x0235
194 #define LEDRING2_REG_PWM_BRI54 0x0236
195 #define LEDRING2_REG_PWM_BRI55 0x0237
196 #define LEDRING2_REG_PWM_BRI56 0x0238
197 #define LEDRING2_REG_PWM_BRI57 0x0239
198 #define LEDRING2_REG_PWM_BRI58 0x023A
199 #define LEDRING2_REG_PWM_BRI59 0x023B
200 #define LEDRING2_REG_PWM_BRI60 0x023C
201 #define LEDRING2_REG_PWM_BRI61 0x023D
202 #define LEDRING2_REG_PWM_BRI62 0x023E
203 #define LEDRING2_REG_PWM_BRI63 0x023F
204 #define LEDRING2_REG_PWM_BRI64 0x0240
205 #define LEDRING2_REG_PWM_BRI65 0x0241
206 #define LEDRING2_REG_PWM_BRI66 0x0242
207 #define LEDRING2_REG_PWM_BRI67 0x0243
208 #define LEDRING2_REG_PWM_BRI68 0x0244
209 #define LEDRING2_REG_PWM_BRI69 0x0245
210 #define LEDRING2_REG_PWM_BRI70 0x0246
211 #define LEDRING2_REG_PWM_BRI71 0x0247
212  // ledring2_reg
214 
229 #define LEDRING2_8_9_BIT_MASK 0x00003
230 
231 #define LEDRING2_LED_DISABLE 0x00
232 #define LEDRING2_LED_ENABLE 0x01
233 
234 #define LEDRING2_OP_MODE_1 0x01
235 #define LEDRING2_OP_MODE_2 0x02
236 #define LEDRING2_OP_MODE_3 0x03
237 
243 #define LEDRING2_LED_GROUP_U1_LED_1_18 0x40
244 #define LEDRING2_LED_GROUP_U2_LED_19_36 0x44
245 #define LEDRING2_LED_GROUP_U3_LED_37_54 0x48
246  // ledring2_set
248 
263 #define LEDRING2_MAP_MIKROBUS( cfg, mikrobus ) \
264  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
265  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
266  cfg.vsy = MIKROBUS( mikrobus, MIKROBUS_PWM )
267  // ledring2_map // ledring2
270 
275 typedef struct
276 {
277  // Output pins
278  digital_out_t vsy;
280  // Modules
281  i2c_master_t i2c;
283  // I2C slave address
284  uint8_t slave_address;
286 } ledring2_t;
287 
292 typedef struct
293 {
294  pin_name_t scl;
295  pin_name_t sda;
297  pin_name_t vsy;
299  uint32_t i2c_speed;
300  uint8_t i2c_address;
303 
308 typedef enum
309 {
311  LEDRING2_ERROR = -1
312 
314 
319 typedef enum
320 {
323 
325 
342 
357 
371 
387 err_t ledring2_set_slave_address ( ledring2_t *ctx, uint8_t slave_address );
388 
409 err_t ledring2_write_reg ( ledring2_t *ctx, uint8_t led_group, uint16_t reg, uint8_t *data_in, uint8_t len );
410 
431 err_t ledring2_read_reg ( ledring2_t *ctx, uint8_t led_group, uint16_t reg, uint8_t *data_out, uint8_t len );
432 
444 
458 
472 
488 
504 err_t ledring2_set_led_pos_state ( ledring2_t *ctx, uint8_t led_pos, ledring2_led_state_t led_state );
505 
521 err_t ledring2_set_led_brightness ( ledring2_t *ctx, uint8_t led_pos, uint16_t led_brightness );
522 
523 #ifdef __cplusplus
524 }
525 #endif
526 #endif // LEDRING2_H
527  // ledring2
529 
530 // ------------------------------------------------------------------------ END
ledring2_set_slave_address
err_t ledring2_set_slave_address(ledring2_t *ctx, uint8_t slave_address)
Set I2C Slave address.
LEDRING2_ERROR
@ LEDRING2_ERROR
Definition: ledring2.h:311
ledring2_t::slave_address
uint8_t slave_address
Definition: ledring2.h:284
ledring2_return_value_t
ledring2_return_value_t
LED Ring 2 Click return value data.
Definition: ledring2.h:309
ledring2_default_cfg
err_t ledring2_default_cfg(ledring2_t *ctx)
LED Ring 2 default configuration function.
ledring2_write_reg
err_t ledring2_write_reg(ledring2_t *ctx, uint8_t led_group, uint16_t reg, uint8_t *data_in, uint8_t len)
LED Ring 2 write register function.
ledring2_t
LED Ring 2 Click context object.
Definition: ledring2.h:276
ledring2_disable
err_t ledring2_disable(ledring2_t *ctx)
LED Ring 2 disable function.
ledring2_cfg_t
LED Ring 2 Click configuration object.
Definition: ledring2.h:293
ledring2_cfg_setup
void ledring2_cfg_setup(ledring2_cfg_t *cfg)
LED Ring 2 configuration object setup function.
ledring2_read_reg
err_t ledring2_read_reg(ledring2_t *ctx, uint8_t led_group, uint16_t reg, uint8_t *data_out, uint8_t len)
LED Ring 2 read registe function.
ledring2_t::i2c
i2c_master_t i2c
Definition: ledring2.h:281
ledring2_led_state_t
ledring2_led_state_t
LED Ring 2 Click LED state data.
Definition: ledring2.h:320
ledring2_init
err_t ledring2_init(ledring2_t *ctx, ledring2_cfg_t *cfg)
LED Ring 2 initialization function.
ledring2_set_all_led_state
err_t ledring2_set_all_led_state(ledring2_t *ctx, ledring2_led_state_t led_state)
LED Ring 2 set all LED state function.
ledring2_enable
err_t ledring2_enable(ledring2_t *ctx)
LED Ring 2 enable function.
ledring2_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: ledring2.h:299
LEDRING2_OK
@ LEDRING2_OK
Definition: ledring2.h:310
ledring2_set_vsync
void ledring2_set_vsync(ledring2_t *ctx)
LED Ring 2 read registe function.
ledring2_cfg_t::i2c_address
uint8_t i2c_address
Definition: ledring2.h:300
ledring2_set_led_brightness
err_t ledring2_set_led_brightness(ledring2_t *ctx, uint8_t led_pos, uint16_t led_brightness)
LED Ring 2 set LED brightness function.
LEDRING2_LED_OFF
@ LEDRING2_LED_OFF
Definition: ledring2.h:321
ledring2_t::vsy
digital_out_t vsy
Definition: ledring2.h:278
ledring2_cfg_t::scl
pin_name_t scl
Definition: ledring2.h:294
ledring2_set_led_pos_state
err_t ledring2_set_led_pos_state(ledring2_t *ctx, uint8_t led_pos, ledring2_led_state_t led_state)
LED Ring 2 set LED state function.
LEDRING2_LED_ON
@ LEDRING2_LED_ON
Definition: ledring2.h:322
ledring2_cfg_t::sda
pin_name_t sda
Definition: ledring2.h:295
ledring2_cfg_t::vsy
pin_name_t vsy
Definition: ledring2.h:297