leddriver11 2.0.0.0
leddriver11.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 LEDDRIVER11_H
29#define LEDDRIVER11_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#include "drv_analog_in.h"
53#include "drv_pwm.h"
54
75#define LEDDRIVER11_MAX_CURRENT 0x0000
76#define LEDDRIVER11_MIN_CURRENT 0x0FFF
77
82#define LEDDRIVER11_DEF_FREQ 5000
88#define LEDDRIVER11_SET_DEV_ADDR 0x60
89
90 // leddriver11_set
91
106#define LEDDRIVER11_MAP_MIKROBUS( cfg, mikrobus ) \
107 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
108 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
109 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
110 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM );
111
112 // leddriver11_map
113 // leddriver11
114
119typedef struct
120{
121 // Modules
122 analog_in_t adc;
123 i2c_master_t i2c;
124 pwm_t pwm;
126 // ctx variable
127 uint32_t pwm_freq;
129 // I2C slave address
133
138typedef struct
139{
140 pin_name_t scl;
141 pin_name_t sda;
142 pin_name_t an;
143 pin_name_t pwm;
145 analog_in_resolution_t resolution;
146 float vref;
147 uint32_t i2c_speed;
148 uint8_t i2c_address;
149 uint32_t dev_pwm_freq;
152
163
180
196
211
226err_t leddriver11_set_current ( leddriver11_t *ctx, uint16_t curr );
227
240err_t leddriver11_read_dac_memory( leddriver11_t *ctx, uint8_t *data_out );
241
254err_t leddriver11_read_an_pin_value ( leddriver11_t *ctx, uint16_t *data_out );
255
270err_t leddriver11_read_an_pin_voltage ( leddriver11_t *ctx, float *data_out );
271
284err_t leddriver11_set_duty_cycle ( leddriver11_t *ctx, float duty_cycle );
285
298
311
312#ifdef __cplusplus
313}
314#endif
315#endif // LEDDRIVER11_H
316
317 // leddriver11
318
319// ------------------------------------------------------------------------ END
err_t leddriver11_default_cfg(leddriver11_t *ctx)
LED Driver 11 default configuration function.
err_t leddriver11_read_an_pin_voltage(leddriver11_t *ctx, float *data_out)
LED Driver 11 read AN pin voltage level function.
err_t leddriver11_init(leddriver11_t *ctx, leddriver11_cfg_t *cfg)
LED Driver 11 initialization function.
err_t leddriver11_read_an_pin_value(leddriver11_t *ctx, uint16_t *data_out)
LED Driver 11 read AN pin value function.
err_t leddriver11_read_dac_memory(leddriver11_t *ctx, uint8_t *data_out)
LED Driver 11 read DAC memory.
void leddriver11_cfg_setup(leddriver11_cfg_t *cfg)
LED Driver 11 configuration object setup function.
err_t leddriver11_set_duty_cycle(leddriver11_t *ctx, float duty_cycle)
LED Driver 11 sets PWM duty cycle.
err_t leddriver11_set_current(leddriver11_t *ctx, uint16_t curr)
LED Driver 11 set current function.
err_t leddriver11_pwm_stop(leddriver11_t *ctx)
LED Driver 11 stop PWM module.
err_t leddriver11_pwm_start(leddriver11_t *ctx)
LED Driver 11 start PWM module.
leddriver11_return_value_t
LED Driver 11 Click return value data.
Definition leddriver11.h:158
@ LEDDRIVER11_OK
Definition leddriver11.h:159
@ LEDDRIVER11_ERROR
Definition leddriver11.h:160
LED Driver 11 Click configuration object.
Definition leddriver11.h:139
analog_in_resolution_t resolution
Definition leddriver11.h:145
float vref
Definition leddriver11.h:146
uint32_t i2c_speed
Definition leddriver11.h:147
uint32_t dev_pwm_freq
Definition leddriver11.h:149
pin_name_t scl
Definition leddriver11.h:140
pin_name_t pwm
Definition leddriver11.h:143
pin_name_t sda
Definition leddriver11.h:141
pin_name_t an
Definition leddriver11.h:142
uint8_t i2c_address
Definition leddriver11.h:148
LED Driver 11 Click context object.
Definition leddriver11.h:120
uint32_t pwm_freq
Definition leddriver11.h:127
i2c_master_t i2c
Definition leddriver11.h:123
uint8_t slave_address
Definition leddriver11.h:130
analog_in_t adc
Definition leddriver11.h:122
pwm_t pwm
Definition leddriver11.h:124