ili9320.h 8.8 KB

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