leddriver6 2.0.0.0
leddriver6.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef LEDDRIVER6_H
36#define LEDDRIVER6_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_in.h"
53#include "drv_pwm.h"
54#include "drv_i2c_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define LEDDRIVER6_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
77#define LEDDRIVER6_OK 0
78#define LEDDRIVER6_INIT_ERROR (-1)
85#define LEDDRIVER6_DEF_FREQ 10000
88 // End group macro
89// --------------------------------------------------------------- PUBLIC TYPES
98typedef struct
99{
100
101 // Input pins
102
103 digital_in_t int_pin;
104
105 // Modules
106
107 pwm_t pwm;
108 i2c_master_t i2c;
109
110 // ctx variables
111
112 uint32_t pwm_freq;
114
116
120typedef struct
121{
122 // Communication gpio pins
123
124 pin_name_t scl;
125 pin_name_t sda;
126 pin_name_t pwm;
127
128 // Additional gpio pins
129
130 pin_name_t int_pin;
131
132 // Static variables
133
134 uint32_t i2c_speed;
135 uint8_t i2c_address;
136 uint32_t dev_pwm_freq;
137
139
140 // End types group
141// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
147#ifdef __cplusplus
148extern "C"{
149#endif
150
160
172
183err_t leddriver6_set_duty_cycle ( leddriver6_t *ctx, float duty_cycle );
184
195
206
217err_t leddriver6_read_adc ( leddriver6_t *ctx, uint16_t *data_out );
218
229err_t leddriver6_get_pg_voltage ( leddriver6_t *ctx, float *data_out );
230
241
242#ifdef __cplusplus
243}
244#endif
245#endif // LEDDRIVER6_H
246
247 // End public_function group
248 // End click Driver group
249
250// ------------------------------------------------------------------------ END
void leddriver6_cfg_setup(leddriver6_cfg_t *cfg)
Config Object Initialization function.
err_t leddriver6_read_adc(leddriver6_t *ctx, uint16_t *data_out)
Read ADC function.
err_t leddriver6_set_duty_cycle(leddriver6_t *ctx, float duty_cycle)
Sets PWM duty cycle.
err_t leddriver6_pwm_start(leddriver6_t *ctx)
Start PWM module.
uint8_t leddriver6_get_interrupt_state(leddriver6_t *ctx)
Function for getting interrupt pin state.
err_t leddriver6_init(leddriver6_t *ctx, leddriver6_cfg_t *cfg)
Initialization function.
err_t leddriver6_get_pg_voltage(leddriver6_t *ctx, float *data_out)
Function for reading current PG output voltage.
err_t leddriver6_pwm_stop(leddriver6_t *ctx)
Stop PWM module.
Click configuration structure definition.
Definition leddriver6.h:121
uint32_t i2c_speed
Definition leddriver6.h:134
uint32_t dev_pwm_freq
Definition leddriver6.h:136
pin_name_t scl
Definition leddriver6.h:124
pin_name_t int_pin
Definition leddriver6.h:130
pin_name_t pwm
Definition leddriver6.h:126
pin_name_t sda
Definition leddriver6.h:125
uint8_t i2c_address
Definition leddriver6.h:135
Click ctx object definition.
Definition leddriver6.h:99
uint32_t pwm_freq
Definition leddriver6.h:112
digital_in_t int_pin
Definition leddriver6.h:103
i2c_master_t i2c
Definition leddriver6.h:108
uint8_t slave_address
Definition leddriver6.h:113
pwm_t pwm
Definition leddriver6.h:107