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
35#include "drv_digital_out.h"
36#include "drv_spi_master.h"
37
58#define C8X8R_DECODE_MODE_REG 0x09
59#define C8X8R_INTENSITY_REG 0x0A
60#define C8X8R_SCAN_LIMIT_REG 0x0B
61#define C8X8R_SHUTDOWN_REG 0x0C
62#define C8X8R_DISPLAY_TEST_REG 0x0F
63
68#define C8X8R_NO_DECODE 0x00
69#define C8X8R_DECODE_DIGIT_0 0x01
70#define C8X8R_DECODE_DIGIT_3_0 0x0F
71#define C8X8R_DECODE_DIGIT_7 0xFF
72
77#define C8X8R_INTENSITY_1 0x00
78#define C8X8R_INTENSITY_3 0x01
79#define C8X8R_INTENSITY_5 0x02
80#define C8X8R_INTENSITY_7 0x03
81#define C8X8R_INTENSITY_9 0x04
82#define C8X8R_INTENSITY_11 0x05
83#define C8X8R_INTENSITY_13 0x06
84#define C8X8R_INTENSITY_15 0x07
85#define C8X8R_INTENSITY_17 0x08
86#define C8X8R_INTENSITY_19 0x09
87#define C8X8R_INTENSITY_21 0x0A
88#define C8X8R_INTENSITY_23 0x0B
89#define C8X8R_INTENSITY_25 0x0C
90#define C8X8R_INTENSITY_27 0x0D
91#define C8X8R_INTENSITY_29 0x0E
92#define C8X8R_INTENSITY_31 0x0F
93
98#define C8X8R_DISPLAY_DIGIT_0 0x00
99#define C8X8R_DISPLAY_DIGIT_0_1 0x01
100#define C8X8R_DISPLAY_DIGIT_0_2 0x02
101#define C8X8R_DISPLAY_DIGIT_0_3 0x03
102#define C8X8R_DISPLAY_DIGIT_0_4 0x04
103#define C8X8R_DISPLAY_DIGIT_0_5 0x05
104#define C8X8R_DISPLAY_DIGIT_0_6 0x06
105#define C8X8R_DISPLAY_DIGIT_0_7 0x07
106
111#define C8X8R_SHUTDOWN_MODE 0x00
112#define C8X8R_NORMAL_OPERATION 0x01
113
114
115#define C8X8R_DISPLAY_NORMAL_OPERATION 0x00
116#define C8X8R_DISPLAY_TEST_MODE 0X01 // c8x8r_reg
118 // c8x8r_set
135
145#define C8X8R_SPEED_FAST 3
146#define C8X8R_SPEED_MEDIUM 2
147#define C8X8R_SPEED_SLOW 1
148 // c8x8r_scroll_speed
150
165#define C8X8R_MAP_MIKROBUS( cfg, mikrobus ) \
166 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
167 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
168 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
169 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
170 // c8x8r_map // c8x8r
173
178typedef struct
179{
180
181 spi_master_t spi;
183 pin_name_t chip_select;
186
187} c8x8r_t;
188
193typedef struct
194{
195 // Communication gpio pins
196
197 pin_name_t miso;
198 pin_name_t mosi;
199 pin_name_t sck;
200 pin_name_t cs;
202 // static variable
203
204 uint32_t spi_speed;
205 spi_master_mode_t spi_mode;
206 spi_master_chip_select_polarity_t cs_polarity;
209
214typedef enum
215{
217 C8X8R_ERROR = -1
218
220
237
252err_t c8x8r_init ( c8x8r_t *ctx, c8x8r_cfg_t *cfg );
253
266
279void c8x8r_write_cmd ( c8x8r_t *ctx, uint8_t cmd, uint8_t tx_data );
280
291
306void c8x8r_set_speed_scroll ( c8x8r_t *ctx, uint8_t speed );
307
321void c8x8r_display_string ( c8x8r_t *ctx, char *p_array );
322
334void c8x8r_display_byte ( c8x8r_t *ctx, char tx_byte );
335
348void c8x8r_display_image ( c8x8r_t *ctx, uint8_t *p_image );
349
350#ifdef __cplusplus
351}
352#endif
353#endif // c8x8R_H
354 // c8x8r
356
357// ------------------------------------------------------------------------ END
c8x8r_return_value_t
8x8 R Click return value data.
Definition: c8x8r.h:215
@ C8X8R_OK
Definition: c8x8r.h:216
@ C8X8R_ERROR
Definition: c8x8r.h:217
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:194
spi_master_chip_select_polarity_t cs_polarity
Definition: c8x8r.h:206
pin_name_t sck
Definition: c8x8r.h:199
spi_master_mode_t spi_mode
Definition: c8x8r.h:205
pin_name_t mosi
Definition: c8x8r.h:198
uint32_t spi_speed
Definition: c8x8r.h:204
pin_name_t miso
Definition: c8x8r.h:197
pin_name_t cs
Definition: c8x8r.h:200
8x8 R Click context object.
Definition: c8x8r.h:179
spi_master_t spi
Definition: c8x8r.h:181
uint8_t speed_scroll
Definition: c8x8r.h:185
pin_name_t chip_select
Definition: c8x8r.h:183