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 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define C4X4RGB_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.in1= MIKROBUS( mikrobus, MIKROBUS_RST ); \
53  cfg.in2= MIKROBUS( mikrobus, MIKROBUS_CS ); \
54  cfg.out= MIKROBUS( mikrobus, MIKROBUS_PWM )
55 
61 #define C4X4RGB_RETVAL uint8_t
62 
63 #define C4X4RGB_OK 0x00
64 #define C4X4RGB_INIT_ERROR 0xFF
65 
72 #define C4X4RGB_CTRL_PIN_IN1 1
73 #define C4X4RGB_CTRL_PIN_IN2 2
74 
81 #define C4X4RGB_COLOR_WHITE 0x001F1F1F
82 #define C4X4RGB_COLOR_RED 0x001F0000
83 #define C4X4RGB_COLOR_GREEN 0x00001F00
84 #define C4X4RGB_COLOR_BLUE 0x0000001F
85 #define C4X4RGB_COLOR_LIGHT_BLUE 0x00001F1F
86 #define C4X4RGB_COLOR_YELLOW 0x001F1F00
87 #define C4X4RGB_COLOR_PURPLE 0x001F001F
88  // End group macro
91 // --------------------------------------------------------------- PUBLIC TYPES
100 typedef void ( *drv_logic_t ) ( void );
101 
105 typedef struct
106 {
107  // Output pins
108 
109  digital_out_t in1;
110  digital_out_t in2;
111  digital_out_t out;
112 
113  digital_out_t ctrl_pin;
114 
115  // Function pointers
116 
119 
120 
121 } c4x4rgb_t;
122 
126 typedef struct
127 {
128  // Additional gpio pins
129 
130  pin_name_t in1;
131  pin_name_t in2;
132  pin_name_t out;
133 
134  uint8_t ctrl_pin;
135 
136  // Function pointers
137 
140 
141 } c4x4rgb_cfg_t;
142  // End types group
144 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
145 
151 #ifdef __cplusplus
152 extern "C"{
153 #endif
154 
165 void c4x4rgb_cfg_setup ( c4x4rgb_cfg_t *cfg, drv_logic_t logic_zero, drv_logic_t logic_one, uint8_t select_ctrl_pin );
166 
175 
187 err_t c4x4rgb_set_diode ( c4x4rgb_t *ctx, uint32_t diode_num, uint32_t diode_color );
188 
197 void c4x4rgb_fill_screen ( c4x4rgb_t *ctx, uint32_t fill_color, uint16_t fill_delay );
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 #endif // _C4X4RGB_H_
203  // End public_function group
206 
207 // ------------------------------------------------------------------------- END
c4x4rgb_cfg_setup
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.
c4x4rgb_cfg_t::logic_one
drv_logic_t logic_one
Definition: c4x4rgb.h:139
c4x4rgb_set_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.
c4x4rgb_cfg_t::logic_zero
drv_logic_t logic_zero
Definition: c4x4rgb.h:138
c4x4rgb_init
C4X4RGB_RETVAL c4x4rgb_init(c4x4rgb_t *ctx, c4x4rgb_cfg_t *cfg)
Initialization function.
c4x4rgb_cfg_t::ctrl_pin
uint8_t ctrl_pin
Definition: c4x4rgb.h:134
c4x4rgb_fill_screen
void c4x4rgb_fill_screen(c4x4rgb_t *ctx, uint32_t fill_color, uint16_t fill_delay)
Function for filling color of ever diode.
drv_logic_t
void(* drv_logic_t)(void)
Function pointer for logic level one and zero.
Definition: c4x4rgb.h:100
c4x4rgb_cfg_t
Click configuration structure definition.
Definition: c4x4rgb.h:126
C4X4RGB_RETVAL
#define C4X4RGB_RETVAL
Definition: c4x4rgb.h:61
c4x4rgb_cfg_t::in1
pin_name_t in1
Definition: c4x4rgb.h:130
c4x4rgb_t::in2
digital_out_t in2
Definition: c4x4rgb.h:110
c4x4rgb_t::ctrl_pin
digital_out_t ctrl_pin
Definition: c4x4rgb.h:113
c4x4rgb_cfg_t::out
pin_name_t out
Definition: c4x4rgb.h:132
c4x4rgb_t::out
digital_out_t out
Definition: c4x4rgb.h:111
c4x4rgb_cfg_t::in2
pin_name_t in2
Definition: c4x4rgb.h:131
c4x4rgb_t::in1
digital_out_t in1
Definition: c4x4rgb.h:109
c4x4rgb_t
Click ctx object definition.
Definition: c4x4rgb.h:105
c4x4rgb_t::logic_zero
drv_logic_t logic_zero
Definition: c4x4rgb.h:117
c4x4rgb_t::logic_one
drv_logic_t logic_one
Definition: c4x4rgb.h:118