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
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
57// -------------------------------------------------------------- PUBLIC MACROS
67#define C4DOTMATRIXR_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM );
73
80#define C4DOTMATRIXR_RETVAL uint8_t
81
82#define C4DOTMATRIXR_OK 0x00
83#define C4DOTMATRIXR_INIT_ERROR 0xFF
86#define C4DOT_IODIRA 0x00
87#define C4DOT_IODIRB 0x01
88#define C4DOT_IPOLA 0x02
89#define C4DOT_IPOLB 0x03
90#define C4DOT_GPINTENA 0x04
91#define C4DOT_GPINTENB 0x05
92#define C4DOT_DEFVALA 0x06
93#define C4DOT_DEFVALB 0x07
94#define C4DOT_INTCONA 0x08
95#define C4DOT_INTCONB 0x09
96#define C4DOT_IOCON 0x0A
97#define C4DOT_GPPUA 0x0C
98#define C4DOT_GPPUB 0x0D
99#define C4DOT_INTFA 0x0E
100#define C4DOT_INTFB 0x0F
101#define C4DOT_INTCAPA 0x10
102#define C4DOT_INTCAPB 0x11
103#define C4DOT_GPIOA 0x12
104#define C4DOT_GPIOB 0x13
105#define C4DOT_OLATA 0x14
106#define C4DOT_OLATB 0x15
107
108 // End group macro
109// --------------------------------------------------------------- PUBLIC TYPES
118typedef struct
119{
120 // Output pins
121
122 digital_out_t rst;
123 digital_out_t cs;
124 digital_out_t pwm;
125
126 // Modules
127
128 i2c_master_t i2c;
129
130 // ctx variable
131
133
135
139typedef struct
140{
141 // Communication gpio pins
142
143 pin_name_t scl;
144 pin_name_t sda;
145
146 // Additional gpio pins
147
148 pin_name_t rst;
149 pin_name_t cs;
150 pin_name_t pwm;
151
152 // static variable
153
154 uint32_t i2c_speed;
155 uint8_t i2c_address;
156
158
159 // End types group
160// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
161
167#ifdef __cplusplus
168extern "C"{
169#endif
170
180
189
198
209void c4dotmatrixr_generic_write ( c4dotmatrixr_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
210
222void c4dotmatrixr_generic_read ( c4dotmatrixr_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
223
240void c4dot_write_char ( c4dotmatrixr_t *ctx, uint8_t char_num, uint8_t char_value );
241
256void c4dot_write_char0 ( c4dotmatrixr_t *ctx, uint8_t char_value );
257
272void c4dot_write_char1 ( c4dotmatrixr_t *ctx, uint8_t char_value );
273
288void c4dot_write_char2 ( c4dotmatrixr_t *ctx, uint8_t char_value );
289
304void c4dot_write_char3 ( c4dotmatrixr_t *ctx, uint8_t char_value);
305
316void c4dot_write_text ( c4dotmatrixr_t *ctx, uint8_t *text_to_write );
317
328void c4dot_write_int ( c4dotmatrixr_t *ctx, int16_t int_to_write, uint8_t int_base );
329
341void c4dot_write_int_bin ( c4dotmatrixr_t *ctx, int16_t int_to_write );
342
354void c4dot_write_int_oct ( c4dotmatrixr_t *ctx, int16_t int_to_write );
355
367void c4dot_write_int_dec ( c4dotmatrixr_t *ctx, int16_t int_to_write);
368
380void c4dot_write_int_hex ( c4dotmatrixr_t *ctx, int16_t int_to_write );
381
391
392#ifdef __cplusplus
393}
394#endif
395#endif // _C4DOTMATRIXR_H_
396
397 // End public_function group
399
400// ------------------------------------------------------------------------- END
#define C4DOTMATRIXR_RETVAL
Definition c4dotmatrixr.h:80
void c4dotmatrixr_generic_write(c4dotmatrixr_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void c4dot_write_char2(c4dotmatrixr_t *ctx, uint8_t char_value)
4DotMatrix Char 2 Write.
void c4dot_write_char1(c4dotmatrixr_t *ctx, uint8_t char_value)
4DotMatrix Char 1 Write.
void c4dot_write_text(c4dotmatrixr_t *ctx, uint8_t *text_to_write)
4DotMatrix Text Write.
void c4dot_write_char3(c4dotmatrixr_t *ctx, uint8_t char_value)
4DotMatrix Char 3 Write.
void c4dot_write_int_dec(c4dotmatrixr_t *ctx, int16_t int_to_write)
4DotMatrix Decimal Int Write.
void c4dot_write_int_hex(c4dotmatrixr_t *ctx, int16_t int_to_write)
4DotMatrix Hexadecimal Int Write.
void c4dotmatrixr_default_cfg(c4dotmatrixr_t *ctx)
Click Default Configuration function.
void c4dot_write_int_bin(c4dotmatrixr_t *ctx, int16_t int_to_write)
4DotMatrix Binary Int Write.
void c4dot_write_char0(c4dotmatrixr_t *ctx, uint8_t char_value)
4DotMatrix Char 0 Write.
C4DOTMATRIXR_RETVAL c4dotmatrixr_init(c4dotmatrixr_t *ctx, c4dotmatrixr_cfg_t *cfg)
Initialization function.
void c4dot_write_int_oct(c4dotmatrixr_t *ctx, int16_t int_to_write)
4DotMatrix Octal Int Write.
void c4dotmatrixr_generic_read(c4dotmatrixr_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void c4dot_write_char(c4dotmatrixr_t *ctx, uint8_t char_num, uint8_t char_value)
4DotMatrix Char Write.
void c4dot_write_int(c4dotmatrixr_t *ctx, int16_t int_to_write, uint8_t int_base)
4DotMatrix Int Write.
void c4dotmatrixr_cfg_setup(c4dotmatrixr_cfg_t *cfg)
Config Object Initialization function.
void c4dot_clear_display(c4dotmatrixr_t *ctx)
4DotMatrix Display Clear.
Click configuration structure definition.
Definition c4dotmatrixr.h:140
uint32_t i2c_speed
Definition c4dotmatrixr.h:154
pin_name_t scl
Definition c4dotmatrixr.h:143
pin_name_t pwm
Definition c4dotmatrixr.h:150
pin_name_t sda
Definition c4dotmatrixr.h:144
pin_name_t rst
Definition c4dotmatrixr.h:148
pin_name_t cs
Definition c4dotmatrixr.h:149
uint8_t i2c_address
Definition c4dotmatrixr.h:155
Click ctx object definition.
Definition c4dotmatrixr.h:119
digital_out_t cs
Definition c4dotmatrixr.h:123
digital_out_t pwm
Definition c4dotmatrixr.h:124
i2c_master_t i2c
Definition c4dotmatrixr.h:128
digital_out_t rst
Definition c4dotmatrixr.h:122
uint8_t slave_address
Definition c4dotmatrixr.h:132