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
38#include "drv_digital_in.h"
39#include "drv_pwm.h"
40#include "drv_i2c_master.h"
41
42// -------------------------------------------------------------- PUBLIC MACROS
52#define LEDDRIVER6_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
54 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
55 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
56 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
63#define LEDDRIVER6_OK 0
64#define LEDDRIVER6_INIT_ERROR (-1)
71#define LEDDRIVER6_DEF_FREQ 10000 // End group macro
75// --------------------------------------------------------------- PUBLIC TYPES
84typedef struct
85{
86
87 // Input pins
88
89 digital_in_t int_pin;
90
91 // Modules
92
93 pwm_t pwm;
94 i2c_master_t i2c;
95
96 // ctx variables
97
98 uint32_t pwm_freq;
100
102
106typedef struct
107{
108 // Communication gpio pins
109
110 pin_name_t scl;
111 pin_name_t sda;
112 pin_name_t pwm;
113
114 // Additional gpio pins
115
116 pin_name_t int_pin;
117
118 // Static variables
119
120 uint32_t i2c_speed;
121 uint8_t i2c_address;
122 uint32_t dev_pwm_freq;
123
125 // End types group
127// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
133#ifdef __cplusplus
134extern "C"{
135#endif
136
146
158
169err_t leddriver6_set_duty_cycle ( leddriver6_t *ctx, float duty_cycle );
170
181
192
203err_t leddriver6_read_adc ( leddriver6_t *ctx, uint16_t *data_out );
204
215err_t leddriver6_get_pg_voltage ( leddriver6_t *ctx, float *data_out );
216
227
228#ifdef __cplusplus
229}
230#endif
231#endif // LEDDRIVER6_H
232 // End public_function group // End click Driver group
235
236// ------------------------------------------------------------------------ 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:107
uint32_t i2c_speed
Definition: leddriver6.h:120
uint32_t dev_pwm_freq
Definition: leddriver6.h:122
pin_name_t scl
Definition: leddriver6.h:110
pin_name_t int_pin
Definition: leddriver6.h:116
pin_name_t pwm
Definition: leddriver6.h:112
pin_name_t sda
Definition: leddriver6.h:111
uint8_t i2c_address
Definition: leddriver6.h:121
Click ctx object definition.
Definition: leddriver6.h:85
uint32_t pwm_freq
Definition: leddriver6.h:98
digital_in_t int_pin
Definition: leddriver6.h:89
i2c_master_t i2c
Definition: leddriver6.h:94
uint8_t slave_address
Definition: leddriver6.h:99
pwm_t pwm
Definition: leddriver6.h:93