c8800retro  2.0.0.0
c8800retro.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 C8800RETRO_H
29 #define C8800RETRO_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_digital_in.h"
47 #include "drv_i2c_master.h"
48 
69 #define C8800RETRO_REG_DIGIT_0 0x01
70 #define C8800RETRO_REG_DIGIT_1 0x02
71 #define C8800RETRO_REG_DIGIT_2 0x03
72 #define C8800RETRO_REG_DIGIT_3 0x04
73 #define C8800RETRO_REG_DIGIT_4 0x05
74 #define C8800RETRO_REG_DIGIT_5 0x06
75 #define C8800RETRO_REG_DIGIT_6 0x07
76 #define C8800RETRO_REG_DIGIT_7 0x08
77 #define C8800RETRO_REG_DECODE_MODE 0x09
78 #define C8800RETRO_REG_GLOBAL_INTENSITY 0x0A
79 #define C8800RETRO_REG_SCAN_LIMIT 0x0B
80 #define C8800RETRO_REG_SHUTDOWN 0x0C
81 #define C8800RETRO_REG_SELF_ADDRESSING 0x2D
82 #define C8800RETRO_REG_FEATURE 0x0E
83 #define C8800RETRO_REG_DISPLAY_TEST_MODE 0x0F
84 #define C8800RETRO_REG_DIG0_DIG1_INTENSITY 0x10
85 #define C8800RETRO_REG_DIG2_DIG3_INTENSITY 0x11
86 #define C8800RETRO_REG_DIG4_DIG5_INTENSITY 0x12
87 #define C8800RETRO_REG_DIG6_DIG7_INTENSITY 0x13
88 #define C8800RETRO_REG_DIAG_DIGIT_0 0x14
89 #define C8800RETRO_REG_DIAG_DIGIT_1 0x15
90 #define C8800RETRO_REG_DIAG_DIGIT_2 0x16
91 #define C8800RETRO_REG_DIAG_DIGIT_3 0x17
92 #define C8800RETRO_REG_DIAG_DIGIT_4 0x18
93 #define C8800RETRO_REG_DIAG_DIGIT_5 0x19
94 #define C8800RETRO_REG_DIAG_DIGIT_6 0x1A
95 #define C8800RETRO_REG_DIAG_DIGIT_7 0x1B
96 #define C8800RETRO_REG_KEYA 0x1C
97 #define C8800RETRO_REG_KEYB 0x1D
98  // c8800retro_reg
100 
115 #define C8800RETRO_SHUTDOWN_RESET 0x00
116 #define C8800RETRO_SHUTDOWN 0x80
117 #define C8800RETRO_NORMAL_OPERATION_RESET 0x01
118 #define C8800RETRO_NORMAL_OPERATION 0x81
119 
124 #define C8800RETRO_NO_DECODE 0x00
125 #define C8800RETRO_DECODE_0 0x01
126 #define C8800RETRO_DECODE_0_2 0x07
127 #define C8800RETRO_DECODE_0_5 0x3F
128 #define C8800RETRO_DECODE_0_2_5 0x25
129 
134 #define C8800RETRO_FACTORY_SET_ADDRESS 0x00
135 #define C8800RETRO_USER_SET_ADDRESS 0x01
136 
141 #define C8800RETRO_INTENSITY_1 0x00
142 #define C8800RETRO_INTENSITY_2 0x01
143 #define C8800RETRO_INTENSITY_3 0x02
144 #define C8800RETRO_INTENSITY_4 0x03
145 #define C8800RETRO_INTENSITY_5 0x04
146 #define C8800RETRO_INTENSITY_6 0x05
147 #define C8800RETRO_INTENSITY_7 0x06
148 #define C8800RETRO_INTENSITY_8 0x07
149 #define C8800RETRO_INTENSITY_9 0x08
150 #define C8800RETRO_INTENSITY_10 0x09
151 #define C8800RETRO_INTENSITY_11 0x0A
152 #define C8800RETRO_INTENSITY_12 0x0B
153 #define C8800RETRO_INTENSITY_13 0x0C
154 #define C8800RETRO_INTENSITY_14 0x0D
155 #define C8800RETRO_INTENSITY_15 0x0E
156 #define C8800RETRO_INTENSITY_16 0x0F
157 
162 #define C8800RETRO_SCAN_LIMIT_0 0x00
163 #define C8800RETRO_SCAN_LIMIT_0_1 0x01
164 #define C8800RETRO_SCAN_LIMIT_0_2 0x02
165 #define C8800RETRO_SCAN_LIMIT_0_3 0x03
166 #define C8800RETRO_SCAN_LIMIT_0_4 0x04
167 #define C8800RETRO_SCAN_LIMIT_0_5 0x05
168 #define C8800RETRO_SCAN_LIMIT_0_6 0x06
169 #define C8800RETRO_SCAN_LIMIT_0_7 0x07
170 
175 #define C8800RETRO_KEY_NONE 0x0000
176 #define C8800RETRO_KEY_A1 0x8000
177 #define C8800RETRO_KEY_A2 0x4000
178 #define C8800RETRO_KEY_A3 0x2000
179 #define C8800RETRO_KEY_A4 0x1000
180 #define C8800RETRO_KEY_B1 0x0800
181 #define C8800RETRO_KEY_B2 0x0400
182 #define C8800RETRO_KEY_B3 0x0200
183 #define C8800RETRO_KEY_B4 0x0100
184 #define C8800RETRO_KEY_C1 0x0080
185 #define C8800RETRO_KEY_C2 0x0040
186 #define C8800RETRO_KEY_C3 0x0020
187 #define C8800RETRO_KEY_C4 0x0010
188 #define C8800RETRO_KEY_D1 0x0008
189 #define C8800RETRO_KEY_D2 0x0004
190 #define C8800RETRO_KEY_D3 0x0002
191 #define C8800RETRO_KEY_D4 0x0001
192 
197 #define C8800RETRO_SCROLL_SPEED_SLOW 300
198 #define C8800RETRO_SCROLL_SPEED_MEDIUM 150
199 #define C8800RETRO_SCROLL_SPEED_FAST 50
200 #define C8800RETRO_SCROLL_HORIZONTAL_LEFT 0
201 #define C8800RETRO_SCROLL_HORIZONTAL_RIGHT 1
202 #define C8800RETRO_SCROLL_VERTICAL_UP 2
203 #define C8800RETRO_SCROLL_VERTICAL_DOWN 3
204 
210 #define C8800RETRO_SET_DEV_ADDR 0x00
211  // c8800retro_set
213 
228 #define C8800RETRO_MAP_MIKROBUS( cfg, mikrobus ) \
229  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
230  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
231  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
232  // c8800retro_map // c8800retro
235 
240 typedef struct
241 {
242  // Input pins
243  digital_in_t int_pin;
245  // Modules
246  i2c_master_t i2c;
248  // I2C slave address
249  uint8_t slave_address;
251 } c8800retro_t;
252 
257 typedef struct
258 {
259  pin_name_t scl;
260  pin_name_t sda;
262  pin_name_t int_pin;
264  uint32_t i2c_speed;
265  uint8_t i2c_address;
268 
273 typedef enum
274 {
276  C8800RETRO_ERROR = -1
277 
279 
296 
312 
327 
341 err_t c8800retro_write_reg ( c8800retro_t *ctx, uint8_t reg, uint8_t data_in );
342 
358 err_t c8800retro_read_reg ( c8800retro_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
359 
372 
387 err_t c8800retro_display_char ( c8800retro_t *ctx, uint8_t char_index );
388 
401 err_t c8800retro_display_image ( c8800retro_t *ctx, uint8_t *p_image );
402 
420 err_t c8800retro_display_string ( c8800retro_t *ctx, uint8_t scroll_mode, uint16_t scroll_speed_ms, uint8_t *text );
421 
431 
444 
458 err_t c8800retro_get_keypad ( c8800retro_t *ctx, uint16_t *keypad );
459 
460 #ifdef __cplusplus
461 }
462 #endif
463 #endif // C8800RETRO_H
464  // c8800retro
466 
467 // ------------------------------------------------------------------------ END
c8800retro_get_int_pin
uint8_t c8800retro_get_int_pin(c8800retro_t *ctx)
8800 Retro get int pin function.
c8800retro_t::i2c
i2c_master_t i2c
Definition: c8800retro.h:246
c8800retro_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: c8800retro.h:264
c8800retro_read_reg
err_t c8800retro_read_reg(c8800retro_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
8800 Retro read register function.
c8800retro_return_value_t
c8800retro_return_value_t
8800 Retro Click return value data.
Definition: c8800retro.h:274
c8800retro_clear_display
err_t c8800retro_clear_display(c8800retro_t *ctx)
8800 Retro clear display function.
C8800RETRO_ERROR
@ C8800RETRO_ERROR
Definition: c8800retro.h:276
c8800retro_display_image
err_t c8800retro_display_image(c8800retro_t *ctx, uint8_t *p_image)
8800 Retro display image function.
c8800retro_write_reg
err_t c8800retro_write_reg(c8800retro_t *ctx, uint8_t reg, uint8_t data_in)
8800 Retro write register function.
c8800retro_init
err_t c8800retro_init(c8800retro_t *ctx, c8800retro_cfg_t *cfg)
8800 Retro initialization function.
c8800retro_cfg_t::scl
pin_name_t scl
Definition: c8800retro.h:259
c8800retro_default_cfg
err_t c8800retro_default_cfg(c8800retro_t *ctx)
8800 Retro default configuration function.
c8800retro_display_char
err_t c8800retro_display_char(c8800retro_t *ctx, uint8_t char_index)
8800 Retro display char function.
C8800RETRO_OK
@ C8800RETRO_OK
Definition: c8800retro.h:275
c8800retro_get_keypad
err_t c8800retro_get_keypad(c8800retro_t *ctx, uint16_t *keypad)
8800 Retro get keypad function.
c8800retro_cfg_t::i2c_address
uint8_t i2c_address
Definition: c8800retro.h:265
c8800retro_display_string
err_t c8800retro_display_string(c8800retro_t *ctx, uint8_t scroll_mode, uint16_t scroll_speed_ms, uint8_t *text)
8800 Retro display string function.
c8800retro_cfg_t::sda
pin_name_t sda
Definition: c8800retro.h:260
c8800retro_t::int_pin
digital_in_t int_pin
Definition: c8800retro.h:243
c8800retro_clear_interrupt
err_t c8800retro_clear_interrupt(c8800retro_t *ctx)
8800 Retro clear interrupt function.
c8800retro_cfg_t
8800 Retro Click configuration object.
Definition: c8800retro.h:258
c8800retro_cfg_setup
void c8800retro_cfg_setup(c8800retro_cfg_t *cfg)
8800 Retro configuration object setup function.
c8800retro_t::slave_address
uint8_t slave_address
Definition: c8800retro.h:249
c8800retro_cfg_t::int_pin
pin_name_t int_pin
Definition: c8800retro.h:262
c8800retro_t
8800 Retro Click context object.
Definition: c8800retro.h:241