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 
35 #include "drv_digital_out.h"
36 #include "drv_spi_master.h"
37 
58 #define C8X8B_DECODE_MODE_REG 0x09
59 #define C8X8B_INTENSITY_REG 0x0A
60 #define C8X8B_SCAN_LIMIT_REG 0x0B
61 #define C8X8B_SHUTDOWN_REG 0x0C
62 #define C8X8B_DISPLAY_TEST_REG 0x0F
63 
68 #define C8X8B_NO_DECODE 0x00
69 #define C8X8B_DECODE_DIGIT_0 0x01
70 #define C8X8B_DECODE_DIGIT_3_0 0x0F
71 #define C8X8B_DECODE_DIGIT_7 0xFF
72 
77 #define C8X8B_INTENSITY_1 0x00
78 #define C8X8B_INTENSITY_3 0x01
79 #define C8X8B_INTENSITY_5 0x02
80 #define C8X8B_INTENSITY_7 0x03
81 #define C8X8B_INTENSITY_9 0x04
82 #define C8X8B_INTENSITY_11 0x05
83 #define C8X8B_INTENSITY_13 0x06
84 #define C8X8B_INTENSITY_15 0x07
85 #define C8X8B_INTENSITY_17 0x08
86 #define C8X8B_INTENSITY_19 0x09
87 #define C8X8B_INTENSITY_21 0x0A
88 #define C8X8B_INTENSITY_23 0x0B
89 #define C8X8B_INTENSITY_25 0x0C
90 #define C8X8B_INTENSITY_27 0x0D
91 #define C8X8B_INTENSITY_29 0x0E
92 #define C8X8B_INTENSITY_31 0x0F
93 
98 #define C8X8B_DISPLAY_DIGIT_0 0x00
99 #define C8X8B_DISPLAY_DIGIT_0_1 0x01
100 #define C8X8B_DISPLAY_DIGIT_0_2 0x02
101 #define C8X8B_DISPLAY_DIGIT_0_3 0x03
102 #define C8X8B_DISPLAY_DIGIT_0_4 0x04
103 #define C8X8B_DISPLAY_DIGIT_0_5 0x05
104 #define C8X8B_DISPLAY_DIGIT_0_6 0x06
105 #define C8X8B_DISPLAY_DIGIT_0_7 0x07
106 
111 #define C8X8B_SHUTDOWN_MODE 0x00
112 #define C8X8B_NORMAL_OPERATION 0x01
113 
114 
115 #define C8X8B_DISPLAY_NORMAL_OPERATION 0x00
116 #define C8X8B_DISPLAY_TEST_MODE 0X01
117  // c8x8b_reg
118  // c8x8b_set
135 
145 #define C8X8B_SPEED_FAST 3
146 #define C8X8B_SPEED_MEDIUM 2
147 #define C8X8B_SPEED_SLOW 1
148  // c8x8b_scroll_speed
150 
165 #define C8X8B_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  // c8x8b_map // c8x8b
173 
178 typedef struct
179 {
180 
181  spi_master_t spi;
183  pin_name_t chip_select;
185  uint8_t speed_scroll;
186 
187 } c8x8b_t;
188 
193 typedef 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;
208 } c8x8b_cfg_t;
209 
214 typedef enum
215 {
216  C8X8B_OK = 0,
217  C8X8B_ERROR = -1
218 
220 
237 
252 err_t c8x8b_init ( c8x8b_t *ctx, c8x8b_cfg_t *cfg );
253 
266 
279 void c8x8b_write_cmd ( c8x8b_t *ctx, uint8_t cmd, uint8_t tx_data );
280 
291 
306 void c8x8b_set_speed_scroll ( c8x8b_t *ctx, uint8_t speed );
307 
321 void c8x8b_display_string ( c8x8b_t *ctx, char *p_array );
322 
334 void c8x8b_display_byte ( c8x8b_t *ctx, char tx_byte );
335 
348 void c8x8b_display_image ( c8x8b_t *ctx, uint8_t *p_image );
349 
350 #ifdef __cplusplus
351 }
352 #endif
353 #endif // c8X8B_H
354  // c8x8b
356 
357 // ------------------------------------------------------------------------ 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:217
c8x8b_t::speed_scroll
uint8_t speed_scroll
Definition: c8x8b.h:185
c8x8b_cfg_t::cs
pin_name_t cs
Definition: c8x8b.h:200
c8x8b_cfg_t
8x8 B Click configuration object.
Definition: c8x8b.h:194
C8X8B_OK
@ C8X8B_OK
Definition: c8x8b.h:216
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:206
c8x8b_t::spi
spi_master_t spi
Definition: c8x8b.h:181
c8x8b_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: c8x8b.h:205
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:204
c8x8b_cfg_t::sck
pin_name_t sck
Definition: c8x8b.h:199
c8x8b_t
8x8 B Click context object.
Definition: c8x8b.h:179
c8x8b_return_value_t
c8x8b_return_value_t
8x8 B Click return value data.
Definition: c8x8b.h:215
c8x8b_t::chip_select
pin_name_t chip_select
Definition: c8x8b.h:183
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:198
c8x8b_cfg_t::miso
pin_name_t miso
Definition: c8x8b.h:197