c8x8b  2.0.0.0
c8x8b.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 c8X8B_H
29 #define c8X8B_H
30 
31 #ifdef __cplusplus
32 extern "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 C8X8B_DECODE_MODE_REG 0x09
73 #define C8X8B_INTENSITY_REG 0x0A
74 #define C8X8B_SCAN_LIMIT_REG 0x0B
75 #define C8X8B_SHUTDOWN_REG 0x0C
76 #define C8X8B_DISPLAY_TEST_REG 0x0F
77 
82 #define C8X8B_NO_DECODE 0x00
83 #define C8X8B_DECODE_DIGIT_0 0x01
84 #define C8X8B_DECODE_DIGIT_3_0 0x0F
85 #define C8X8B_DECODE_DIGIT_7 0xFF
86 
91 #define C8X8B_INTENSITY_1 0x00
92 #define C8X8B_INTENSITY_3 0x01
93 #define C8X8B_INTENSITY_5 0x02
94 #define C8X8B_INTENSITY_7 0x03
95 #define C8X8B_INTENSITY_9 0x04
96 #define C8X8B_INTENSITY_11 0x05
97 #define C8X8B_INTENSITY_13 0x06
98 #define C8X8B_INTENSITY_15 0x07
99 #define C8X8B_INTENSITY_17 0x08
100 #define C8X8B_INTENSITY_19 0x09
101 #define C8X8B_INTENSITY_21 0x0A
102 #define C8X8B_INTENSITY_23 0x0B
103 #define C8X8B_INTENSITY_25 0x0C
104 #define C8X8B_INTENSITY_27 0x0D
105 #define C8X8B_INTENSITY_29 0x0E
106 #define C8X8B_INTENSITY_31 0x0F
107 
112 #define C8X8B_DISPLAY_DIGIT_0 0x00
113 #define C8X8B_DISPLAY_DIGIT_0_1 0x01
114 #define C8X8B_DISPLAY_DIGIT_0_2 0x02
115 #define C8X8B_DISPLAY_DIGIT_0_3 0x03
116 #define C8X8B_DISPLAY_DIGIT_0_4 0x04
117 #define C8X8B_DISPLAY_DIGIT_0_5 0x05
118 #define C8X8B_DISPLAY_DIGIT_0_6 0x06
119 #define C8X8B_DISPLAY_DIGIT_0_7 0x07
120 
125 #define C8X8B_SHUTDOWN_MODE 0x00
126 #define C8X8B_NORMAL_OPERATION 0x01
127 
128 
129 #define C8X8B_DISPLAY_NORMAL_OPERATION 0x00
130 #define C8X8B_DISPLAY_TEST_MODE 0X01
131  // c8x8b_reg
132  // c8x8b_set
149 
159 #define C8X8B_SPEED_FAST 3
160 #define C8X8B_SPEED_MEDIUM 2
161 #define C8X8B_SPEED_SLOW 1
162  // c8x8b_scroll_speed
164 
179 #define C8X8B_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  // c8x8b_map // c8x8b
187 
192 typedef struct
193 {
194 
195  spi_master_t spi;
197  pin_name_t chip_select;
199  uint8_t speed_scroll;
200 
201 } c8x8b_t;
202 
207 typedef 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;
222 } c8x8b_cfg_t;
223 
228 typedef enum
229 {
230  C8X8B_OK = 0,
231  C8X8B_ERROR = -1
232 
234 
251 
266 err_t c8x8b_init ( c8x8b_t *ctx, c8x8b_cfg_t *cfg );
267 
280 
293 void c8x8b_write_cmd ( c8x8b_t *ctx, uint8_t cmd, uint8_t tx_data );
294 
305 
320 void c8x8b_set_speed_scroll ( c8x8b_t *ctx, uint8_t speed );
321 
335 void c8x8b_display_string ( c8x8b_t *ctx, char *p_array );
336 
348 void c8x8b_display_byte ( c8x8b_t *ctx, char tx_byte );
349 
362 void c8x8b_display_image ( c8x8b_t *ctx, uint8_t *p_image );
363 
364 #ifdef __cplusplus
365 }
366 #endif
367 #endif // c8X8B_H
368  // c8x8b
370 
371 // ------------------------------------------------------------------------ END
c8x8b_cfg_setup
void c8x8b_cfg_setup(c8x8b_cfg_t *cfg)
8x8 B configuration object setup function.
C8X8B_ERROR
@ C8X8B_ERROR
Definition: c8x8b.h:231
c8x8b_t::speed_scroll
uint8_t speed_scroll
Definition: c8x8b.h:199
c8x8b_cfg_t::cs
pin_name_t cs
Definition: c8x8b.h:214
c8x8b_cfg_t
8x8 B Click configuration object.
Definition: c8x8b.h:208
C8X8B_OK
@ C8X8B_OK
Definition: c8x8b.h:230
c8x8b_init
err_t c8x8b_init(c8x8b_t *ctx, c8x8b_cfg_t *cfg)
8x8 B initialization function.
c8x8b_display_refresh
void c8x8b_display_refresh(c8x8b_t *ctx)
8x8 B function for refresh display.
c8x8b_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: c8x8b.h:220
c8x8b_t::spi
spi_master_t spi
Definition: c8x8b.h:195
c8x8b_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: c8x8b.h:219
c8x8b_display_image
void c8x8b_display_image(c8x8b_t *ctx, uint8_t *p_image)
8x8 B function for displaying image.
c8x8b_display_byte
void c8x8b_display_byte(c8x8b_t *ctx, char tx_byte)
8x8 B function for displaying one character.
c8x8b_write_cmd
void c8x8b_write_cmd(c8x8b_t *ctx, uint8_t cmd, uint8_t tx_data)
8x8 B data writing function.
c8x8b_display_string
void c8x8b_display_string(c8x8b_t *ctx, char *p_array)
8x8 B function for displaying scrolling string.
c8x8b_default_cfg
void c8x8b_default_cfg(c8x8b_t *ctx)
8x8 B default configuration function.
c8x8b_cfg_t::spi_speed
uint32_t spi_speed
Definition: c8x8b.h:218
c8x8b_cfg_t::sck
pin_name_t sck
Definition: c8x8b.h:213
c8x8b_t
8x8 B Click context object.
Definition: c8x8b.h:193
c8x8b_return_value_t
c8x8b_return_value_t
8x8 B Click return value data.
Definition: c8x8b.h:229
c8x8b_t::chip_select
pin_name_t chip_select
Definition: c8x8b.h:197
c8x8b_set_speed_scroll
void c8x8b_set_speed_scroll(c8x8b_t *ctx, uint8_t speed)
8x8 B scroll setting function.
c8x8b_cfg_t::mosi
pin_name_t mosi
Definition: c8x8b.h:212
c8x8b_cfg_t::miso
pin_name_t miso
Definition: c8x8b.h:211