c7x10y  2.0.0.0
c7x10y.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 C7X10Y_H
29 #define C7X10Y_H
30 
31 #include "mikrosdk_version.h"
32 
33 #ifdef __GNUC__
34 #if mikroSDK_GET_VERSION < 20800ul
35 #include "rcu_delays.h"
36 #else
37 #include "delays.h"
38 #endif
39 #endif
40 
41 #include "drv_digital_out.h"
42 #include "drv_digital_in.h"
43 #include "drv_spi_master.h"
44 
45 // -------------------------------------------------------------- PUBLIC MACROS
46 
57 #define C7X10Y_MAP_MIKROBUS( cfg, mikrobus ) \
58  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
59  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
60  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
61  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
62  cfg.rc = MIKROBUS( mikrobus, MIKROBUS_AN ); \
63  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
64  cfg.rr = MIKROBUS( mikrobus, MIKROBUS_PWM )
65 
71 #define C7X10Y_DISPLAY_DELAY_5MS 5
72 #define C7X10Y_DISPLAY_DELAY_10MS 10
73 #define C7X10Y_DISPLAY_DELAY_20MS 20
74 #define C7X10Y_DISPLAY_DELAY_35MS 35
75 #define C7X10Y_DISPLAY_DELAY_50MS 50
76 #define C7X10Y_DISPLAY_DELAY_100MS 100
77 #define C7X10Y_DISPLAY_DELAY_150MS 150
78 
84 #define C7X10Y_DISPLAY_LEFT 0x00
85 #define C7X10Y_DISPLAY_RIGHT 0x01
86 #define C7X10Y_DISPLAY_REFRESH 0x10
87 
93 #define C7X10Y_DISPLAY_PIXEL_REFRESH 0x01
94 #define C7X10Y_DISPLAY_PIXEL_STORAGE 0x00
95  // End group macro
98 
99 // --------------------------------------------------------------- PUBLIC TYPES
100 
109 typedef struct
110 {
111  digital_out_t cs;
112 
113  // Output pins
114 
115  digital_out_t rc;
116  digital_out_t rst;
117  digital_out_t rr;
118 
119  // Modules
120 
121  spi_master_t spi;
122  pin_name_t chip_select;
123 
124 } c7x10y_t;
125 
129 typedef struct
130 {
131  // Communication gpio pins
132 
133  pin_name_t miso;
134  pin_name_t mosi;
135  pin_name_t sck;
136  pin_name_t cs;
137 
138  // Additional gpio pins
139 
140  pin_name_t rc;
141  pin_name_t rst;
142  pin_name_t rr;
143 
144  // static variable
145 
146  uint32_t spi_speed;
147  spi_master_mode_t spi_mode;
148  spi_master_chip_select_polarity_t cs_polarity;
149 
150 } c7x10y_cfg_t;
151 
155 typedef struct
156 {
157  uint8_t cord_x;
158  uint8_t cord_y;
159 
161 
162 typedef enum
163 {
164 
166  C7X10Y_ERROR = -1
167 
169  // End types group
171 
172 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
173 
178 #ifdef __cplusplus
179 extern "C"{
180 #endif
181 
191 
201 
211 void c7x10y_display_process ( c7x10y_t *ctx, uint8_t *frame, uint16_t disp_delay );
212 
222 void c7x10y_draw_pixel ( c7x10y_t *ctx, c7x10y_pixel_t *pixel, uint8_t mode, uint8_t px_delay );
223 
234 void c7x10y_draw_char ( c7x10y_t *ctx, char ch, uint8_t pos, uint8_t ch_delay );
235 
245 void c7x10y_draw_number ( c7x10y_t *ctx, uint8_t num, uint16_t num_delay );
246 
247 #ifdef __cplusplus
248 }
249 #endif
250 #endif // _C7X10Y_H_
251  // End public_function group
254 
255 // ------------------------------------------------------------------------- END
c7x10y_cfg_t::sck
pin_name_t sck
Definition: c7x10y.h:135
c7x10y_cfg_t::spi_speed
uint32_t spi_speed
Definition: c7x10y.h:146
c7x10y_t::chip_select
pin_name_t chip_select
Definition: c7x10y.h:122
c7x10y_pixel_t::cord_x
uint8_t cord_x
Definition: c7x10y.h:157
c7x10y_t::rc
digital_out_t rc
Definition: c7x10y.h:115
c7x10y_cfg_t::mosi
pin_name_t mosi
Definition: c7x10y.h:134
c7x10y_cfg_t::cs
pin_name_t cs
Definition: c7x10y.h:136
c7x10y_cfg_t::rst
pin_name_t rst
Definition: c7x10y.h:141
c7x10y_cfg_setup
void c7x10y_cfg_setup(c7x10y_cfg_t *cfg)
Config Object Initialization function.
c7x10y_t
Click ctx object definition.
Definition: c7x10y.h:110
c7x10y_draw_number
void c7x10y_draw_number(c7x10y_t *ctx, uint8_t num, uint16_t num_delay)
Draw number (function).
c7x10y_t::rst
digital_out_t rst
Definition: c7x10y.h:116
c7x10y_pixel_t
pixel structure definition.
Definition: c7x10y.h:156
c7x10y_draw_pixel
void c7x10y_draw_pixel(c7x10y_t *ctx, c7x10y_pixel_t *pixel, uint8_t mode, uint8_t px_delay)
Draw pixel (function).
c7x10y_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: c7x10y.h:148
c7x10y_display_process
void c7x10y_display_process(c7x10y_t *ctx, uint8_t *frame, uint16_t disp_delay)
Display process (function).
c7x10y_t::spi
spi_master_t spi
Definition: c7x10y.h:121
c7x10y_cfg_t::miso
pin_name_t miso
Definition: c7x10y.h:133
c7x10y_cfg_t::rr
pin_name_t rr
Definition: c7x10y.h:142
c7x10y_pixel_t::cord_y
uint8_t cord_y
Definition: c7x10y.h:158
c7x10y_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: c7x10y.h:147
c7x10y_t::rr
digital_out_t rr
Definition: c7x10y.h:117
c7x10y_cfg_t
Click configuration structure definition.
Definition: c7x10y.h:130
c7x10y_cfg_t::rc
pin_name_t rc
Definition: c7x10y.h:140
c7x10y_init
c7x10y_return_value_t c7x10y_init(c7x10y_t *ctx, c7x10y_cfg_t *cfg)
Initialization function.
C7X10Y_OK
@ C7X10Y_OK
Definition: c7x10y.h:165
c7x10y_draw_char
void c7x10y_draw_char(c7x10y_t *ctx, char ch, uint8_t pos, uint8_t ch_delay)
Draw char (function).
C7X10Y_ERROR
@ C7X10Y_ERROR
Definition: c7x10y.h:166
c7x10y_t::cs
digital_out_t cs
Definition: c7x10y.h:111
c7x10y_return_value_t
c7x10y_return_value_t
Definition: c7x10y.h:163