c7x10b  2.0.0.0
c7x10b.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 
23 #ifndef C7X10B_H
24 #define C7X10B_H
25 
26 #include "mikrosdk_version.h"
27 
28 #ifdef __GNUC__
29 #if mikroSDK_GET_VERSION < 20800ul
30 #include "rcu_delays.h"
31 #else
32 #include "delays.h"
33 #endif
34 #endif
35 
36 #include "drv_digital_out.h"
37 #include "drv_digital_in.h"
38 #include "drv_spi_master.h"
39 
40 // -------------------------------------------------------------- PUBLIC MACROS
41 
52 #define C7X10B_MAP_MIKROBUS( cfg, mikrobus ) \
53  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
54  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
55  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
56  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
57  cfg.rc = MIKROBUS( mikrobus, MIKROBUS_AN ); \
58  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
59  cfg.rr = MIKROBUS( mikrobus, MIKROBUS_PWM )
60 
66 #define C7X10B_DISPLAY_DELAY_5MS 5
67 #define C7X10B_DISPLAY_DELAY_10MS 10
68 #define C7X10B_DISPLAY_DELAY_20MS 20
69 #define C7X10B_DISPLAY_DELAY_35MS 35
70 #define C7X10B_DISPLAY_DELAY_50MS 50
71 #define C7X10B_DISPLAY_DELAY_100MS 100
72 #define C7X10B_DISPLAY_DELAY_150MS 150
73 
79 #define C7X10B_DISPLAY_LEFT 0x00
80 #define C7X10B_DISPLAY_RIGHT 0x01
81 #define C7X10B_DISPLAY_REFRESH 0x10
82 
88 #define C7X10B_DISPLAY_PIXEL_REFRESH 0x01
89 #define C7X10B_DISPLAY_PIXEL_STORAGE 0x00
90  // End group macro
93 
94 // --------------------------------------------------------------- PUBLIC TYPES
95 
104 typedef struct
105 {
106  digital_out_t cs;
107 
108  // Output pins
109 
110  digital_out_t rc;
111  digital_out_t rst;
112  digital_out_t rr;
113 
114  // Modules
115 
116  spi_master_t spi;
117  pin_name_t chip_select;
118 
119 } c7x10b_t;
120 
124 typedef struct
125 {
126  // Communication gpio pins
127 
128  pin_name_t miso;
129  pin_name_t mosi;
130  pin_name_t sck;
131  pin_name_t cs;
132 
133  // Additional gpio pins
134 
135  pin_name_t rc;
136  pin_name_t rst;
137  pin_name_t rr;
138 
139  // static variable
140 
141  uint32_t spi_speed;
142  spi_master_mode_t spi_mode;
143  spi_master_chip_select_polarity_t cs_polarity;
144 
145 } c7x10b_cfg_t;
146 
150 typedef struct
151 {
152  uint8_t cord_x;
153  uint8_t cord_y;
154 
156 
157 typedef enum
158 {
160  C7X10B_ERROR = -1
162  // End types group
164 
165 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
166 
171 #ifdef __cplusplus
172 extern "C"{
173 #endif
174 
184 
194 
204 void c7x10b_display_process ( c7x10b_t *ctx, uint8_t *frame, uint16_t disp_delay );
205 
215 void c7x10b_draw_pixel ( c7x10b_t *ctx, c7x10b_pixel_t *pixel, uint8_t mode, uint8_t px_delay );
216 
227 void c7x10b_draw_char ( c7x10b_t *ctx, char ch, uint8_t pos, uint8_t ch_delay );
228 
238 void c7x10b_draw_number ( c7x10b_t *ctx, uint8_t num, uint16_t num_delay );
239 
240 #ifdef __cplusplus
241 }
242 #endif
243 #endif // _C7X10B_H_
244  // End public_function group
247 
248 // ------------------------------------------------------------------------- END
c7x10b_cfg_t::cs
pin_name_t cs
Definition: c7x10b.h:131
c7x10b_cfg_t::rr
pin_name_t rr
Definition: c7x10b.h:137
c7x10b_cfg_t
Click configuration structure definition.
Definition: c7x10b.h:125
c7x10b_t::rr
digital_out_t rr
Definition: c7x10b.h:112
c7x10b_cfg_t::mosi
pin_name_t mosi
Definition: c7x10b.h:129
c7x10b_t::rst
digital_out_t rst
Definition: c7x10b.h:111
c7x10b_t::cs
digital_out_t cs
Definition: c7x10b.h:106
c7x10b_cfg_setup
void c7x10b_cfg_setup(c7x10b_cfg_t *cfg)
Config Object Initialization function.
c7x10b_pixel_t
pixel structure definition.
Definition: c7x10b.h:151
c7x10b_pixel_t::cord_x
uint8_t cord_x
Definition: c7x10b.h:152
c7x10b_draw_pixel
void c7x10b_draw_pixel(c7x10b_t *ctx, c7x10b_pixel_t *pixel, uint8_t mode, uint8_t px_delay)
Draw pixel (function).
c7x10b_cfg_t::sck
pin_name_t sck
Definition: c7x10b.h:130
c7x10b_cfg_t::rst
pin_name_t rst
Definition: c7x10b.h:136
c7x10b_cfg_t::rc
pin_name_t rc
Definition: c7x10b.h:135
C7X10B_ERROR
@ C7X10B_ERROR
Definition: c7x10b.h:160
c7x10b_draw_char
void c7x10b_draw_char(c7x10b_t *ctx, char ch, uint8_t pos, uint8_t ch_delay)
Draw char (function).
c7x10b_cfg_t::spi_speed
uint32_t spi_speed
Definition: c7x10b.h:141
c7x10b_pixel_t::cord_y
uint8_t cord_y
Definition: c7x10b.h:153
c7x10b_draw_number
void c7x10b_draw_number(c7x10b_t *ctx, uint8_t num, uint16_t num_delay)
Draw number (function).
c7x10b_t::rc
digital_out_t rc
Definition: c7x10b.h:110
c7x10b_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: c7x10b.h:143
c7x10b_display_process
void c7x10b_display_process(c7x10b_t *ctx, uint8_t *frame, uint16_t disp_delay)
Display process (function).
C7X10B_OK
@ C7X10B_OK
Definition: c7x10b.h:159
c7x10b_return_value_t
c7x10b_return_value_t
Definition: c7x10b.h:158
c7x10b_cfg_t::miso
pin_name_t miso
Definition: c7x10b.h:128
c7x10b_t::chip_select
pin_name_t chip_select
Definition: c7x10b.h:117
c7x10b_init
c7x10b_return_value_t c7x10b_init(c7x10b_t *ctx, c7x10b_cfg_t *cfg)
Initialization function.
c7x10b_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: c7x10b.h:142
c7x10b_t
Click ctx object definition.
Definition: c7x10b.h:105
c7x10b_t::spi
spi_master_t spi
Definition: c7x10b.h:116