c4x4rgb 2.0.0.0
c4x4rgb.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 C4X4RGB_H
36#define C4X4RGB_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
55// -------------------------------------------------------------- PUBLIC MACROS
65#define C4X4RGB_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
67 cfg.in2 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
68 cfg.out = MIKROBUS( mikrobus, MIKROBUS_PWM )
75#define C4X4RGB_OK 0
76#define C4X4RGB_ERROR -1
84#define C4X4RGB_CTRL_PIN_IN1 1
85#define C4X4RGB_CTRL_PIN_IN2 2
93#define C4X4RGB_COLOR_WHITE 0x001F1F1F
94#define C4X4RGB_COLOR_RED 0x001F0000
95#define C4X4RGB_COLOR_GREEN 0x00001F00
96#define C4X4RGB_COLOR_BLUE 0x0000001F
97#define C4X4RGB_COLOR_LIGHT_BLUE 0x00001F1F
98#define C4X4RGB_COLOR_YELLOW 0x001F1F00
99#define C4X4RGB_COLOR_PURPLE 0x001F001F
102 // End group macro
103// --------------------------------------------------------------- PUBLIC TYPES
112typedef void ( *drv_logic_t ) ( void );
113
117typedef struct
118{
119 // Output pins
120 digital_out_t in1;
121 digital_out_t in2;
122 digital_out_t out;
123
124 digital_out_t ctrl_pin;
125
126 // Function pointers
129
130 uint32_t diode_array[ 16 ];
131
132} c4x4rgb_t;
133
137typedef struct
138{
139 // Additional gpio pins
140 pin_name_t in1;
141 pin_name_t in2;
142 pin_name_t out;
143
144 uint8_t ctrl_pin;
145
146 // Function pointers
149
151
152 // End types group
153// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
154
160#ifdef __cplusplus
161extern "C"{
162#endif
163
174void c4x4rgb_cfg_setup ( c4x4rgb_cfg_t *cfg, drv_logic_t logic_zero, drv_logic_t logic_one, uint8_t select_ctrl_pin );
175
184
196err_t c4x4rgb_set_diode ( c4x4rgb_t *ctx, uint32_t diode_num, uint32_t diode_color );
197
205void c4x4rgb_fill_screen ( c4x4rgb_t *ctx, uint32_t fill_color );
206
207#ifdef __cplusplus
208}
209#endif
210#endif // _C4X4RGB_H_
211
212 // End public_function group
214
215// ------------------------------------------------------------------------- END
void c4x4rgb_fill_screen(c4x4rgb_t *ctx, uint32_t fill_color)
Function for filling color of ever diode.
err_t c4x4rgb_set_diode(c4x4rgb_t *ctx, uint32_t diode_num, uint32_t diode_color)
Function for setting color color of one diode.
void c4x4rgb_cfg_setup(c4x4rgb_cfg_t *cfg, drv_logic_t logic_zero, drv_logic_t logic_one, uint8_t select_ctrl_pin)
Config Object Initialization function.
err_t c4x4rgb_init(c4x4rgb_t *ctx, c4x4rgb_cfg_t *cfg)
Initialization function.
void(* drv_logic_t)(void)
Function pointer for logic level one and zero.
Definition c4x4rgb.h:112
Click configuration structure definition.
Definition c4x4rgb.h:138
pin_name_t out
Definition c4x4rgb.h:142
pin_name_t in2
Definition c4x4rgb.h:141
drv_logic_t logic_one
Definition c4x4rgb.h:148
drv_logic_t logic_zero
Definition c4x4rgb.h:147
uint8_t ctrl_pin
Definition c4x4rgb.h:144
pin_name_t in1
Definition c4x4rgb.h:140
Click ctx object definition.
Definition c4x4rgb.h:118
digital_out_t in2
Definition c4x4rgb.h:121
digital_out_t ctrl_pin
Definition c4x4rgb.h:124
digital_out_t out
Definition c4x4rgb.h:122
drv_logic_t logic_one
Definition c4x4rgb.h:128
drv_logic_t logic_zero
Definition c4x4rgb.h:127
digital_out_t in1
Definition c4x4rgb.h:120