leddriver3 2.0.0.0
leddriver3.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 LEDDRIVER3_H
36#define LEDDRIVER3_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_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define LEDDRIVER3_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
75#define LEDDRIVER3_RETVAL uint8_t
76
77#define LEDDRIVER3_OK 0x00
78#define LEDDRIVER3_INIT_ERROR 0xFF
85#define LEDDRIVER3_COLOR_RED 0x5F6080
86#define LEDDRIVER3_COLOR_ORANGE 0x5F6280
87#define LEDDRIVER3_COLOR_YELLOW 0x5F7480
88#define LEDDRIVER3_COLOR_GREEN 0x407F80
89#define LEDDRIVER3_COLOR_BLUE 0x40609F
90#define LEDDRIVER3_COLOR_WHITE 0x5F7F9F
91#define LEDDRIVER3_COLOR_PURPLE 0x58609C
92#define LEDDRIVER3_COLOR_OFF 0x000000
99#define LEDDRIVER3_TIMER_8ms 0xE1
100#define LEDDRIVER3_TIMER_16ms 0xE2
101#define LEDDRIVER3_TIMER_32ms 0xE4
102#define LEDDRIVER3_TIMER_64ms 0xE8
103#define LEDDRIVER3_TIMER_128ms 0xE0
110#define LEDDRIVER3_INTENSITY_1 0x01
111#define LEDDRIVER3_INTENSITY_2 0x02
112#define LEDDRIVER3_INTENSITY_4 0x04
113#define LEDDRIVER3_INTENSITY_8 0x08
114#define LEDDRIVER3_INTENSITY_16 0x10
115
116#define LEDDRIVER3_INCREMENT 0xA0
117#define LEDDRIVER3_DECREMENT 0xC0
118#define LEDDRIVER3_CONSTANT 0x20
121 // End group macro
122// --------------------------------------------------------------- PUBLIC TYPES
131typedef struct
132{
133 uint8_t red;
134 uint8_t green;
135 uint8_t blue;
137
141typedef struct
142{
143 // Modules
144
145 i2c_master_t i2c;
146
147 // ctx variable
148
150
152
156typedef struct
157{
158 // Communication gpio pins
159
160 pin_name_t scl;
161 pin_name_t sda;
162
163 // static variable
164
165 i2c_master_speed_t i2c_speed;
166 uint8_t i2c_address;
167
169
170 // End types group
171// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
172
178#ifdef __cplusplus
179extern "C"{
180#endif
181
191
200
209void leddriver3_generic_write ( leddriver3_t *ctx, uint8_t reg );
210
221void leddriver3_generic_read ( leddriver3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
222
235void leddriver3_set_intensity ( leddriver3_t *ctx, uint8_t intensity );
236
248
265void leddriver3_set_color ( leddriver3_t *ctx, uint32_t color );
266
275
284void leddriver3_set_timer ( leddriver3_t *ctx, uint8_t time );
285
286#ifdef __cplusplus
287}
288#endif
289#endif // _LEDDRIVER3_H_
290
291 // End public_function group
293
294// ------------------------------------------------------------------------- END
#define LEDDRIVER3_RETVAL
Definition leddriver3.h:75
void leddriver3_set_color(leddriver3_t *ctx, uint32_t color)
Function set color.
void leddriver3_generic_read(leddriver3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void leddriver3_set_timer(leddriver3_t *ctx, uint8_t time)
Set timer function.
void leddriver3_set_rgb_color(leddriver3_t *ctx, leddriver3_rgb_t *rgb)
Function set RGB color.
void leddriver3_generic_write(leddriver3_t *ctx, uint8_t reg)
Generic write function.
void leddriver3_shut_down(leddriver3_t *ctx)
Shut down function.
LEDDRIVER3_RETVAL leddriver3_init(leddriver3_t *ctx, leddriver3_cfg_t *cfg)
Initialization function.
void leddriver3_set_intensity(leddriver3_t *ctx, uint8_t intensity)
Set intensity function.
void leddriver3_cfg_setup(leddriver3_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition leddriver3.h:157
i2c_master_speed_t i2c_speed
Definition leddriver3.h:165
pin_name_t scl
Definition leddriver3.h:160
pin_name_t sda
Definition leddriver3.h:161
uint8_t i2c_address
Definition leddriver3.h:166
RGB color value definition.
Definition leddriver3.h:132
uint8_t blue
Definition leddriver3.h:135
uint8_t green
Definition leddriver3.h:134
uint8_t red
Definition leddriver3.h:133
Click ctx object definition.
Definition leddriver3.h:142
i2c_master_t i2c
Definition leddriver3.h:145
uint8_t slave_address
Definition leddriver3.h:149