lcd_001.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /*
  2. * @brief LCD controller Registers and control functions
  3. *
  4. * @note
  5. * Copyright(C) NXP Semiconductors, 2012
  6. * All rights reserved.
  7. *
  8. * @par
  9. * Software that is described herein is for illustrative purposes only
  10. * which provides customers with programming information regarding the
  11. * LPC products. This software is supplied "AS IS" without any warranties of
  12. * any kind, and NXP Semiconductors and its licensor disclaim any and
  13. * all warranties, express or implied, including all implied warranties of
  14. * merchantability, fitness for a particular purpose and non-infringement of
  15. * intellectual property rights. NXP Semiconductors assumes no responsibility
  16. * or liability for the use of the software, conveys no license or rights under any
  17. * patent, copyright, mask work right, or any other intellectual property rights in
  18. * or to any products. NXP Semiconductors reserves the right to make changes
  19. * in the software without notification. NXP Semiconductors also makes no
  20. * representation or warranty that such application will be suitable for the
  21. * specified use without further testing or modification.
  22. *
  23. * @par
  24. * Permission to use, copy, modify, and distribute this software and its
  25. * documentation is hereby granted, under NXP Semiconductors' and its
  26. * licensor's relevant copyrights in the software, without fee, provided that it
  27. * is used in conjunction with NXP Semiconductors microcontrollers. This
  28. * copyright, permission, and disclaimer notice must appear in all copies of
  29. * this code.
  30. */
  31. #ifndef __LCD_001_H_
  32. #define __LCD_001_H_
  33. #include "sys_config.h"
  34. #include "cmsis.h"
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /** @defgroup IP_LCD_001 IP: LCD register block and driver
  39. * @ingroup IP_Drivers
  40. * @{
  41. */
  42. /**
  43. * @brief LCD Controller register block structure
  44. */
  45. typedef struct { /*!< LCD Structure */
  46. __IO uint32_t TIMH; /*!< Horizontal Timing Control register */
  47. __IO uint32_t TIMV; /*!< Vertical Timing Control register */
  48. __IO uint32_t POL; /*!< Clock and Signal Polarity Control register */
  49. __IO uint32_t LE; /*!< Line End Control register */
  50. __IO uint32_t UPBASE; /*!< Upper Panel Frame Base Address register */
  51. __IO uint32_t LPBASE; /*!< Lower Panel Frame Base Address register */
  52. __IO uint32_t CTRL; /*!< LCD Control register */
  53. __IO uint32_t INTMSK; /*!< Interrupt Mask register */
  54. __I uint32_t INTRAW; /*!< Raw Interrupt Status register */
  55. __I uint32_t INTSTAT; /*!< Masked Interrupt Status register */
  56. __O uint32_t INTCLR; /*!< Interrupt Clear register */
  57. __I uint32_t UPCURR; /*!< Upper Panel Current Address Value register */
  58. __I uint32_t LPCURR; /*!< Lower Panel Current Address Value register */
  59. __I uint32_t RESERVED0[115];
  60. __IO uint16_t PAL[256]; /*!< 256x16-bit Color Palette registers */
  61. __I uint32_t RESERVED1[256];
  62. __IO uint32_t CRSR_IMG[256];/*!< Cursor Image registers */
  63. __IO uint32_t CRSR_CTRL; /*!< Cursor Control register */
  64. __IO uint32_t CRSR_CFG; /*!< Cursor Configuration register */
  65. __IO uint32_t CRSR_PAL0; /*!< Cursor Palette register 0 */
  66. __IO uint32_t CRSR_PAL1; /*!< Cursor Palette register 1 */
  67. __IO uint32_t CRSR_XY; /*!< Cursor XY Position register */
  68. __IO uint32_t CRSR_CLIP; /*!< Cursor Clip Position register */
  69. __I uint32_t RESERVED2[2];
  70. __IO uint32_t CRSR_INTMSK; /*!< Cursor Interrupt Mask register */
  71. __O uint32_t CRSR_INTCLR; /*!< Cursor Interrupt Clear register */
  72. __I uint32_t CRSR_INTRAW; /*!< Cursor Raw Interrupt Status register */
  73. __I uint32_t CRSR_INTSTAT;/*!< Cursor Masked Interrupt Status register */
  74. } IP_LCD_001_Type;
  75. /**
  76. * @brief LCD Palette entry format
  77. */
  78. typedef struct {
  79. uint32_t Rl : 5;
  80. uint32_t Gl : 5;
  81. uint32_t Bl : 5;
  82. uint32_t Il : 1;
  83. uint32_t Ru : 5;
  84. uint32_t Gu : 5;
  85. uint32_t Bu : 5;
  86. uint32_t Iu : 1;
  87. } LCD_PALETTE_ENTRY_Type;
  88. /**
  89. * @brief LCD Panel type
  90. */
  91. typedef enum {
  92. LCD_TFT = 0x02, /*!< standard TFT */
  93. LCD_MONO_4 = 0x01, /*!< 4-bit STN mono */
  94. LCD_MONO_8 = 0x05, /*!< 8-bit STN mono */
  95. LCD_CSTN = 0x00 /*!< color STN */
  96. } LCD_PANEL_OPT;
  97. /**
  98. * @brief LCD Color Format
  99. */
  100. typedef enum {
  101. LCD_COLOR_FORMAT_RGB = 0,
  102. LCD_COLOR_FORMAT_BGR
  103. } LCD_COLOR_FORMAT_OPT;
  104. /** LCD Interrupt control mask register bits */
  105. #define LCD_INTMSK_FUFIM 0x2 /*!< FIFO underflow interrupt enable */
  106. #define LCD_INTMSK_LNBUIM 0x4 /*!< LCD next base address update interrupt enable */
  107. #define LCD_INTMSK_VCOMPIM 0x8 /*!< Vertical compare interrupt enable */
  108. #define LCD_INTMSK_BERIM 0x10 /*!< AHB master error interrupt enable */
  109. #define CLCDC_LCDCTRL_ENABLE _BIT(0) /*!< LCD control enable bit */
  110. #define CLCDC_LCDCTRL_PWR _BIT(11) /*!< LCD control power enable bit */
  111. /**
  112. * @brief A structure for LCD Configuration
  113. */
  114. typedef struct {
  115. uint8_t HBP; /*!< Horizontal back porch in clocks */
  116. uint8_t HFP; /*!< Horizontal front porch in clocks */
  117. uint8_t HSW; /*!< HSYNC pulse width in clocks */
  118. uint16_t PPL; /*!< Pixels per line */
  119. uint8_t VBP; /*!< Vertical back porch in clocks */
  120. uint8_t VFP; /*!< Vertical front porch in clocks */
  121. uint8_t VSW; /*!< VSYNC pulse width in clocks */
  122. uint16_t LPP; /*!< Lines per panel */
  123. uint8_t IOE; /*!< Invert output enable, 1 = invert */
  124. uint8_t IPC; /*!< Invert panel clock, 1 = invert */
  125. uint8_t IHS; /*!< Invert HSYNC, 1 = invert */
  126. uint8_t IVS; /*!< Invert VSYNC, 1 = invert */
  127. uint8_t ACB; /*!< AC bias frequency in clocks (not used) */
  128. uint8_t BPP; /*!< Maximum bits per pixel the display supports */
  129. LCD_PANEL_OPT LCD; /*!< LCD panel type */
  130. LCD_COLOR_FORMAT_OPT color_format; /*!<BGR or RGB */
  131. uint8_t Dual; /*!< Dual panel, 1 = dual panel display */
  132. } LCD_Config_Type;
  133. /**
  134. * @brief LCD Cursor Size
  135. */
  136. typedef enum {
  137. LCD_CURSOR_32x32 = 0,
  138. LCD_CURSOR_64x64
  139. } LCD_CURSOR_SIZE_OPT;
  140. /**
  141. * @brief Enable Controller Interrupt
  142. * @param LCDx : pointer to LCD Controller Reg Struct
  143. * @param ints : OR'ed interrupt bits to enable
  144. * @return None
  145. */
  146. STATIC INLINE void IP_LCD_EnableInts(IP_LCD_001_Type *LCDx, uint32_t ints)
  147. {
  148. LCDx->INTMSK = ints;
  149. }
  150. /**
  151. * @brief Disable Controller Interrupt
  152. * @param LCDx : pointer to LCD Controller Reg Struct
  153. * @param ints : OR'ed interrupt bits to disable
  154. * @return None
  155. */
  156. STATIC INLINE void IP_LCD_DisableInts(IP_LCD_001_Type *LCDx, uint32_t ints)
  157. {
  158. LCDx->INTMSK = LCDx->INTMSK & ~(ints);
  159. }
  160. /**
  161. * @brief Clear Controller Interrupt
  162. * @param LCDx : pointer to LCD Controller Reg Struct
  163. * @param ints : OR'ed interrupt bits to clear
  164. * @return None
  165. */
  166. STATIC INLINE void IP_LCD_ClearInts(IP_LCD_001_Type *LCDx, uint32_t ints)
  167. {
  168. LCDx->INTCLR = LCDx->INTMSK & (ints);
  169. }
  170. /**
  171. * @brief Initialize the LCD controller
  172. * @param LCDx : pointer to LCD Controller Reg Struct
  173. * @param LCD_ConfigStruct : Pointer to LCD configuration
  174. * @return LCD_FUNC_OK is executed successfully or LCD_FUNC_ERR on error
  175. */
  176. void IP_LCD_Init(IP_LCD_001_Type *LCDx, LCD_Config_Type *LCD_ConfigStruct);
  177. /**
  178. * @brief Power the LCD Panel (power pin)
  179. * @param LCDx : pointer to LCD Controller Reg Struct
  180. * @param OnOff : true to power on, false to power off
  181. * @return None
  182. */
  183. void IP_LCD_Power(IP_LCD_001_Type *LCDx, FunctionalState OnOff);
  184. /**
  185. * @brief Enable/Disable the LCD Controller
  186. * @param LCDx : pointer to LCD Controller Reg Struct
  187. * @param EnDis : true to enable, false to disable
  188. * @return None
  189. */
  190. void IP_LCD_Enable(IP_LCD_001_Type *LCDx, FunctionalState EnDis);
  191. /**
  192. * @brief Set LCD Upper Panel Frame Buffer for Single Panel or Upper Panel Frame
  193. * Buffer for Dual Panel
  194. * @param LCDx : pointer to LCD Controller Reg Struct
  195. * @param buffer : address of buffer
  196. * @return None
  197. */
  198. void IP_LCD_SetUPFrameBuffer(IP_LCD_001_Type *LCDx, void *buffer);
  199. /**
  200. * @brief Set LCD Lower Panel Frame Buffer for Dual Panel
  201. * @param LCDx : pointer to LCD Controller Reg Struct
  202. * @param buffer : address of buffer
  203. * @return None
  204. */
  205. void IP_LCD_SetLPFrameBuffer(IP_LCD_001_Type *LCDx, void *buffer);
  206. /**
  207. * @brief Configure Cursor
  208. * @param LCDx : pointer to LCD Controller Reg Struct
  209. * @param cursor_size : specify size of cursor
  210. * - LCD_CURSOR_32x32 :cursor size is 32x32 pixels
  211. * - LCD_CURSOR_64x64 :cursor size is 64x64 pixels
  212. * @param sync : cursor sync mode
  213. * - TRUE :cursor sync to the frame sync pulse
  214. * - FALSE :cursor async mode
  215. * @return None
  216. */
  217. void IP_LCD_Cursor_Config(IP_LCD_001_Type *LCDx, LCD_CURSOR_SIZE_OPT cursor_size, bool sync);
  218. /**
  219. * @brief Get Internal Cursor Image Buffer Address
  220. * @param LCDx : pointer to LCD Controller Reg Struct
  221. * @param cursor_num : specify number of cursor is going to be written
  222. * this param must < 4
  223. * @return Cursor Image Buffer Address
  224. */
  225. void *IP_LCD_Cursor_GetImageBufferAddress(IP_LCD_001_Type *LCDx, uint8_t cursor_num);
  226. /**
  227. * @brief Enable Cursor
  228. * @param LCDx : pointer to LCD Controller Reg Struct
  229. * @param cursor_num : specify number of cursor is going to be written
  230. * this param must < 4
  231. * @param OnOff : true to turn on LCD, false to turn off
  232. * @return None
  233. */
  234. void IP_LCD_Cursor_Enable(IP_LCD_001_Type *LCDx, uint8_t cursor_num, FunctionalState OnOff);
  235. /**
  236. * @brief Load Cursor Palette
  237. * @param LCDx : pointer to LCD Controller Reg Struct
  238. * @param palette_color : cursor palette 0 value
  239. * @return None
  240. */
  241. void IP_LCD_Cursor_LoadPalette0(IP_LCD_001_Type *LCDx, uint32_t palette_color);
  242. /**
  243. * @brief Load Cursor Palette
  244. * @param LCDx : pointer to LCD Controller Reg Struct
  245. * @param palette_color : cursor palette 1 value
  246. * @return None
  247. */
  248. void IP_LCD_Cursor_LoadPalette1(IP_LCD_001_Type *LCDx, uint32_t palette_color);
  249. /**
  250. * @brief Set Cursor Position
  251. * @param LCDx : pointer to LCD Controller Reg Struct
  252. * @param x : horizontal position
  253. * @param y : vertical position
  254. * @return None
  255. */
  256. void IP_LCD_Cursor_SetPos(IP_LCD_001_Type *LCDx, uint16_t x, uint16_t y);
  257. /**
  258. * @brief Set Cursor Clipping Position
  259. * @param LCDx : pointer to LCD Controller Reg Struct
  260. * @param x : horizontal position, should be in range: 0..63
  261. * @param y : vertical position, should be in range: 0..63
  262. * @return None
  263. */
  264. void IP_LCD_Cursor_SetClip(IP_LCD_001_Type *LCDx, uint16_t x, uint16_t y);
  265. /**
  266. * @brief Load a color Palette entry
  267. * @param LCDx : pointer to LCD Controller Reg Struct
  268. * @param palette_addr : Address of palette table to load from
  269. * @param index : palette entry index to load
  270. * @return None
  271. */
  272. void IP_LCD_Color_LoadPalette(IP_LCD_001_Type *LCDx, uint32_t *palette_addr, uint32_t index);
  273. /**
  274. * @}
  275. */
  276. #ifdef __cplusplus
  277. }
  278. #endif
  279. #endif /* __LCD_001_H_ */