leddriver14 2.0.0.0
leddriver14.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 LEDDRIVER14_H
29#define LEDDRIVER14_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_i2c_master.h"
38#include "drv_pwm.h"
39
60#define LEDDRIVER14_RSET_1 0
61#define LEDDRIVER14_RSET_2 1
62#define LEDDRIVER14_RSET_3 2
63#define LEDDRIVER14_RSET_4 3
64
69#define LEDDRIVER14_DIGIPOT_MAX_VALUE 50000
70#define LEDDRIVER14_DIGIPOT_RESOLUTION 257
71#define LEDDRIVER14_ROUND_TO_NEAREST_INT 0.5
72#define LEDDRIVER14_RSET_RES_MAX 24000
73#define LEDDRIVER14_RSET_RES_DEFAULT 12000
74#define LEDDRIVER14_RSET1_AND_RSET3_ADDRESS 0x10
75
80#define LEDDRIVER14_WRITE_PROTECT_ENABLE 0
81#define LEDDRIVER14_WRITE_PROTECT_DISABLE 1
82
88#define LEDDRIVER14_U2_ADDR_A2_GND 0x28
89#define LEDDRIVER14_U2_ADDR_A2_VCC 0x2C
90#define LEDDRIVER14_U3_ADDR_A2_GND 0x29
91#define LEDDRIVER14_U3_ADDR_A2_VCC 0x2D
92
97#define LEDDRIVER14_DEF_FREQ 500
98 // leddriver14_set
100
115#define LEDDRIVER14_MAP_MIKROBUS( cfg, mikrobus ) \
116 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
117 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
118 cfg.wp = MIKROBUS( mikrobus, MIKROBUS_RST ); \
119 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
120 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
121 // leddriver14_map // leddriver14
124
129typedef struct
130{
131 // Output pins
132 digital_out_t wp;
134 // Input pins
135 digital_in_t int_pin;
137 // Modules
138 i2c_master_t i2c;
139 pwm_t pwm;
141 // I2C slave address
144 uint32_t pwm_freq;
147
152typedef struct
153{
154 pin_name_t scl;
155 pin_name_t sda;
157 pin_name_t wp;
158 pin_name_t pwm;
159 pin_name_t int_pin;
161 uint32_t i2c_speed;
164 uint32_t dev_pwm_freq;
167
172typedef enum
173{
176
178
195
211
226
240err_t leddriver14_set_rset ( leddriver14_t *ctx, uint8_t rset, uint16_t res_ohm );
241
253
264
277err_t leddriver14_set_duty_cycle ( leddriver14_t *ctx, float duty_cycle );
278
291
304
305#ifdef __cplusplus
306}
307#endif
308#endif // LEDDRIVER14_H
309 // leddriver14
311
312// ------------------------------------------------------------------------ END
err_t leddriver14_init(leddriver14_t *ctx, leddriver14_cfg_t *cfg)
LED Driver 14 initialization function.
void leddriver14_rset_write_protect(leddriver14_t *ctx, uint8_t state)
LED Driver 14 rset write protect function.
err_t leddriver14_pwm_start(leddriver14_t *ctx)
LED Driver 14 start PWM module.
err_t leddriver14_default_cfg(leddriver14_t *ctx)
LED Driver 14 default configuration function.
uint8_t leddriver14_get_int_pin(leddriver14_t *ctx)
LED Driver 14 get int pin function.
err_t leddriver14_set_duty_cycle(leddriver14_t *ctx, float duty_cycle)
LED Driver 14 sets PWM duty cycle.
err_t leddriver14_pwm_stop(leddriver14_t *ctx)
LED Driver 14 stop PWM module.
err_t leddriver14_set_rset(leddriver14_t *ctx, uint8_t rset, uint16_t res_ohm)
LED Driver 14 set rset function.
void leddriver14_cfg_setup(leddriver14_cfg_t *cfg)
LED Driver 14 configuration object setup function.
leddriver14_return_value_t
LED Driver 14 Click return value data.
Definition: leddriver14.h:173
@ LEDDRIVER14_OK
Definition: leddriver14.h:174
@ LEDDRIVER14_ERROR
Definition: leddriver14.h:175
LED Driver 14 Click configuration object.
Definition: leddriver14.h:153
uint8_t i2c_address_u3
Definition: leddriver14.h:163
uint32_t i2c_speed
Definition: leddriver14.h:161
uint8_t i2c_address_u2
Definition: leddriver14.h:162
pin_name_t wp
Definition: leddriver14.h:157
uint32_t dev_pwm_freq
Definition: leddriver14.h:164
pin_name_t scl
Definition: leddriver14.h:154
pin_name_t int_pin
Definition: leddriver14.h:159
pin_name_t pwm
Definition: leddriver14.h:158
pin_name_t sda
Definition: leddriver14.h:155
LED Driver 14 Click context object.
Definition: leddriver14.h:130
uint8_t slave_address_u2
Definition: leddriver14.h:142
uint32_t pwm_freq
Definition: leddriver14.h:144
digital_in_t int_pin
Definition: leddriver14.h:135
i2c_master_t i2c
Definition: leddriver14.h:138
uint8_t slave_address_u3
Definition: leddriver14.h:143
pwm_t pwm
Definition: leddriver14.h:139
digital_out_t wp
Definition: leddriver14.h:132