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 )
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
88#define C7X10G_DISPLAY_LEFT 0x00
89#define C7X10G_DISPLAY_RIGHT 0x01
90#define C7X10G_DISPLAY_REFRESH 0x10
97#define C7X10G_DISPLAY_PIXEL_REFRESH 0x01
98#define C7X10G_DISPLAY_PIXEL_STORAGE 0x00
101 // End group macro
102
103// --------------------------------------------------------------- PUBLIC TYPES
104
113typedef 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
133typedef 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
155
159typedef struct
160{
161 uint8_t cord_x;
162 uint8_t cord_y;
163
165
166typedef enum
167{
168
170 C7X10G_ERROR = -1
171
173
174 // End types group
175
176// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
177
182#ifdef __cplusplus
183extern "C"{
184#endif
185
195
205
215void c7x10g_display_process ( c7x10g_t *ctx, uint8_t *frame, uint16_t disp_delay );
216
226void c7x10g_draw_pixel ( c7x10g_t *ctx, c7x10g_pixel_t *pixel, uint8_t mode, uint8_t px_delay );
227
238void c7x10g_draw_char ( c7x10g_t *ctx, char ch, uint8_t pos, uint8_t ch_delay );
239
249void 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
256 // End public_function group
258
259// ------------------------------------------------------------------------- END
c7x10g_return_value_t c7x10g_init(c7x10g_t *ctx, c7x10g_cfg_t *cfg)
Initialization function.
void c7x10g_draw_pixel(c7x10g_t *ctx, c7x10g_pixel_t *pixel, uint8_t mode, uint8_t px_delay)
Draw pixel (function).
void c7x10g_display_process(c7x10g_t *ctx, uint8_t *frame, uint16_t disp_delay)
Display process (function).
void c7x10g_draw_number(c7x10g_t *ctx, uint8_t num, uint16_t num_delay)
Draw number (function).
void c7x10g_cfg_setup(c7x10g_cfg_t *cfg)
Config Object Initialization function.
void c7x10g_draw_char(c7x10g_t *ctx, char ch, uint8_t pos, uint8_t ch_delay)
Draw char (function).
c7x10g_return_value_t
Definition c7x10g.h:167
@ C7X10G_ERROR
Definition c7x10g.h:170
@ C7X10G_OK
Definition c7x10g.h:169
Click configuration structure definition.
Definition c7x10g.h:134
pin_name_t rr
Definition c7x10g.h:146
spi_master_chip_select_polarity_t cs_polarity
Definition c7x10g.h:152
pin_name_t sck
Definition c7x10g.h:139
spi_master_mode_t spi_mode
Definition c7x10g.h:151
pin_name_t mosi
Definition c7x10g.h:138
uint32_t spi_speed
Definition c7x10g.h:150
pin_name_t rc
Definition c7x10g.h:144
pin_name_t miso
Definition c7x10g.h:137
pin_name_t rst
Definition c7x10g.h:145
pin_name_t cs
Definition c7x10g.h:140
pixel structure definition.
Definition c7x10g.h:160
uint8_t cord_x
Definition c7x10g.h:161
uint8_t cord_y
Definition c7x10g.h:162
Click ctx object definition.
Definition c7x10g.h:114
digital_out_t cs
Definition c7x10g.h:115
spi_master_t spi
Definition c7x10g.h:125
digital_out_t rc
Definition c7x10g.h:119
digital_out_t rst
Definition c7x10g.h:120
pin_name_t chip_select
Definition c7x10g.h:126
digital_out_t rr
Definition c7x10g.h:121