µGFX  2.9
version 2.9
src/gfx.h
Go to the documentation of this file.
1 /*
2  * This file is subject to the terms of the GFX License. If a copy of
3  * the license was not distributed with this file, you can obtain one at:
4  *
5  * http://ugfx.io/license.html
6  */
7 
8 /**
9  * @file gfx.h
10  * @brief GFX system header file.
11  *
12  * @addtogroup GFX
13  *
14  * @brief Main module to glue all the others together
15  *
16  * @{
17  */
18 
19 #ifndef _GFX_H
20 #define _GFX_H
21 
22 // Everything here is C, not C++
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 // ------------------------------ Initial preparation ---------------------------------
28 #undef GFX_COMPILESTAGE
29 #define GFX_COMPILESTAGE GFX_COMPILESTAGE_PREP
30 
31 // Compiling stages
32 #define GFX_COMPILESTAGE_USERPROGRAM 0 // Compiling the user program
33 #define GFX_COMPILESTAGE_PREP 1 // gfx.h: Initial preparation
34 #define GFX_COMPILESTAGE_USERCONFIG 2 // gfx.h: Load the user configuration
35 #define GFX_COMPILESTAGE_COMPILECONFIG 3 // gfx.h: Determine build environment info - COMPILER, CPU etc
36 #define GFX_COMPILESTAGE_OPTIONS 4 // gfx.h: Enumerate all options
37 #define GFX_COMPILESTAGE_RULES 5 // gfx.h: Apply configuration rules
38 #define GFX_COMPILESTAGE_APIDEFS 6 // gfx.h: Define API definitions
39 #define GFX_COMPILESTAGE_COMPILECAPI 100 // gfx.c: Compile the uGFX C API
40 #define GFX_COMPILESTAGE_COMPILEDRIVERINIT 101 // gfx.c: Compile driver init structures
41 #define GFX_COMPILESTAGE_COMPILECPPAPI 102 // gfx.cpp: Compile the uGFX C++ API
42 
43 // ------------------------------ Load the user configuration ---------------------------------
44 #undef GFX_COMPILESTAGE
45 #define GFX_COMPILESTAGE GFX_COMPILESTAGE_USERCONFIG
46 
47 // Definitions for option configuration
48 #define GFXOFF (0)
49 #define GFXON (-1)
50 
51 // gfxconf.h is the user's project configuration for the GFX system.
52 #include "gfxconf.h"
53 
54 // ------------------------------ Determine build environment info - COMPILER, CPU etc ---------------------------------
55 #undef GFX_COMPILESTAGE
56 #define GFX_COMPILESTAGE GFX_COMPILESTAGE_COMPILECONFIG
57 
58 /**
59  * @name GFX compatibility options
60  * @{
61  */
62  /**
63  * @brief Include the uGFX V2.x API
64  * @details Defaults to GFXON
65  */
66  #ifndef GFX_COMPAT_V2
67  #define GFX_COMPAT_V2 GFXON
68  #endif
69 /** @} */
70 
71 #if GFX_COMPAT_V2
72  // These need to be defined here for compatibility with V2.x user config files
73  #if !defined(FALSE)
74  #define FALSE 0
75  #endif
76  #if !defined(TRUE)
77  #define TRUE -1
78  #endif
79 #endif
80 
81 // Are we in the uGFX library implementation itself? - not API documented
82 #ifndef GFX_COMPILE_INTERNAL_API
83  #define GFX_COMPILE_INTERNAL_API GFXOFF
84 #endif
85 
86 // Macro concatination and strify - not API documented
87 #define GFXCAT(a, b) a ## b
88 #define GFXCATX(a, b) GFXCAT(a, b)
89 #define GFXSTR(a) #a
90 #define GFXSTRX(a) GFXSTR(a)
91 
92 // Include Compiler and CPU support
93 #include "gfx_compilers.h"
94 
95 // Include standard types
96 #include "gfx_types.h"
97 
98 // Public uGFX API calling convention
99 #ifndef GFXAPI
100  #define GFXAPI
101 #endif
102 
103 // Public uGFX API callback convention
104 #ifndef GFXUSERFN
105  #define GFXUSERFN GFXAPI
106 #endif
107 
108 // Private uGFX API calling convention
109 #if GFX_COMPILE_INTERNAL_API && !defined(GFXINTERNAL)
110  #define GFXINTERNAL
111 #endif
112 
113 // ------------------------------ Enumerate all options ---------------------------------
114 #undef GFX_COMPILESTAGE
115 #define GFX_COMPILESTAGE GFX_COMPILESTAGE_OPTIONS
116 
117 /**
118  * Get all the options for each sub-system.
119  */
120 #include "gfx_options.h"
121 #include "gos/gos_options.h"
122 #include "gdriver/gdriver_options.h"
123 #include "gfile/gfile_options.h"
124 #include "gmisc/gmisc_options.h"
125 #include "gtrans/gtrans_options.h"
126 #include "gqueue/gqueue_options.h"
127 #include "gevent/gevent_options.h"
128 #include "gtimer/gtimer_options.h"
129 #include "gdisp/gdisp_options.h"
130 #include "gwin/gwin_options.h"
131 #include "ginput/ginput_options.h"
132 #include "gadc/gadc_options.h"
133 #include "gaudio/gaudio_options.h"
134 
135 // ------------------------------ Apply configuration rules ---------------------------------
136 #undef GFX_COMPILESTAGE
137 #define GFX_COMPILESTAGE GFX_COMPILESTAGE_RULES
138 
139 /**
140  * Interdependency safety checks on the sub-systems.
141  * These must be in dependency order.
142  */
143 #ifndef GFX_DISPLAY_RULE_WARNINGS
144  #define GFX_DISPLAY_RULE_WARNINGS GFXOFF
145 #endif
146 #include "gwin/gwin_rules.h"
147 #include "ginput/ginput_rules.h"
148 #include "gdisp/gdisp_rules.h"
149 #include "gaudio/gaudio_rules.h"
150 #include "gadc/gadc_rules.h"
151 #include "gevent/gevent_rules.h"
152 #include "gtimer/gtimer_rules.h"
153 #include "gqueue/gqueue_rules.h"
154 #include "gmisc/gmisc_rules.h"
155 #include "gtrans/gtrans_rules.h"
156 #include "gfile/gfile_rules.h"
157 #include "gdriver/gdriver_rules.h"
158 #include "gos/gos_rules.h"
159 
160 // ------------------------------ Define API definitions ---------------------------------
161 #undef GFX_COMPILESTAGE
162 #define GFX_COMPILESTAGE GFX_COMPILESTAGE_APIDEFS
163 
164 /**
165  * Include the sub-system header files
166  */
167 #include "gos/gos.h"
168 #if GFX_COMPILE_INTERNAL_API
169  #include "gdriver/gdriver.h"
170 #endif
171 #include "gfile/gfile.h"
172 #include "gmisc/gmisc.h"
173 #include "gtrans/gtrans.h"
174 #include "gqueue/gqueue.h"
175 #include "gevent/gevent.h"
176 #include "gtimer/gtimer.h"
177 #include "gdisp/gdisp.h"
178 #include "gwin/gwin.h"
179 #include "ginput/ginput.h"
180 #include "gadc/gadc.h"
181 #include "gaudio/gaudio.h"
182 
183 /**
184  * @brief The one call to start it all
185  *
186  * @note This will initialise each sub-system that has been turned on.
187  * For example, if GFX_USE_GDISP is defined then display will be initialised
188  * and cleared to black.
189  * @note If you define GFX_OS_NO_INIT as GFXON in your gfxconf.h file then ugfx doesn't try to
190  * initialise the operating system for you when you call @p gfxInit().
191  * @note If you define GFX_OS_EXTRA_INIT_FUNCTION in your gfxconf.h file the macro is the
192  * name of a void function with no parameters that is called immediately after
193  * operating system initialisation (whether or not GFX_OS_NO_INIT is set).
194  * @note If you define GFX_OS_EXTRA_DEINIT_FUNCTION in your gfxconf.h file the macro is the
195  * name of a void function with no parameters that is called immediately before
196  * operating system de-initialisation (as ugfx is exiting).
197  * @note If GFX_OS_CALL_UGFXMAIN is set uGFXMain() is called after all initialisation is complete.
198  *
199  * @api
200  */
201 void GFXAPI gfxInit(void);
202 
203 /**
204  * @brief The one call to end it all
205  *
206  * @note This will de-initialise each sub-system that has been turned on.
207  *
208  * @api
209  */
210 void GFXAPI gfxDeinit(void);
211 
212 #if GFX_OS_CALL_UGFXMAIN || defined(__DOXYGEN__)
213  /**
214  * @brief The user supplied function containing all the user uGFX application code.
215  *
216  * @note This is called by gfxInit() and is expected to never return.
217  * It is defined by the user.
218  *
219  * @pre GFX_OS_CALL_UGFXMAIN is GFXON
220  */
221  void GFXUSERFN uGFXMain(void);
222 #endif
223 
224 // ------------------------------ Compiling the user program ---------------------------------
225 #undef GFX_COMPILESTAGE
226 #define GFX_COMPILESTAGE GFX_COMPILESTAGE_USERPROGRAM
227 
228 #ifdef __cplusplus
229 }
230 #endif
231 #endif /* _GFX_H */
232 /** @} */
GADC - Periodic ADC subsystem options header file.
GADC safety rules header file.
GAUDIO - Audio subsystem options header file.
GAUDIO safety rules header file.
GDISP Graphic Driver subsystem header file.
GDISP sub-system options header file.
GDISP safety rules header file.
GDRIVER - Driver options header file.
GDRIVER safety rules header file.
GEVENT sub-system options header file.
GEVENT safety rules header file.
GFILE - File IO Routines header file.
GFILE - File IO options header file.
GFILE safety rules header file.
GFX compiler support header file.
GFX system options.
GINPUT sub-system options header file.
GINPUT safety rules header file.
GMISC - Miscellaneous Routines header file.
GMISC - Miscellaneous Routines options header file.
GMISC safety rules header file.
GOS - Operating System Support header file.
GOS - Operating System options header file.
GOS safety rules header file.
GQUEUE header file.
GQUEUE - Queue options header file.
GQUEUE safety rules header file.
void GFXAPI gfxDeinit(void)
The one call to end it all.
Definition: gfx.c:140
void GFXAPI gfxInit(void)
The one call to start it all.
Definition: gfx.c:82
void GFXUSERFN uGFXMain(void)
The user supplied function containing all the user uGFX application code.
GTIMER sub-system options header file.
GTIMER safety rules header file.
GWIN sub-system options header file.
GWIN safety rules header file.