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 
35 #ifdef PREINIT_SUPPORTED
36 #include "preinit.h"
37 #endif
38 
39 #ifdef MikroCCoreVersion
40  #if MikroCCoreVersion >= 1
41  #include "delays.h"
42  #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_spi_master.h"
48 
49 // -------------------------------------------------------------- PUBLIC MACROS
50 
61 #define C7X10G_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
63  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
64  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
65  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
66  cfg.rc = MIKROBUS( mikrobus, MIKROBUS_AN ); \
67  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
68  cfg.rr = MIKROBUS( mikrobus, MIKROBUS_PWM )
69 
75 #define C7X10G_DISPLAY_DELAY_5MS 5
76 #define C7X10G_DISPLAY_DELAY_10MS 10
77 #define C7X10G_DISPLAY_DELAY_20MS 20
78 #define C7X10G_DISPLAY_DELAY_35MS 35
79 #define C7X10G_DISPLAY_DELAY_50MS 50
80 #define C7X10G_DISPLAY_DELAY_100MS 100
81 #define C7X10G_DISPLAY_DELAY_150MS 150
82 
88 #define C7X10G_DISPLAY_LEFT 0x00
89 #define C7X10G_DISPLAY_RIGHT 0x01
90 #define C7X10G_DISPLAY_REFRESH 0x10
91 
97 #define C7X10G_DISPLAY_PIXEL_REFRESH 0x01
98 #define C7X10G_DISPLAY_PIXEL_STORAGE 0x00
99  // End group macro
102 
103 // --------------------------------------------------------------- PUBLIC TYPES
104 
113 typedef struct
114 {
115  digital_out_t cs;
116 
117  // Output pins
118 
119  digital_out_t rc;
120  digital_out_t rst;
121  digital_out_t rr;
122 
123  // Modules
124 
125  spi_master_t spi;
126  pin_name_t chip_select;
127 
128 } c7x10g_t;
129 
133 typedef struct
134 {
135  // Communication gpio pins
136 
137  pin_name_t miso;
138  pin_name_t mosi;
139  pin_name_t sck;
140  pin_name_t cs;
141 
142  // Additional gpio pins
143 
144  pin_name_t rc;
145  pin_name_t rst;
146  pin_name_t rr;
147 
148  // static variable
149 
150  uint32_t spi_speed;
151  spi_master_mode_t spi_mode;
152  spi_master_chip_select_polarity_t cs_polarity;
153 
154 } c7x10g_cfg_t;
155 
159 typedef struct
160 {
161  uint8_t cord_x;
162  uint8_t cord_y;
163 
165 
166 typedef enum
167 {
168 
170  C7X10G_ERROR = -1
171 
173  // End types group
175 
176 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
177 
182 #ifdef __cplusplus
183 extern "C"{
184 #endif
185 
195 
205 
215 void c7x10g_display_process ( c7x10g_t *ctx, uint8_t *frame, uint16_t disp_delay );
216 
226 void c7x10g_draw_pixel ( c7x10g_t *ctx, c7x10g_pixel_t *pixel, uint8_t mode, uint8_t px_delay );
227 
238 void c7x10g_draw_char ( c7x10g_t *ctx, char ch, uint8_t pos, uint8_t ch_delay );
239 
249 void c7x10g_draw_number ( c7x10g_t *ctx, uint8_t num, uint16_t num_delay );
250 
251 #ifdef __cplusplus
252 }
253 #endif
254 #endif // _C7X10G_H_
255  // End public_function group
258 
259 // ------------------------------------------------------------------------- END
c7x10g_t::cs
digital_out_t cs
Definition: c7x10g.h:115
c7x10g_cfg_t
Click configuration structure definition.
Definition: c7x10g.h:134
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:167
c7x10g_t::rst
digital_out_t rst
Definition: c7x10g.h:120
c7x10g_cfg_t::miso
pin_name_t miso
Definition: c7x10g.h:137
c7x10g_cfg_setup
void c7x10g_cfg_setup(c7x10g_cfg_t *cfg)
Config Object Initialization function.
C7X10G_ERROR
@ C7X10G_ERROR
Definition: c7x10g.h:170
c7x10g_t::rr
digital_out_t rr
Definition: c7x10g.h:121
c7x10g_pixel_t::cord_x
uint8_t cord_x
Definition: c7x10g.h:161
c7x10g_init
c7x10g_return_value_t c7x10g_init(c7x10g_t *ctx, c7x10g_cfg_t *cfg)
Initialization function.
c7x10g_cfg_t::spi_speed
uint32_t spi_speed
Definition: c7x10g.h:150
c7x10g_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: c7x10g.h:151
c7x10g_t::rc
digital_out_t rc
Definition: c7x10g.h:119
c7x10g_pixel_t::cord_y
uint8_t cord_y
Definition: c7x10g.h:162
c7x10g_draw_number
void c7x10g_draw_number(c7x10g_t *ctx, uint8_t num, uint16_t num_delay)
Draw number (function).
c7x10g_cfg_t::sck
pin_name_t sck
Definition: c7x10g.h:139
c7x10g_cfg_t::rst
pin_name_t rst
Definition: c7x10g.h:145
c7x10g_t
Click ctx object definition.
Definition: c7x10g.h:114
c7x10g_cfg_t::cs
pin_name_t cs
Definition: c7x10g.h:140
c7x10g_cfg_t::rc
pin_name_t rc
Definition: c7x10g.h:144
c7x10g_cfg_t::rr
pin_name_t rr
Definition: c7x10g.h:146
c7x10g_display_process
void c7x10g_display_process(c7x10g_t *ctx, uint8_t *frame, uint16_t disp_delay)
Display process (function).
C7X10G_OK
@ C7X10G_OK
Definition: c7x10g.h:169
c7x10g_pixel_t
pixel structure definition.
Definition: c7x10g.h:160
c7x10g_t::spi
spi_master_t spi
Definition: c7x10g.h:125
c7x10g_cfg_t::mosi
pin_name_t mosi
Definition: c7x10g.h:138
c7x10g_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: c7x10g.h:152
c7x10g_t::chip_select
pin_name_t chip_select
Definition: c7x10g.h:126