c4dotmatrixr  2.0.0.0
c4dotmatrixr.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 C4DOTMATRIXR_H
36 #define C4DOTMATRIXR_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
53 #define C4DOTMATRIXR_MAP_MIKROBUS( cfg, mikrobus ) \
54  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
55  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
56  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
57  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
58  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM );
59 
66 #define C4DOTMATRIXR_RETVAL uint8_t
67 
68 #define C4DOTMATRIXR_OK 0x00
69 #define C4DOTMATRIXR_INIT_ERROR 0xFF
70 
72 #define C4DOT_IODIRA 0x00
73 #define C4DOT_IODIRB 0x01
74 #define C4DOT_IPOLA 0x02
75 #define C4DOT_IPOLB 0x03
76 #define C4DOT_GPINTENA 0x04
77 #define C4DOT_GPINTENB 0x05
78 #define C4DOT_DEFVALA 0x06
79 #define C4DOT_DEFVALB 0x07
80 #define C4DOT_INTCONA 0x08
81 #define C4DOT_INTCONB 0x09
82 #define C4DOT_IOCON 0x0A
83 #define C4DOT_GPPUA 0x0C
84 #define C4DOT_GPPUB 0x0D
85 #define C4DOT_INTFA 0x0E
86 #define C4DOT_INTFB 0x0F
87 #define C4DOT_INTCAPA 0x10
88 #define C4DOT_INTCAPB 0x11
89 #define C4DOT_GPIOA 0x12
90 #define C4DOT_GPIOB 0x13
91 #define C4DOT_OLATA 0x14
92 #define C4DOT_OLATB 0x15
93  // End group macro
95 // --------------------------------------------------------------- PUBLIC TYPES
104 typedef struct
105 {
106  // Output pins
107 
108  digital_out_t rst;
109  digital_out_t cs;
110  digital_out_t pwm;
111 
112  // Modules
113 
114  i2c_master_t i2c;
115 
116  // ctx variable
117 
118  uint8_t slave_address;
119 
121 
125 typedef struct
126 {
127  // Communication gpio pins
128 
129  pin_name_t scl;
130  pin_name_t sda;
131 
132  // Additional gpio pins
133 
134  pin_name_t rst;
135  pin_name_t cs;
136  pin_name_t pwm;
137 
138  // static variable
139 
140  uint32_t i2c_speed;
141  uint8_t i2c_address;
142 
144  // End types group
146 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
147 
153 #ifdef __cplusplus
154 extern "C"{
155 #endif
156 
166 
175 
184 
195 void c4dotmatrixr_generic_write ( c4dotmatrixr_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
196 
208 void c4dotmatrixr_generic_read ( c4dotmatrixr_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
209 
226 void c4dot_write_char ( c4dotmatrixr_t *ctx, uint8_t char_num, uint8_t char_value );
227 
242 void c4dot_write_char0 ( c4dotmatrixr_t *ctx, uint8_t char_value );
243 
258 void c4dot_write_char1 ( c4dotmatrixr_t *ctx, uint8_t char_value );
259 
274 void c4dot_write_char2 ( c4dotmatrixr_t *ctx, uint8_t char_value );
275 
290 void c4dot_write_char3 ( c4dotmatrixr_t *ctx, uint8_t char_value);
291 
302 void c4dot_write_text ( c4dotmatrixr_t *ctx, uint8_t *text_to_write );
303 
314 void c4dot_write_int ( c4dotmatrixr_t *ctx, int16_t int_to_write, uint8_t int_base );
315 
327 void c4dot_write_int_bin ( c4dotmatrixr_t *ctx, int16_t int_to_write );
328 
340 void c4dot_write_int_oct ( c4dotmatrixr_t *ctx, int16_t int_to_write );
341 
353 void c4dot_write_int_dec ( c4dotmatrixr_t *ctx, int16_t int_to_write);
354 
366 void c4dot_write_int_hex ( c4dotmatrixr_t *ctx, int16_t int_to_write );
367 
376 void c4dot_clear_display ( c4dotmatrixr_t *ctx );
377 
378 #ifdef __cplusplus
379 }
380 #endif
381 #endif // _C4DOTMATRIXR_H_
382  // End public_function group
385 
386 // ------------------------------------------------------------------------- END
c4dotmatrixr_cfg_t
Click configuration structure definition.
Definition: c4dotmatrixr.h:125
c4dot_write_int
void c4dot_write_int(c4dotmatrixr_t *ctx, int16_t int_to_write, uint8_t int_base)
4DotMatrix Int Write.
c4dotmatrixr_t::i2c
i2c_master_t i2c
Definition: c4dotmatrixr.h:114
c4dot_write_int_oct
void c4dot_write_int_oct(c4dotmatrixr_t *ctx, int16_t int_to_write)
4DotMatrix Octal Int Write.
c4dotmatrixr_t
Click ctx object definition.
Definition: c4dotmatrixr.h:104
c4dot_write_char0
void c4dot_write_char0(c4dotmatrixr_t *ctx, uint8_t char_value)
4DotMatrix Char 0 Write.
c4dotmatrixr_t::cs
digital_out_t cs
Definition: c4dotmatrixr.h:109
c4dotmatrixr_generic_write
void c4dotmatrixr_generic_write(c4dotmatrixr_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
c4dotmatrixr_generic_read
void c4dotmatrixr_generic_read(c4dotmatrixr_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
c4dotmatrixr_init
C4DOTMATRIXR_RETVAL c4dotmatrixr_init(c4dotmatrixr_t *ctx, c4dotmatrixr_cfg_t *cfg)
Initialization function.
c4dotmatrixr_t::pwm
digital_out_t pwm
Definition: c4dotmatrixr.h:110
c4dot_write_char
void c4dot_write_char(c4dotmatrixr_t *ctx, uint8_t char_num, uint8_t char_value)
4DotMatrix Char Write.
c4dotmatrixr_default_cfg
void c4dotmatrixr_default_cfg(c4dotmatrixr_t *ctx)
Click Default Configuration function.
c4dot_write_int_bin
void c4dot_write_int_bin(c4dotmatrixr_t *ctx, int16_t int_to_write)
4DotMatrix Binary Int Write.
c4dotmatrixr_cfg_t::scl
pin_name_t scl
Definition: c4dotmatrixr.h:129
c4dot_write_char3
void c4dot_write_char3(c4dotmatrixr_t *ctx, uint8_t char_value)
4DotMatrix Char 3 Write.
c4dotmatrixr_cfg_t::i2c_address
uint8_t i2c_address
Definition: c4dotmatrixr.h:141
c4dotmatrixr_cfg_setup
void c4dotmatrixr_cfg_setup(c4dotmatrixr_cfg_t *cfg)
Config Object Initialization function.
c4dotmatrixr_cfg_t::pwm
pin_name_t pwm
Definition: c4dotmatrixr.h:136
c4dotmatrixr_cfg_t::sda
pin_name_t sda
Definition: c4dotmatrixr.h:130
c4dotmatrixr_t::rst
digital_out_t rst
Definition: c4dotmatrixr.h:108
c4dotmatrixr_t::slave_address
uint8_t slave_address
Definition: c4dotmatrixr.h:118
c4dotmatrixr_cfg_t::cs
pin_name_t cs
Definition: c4dotmatrixr.h:135
c4dot_write_char2
void c4dot_write_char2(c4dotmatrixr_t *ctx, uint8_t char_value)
4DotMatrix Char 2 Write.
c4dot_write_text
void c4dot_write_text(c4dotmatrixr_t *ctx, uint8_t *text_to_write)
4DotMatrix Text Write.
c4dot_clear_display
void c4dot_clear_display(c4dotmatrixr_t *ctx)
4DotMatrix Display Clear.
c4dot_write_int_dec
void c4dot_write_int_dec(c4dotmatrixr_t *ctx, int16_t int_to_write)
4DotMatrix Decimal Int Write.
c4dotmatrixr_cfg_t::rst
pin_name_t rst
Definition: c4dotmatrixr.h:134
c4dot_write_char1
void c4dot_write_char1(c4dotmatrixr_t *ctx, uint8_t char_value)
4DotMatrix Char 1 Write.
c4dot_write_int_hex
void c4dot_write_int_hex(c4dotmatrixr_t *ctx, int16_t int_to_write)
4DotMatrix Hexadecimal Int Write.
c4dotmatrixr_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: c4dotmatrixr.h:140
C4DOTMATRIXR_RETVAL
#define C4DOTMATRIXR_RETVAL
Definition: c4dotmatrixr.h:66