The official µGFX library repository.

gfx.c 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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.org/license.html
  6. */
  7. /**
  8. * @file src/gfx.c
  9. * @brief GFX common routines.
  10. */
  11. /* Display various warnings from gfx_rules.h */
  12. #define GFX_DISPLAY_RULE_WARNINGS TRUE
  13. #include "../gfx.h"
  14. static bool_t gfxInitDone = FALSE;
  15. /* These init functions are defined by each module but not published */
  16. extern void _gosInit(void);
  17. extern void _gosDeinit(void);
  18. #ifdef GFX_OS_PRE_INIT_FUNCTION
  19. extern void GFX_OS_PRE_INIT_FUNCTION(void);
  20. #endif
  21. #ifdef GFX_OS_EXTRA_INIT_FUNCTION
  22. extern void GFX_OS_EXTRA_INIT_FUNCTION(void);
  23. #endif
  24. #ifdef GFX_OS_EXTRA_DEINIT_FUNCTION
  25. extern void GFX_OS_EXTRA_DEINIT_FUNCTION(void);
  26. #endif
  27. #if GFX_USE_GDRIVER
  28. extern void _gdriverInit(void);
  29. extern void _gdriverDeinit(void);
  30. #endif
  31. #if GFX_USE_GFILE
  32. extern void _gfileInit(void);
  33. extern void _gfileDeinit(void);
  34. #endif
  35. #if GFX_USE_GDISP
  36. extern void _gdispInit(void);
  37. extern void _gdispDeinit(void);
  38. #endif
  39. #if GFX_USE_GWIN
  40. extern void _gwinInit(void);
  41. extern void _gwinDeinit(void);
  42. #endif
  43. #if GFX_USE_GEVENT
  44. extern void _geventInit(void);
  45. extern void _geventDeinit(void);
  46. #endif
  47. #if GFX_USE_GTIMER
  48. extern void _gtimerInit(void);
  49. extern void _gtimerDeinit(void);
  50. #endif
  51. #if GFX_USE_GINPUT
  52. extern void _ginputInit(void);
  53. extern void _ginputDeinit(void);
  54. #endif
  55. #if GFX_USE_GADC
  56. extern void _gadcInit(void);
  57. extern void _gadcDeinit(void);
  58. #endif
  59. #if GFX_USE_GAUDIO
  60. extern void _gaudioInit(void);
  61. extern void _gaudioDeinit(void);
  62. #endif
  63. #if GFX_USE_GQUEUE
  64. extern void _gqueueInit(void);
  65. extern void _gqueueDeinit(void);
  66. #endif
  67. #if GFX_USE_GMISC
  68. extern void _gmiscInit(void);
  69. extern void _gmiscDeinit(void);
  70. #endif
  71. #if GFX_USE_GTRANS
  72. extern void _gtransInit(void);
  73. extern void _gtransDeinit(void);
  74. #endif
  75. void gfxInit(void)
  76. {
  77. /* Ensure we only initialise once */
  78. if (gfxInitDone)
  79. return;
  80. gfxInitDone = TRUE;
  81. // These must be initialised in the order of their dependancies
  82. #ifdef GFX_OS_PRE_INIT_FUNCTION
  83. GFX_OS_PRE_INIT_FUNCTION();
  84. #endif
  85. _gosInit();
  86. #ifdef GFX_OS_EXTRA_INIT_FUNCTION
  87. GFX_OS_EXTRA_INIT_FUNCTION();
  88. #endif
  89. #if GFX_USE_GQUEUE
  90. _gqueueInit();
  91. #endif
  92. #if GFX_USE_GMISC
  93. _gmiscInit();
  94. #endif
  95. #if GFX_USE_GTRANS
  96. _gtransInit();
  97. #endif
  98. #if GFX_USE_GEVENT
  99. _geventInit();
  100. #endif
  101. #if GFX_USE_GTIMER
  102. _gtimerInit();
  103. #endif
  104. #if GFX_USE_GDRIVER
  105. _gdriverInit();
  106. #endif
  107. #if GFX_USE_GFILE
  108. _gfileInit();
  109. #endif
  110. #if GFX_USE_GDISP
  111. _gdispInit();
  112. #endif
  113. #if GFX_USE_GINPUT
  114. _ginputInit();
  115. #endif
  116. #if GFX_USE_GADC
  117. _gadcInit();
  118. #endif
  119. #if GFX_USE_GAUDIO
  120. _gaudioInit();
  121. #endif
  122. #if GFX_USE_GWIN
  123. _gwinInit();
  124. #endif
  125. }
  126. void gfxDeinit(void)
  127. {
  128. if (!gfxInitDone)
  129. return;
  130. gfxInitDone = FALSE;
  131. // We deinitialise the opposite way as we initialised
  132. #if GFX_USE_GWIN
  133. _gwinDeinit();
  134. #endif
  135. #if GFX_USE_GAUDIN
  136. _gaudioDeinit();
  137. #endif
  138. #if GFX_USE_GADC
  139. _gadcDeinit();
  140. #endif
  141. #if GFX_USE_GINPUT
  142. _ginputDeinit();
  143. #endif
  144. #if GFX_USE_GDISP
  145. _gdispDeinit();
  146. #endif
  147. #if GFX_USE_GFILE
  148. _gfileDeinit();
  149. #endif
  150. #if GFX_USE_GDRIVER
  151. _gdriverDeinit();
  152. #endif
  153. #if GFX_USE_GTIMER
  154. _gtimerDeinit();
  155. #endif
  156. #if GFX_USE_GEVENT
  157. _geventDeinit();
  158. #endif
  159. #if GFX_USE_GTRANS
  160. _gtransDeinit();
  161. #endif
  162. #if GFX_USE_GMISC
  163. _gmiscDeinit();
  164. #endif
  165. #if GFX_USE_GQUEUE
  166. _gqueueDeinit();
  167. #endif
  168. #ifdef GFX_OS_EXTRA_DEINIT_FUNCTION
  169. GFX_OS_EXTRA_DEINIT_FUNCTION();
  170. #endif
  171. _gosDeinit();
  172. }