lpc_lcd.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /**********************************************************************
  2. * $Id$ lpc_lcd.h 2011-10-14
  3. *//**
  4. * @file lpc_lcd.h
  5. * @brief Contains all functions support for LCD firmware library
  6. * on LPC
  7. * @version 1.0
  8. * @date 14. October. 2011
  9. * @author NXP MCU SW Application Team
  10. *
  11. * Copyright(C) 2011, NXP Semiconductor
  12. * All rights reserved.
  13. *
  14. ***********************************************************************
  15. * Software that is described herein is for illustrative purposes only
  16. * which provides customers with programming information regarding the
  17. * products. This software is supplied "AS IS" without any warranties.
  18. * NXP Semiconductors assumes no responsibility or liability for the
  19. * use of the software, conveys no license or title under any patent,
  20. * copyright, or mask work right to the product. NXP Semiconductors
  21. * reserves the right to make changes in the software without
  22. * notification. NXP Semiconductors also make no representation or
  23. * warranty that such application will be suitable for the specified
  24. * use without further testing or modification.
  25. * Permission to use, copy, modify, and distribute this software and its
  26. * documentation is hereby granted, under NXP Semiconductors'
  27. * relevant copyright in the software, without fee, provided that it
  28. * is used in conjunction with NXP Semiconductors microcontrollers. This
  29. * copyright, permission, and disclaimer notice must appear in all copies of
  30. * this code.
  31. **********************************************************************/
  32. #include "lpc_types.h"
  33. #ifndef __LPC_LCD_H_
  34. #define __LPC_LCD_H_
  35. /** @defgroup LCD LCD (Liquid Crystal Display)
  36. * @ingroup LPC_CMSIS_FwLib_Drivers
  37. * @{
  38. */
  39. /** @defgroup LCD_Public_Macros LCD Public Macros
  40. * @{
  41. */
  42. #define LCD_PWR_ENA_DIS_DLY 10000
  43. #define LCD_FUNC_OK 0
  44. #define LCD_FUNC_ERR -1
  45. #define GET_CURSOR_IMG_SIZE(size) ((size == 32) ? 64:256)
  46. /**
  47. * @}
  48. */
  49. /** @defgroup LCD_Public_Types LCD Public Types
  50. * @{
  51. */
  52. typedef enum __LCD_TYPES
  53. {
  54. LCD_STN_MONOCHROME,
  55. LCD_STN_COLOR,
  56. LCD_TFT,
  57. LCD_TYPE_UNKNOWN,
  58. } LCD_TYPES;
  59. typedef enum __LCD_BPP
  60. {
  61. LCD_BPP_1 = 0x00,
  62. LCD_BPP_2 = 0x01,
  63. LCD_BPP_4 = 0x02,
  64. LCD_BPP_8 = 0x03,
  65. LCD_BPP_16 = 0x04,
  66. LCD_BPP_24 = 0x05,
  67. LCD_BPP_16_565Mode = 0x06,
  68. LCD_BPP_12_444Mode = 0x07,
  69. } LCD_BPP;
  70. typedef enum __LCD_PANEL
  71. {
  72. LCD_PANEL_UPPER,
  73. LCD_PANEL_LOWER,
  74. }LCD_PANEL;
  75. /**
  76. * @brief A struct for Bitmap on LCD screen
  77. */
  78. typedef struct _Bmp_t
  79. {
  80. uint32_t H_Size;
  81. uint32_t V_Size;
  82. uint32_t BitsPP;
  83. uint32_t BytesPP;
  84. uint8_t *pPalette;
  85. uint8_t *pPicStream;
  86. uint8_t *pPicDesc;
  87. } Bmp_t, *pBmp_t;
  88. /**
  89. * @brief A struct for Font Type on LCD screen
  90. */
  91. typedef struct _FontType_t
  92. {
  93. uint32_t H_Size;
  94. uint32_t V_Size;
  95. uint32_t CharacterOffset;
  96. uint32_t CharactersNuber;
  97. uint8_t *pFontStream;
  98. uint8_t *pFontDesc;
  99. } FontType_t, *pFontType_t;
  100. /**
  101. * @brief A struct for LCD Palette
  102. */
  103. typedef struct __LCD_PALETTE_Type
  104. {
  105. uint8_t Red;
  106. uint8_t Green;
  107. uint8_t Blue;
  108. }LCD_PALETTE_Type, *pLCD_PALETTE_Type;
  109. /**
  110. * @brief A struct for Horizontal configuration
  111. */
  112. typedef struct __LCD_HConfig_Type
  113. {
  114. uint8_t hfp; // Horizontal front porch
  115. uint8_t hbp; // Horizontal back porch
  116. uint8_t hsw; // Horizontal synchronization pulse width
  117. uint16_t ppl; // Number of pixels per line
  118. }LCD_HConfig_Type;
  119. /**
  120. * @brief A struct for Vertical configuration
  121. */
  122. typedef struct __LCD_VConfig_Type
  123. {
  124. uint8_t vfp; // Vertical front and back porch
  125. uint8_t vbp; // Vertical back porch
  126. uint8_t vsw; // Vertical synchronization pulse width
  127. uint16_t lpp; // Number of lines per panel
  128. }LCD_VConfig_Type;
  129. /**
  130. * @brief A struct for Polarity configuration
  131. */
  132. typedef struct __LCD_POLARITY_Type
  133. {
  134. uint16_t cpl; // Number of pixel clocks per line
  135. uint8_t active_high; // Signal polarity, active HIGH or LOW
  136. uint8_t acb; // AC bias pin frequency
  137. uint8_t invert_panel_clock; // Invert Panel clock;
  138. uint8_t invert_hsync; // Invert HSYNC
  139. uint8_t invert_vsync; // Invert VSYSNC
  140. }LCD_POLARITY_Type;
  141. /**
  142. * @brief A struct for LCD Configuration
  143. */
  144. typedef struct __LCD_Config_Type
  145. {
  146. LCD_HConfig_Type hConfig; // Horizontal config
  147. LCD_VConfig_Type vConfig; // Vertical config
  148. LCD_POLARITY_Type polarity; // Polarity config
  149. uint32_t panel_clk; // Panel clock frequency
  150. LCD_BPP lcd_bpp; // Bits-per-pixel
  151. LCD_TYPES lcd_type; // Display type: STN monochrome, STN color, or TFT
  152. uint8_t lcd_mono8; // STN 4 or 8-bit interface mode
  153. uint8_t lcd_dual; // STN dual or single panel mode
  154. uint8_t big_endian_byte; // byte ordering in memory
  155. uint8_t big_endian_pixel; // pixel ordering within a byte
  156. uint32_t lcd_panel_upper; // base address of frame buffer
  157. uint32_t lcd_panel_lower; // base address of frame buffer
  158. uint8_t* lcd_palette; // point to palette buffer
  159. Bool lcd_bgr; // False: RGB , TRUE: BGR
  160. } LCD_Config_Type;
  161. /**
  162. * @brief A struct for Cursor configuration
  163. */
  164. typedef struct __LCD_Cursor_Config_Type
  165. {
  166. uint8_t size32; // 32x32 or 64x64
  167. uint8_t framesync;
  168. LCD_PALETTE_Type palette[2];
  169. uint32_t baseaddress;
  170. } LCD_Cursor_Config_Type;
  171. typedef uint32_t LcdPixel_t, *pLcdPixel_t;
  172. typedef int32_t LCD_RET_CODE;
  173. /**
  174. * @}
  175. */
  176. /** @defgroup LCD_Public_Functions LCD Public Functions
  177. * @{
  178. */
  179. LCD_RET_CODE LCD_Init (LCD_Config_Type* pConfig);
  180. void LCD_SetBaseAddress(LCD_PANEL panel, uint32_t pAddress);
  181. void LCD_SetPalette (const uint8_t* pPallete);
  182. void LCD_Enable (Bool bEna);
  183. void LCD_Cursor_Cfg(LCD_Cursor_Config_Type* pConfig);
  184. void LCD_Cursor_Enable(int enable, int cursor);
  185. void LCD_Move_Cursor(int x, int y);
  186. void LCD_Cursor_SetImage (const uint32_t *pCursor, int cursor, int size);
  187. void LCD_SetImage(LCD_PANEL panel,const uint8_t *pPain);
  188. void LCD_FillRect (LCD_PANEL panel, uint32_t startx,uint32_t endx,
  189. uint32_t starty, uint32_t endy,
  190. LcdPixel_t color);
  191. void LCD_PutPixel (LCD_PANEL panel, uint32_t X_Left, uint32_t Y_Up, LcdPixel_t color);
  192. void LCD_LoadPic (LCD_PANEL panel,uint32_t X_Left, uint32_t Y_Up, Bmp_t * pBmp, uint32_t Mask);
  193. /**
  194. * @}
  195. */
  196. #endif // __LPC_LCD_H_
  197. /**
  198. * @}
  199. */