c8x8g  2.0.0.0
c8x8g.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 C8X8G_H
29 #define C8X8G_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_spi_master.h"
47 
68 #define C8X8G_DECODE_MODE_REG 0x09
69 #define C8X8G_INTENSITY_REG 0x0A
70 #define C8X8G_SCAN_LIMIT_REG 0x0B
71 #define C8X8G_SHUTDOWN_REG 0x0C
72 #define C8X8G_DISPLAY_TEST_REG 0x0F
73 
78 #define C8X8G_NO_DECODE 0x00
79 #define C8X8G_DECODE_DIGIT_0 0x01
80 #define C8X8G_DECODE_DIGIT_3_0 0x0F
81 #define C8X8G_DECODE_DIGIT_7 0xFF
82 
87 #define C8X8G_INTENSITY_1 0x00
88 #define C8X8G_INTENSITY_3 0x01
89 #define C8X8G_INTENSITY_5 0x02
90 #define C8X8G_INTENSITY_7 0x03
91 #define C8X8G_INTENSITY_9 0x04
92 #define C8X8G_INTENSITY_11 0x05
93 #define C8X8G_INTENSITY_13 0x06
94 #define C8X8G_INTENSITY_15 0x07
95 #define C8X8G_INTENSITY_17 0x08
96 #define C8X8G_INTENSITY_19 0x09
97 #define C8X8G_INTENSITY_21 0x0A
98 #define C8X8G_INTENSITY_23 0x0B
99 #define C8X8G_INTENSITY_25 0x0C
100 #define C8X8G_INTENSITY_27 0x0D
101 #define C8X8G_INTENSITY_29 0x0E
102 #define C8X8G_INTENSITY_31 0x0F
103 
108 #define C8X8G_DISPLAY_DIGIT_0 0x00
109 #define C8X8G_DISPLAY_DIGIT_0_1 0x01
110 #define C8X8G_DISPLAY_DIGIT_0_2 0x02
111 #define C8X8G_DISPLAY_DIGIT_0_3 0x03
112 #define C8X8G_DISPLAY_DIGIT_0_4 0x04
113 #define C8X8G_DISPLAY_DIGIT_0_5 0x05
114 #define C8X8G_DISPLAY_DIGIT_0_6 0x06
115 #define C8X8G_DISPLAY_DIGIT_0_7 0x07
116 
121 #define C8X8G_SHUTDOWN_MODE 0x00
122 #define C8X8G_NORMAL_OPERATION 0x01
123 
124 
125 #define C8X8G_DISPLAY_NORMAL_OPERATION 0x00
126 #define C8X8G_DISPLAY_TEST_MODE 0X01
127  // c8x8g_reg
128  // c8x8g_set
145 
155 #define C8X8G_SPEED_FAST 3
156 #define C8X8G_SPEED_MEDIUM 2
157 #define C8X8G_SPEED_SLOW 1
158  // c8x8g_scroll_speed
160 
175 #define C8X8G_MAP_MIKROBUS( cfg, mikrobus ) \
176  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
177  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
178  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
179  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
180  // c8x8g_map // c8x8g
183 
188 typedef struct
189 {
190 
191  spi_master_t spi;
193  pin_name_t chip_select;
195  uint8_t speed_scroll;
196 
197 } c8x8g_t;
198 
203 typedef struct
204 {
205  // Communication gpio pins
206 
207  pin_name_t miso;
208  pin_name_t mosi;
209  pin_name_t sck;
210  pin_name_t cs;
212  // static variable
213 
214  uint32_t spi_speed;
215  spi_master_mode_t spi_mode;
216  spi_master_chip_select_polarity_t cs_polarity;
218 } c8x8g_cfg_t;
219 
224 typedef enum
225 {
226  C8X8G_OK = 0,
227  C8X8G_ERROR = -1
228 
230 
247 
262 err_t c8x8g_init ( c8x8g_t *ctx, c8x8g_cfg_t *cfg );
263 
276 
289 void c8x8g_write_cmd ( c8x8g_t *ctx, uint8_t cmd, uint8_t tx_data );
290 
301 
316 void c8x8g_set_speed_scroll ( c8x8g_t *ctx, uint8_t speed );
317 
331 void c8x8g_display_string ( c8x8g_t *ctx, char *p_array );
332 
344 void c8x8g_display_byte ( c8x8g_t *ctx, char tx_byte );
345 
358 void c8x8g_display_image ( c8x8g_t *ctx, uint8_t *p_image );
359 
360 #ifdef __cplusplus
361 }
362 #endif
363 #endif // C8X8G_H
364  // c8x8g
366 
367 // ------------------------------------------------------------------------ END
c8x8g_t::speed_scroll
uint8_t speed_scroll
Definition: c8x8g.h:195
c8x8g_display_image
void c8x8g_display_image(c8x8g_t *ctx, uint8_t *p_image)
8x8 G function for displaying image.
c8x8g_cfg_t
8x8 G Click configuration object.
Definition: c8x8g.h:204
C8X8G_OK
@ C8X8G_OK
Definition: c8x8g.h:226
c8x8g_cfg_setup
void c8x8g_cfg_setup(c8x8g_cfg_t *cfg)
8x8 G configuration object setup function.
C8X8G_ERROR
@ C8X8G_ERROR
Definition: c8x8g.h:227
c8x8g_cfg_t::miso
pin_name_t miso
Definition: c8x8g.h:207
c8x8g_t::spi
spi_master_t spi
Definition: c8x8g.h:191
c8x8g_display_refresh
void c8x8g_display_refresh(c8x8g_t *ctx)
8x8 G function for refresh display.
c8x8g_write_cmd
void c8x8g_write_cmd(c8x8g_t *ctx, uint8_t cmd, uint8_t tx_data)
8x8 G data writing function.
c8x8g_set_speed_scroll
void c8x8g_set_speed_scroll(c8x8g_t *ctx, uint8_t speed)
8x8 G scroll setting function.
c8x8g_display_byte
void c8x8g_display_byte(c8x8g_t *ctx, char tx_byte)
8x8 G function for displaying one character.
c8x8g_cfg_t::spi_speed
uint32_t spi_speed
Definition: c8x8g.h:214
c8x8g_t
8x8 G Click context object.
Definition: c8x8g.h:189
c8x8g_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: c8x8g.h:215
c8x8g_cfg_t::sck
pin_name_t sck
Definition: c8x8g.h:209
c8x8g_display_string
void c8x8g_display_string(c8x8g_t *ctx, char *p_array)
8x8 G function for displaying scrolling string.
c8x8g_default_cfg
void c8x8g_default_cfg(c8x8g_t *ctx)
8x8 G default configuration function.
c8x8g_cfg_t::cs
pin_name_t cs
Definition: c8x8g.h:210
c8x8g_init
err_t c8x8g_init(c8x8g_t *ctx, c8x8g_cfg_t *cfg)
8x8 G initialization function.
c8x8g_t::chip_select
pin_name_t chip_select
Definition: c8x8g.h:193
c8x8g_return_value_t
c8x8g_return_value_t
8x8 G Click return value data.
Definition: c8x8g.h:225
c8x8g_cfg_t::mosi
pin_name_t mosi
Definition: c8x8g.h:208
c8x8g_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: c8x8g.h:216