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 "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_i2c_master.h"
51 
52 
53 // -------------------------------------------------------------- PUBLIC MACROS
63 #define C4DOTMATRIXR_MAP_MIKROBUS( cfg, mikrobus ) \
64  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
65  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
66  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
67  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
68  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM );
69 
76 #define C4DOTMATRIXR_RETVAL uint8_t
77 
78 #define C4DOTMATRIXR_OK 0x00
79 #define C4DOTMATRIXR_INIT_ERROR 0xFF
80 
82 #define C4DOT_IODIRA 0x00
83 #define C4DOT_IODIRB 0x01
84 #define C4DOT_IPOLA 0x02
85 #define C4DOT_IPOLB 0x03
86 #define C4DOT_GPINTENA 0x04
87 #define C4DOT_GPINTENB 0x05
88 #define C4DOT_DEFVALA 0x06
89 #define C4DOT_DEFVALB 0x07
90 #define C4DOT_INTCONA 0x08
91 #define C4DOT_INTCONB 0x09
92 #define C4DOT_IOCON 0x0A
93 #define C4DOT_GPPUA 0x0C
94 #define C4DOT_GPPUB 0x0D
95 #define C4DOT_INTFA 0x0E
96 #define C4DOT_INTFB 0x0F
97 #define C4DOT_INTCAPA 0x10
98 #define C4DOT_INTCAPB 0x11
99 #define C4DOT_GPIOA 0x12
100 #define C4DOT_GPIOB 0x13
101 #define C4DOT_OLATA 0x14
102 #define C4DOT_OLATB 0x15
103  // End group macro
105 // --------------------------------------------------------------- PUBLIC TYPES
114 typedef struct
115 {
116  // Output pins
117 
118  digital_out_t rst;
119  digital_out_t cs;
120  digital_out_t pwm;
121 
122  // Modules
123 
124  i2c_master_t i2c;
125 
126  // ctx variable
127 
128  uint8_t slave_address;
129 
131 
135 typedef struct
136 {
137  // Communication gpio pins
138 
139  pin_name_t scl;
140  pin_name_t sda;
141 
142  // Additional gpio pins
143 
144  pin_name_t rst;
145  pin_name_t cs;
146  pin_name_t pwm;
147 
148  // static variable
149 
150  uint32_t i2c_speed;
151  uint8_t i2c_address;
152 
154  // End types group
156 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
157 
163 #ifdef __cplusplus
164 extern "C"{
165 #endif
166 
176 
185 
194 
205 void c4dotmatrixr_generic_write ( c4dotmatrixr_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
206 
218 void c4dotmatrixr_generic_read ( c4dotmatrixr_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
219 
236 void c4dot_write_char ( c4dotmatrixr_t *ctx, uint8_t char_num, uint8_t char_value );
237 
252 void c4dot_write_char0 ( c4dotmatrixr_t *ctx, uint8_t char_value );
253 
268 void c4dot_write_char1 ( c4dotmatrixr_t *ctx, uint8_t char_value );
269 
284 void c4dot_write_char2 ( c4dotmatrixr_t *ctx, uint8_t char_value );
285 
300 void c4dot_write_char3 ( c4dotmatrixr_t *ctx, uint8_t char_value);
301 
312 void c4dot_write_text ( c4dotmatrixr_t *ctx, uint8_t *text_to_write );
313 
324 void c4dot_write_int ( c4dotmatrixr_t *ctx, int16_t int_to_write, uint8_t int_base );
325 
337 void c4dot_write_int_bin ( c4dotmatrixr_t *ctx, int16_t int_to_write );
338 
350 void c4dot_write_int_oct ( c4dotmatrixr_t *ctx, int16_t int_to_write );
351 
363 void c4dot_write_int_dec ( c4dotmatrixr_t *ctx, int16_t int_to_write);
364 
376 void c4dot_write_int_hex ( c4dotmatrixr_t *ctx, int16_t int_to_write );
377 
387 
388 #ifdef __cplusplus
389 }
390 #endif
391 #endif // _C4DOTMATRIXR_H_
392  // End public_function group
395 
396 // ------------------------------------------------------------------------- END
c4dotmatrixr_cfg_t
Click configuration structure definition.
Definition: c4dotmatrixr.h:136
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:124
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:115
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:119
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:120
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:139
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:151
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:146
c4dotmatrixr_cfg_t::sda
pin_name_t sda
Definition: c4dotmatrixr.h:140
c4dotmatrixr_t::rst
digital_out_t rst
Definition: c4dotmatrixr.h:118
c4dotmatrixr_t::slave_address
uint8_t slave_address
Definition: c4dotmatrixr.h:128
c4dotmatrixr_cfg_t::cs
pin_name_t cs
Definition: c4dotmatrixr.h:145
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:144
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:150
C4DOTMATRIXR_RETVAL
#define C4DOTMATRIXR_RETVAL
Definition: c4dotmatrixr.h:76