ili9341.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /**
  2. ******************************************************************************
  3. * @file ili9341.h
  4. * @author MCD Application Team
  5. * @version V1.0.2
  6. * @date 02-December-2014
  7. * @brief This file contains all the functions prototypes for the ili9341.c
  8. * driver.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
  13. *
  14. * Redistribution and use in source and binary forms, with or without modification,
  15. * are permitted provided that the following conditions are met:
  16. * 1. Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. * 2. Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  22. * may be used to endorse or promote products derived from this software
  23. * without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  29. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  31. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  32. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  33. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ******************************************************************************
  37. */
  38. /* Define to prevent recursive inclusion -------------------------------------*/
  39. #ifndef __ILI9341_H
  40. #define __ILI9341_H
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. /* Includes ------------------------------------------------------------------*/
  45. #include "../Common/lcd.h"
  46. /** @addtogroup BSP
  47. * @{
  48. */
  49. /** @addtogroup Components
  50. * @{
  51. */
  52. /** @addtogroup ILI9341
  53. * @{
  54. */
  55. /** @defgroup ILI9341_Exported_Types
  56. * @{
  57. */
  58. /**
  59. * @}
  60. */
  61. /** @defgroup ILI9341_Exported_Constants
  62. * @{
  63. */
  64. /**
  65. * @brief ILI9341 chip IDs
  66. */
  67. #define ILI9341_ID 0x9341
  68. /**
  69. * @brief ILI9341 Size
  70. */
  71. #define ILI9341_LCD_PIXEL_WIDTH ((uint16_t)240)
  72. #define ILI9341_LCD_PIXEL_HEIGHT ((uint16_t)320)
  73. /**
  74. * @brief ILI9341 Timing
  75. */
  76. /* Timing configuration (Typical configuration from ILI9341 datasheet)
  77. HSYNC=10 (9+1)
  78. HBP=20 (29-10+1)
  79. ActiveW=240 (269-20-10+1)
  80. HFP=10 (279-240-20-10+1)
  81. VSYNC=2 (1+1)
  82. VBP=2 (3-2+1)
  83. ActiveH=320 (323-2-2+1)
  84. VFP=4 (327-320-2-2+1)
  85. */
  86. #define ILI9341_HSYNC ((uint32_t)9) /* Horizontal synchronization */
  87. #define ILI9341_HBP ((uint32_t)29) /* Horizontal back porch */
  88. #define ILI9341_HFP ((uint32_t)2) /* Horizontal front porch */
  89. #define ILI9341_VSYNC ((uint32_t)1) /* Vertical synchronization */
  90. #define ILI9341_VBP ((uint32_t)3) /* Vertical back porch */
  91. #define ILI9341_VFP ((uint32_t)2) /* Vertical front porch */
  92. /**
  93. * @brief ILI9341 Registers
  94. */
  95. /* Level 1 Commands */
  96. #define LCD_SWRESET 0x01 /* Software Reset */
  97. #define LCD_READ_DISPLAY_ID 0x04 /* Read display identification information */
  98. #define LCD_RDDST 0x09 /* Read Display Status */
  99. #define LCD_RDDPM 0x0A /* Read Display Power Mode */
  100. #define LCD_RDDMADCTL 0x0B /* Read Display MADCTL */
  101. #define LCD_RDDCOLMOD 0x0C /* Read Display Pixel Format */
  102. #define LCD_RDDIM 0x0D /* Read Display Image Format */
  103. #define LCD_RDDSM 0x0E /* Read Display Signal Mode */
  104. #define LCD_RDDSDR 0x0F /* Read Display Self-Diagnostic Result */
  105. #define LCD_SPLIN 0x10 /* Enter Sleep Mode */
  106. #define LCD_SLEEP_OUT 0x11 /* Sleep out register */
  107. #define LCD_PTLON 0x12 /* Partial Mode ON */
  108. #define LCD_NORMAL_MODE_ON 0x13 /* Normal Display Mode ON */
  109. #define LCD_DINVOFF 0x20 /* Display Inversion OFF */
  110. #define LCD_DINVON 0x21 /* Display Inversion ON */
  111. #define LCD_GAMMA 0x26 /* Gamma register */
  112. #define LCD_DISPLAY_OFF 0x28 /* Display off register */
  113. #define LCD_DISPLAY_ON 0x29 /* Display on register */
  114. #define LCD_COLUMN_ADDR 0x2A /* Colomn address register */
  115. #define LCD_PAGE_ADDR 0x2B /* Page address register */
  116. #define LCD_GRAM 0x2C /* GRAM register */
  117. #define LCD_RGBSET 0x2D /* Color SET */
  118. #define LCD_RAMRD 0x2E /* Memory Read */
  119. #define LCD_PLTAR 0x30 /* Partial Area */
  120. #define LCD_VSCRDEF 0x33 /* Vertical Scrolling Definition */
  121. #define LCD_TEOFF 0x34 /* Tearing Effect Line OFF */
  122. #define LCD_TEON 0x35 /* Tearing Effect Line ON */
  123. #define LCD_MAC 0x36 /* Memory Access Control register*/
  124. #define LCD_VSCRSADD 0x37 /* Vertical Scrolling Start Address */
  125. #define LCD_IDMOFF 0x38 /* Idle Mode OFF */
  126. #define LCD_IDMON 0x39 /* Idle Mode ON */
  127. #define LCD_PIXEL_FORMAT 0x3A /* Pixel Format register */
  128. #define LCD_WRITE_MEM_CONTINUE 0x3C /* Write Memory Continue */
  129. #define LCD_READ_MEM_CONTINUE 0x3E /* Read Memory Continue */
  130. #define LCD_SET_TEAR_SCANLINE 0x44 /* Set Tear Scanline */
  131. #define LCD_GET_SCANLINE 0x45 /* Get Scanline */
  132. #define LCD_WDB 0x51 /* Write Brightness Display register */
  133. #define LCD_RDDISBV 0x52 /* Read Display Brightness */
  134. #define LCD_WCD 0x53 /* Write Control Display register*/
  135. #define LCD_RDCTRLD 0x54 /* Read CTRL Display */
  136. #define LCD_WRCABC 0x55 /* Write Content Adaptive Brightness Control */
  137. #define LCD_RDCABC 0x56 /* Read Content Adaptive Brightness Control */
  138. #define LCD_WRITE_CABC 0x5E /* Write CABC Minimum Brightness */
  139. #define LCD_READ_CABC 0x5F /* Read CABC Minimum Brightness */
  140. #define LCD_READ_ID1 0xDA /* Read ID1 */
  141. #define LCD_READ_ID2 0xDB /* Read ID2 */
  142. #define LCD_READ_ID3 0xDC /* Read ID3 */
  143. /* Level 2 Commands */
  144. #define LCD_RGB_INTERFACE 0xB0 /* RGB Interface Signal Control */
  145. #define LCD_FRMCTR1 0xB1 /* Frame Rate Control (In Normal Mode) */
  146. #define LCD_FRMCTR2 0xB2 /* Frame Rate Control (In Idle Mode) */
  147. #define LCD_FRMCTR3 0xB3 /* Frame Rate Control (In Partial Mode) */
  148. #define LCD_INVTR 0xB4 /* Display Inversion Control */
  149. #define LCD_BPC 0xB5 /* Blanking Porch Control register */
  150. #define LCD_DFC 0xB6 /* Display Function Control register */
  151. #define LCD_ETMOD 0xB7 /* Entry Mode Set */
  152. #define LCD_BACKLIGHT1 0xB8 /* Backlight Control 1 */
  153. #define LCD_BACKLIGHT2 0xB9 /* Backlight Control 2 */
  154. #define LCD_BACKLIGHT3 0xBA /* Backlight Control 3 */
  155. #define LCD_BACKLIGHT4 0xBB /* Backlight Control 4 */
  156. #define LCD_BACKLIGHT5 0xBC /* Backlight Control 5 */
  157. #define LCD_BACKLIGHT7 0xBE /* Backlight Control 7 */
  158. #define LCD_BACKLIGHT8 0xBF /* Backlight Control 8 */
  159. #define LCD_POWER1 0xC0 /* Power Control 1 register */
  160. #define LCD_POWER2 0xC1 /* Power Control 2 register */
  161. #define LCD_VCOM1 0xC5 /* VCOM Control 1 register */
  162. #define LCD_VCOM2 0xC7 /* VCOM Control 2 register */
  163. #define LCD_NVMWR 0xD0 /* NV Memory Write */
  164. #define LCD_NVMPKEY 0xD1 /* NV Memory Protection Key */
  165. #define LCD_RDNVM 0xD2 /* NV Memory Status Read */
  166. #define LCD_READ_ID4 0xD3 /* Read ID4 */
  167. #define LCD_PGAMMA 0xE0 /* Positive Gamma Correction register */
  168. #define LCD_NGAMMA 0xE1 /* Negative Gamma Correction register */
  169. #define LCD_DGAMCTRL1 0xE2 /* Digital Gamma Control 1 */
  170. #define LCD_DGAMCTRL2 0xE3 /* Digital Gamma Control 2 */
  171. #define LCD_INTERFACE 0xF6 /* Interface control register */
  172. /* Extend register commands */
  173. #define LCD_POWERA 0xCB /* Power control A register */
  174. #define LCD_POWERB 0xCF /* Power control B register */
  175. #define LCD_DTCA 0xE8 /* Driver timing control A */
  176. #define LCD_DTCB 0xEA /* Driver timing control B */
  177. #define LCD_POWER_SEQ 0xED /* Power on sequence register */
  178. #define LCD_3GAMMA_EN 0xF2 /* 3 Gamma enable register */
  179. #define LCD_PRC 0xF7 /* Pump ratio control register */
  180. /* Size of read registers */
  181. #define LCD_READ_ID4_SIZE 3 /* Size of Read ID4 */
  182. /**
  183. * @}
  184. */
  185. /** @defgroup ILI9341_Exported_Functions
  186. * @{
  187. */
  188. void ili9341_Init(void);
  189. uint16_t ili9341_ReadID(void);
  190. void ili9341_WriteReg(uint8_t LCD_Reg);
  191. void ili9341_WriteData(uint16_t RegValue);
  192. uint32_t ili9341_ReadData(uint16_t RegValue, uint8_t ReadSize);
  193. void ili9341_DisplayOn(void);
  194. void ili9341_DisplayOff(void);
  195. uint16_t ili9341_GetLcdPixelWidth(void);
  196. uint16_t ili9341_GetLcdPixelHeight(void);
  197. /* LCD driver structure */
  198. extern LCD_DrvTypeDef ili9341_drv;
  199. /* LCD IO functions */
  200. void LCD_IO_Init(void);
  201. void LCD_IO_WriteData(uint16_t RegValue);
  202. void LCD_IO_WriteReg(uint8_t Reg);
  203. uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize);
  204. void LCD_Delay (uint32_t delay);
  205. #ifdef __cplusplus
  206. }
  207. #endif
  208. #endif /* __ILI9341_H */
  209. /**
  210. * @}
  211. */
  212. /**
  213. * @}
  214. */
  215. /**
  216. * @}
  217. */
  218. /**
  219. * @}
  220. */
  221. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/