c7x10g  2.0.0.0
c7x10g.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 C7X10G_H
29 #define C7X10G_H
30 
31 #include "drv_digital_out.h"
32 #include "drv_digital_in.h"
33 #include "drv_spi_master.h"
34 
35 // -------------------------------------------------------------- PUBLIC MACROS
36 
47 #define C7X10G_MAP_MIKROBUS( cfg, mikrobus ) \
48  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
49  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
50  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
51  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
52  cfg.rc = MIKROBUS( mikrobus, MIKROBUS_AN ); \
53  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
54  cfg.rr = MIKROBUS( mikrobus, MIKROBUS_PWM )
55 
61 #define C7X10G_DISPLAY_DELAY_5MS 5
62 #define C7X10G_DISPLAY_DELAY_10MS 10
63 #define C7X10G_DISPLAY_DELAY_20MS 20
64 #define C7X10G_DISPLAY_DELAY_35MS 35
65 #define C7X10G_DISPLAY_DELAY_50MS 50
66 #define C7X10G_DISPLAY_DELAY_100MS 100
67 #define C7X10G_DISPLAY_DELAY_150MS 150
68 
74 #define C7X10G_DISPLAY_LEFT 0x00
75 #define C7X10G_DISPLAY_RIGHT 0x01
76 #define C7X10G_DISPLAY_REFRESH 0x10
77 
83 #define C7X10G_DISPLAY_PIXEL_REFRESH 0x01
84 #define C7X10G_DISPLAY_PIXEL_STORAGE 0x00
85  // End group macro
88 
89 // --------------------------------------------------------------- PUBLIC TYPES
90 
99 typedef struct
100 {
101  digital_out_t cs;
102 
103  // Output pins
104 
105  digital_out_t rc;
106  digital_out_t rst;
107  digital_out_t rr;
108 
109  // Modules
110 
111  spi_master_t spi;
112  pin_name_t chip_select;
113 
114 } c7x10g_t;
115 
119 typedef struct
120 {
121  // Communication gpio pins
122 
123  pin_name_t miso;
124  pin_name_t mosi;
125  pin_name_t sck;
126  pin_name_t cs;
127 
128  // Additional gpio pins
129 
130  pin_name_t rc;
131  pin_name_t rst;
132  pin_name_t rr;
133 
134  // static variable
135 
136  uint32_t spi_speed;
137  spi_master_mode_t spi_mode;
138  spi_master_chip_select_polarity_t cs_polarity;
139 
140 } c7x10g_cfg_t;
141 
145 typedef struct
146 {
147  uint8_t cord_x;
148  uint8_t cord_y;
149 
151 
152 typedef enum
153 {
154 
156  C7X10G_ERROR = -1
157 
159  // End types group
161 
162 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
163 
168 #ifdef __cplusplus
169 extern "C"{
170 #endif
171 
180 void c7x10g_cfg_setup ( c7x10g_cfg_t *cfg );
181 
191 
201 void c7x10g_display_process ( c7x10g_t *ctx, uint8_t *frame, uint16_t disp_delay );
202 
212 void c7x10g_draw_pixel ( c7x10g_t *ctx, c7x10g_pixel_t *pixel, uint8_t mode, uint8_t px_delay );
213 
224 void c7x10g_draw_char ( c7x10g_t *ctx, char ch, uint8_t pos, uint8_t ch_delay );
225 
235 void c7x10g_draw_number ( c7x10g_t *ctx, uint8_t num, uint16_t num_delay );
236 
237 #ifdef __cplusplus
238 }
239 #endif
240 #endif // _C7X10G_H_
241  // End public_function group
244 
245 // ------------------------------------------------------------------------- END
c7x10g_cfg_t
Click configuration structure definition.
Definition: c7x10g.h:118
c7x10g_draw_char
void c7x10g_draw_char(c7x10g_t *ctx, char ch, uint8_t pos, uint8_t ch_delay)
Draw char (function).
c7x10g_draw_pixel
void c7x10g_draw_pixel(c7x10g_t *ctx, c7x10g_pixel_t *pixel, uint8_t mode, uint8_t px_delay)
Draw pixel (function).
c7x10g_return_value_t
c7x10g_return_value_t
Definition: c7x10g.h:151
c7x10g_cfg_setup
void c7x10g_cfg_setup(c7x10g_cfg_t *cfg)
Config Object Initialization function.
C7X10G_ERROR
Definition: c7x10g.h:155
c7x10g_init
c7x10g_return_value_t c7x10g_init(c7x10g_t *ctx, c7x10g_cfg_t *cfg)
Initialization function.
c7x10g_draw_number
void c7x10g_draw_number(c7x10g_t *ctx, uint8_t num, uint16_t num_delay)
Draw number (function).
c7x10g_t
Click ctx object definition.
Definition: c7x10g.h:98
c7x10g_display_process
void c7x10g_display_process(c7x10g_t *ctx, uint8_t *frame, uint16_t disp_delay)
Display process (function).
C7X10G_OK
Definition: c7x10g.h:154
c7x10g_pixel_t
pixel structure definition.
Definition: c7x10g.h:144