leddriver15 2.1.0.0
leddriver15.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 LEDDRIVER15_H
29#define LEDDRIVER15_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
73#define LEDDRIVER15_REG_R0 0x00
74#define LEDDRIVER15_REG_R1 0x01
75
76 // leddriver15_reg
77
92#define LEDDRIVER15_R0_EN 0x80
93#define LEDDRIVER15_R0_REF_SET_MASK 0x7C
94#define LEDDRIVER15_R0_REF_SET_OFFSET 2
95
100#define LEDDRIVER15_R1_DIMS_I2C 0x00
101#define LEDDRIVER15_R1_DIMS_PWM 0x40
102#define LEDDRIVER15_R1_DIMS_MASK 0x40
103#define LEDDRIVER15_R1_SYNC_DISABLE 0x00
104#define LEDDRIVER15_R1_SYNC_ENABLE 0x20
105#define LEDDRIVER15_R1_SYNC_MASK 0x20
106#define LEDDRIVER15_R1_OVP_13p5V 0x00
107#define LEDDRIVER15_R1_OVP_24V 0x10
108#define LEDDRIVER15_R1_OVP_35p5V 0x08
109#define LEDDRIVER15_R1_OVP_MASK 0x18
110#define LEDDRIVER15_R1_VOS 0x04
111#define LEDDRIVER15_R1_LED0 0x02
112#define LEDDRIVER15_R1_OTP 0x01
113
118#define LEDDRIVER15_I2C_DIMMING_MIN 0
119#define LEDDRIVER15_I2C_DIMMING_MAX 31
120
126#define LEDDRIVER15_DEVICE_ADDRESS 0x17
127
128 // leddriver15_set
129
144#define LEDDRIVER15_MAP_MIKROBUS( cfg, mikrobus ) \
145 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
146 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
147 cfg.en = MIKROBUS( mikrobus, MIKROBUS_PWM );
148
149 // leddriver15_map
150 // leddriver15
151
156typedef struct
157{
158 digital_out_t en;
160 i2c_master_t i2c;
165
170typedef struct
171{
172 pin_name_t scl;
173 pin_name_t sda;
174 pin_name_t en;
176 uint32_t i2c_speed;
177 uint8_t i2c_address;
180
191
208
223
237
250err_t leddriver15_write_register ( leddriver15_t *ctx, uint8_t reg, uint8_t data_in );
251
264err_t leddriver15_read_register ( leddriver15_t *ctx, uint8_t reg, uint8_t *data_out );
265
275
285
297err_t leddriver15_set_i2c_dimming ( leddriver15_t *ctx, uint8_t dimming );
298
299#ifdef __cplusplus
300}
301#endif
302#endif // LEDDRIVER15_H
303
304 // leddriver15
305
306// ------------------------------------------------------------------------ END
void leddriver15_cfg_setup(leddriver15_cfg_t *cfg)
LED Driver 15 configuration object setup function.
err_t leddriver15_default_cfg(leddriver15_t *ctx)
LED Driver 15 default configuration function.
void leddriver15_enable_device(leddriver15_t *ctx)
LED Driver 15 enable device function.
void leddriver15_disable_device(leddriver15_t *ctx)
LED Driver 15 disable device function.
err_t leddriver15_write_register(leddriver15_t *ctx, uint8_t reg, uint8_t data_in)
LED Driver 15 write register function.
err_t leddriver15_read_register(leddriver15_t *ctx, uint8_t reg, uint8_t *data_out)
LED Driver 15 read register function.
err_t leddriver15_set_i2c_dimming(leddriver15_t *ctx, uint8_t dimming)
LED Driver 15 set i2c dimming function.
err_t leddriver15_init(leddriver15_t *ctx, leddriver15_cfg_t *cfg)
LED Driver 15 initialization function.
leddriver15_return_value_t
LED Driver 15 Click return value data.
Definition leddriver15.h:186
@ LEDDRIVER15_OK
Definition leddriver15.h:187
@ LEDDRIVER15_ERROR
Definition leddriver15.h:188
LED Driver 15 Click configuration object.
Definition leddriver15.h:171
uint32_t i2c_speed
Definition leddriver15.h:176
pin_name_t scl
Definition leddriver15.h:172
pin_name_t en
Definition leddriver15.h:174
pin_name_t sda
Definition leddriver15.h:173
uint8_t i2c_address
Definition leddriver15.h:177
LED Driver 15 Click context object.
Definition leddriver15.h:157
i2c_master_t i2c
Definition leddriver15.h:160
digital_out_t en
Definition leddriver15.h:158
uint8_t slave_address
Definition leddriver15.h:162