gd32f303e_lcd_eval.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*!
  2. \file gd32f303e_lcd_eval.h
  3. \brief LCD driver header file
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2017-05-19, V1.0.0, demo for GD32F30x
  8. */
  9. #ifndef GD32F303E_LCD_EVAL_H
  10. #define GD32F303E_LCD_EVAL_H
  11. #include "gd32f30x.h"
  12. #define BANK0_LCD_D ((uint32_t)0x65000000) /*!< LCD data address */
  13. #define BANK0_LCD_C ((uint32_t)0x64000000) /*!< LCD register address */
  14. /* LCD registers */
  15. #define R0 0x00
  16. #define R1 0x01
  17. #define R2 0x02
  18. #define R3 0x03
  19. #define R4 0x04
  20. #define R5 0x05
  21. #define R6 0x06
  22. #define R7 0x07
  23. #define R8 0x08
  24. #define R9 0x09
  25. #define R10 0x0A
  26. #define R11 0x0B
  27. #define R12 0x0C
  28. #define R13 0x0D
  29. #define R14 0x0E
  30. #define R15 0x0F
  31. #define R16 0x10
  32. #define R17 0x11
  33. #define R18 0x12
  34. #define R19 0x13
  35. #define R20 0x14
  36. #define R21 0x15
  37. #define R22 0x16
  38. #define R23 0x17
  39. #define R24 0x18
  40. #define R25 0x19
  41. #define R26 0x1A
  42. #define R27 0x1B
  43. #define R28 0x1C
  44. #define R29 0x1D
  45. #define R30 0x1E
  46. #define R31 0x1F
  47. #define R32 0x20
  48. #define R33 0x21
  49. #define R34 0x22
  50. #define R35 0x23
  51. #define R36 0x24
  52. #define R37 0x25
  53. #define R40 0x28
  54. #define R41 0x29
  55. #define R43 0x2B
  56. #define R45 0x2D
  57. #define R48 0x30
  58. #define R49 0x31
  59. #define R50 0x32
  60. #define R51 0x33
  61. #define R52 0x34
  62. #define R53 0x35
  63. #define R54 0x36
  64. #define R55 0x37
  65. #define R56 0x38
  66. #define R57 0x39
  67. #define R58 0x3A
  68. #define R59 0x3B
  69. #define R60 0x3C
  70. #define R61 0x3D
  71. #define R62 0x3E
  72. #define R63 0x3F
  73. #define R64 0x40
  74. #define R65 0x41
  75. #define R66 0x42
  76. #define R67 0x43
  77. #define R68 0x44
  78. #define R69 0x45
  79. #define R70 0x46
  80. #define R71 0x47
  81. #define R72 0x48
  82. #define R73 0x49
  83. #define R74 0x4A
  84. #define R75 0x4B
  85. #define R76 0x4C
  86. #define R77 0x4D
  87. #define R78 0x4E
  88. #define R79 0x4F
  89. #define R80 0x50
  90. #define R81 0x51
  91. #define R82 0x52
  92. #define R83 0x53
  93. #define R96 0x60
  94. #define R97 0x61
  95. #define R106 0x6A
  96. #define R118 0x76
  97. #define R128 0x80
  98. #define R129 0x81
  99. #define R130 0x82
  100. #define R131 0x83
  101. #define R132 0x84
  102. #define R133 0x85
  103. #define R134 0x86
  104. #define R135 0x87
  105. #define R136 0x88
  106. #define R137 0x89
  107. #define R139 0x8B
  108. #define R140 0x8C
  109. #define R141 0x8D
  110. #define R143 0x8F
  111. #define R144 0x90
  112. #define R145 0x91
  113. #define R146 0x92
  114. #define R147 0x93
  115. #define R148 0x94
  116. #define R149 0x95
  117. #define R150 0x96
  118. #define R151 0x97
  119. #define R152 0x98
  120. #define R153 0x99
  121. #define R154 0x9A
  122. #define R157 0x9D
  123. #define R192 0xC0
  124. #define R193 0xC1
  125. #define R229 0xE5
  126. /* LCD color */
  127. #define WHITE 0xFFFF
  128. #define BLACK 0x0000
  129. #define GREY 0xF7DE
  130. #define BLUE 0x001F
  131. #define BLUE2 0x051F
  132. #define RED 0xF800
  133. #define MAGENTA 0xF81F
  134. #define GREEN 0x07E0
  135. #define CYAN 0x7FFF
  136. #define YELLOW 0xFFE0
  137. #define LINE0 0
  138. #define LINE1 24
  139. #define LINE2 48
  140. #define LINE3 72
  141. #define LINE4 96
  142. #define LINE5 120
  143. #define LINE6 144
  144. #define LINE7 168
  145. #define LINE8 192
  146. #define LINE9 216
  147. /* char format struct definitions */
  148. typedef struct
  149. {
  150. uint16_t font; /*!< the type of font */
  151. uint16_t direction; /*!< the direction of char */
  152. uint16_t char_color; /*!< the color of char */
  153. uint16_t bk_color; /*!< the color of backgroud */
  154. }char_format_struct;
  155. #define CHAR_FONT_8_16 ((uint16_t)0x0000U) /*!< the font of char is 8X16 */
  156. #define CHAR_FONT_16_24 ((uint16_t)0x0001U) /*!< the font of char is 16X24 */
  157. #define CHAR_DIRECTION_HORIZONTAL ((uint16_t)0x0000U) /*!< character display direction is horizontal */
  158. #define CHAR_DIRECTION_VERTICAL ((uint16_t)0x0001U) /*!< character display direction is vertical */
  159. /* lcd peripheral initialize */
  160. void exmc_lcd_init(void);
  161. /* initize the LCD */
  162. void lcd_init(void);
  163. /* write data to the selected LCD register */
  164. void lcd_register_write(uint16_t register_id,uint16_t value);
  165. /* read the value of LCD register */
  166. uint16_t lcd_register_read(uint8_t register_id);
  167. /* write command to LCD register */
  168. void lcd_command_write (uint16_t value);
  169. /* prepare to write to the LCD GRAM */
  170. void lcd_gram_write_prepare(void);
  171. /* write RGB code to the LCD GRAM register */
  172. void lcd_gram_write(uint16_t rgb_code);
  173. /* read data from GRAM */
  174. uint16_t lcd_gram_read(void);
  175. /* set the curson of LCD */
  176. void lcd_cursor_set(uint16_t x,uint16_t y);
  177. /* clear the LCD screen to the specified color */
  178. void lcd_clear(uint16_t Color);
  179. /* set the point according to the specified position and color */
  180. void lcd_point_set(uint16_t x,uint16_t y,uint16_t point);
  181. /* get the point according to the specified position */
  182. uint16_t lcd_point_get(uint16_t x,uint16_t y);
  183. /* set window area */
  184. void lcd_windows_set(uint16_t start_x,uint16_t start_y,uint16_t end_x,uint16_t end_y);
  185. /* draw a horizontal line on LCD screen */
  186. void lcd_hline_draw(uint16_t x,uint16_t start_y,uint16_t end_y,uint16_t color,uint16_t width);
  187. /* draw a rectangle according to the specified position and color */
  188. void lcd_rectangle_draw(uint16_t start_x,uint16_t start_y,uint16_t end_x,uint16_t end_y,uint16_t point);
  189. /* fill the specified color to a rectangle */
  190. void lcd_rectangle_fill(uint16_t start_x,uint16_t start_y,uint16_t end_x,uint16_t end_y,uint16_t color);
  191. /* draw a picture on LCD screen according to the specified position */
  192. void lcd_picture_draw(uint16_t start_x,uint16_t start_y,uint16_t end_x,uint16_t end_y,uint16_t *pic);
  193. /* display a char on LCD screen according to the specified position */
  194. void lcd_char_display(uint16_t x,uint16_t y,uint8_t c,char_format_struct c_format);
  195. #endif /* GD32F303E_LCD_EVAL_H */