gd32f307c_lcd_eval.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /*!
  2. \file gd32f307c_lcd_eval.h
  3. \brief LCD driver header file
  4. \version 2017-02-10, V1.0.0, firmware for GD32F30x
  5. \version 2018-10-10, V1.1.0, firmware for GD32F30x
  6. \version 2018-12-25, V2.0.0, firmware for GD32F30x
  7. \version 2020-09-30, V2.1.0, firmware for GD32F30x
  8. */
  9. /*
  10. Copyright (c) 2020, GigaDevice Semiconductor Inc.
  11. Redistribution and use in source and binary forms, with or without modification,
  12. are permitted provided that the following conditions are met:
  13. 1. Redistributions of source code must retain the above copyright notice, this
  14. list of conditions and the following disclaimer.
  15. 2. Redistributions in binary form must reproduce the above copyright notice,
  16. this list of conditions and the following disclaimer in the documentation
  17. and/or other materials provided with the distribution.
  18. 3. Neither the name of the copyright holder nor the names of its contributors
  19. may be used to endorse or promote products derived from this software without
  20. specific prior written permission.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  25. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  26. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  27. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  28. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  30. OF SUCH DAMAGE.
  31. */
  32. #ifndef GD32F307C_LCD_EVAL_H
  33. #define GD32F307C_LCD_EVAL_H
  34. #include "lcd_font.h"
  35. #include "gd32f30x.h"
  36. #define BANK0_LCD_C ((uint32_t)0x60000000) /*!< LCD registers address */
  37. #define BANK0_LCD_D ((uint32_t)0x61000000) /*!< LCD data address */
  38. /* LCD registers */
  39. #define R0 0x00
  40. #define R1 0x01
  41. #define R2 0x02
  42. #define R3 0x03
  43. #define R4 0x04
  44. #define R5 0x05
  45. #define R6 0x06
  46. #define R7 0x07
  47. #define R8 0x08
  48. #define R9 0x09
  49. #define R10 0x0A
  50. #define R11 0x0B
  51. #define R12 0x0C
  52. #define R13 0x0D
  53. #define R14 0x0E
  54. #define R15 0x0F
  55. #define R16 0x10
  56. #define R17 0x11
  57. #define R18 0x12
  58. #define R19 0x13
  59. #define R20 0x14
  60. #define R21 0x15
  61. #define R22 0x16
  62. #define R23 0x17
  63. #define R24 0x18
  64. #define R25 0x19
  65. #define R26 0x1A
  66. #define R27 0x1B
  67. #define R28 0x1C
  68. #define R29 0x1D
  69. #define R30 0x1E
  70. #define R31 0x1F
  71. #define R32 0x20
  72. #define R33 0x21
  73. #define R34 0x22
  74. #define R35 0x23
  75. #define R36 0x24
  76. #define R37 0x25
  77. #define R40 0x28
  78. #define R41 0x29
  79. #define R43 0x2B
  80. #define R45 0x2D
  81. #define R48 0x30
  82. #define R49 0x31
  83. #define R50 0x32
  84. #define R51 0x33
  85. #define R52 0x34
  86. #define R53 0x35
  87. #define R54 0x36
  88. #define R55 0x37
  89. #define R56 0x38
  90. #define R57 0x39
  91. #define R58 0x3A
  92. #define R59 0x3B
  93. #define R60 0x3C
  94. #define R61 0x3D
  95. #define R62 0x3E
  96. #define R63 0x3F
  97. #define R64 0x40
  98. #define R65 0x41
  99. #define R66 0x42
  100. #define R67 0x43
  101. #define R68 0x44
  102. #define R69 0x45
  103. #define R70 0x46
  104. #define R71 0x47
  105. #define R72 0x48
  106. #define R73 0x49
  107. #define R74 0x4A
  108. #define R75 0x4B
  109. #define R76 0x4C
  110. #define R77 0x4D
  111. #define R78 0x4E
  112. #define R79 0x4F
  113. #define R80 0x50
  114. #define R81 0x51
  115. #define R82 0x52
  116. #define R83 0x53
  117. #define R96 0x60
  118. #define R97 0x61
  119. #define R106 0x6A
  120. #define R118 0x76
  121. #define R128 0x80
  122. #define R129 0x81
  123. #define R130 0x82
  124. #define R131 0x83
  125. #define R132 0x84
  126. #define R133 0x85
  127. #define R134 0x86
  128. #define R135 0x87
  129. #define R136 0x88
  130. #define R137 0x89
  131. #define R139 0x8B
  132. #define R140 0x8C
  133. #define R141 0x8D
  134. #define R143 0x8F
  135. #define R144 0x90
  136. #define R145 0x91
  137. #define R146 0x92
  138. #define R147 0x93
  139. #define R148 0x94
  140. #define R149 0x95
  141. #define R150 0x96
  142. #define R151 0x97
  143. #define R152 0x98
  144. #define R153 0x99
  145. #define R154 0x9A
  146. #define R157 0x9D
  147. #define R192 0xC0
  148. #define R193 0xC1
  149. #define R229 0xE5
  150. /* LCD color */
  151. #define LCD_COLOR_WHITE 0xFFFF
  152. #define LCD_COLOR_BLACK 0x0000
  153. #define LCD_COLOR_GREY 0xF7DE
  154. #define LCD_COLOR_BLUE 0x001F
  155. #define LCD_COLOR_BLUE2 0x051F
  156. #define LCD_COLOR_RED 0xF800
  157. #define LCD_COLOR_MAGENTA 0xF81F
  158. #define LCD_COLOR_GREEN 0x07E0
  159. #define LCD_COLOR_CYAN 0x7FFF
  160. #define LCD_COLOR_YELLOW 0xFFE0
  161. /* definitions of lines depending on the chosen fonts */
  162. #define LCD_LINE_0 LINE(0)
  163. #define LCD_LINE_1 LINE(1)
  164. #define LCD_LINE_2 LINE(2)
  165. #define LCD_LINE_3 LINE(3)
  166. #define LCD_LINE_4 LINE(4)
  167. #define LCD_LINE_5 LINE(5)
  168. #define LCD_LINE_6 LINE(6)
  169. #define LCD_LINE_7 LINE(7)
  170. #define LCD_LINE_8 LINE(8)
  171. #define LCD_LINE_9 LINE(9)
  172. #define LCD_DEFAULT_FONT font16x24 /*!< LCD default font */
  173. #define CHAR_FONT_8_16 ((uint16_t)0x0000U) /*!< the font of char is 8X16 */
  174. #define CHAR_FONT_16_24 ((uint16_t)0x0001U) /*!< the font of char is 16X24 */
  175. #define CHAR_DIRECTION_HORIZONTAL ((uint16_t)0x0000U) /*!< character display direction is horizontal */
  176. #define CHAR_DIRECTION_VERTICAL ((uint16_t)0x0001U) /*!< character display direction is vertical */
  177. #define LCD_PIXEL_HEIGHT (uint16_t)320
  178. #define LCD_PIXEL_WIDTH (uint16_t)240
  179. /* initializes the LCD of GD EVAL board */
  180. void gd_eval_lcd_init(void);
  181. /* LCD peripheral initialize */
  182. void exmc_lcd_init(void);
  183. /* initializes the LCD */
  184. void lcd_init(void);
  185. /* write data to the selected LCD register */
  186. void lcd_register_write(uint16_t register_id,uint16_t value);
  187. /* read the value of LCD register */
  188. uint16_t lcd_register_read(uint8_t register_id);
  189. /* write command to LCD register */
  190. void lcd_command_write (uint16_t value);
  191. /* prepare to write to the LCD GRAM */
  192. void lcd_gram_write_prepare(void);
  193. /* write RGB code to the LCD GRAM register */
  194. void lcd_gram_write(uint16_t rgb_code);
  195. /* read data from GRAM */
  196. uint16_t lcd_gram_read(void);
  197. /* clear the LCD with specified color */
  198. void lcd_clear(uint16_t color);
  199. /* set the text font */
  200. void lcd_font_set(font_struct *font);
  201. /* get the text font */
  202. font_struct *lcd_font_get(void);
  203. /* set the text color */
  204. void lcd_text_color_set(uint16_t color);
  205. /* get the current text color */
  206. uint16_t lcd_text_color_get(void);
  207. /* set the background color */
  208. void lcd_background_color_set(uint16_t color);
  209. /* get the current background color */
  210. uint16_t lcd_background_color_get(void);
  211. /* set the point according to the specified position and color */
  212. void lcd_point_set(uint16_t x,uint16_t y,uint16_t point);
  213. /* get the point according to the specified position */
  214. uint16_t lcd_point_get(uint16_t x,uint16_t y);
  215. /* draw a horizontal line on LCD screen */
  216. void lcd_hline_draw(uint16_t x,uint16_t start_y,uint16_t end_y,uint16_t color,uint16_t width);
  217. /* draw a rectangle according to the specified position and color */
  218. void lcd_rectangle_draw(uint16_t start_x,uint16_t start_y,uint16_t end_x,uint16_t end_y,uint16_t point);
  219. /* fill the specified color to a rectangle */
  220. void lcd_rectangle_fill(uint16_t start_x,uint16_t start_y,uint16_t width,uint16_t height);
  221. /* display a char on LCD screen according to the specified position */
  222. void lcd_char_display(uint16_t x,uint16_t y,uint8_t c);
  223. /* display the vertical character on LCD */
  224. void lcd_vertical_char_display(uint16_t line, uint16_t column, uint8_t ascii);
  225. /* display the vertical string on LCD */
  226. void lcd_vertical_string_display(uint16_t stringline, uint16_t offset, uint8_t *ptr);
  227. #endif /* GD32F307C_LCD_EVAL_H */