c8x8r 2.0.0.0
c8x8r.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef c8x8R_H
29#define c8x8R_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_spi_master.h"
51
72#define C8X8R_DECODE_MODE_REG 0x09
73#define C8X8R_INTENSITY_REG 0x0A
74#define C8X8R_SCAN_LIMIT_REG 0x0B
75#define C8X8R_SHUTDOWN_REG 0x0C
76#define C8X8R_DISPLAY_TEST_REG 0x0F
77
82#define C8X8R_NO_DECODE 0x00
83#define C8X8R_DECODE_DIGIT_0 0x01
84#define C8X8R_DECODE_DIGIT_3_0 0x0F
85#define C8X8R_DECODE_DIGIT_7 0xFF
86
91#define C8X8R_INTENSITY_1 0x00
92#define C8X8R_INTENSITY_3 0x01
93#define C8X8R_INTENSITY_5 0x02
94#define C8X8R_INTENSITY_7 0x03
95#define C8X8R_INTENSITY_9 0x04
96#define C8X8R_INTENSITY_11 0x05
97#define C8X8R_INTENSITY_13 0x06
98#define C8X8R_INTENSITY_15 0x07
99#define C8X8R_INTENSITY_17 0x08
100#define C8X8R_INTENSITY_19 0x09
101#define C8X8R_INTENSITY_21 0x0A
102#define C8X8R_INTENSITY_23 0x0B
103#define C8X8R_INTENSITY_25 0x0C
104#define C8X8R_INTENSITY_27 0x0D
105#define C8X8R_INTENSITY_29 0x0E
106#define C8X8R_INTENSITY_31 0x0F
107
112#define C8X8R_DISPLAY_DIGIT_0 0x00
113#define C8X8R_DISPLAY_DIGIT_0_1 0x01
114#define C8X8R_DISPLAY_DIGIT_0_2 0x02
115#define C8X8R_DISPLAY_DIGIT_0_3 0x03
116#define C8X8R_DISPLAY_DIGIT_0_4 0x04
117#define C8X8R_DISPLAY_DIGIT_0_5 0x05
118#define C8X8R_DISPLAY_DIGIT_0_6 0x06
119#define C8X8R_DISPLAY_DIGIT_0_7 0x07
120
125#define C8X8R_SHUTDOWN_MODE 0x00
126#define C8X8R_NORMAL_OPERATION 0x01
127
128
129#define C8X8R_DISPLAY_NORMAL_OPERATION 0x00
130#define C8X8R_DISPLAY_TEST_MODE 0X01
131 // c8x8r_reg
132
148 // c8x8r_set
149
159#define C8X8R_SPEED_FAST 3
160#define C8X8R_SPEED_MEDIUM 2
161#define C8X8R_SPEED_SLOW 1
162
163 // c8x8r_scroll_speed
164
179#define C8X8R_MAP_MIKROBUS( cfg, mikrobus ) \
180 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
181 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
182 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
183 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
184
185 // c8x8r_map
186 // c8x8r
187
192typedef struct
193{
194
195 spi_master_t spi;
197 pin_name_t chip_select;
200
201} c8x8r_t;
202
207typedef struct
208{
209 // Communication gpio pins
210
211 pin_name_t miso;
212 pin_name_t mosi;
213 pin_name_t sck;
214 pin_name_t cs;
216 // static variable
217
218 uint32_t spi_speed;
219 spi_master_mode_t spi_mode;
220 spi_master_chip_select_polarity_t cs_polarity;
223
228typedef enum
229{
231 C8X8R_ERROR = -1
232
234
251
266err_t c8x8r_init ( c8x8r_t *ctx, c8x8r_cfg_t *cfg );
267
280
293void c8x8r_write_cmd ( c8x8r_t *ctx, uint8_t cmd, uint8_t tx_data );
294
305
320void c8x8r_set_speed_scroll ( c8x8r_t *ctx, uint8_t speed );
321
335void c8x8r_display_string ( c8x8r_t *ctx, char *p_array );
336
348void c8x8r_display_byte ( c8x8r_t *ctx, char tx_byte );
349
362void c8x8r_display_image ( c8x8r_t *ctx, uint8_t *p_image );
363
364#ifdef __cplusplus
365}
366#endif
367#endif // c8x8R_H
368
369 // c8x8r
370
371// ------------------------------------------------------------------------ END
c8x8r_return_value_t
8x8 R Click return value data.
Definition c8x8r.h:229
@ C8X8R_OK
Definition c8x8r.h:230
@ C8X8R_ERROR
Definition c8x8r.h:231
void c8x8r_cfg_setup(c8x8r_cfg_t *cfg)
8x8 R configuration object setup function.
void c8x8r_set_speed_scroll(c8x8r_t *ctx, uint8_t speed)
8x8 R scroll setting function.
void c8x8r_display_refresh(c8x8r_t *ctx)
8x8 R function for refresh display.
void c8x8r_display_byte(c8x8r_t *ctx, char tx_byte)
8x8 R function for displaying one character.
void c8x8r_display_string(c8x8r_t *ctx, char *p_array)
8x8 R function for displaying scrolling string.
void c8x8r_write_cmd(c8x8r_t *ctx, uint8_t cmd, uint8_t tx_data)
8x8 R data writing function.
err_t c8x8r_init(c8x8r_t *ctx, c8x8r_cfg_t *cfg)
8x8 R initialization function.
void c8x8r_display_image(c8x8r_t *ctx, uint8_t *p_image)
8x8 R function for displaying image.
void c8x8r_default_cfg(c8x8r_t *ctx)
8x8 R default configuration function.
8x8 R Click configuration object.
Definition c8x8r.h:208
spi_master_chip_select_polarity_t cs_polarity
Definition c8x8r.h:220
pin_name_t sck
Definition c8x8r.h:213
spi_master_mode_t spi_mode
Definition c8x8r.h:219
pin_name_t mosi
Definition c8x8r.h:212
uint32_t spi_speed
Definition c8x8r.h:218
pin_name_t miso
Definition c8x8r.h:211
pin_name_t cs
Definition c8x8r.h:214
8x8 R Click context object.
Definition c8x8r.h:193
spi_master_t spi
Definition c8x8r.h:195
uint8_t speed_scroll
Definition c8x8r.h:199
pin_name_t chip_select
Definition c8x8r.h:197