lcd.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * File : lcd.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2008-03-29 Yi.Qiu
  13. */
  14. #ifndef __LCD_H__
  15. #define __LCD_H__
  16. #include <rtthread.h>
  17. #include "mb9bf506r.h"
  18. /********* LCD Hardward Interface *************
  19. LCD_CS PORT1.7
  20. LCD_CD PORT1.6
  21. LCD_WR PORT1.5
  22. LCD_RD PORT1.4
  23. LCD_SCK PORT1.3
  24. LCD_MOSI PORT1.2
  25. LCD_C86 PORT1.1
  26. LCD_PS PORT1.0
  27. LCD_DATA[0..7] PORT5.[0..7]
  28. ***********************************************/
  29. #define LCD_CS (1UL << 7)
  30. #define LCD_CS_DDR (FM3_GPIO->DDR1)
  31. #define LCD_CS_PFR (FM3_GPIO->PFR1)
  32. #define LCD_CS_PDOR (FM3_GPIO->PDOR1)
  33. #define LCD_CD (1UL << 6)
  34. #define LCD_CD_DDR (FM3_GPIO->DDR1)
  35. #define LCD_CD_PFR (FM3_GPIO->PFR1)
  36. #define LCD_CD_PDOR (FM3_GPIO->PDOR1)
  37. #define LCD_PS (1UL << 0)
  38. #define LCD_PS_DDR (FM3_GPIO->DDR1)
  39. #define LCD_PS_PFR (FM3_GPIO->PFR1)
  40. #define LCD_PS_PDOR (FM3_GPIO->PDOR1)
  41. #define LCD_CLK (1UL << 6)
  42. #define LCD_CLK_DDR (FM3_GPIO->DDR5)
  43. #define LCD_CLK_PFR (FM3_GPIO->PFR5)
  44. #define LCD_CLK_PDOR (FM3_GPIO->PDOR5)
  45. #define LCD_DATA (1UL << 7)
  46. #define LCD_DATA_DDR (FM3_GPIO->DDR5)
  47. #define LCD_DATA_PFR (FM3_GPIO->PFR5)
  48. #define LCD_DATA_PDOR (FM3_GPIO->PDOR5)
  49. /* LCD driver for ZYMG12864C3 */
  50. #define LCD_WIDTH 128
  51. #define LCD_HEIGHT 64
  52. // Driver the LCD with Parallel or serial interface and the command/data control pin is gpio
  53. #define LCD_CS_HIGH() LCD_CS_PDOR |= LCD_CS
  54. #define LCD_CS_LOW() LCD_CS_PDOR &= ~LCD_CS
  55. #define LCD_CD_HIGH() LCD_CD_PDOR |= LCD_CD
  56. #define LCD_CD_LOW() LCD_CD_PDOR &= ~LCD_CD
  57. #define LCD_PS_HIGH() LCD_PS_PDOR |= LCD_PS
  58. #define LCD_PS_LOW() LCD_PS_PDOR &= ~LCD_PS
  59. #define LCD_CLK_HIGH() LCD_CLK_PDOR |= LCD_CLK
  60. #define LCD_CLK_LOW() LCD_CLK_PDOR &= ~LCD_CLK
  61. #define LCD_DATA_HIGH() LCD_DATA_PDOR |= LCD_DATA
  62. #define LCD_DATA_LOW() LCD_DATA_PDOR &= ~LCD_DATA
  63. // define the arrtibute of ZYMG12864(LCM)
  64. #define GUI_LCM_XMAX 128 // defined the lcd's line-number is 128
  65. #define GUI_LCM_YMAX 64 // defined the lcd's column-number is 64
  66. #define GUI_LCM_PAGE 8 // defined the lcd's page-number is 8(GUI_LCM_YMAX/8)
  67. /* set LCD command */
  68. #define Display_On 0xAF // A0,RD,WR:010
  69. #define Display_Off 0xAE // A0,RD,WR:010
  70. #define Set_Start_Line_0 0x40 // A0,RD,WR:010; line0~line63
  71. #define Set_Page_Addr_0 0xB0 // A0,RD,WR:010; addr0~addr8
  72. #define Set_ColH_Addr_0 0x10 // A0,RD,WR:010;
  73. #define Set_ColL_Addr_0 0x00 // A0,RD,WR:010; addr0~addr131
  74. #define Read_Status 0x-0 // A0,RD,WR:001; BUSY | ADC | ON/OFF | RESET | 0 0 0 0
  75. #define Status_Busy 0x80
  76. #define Status_ADC_Reverse 0x40 // column address 131-n : SEG n, else column address n : SEG n
  77. #define Status_Display_Off 0x20
  78. #define Status_Reset 0x80
  79. #define Write_Data 0x-- // A0,RD,WR:110
  80. #define Read_Date 0x-- // A0,RD,WR:101; spi mode is unavailable
  81. #define Set_ADC_Normal 0xA0 // A0,RD,WR:010
  82. #define Set_ADC_Reverse 0xA1 // A0,RD,WR:010
  83. #define Display_Normal 0xA6 // A0,RD,WR:010
  84. #define Display_Reverse 0xA7 // A0,RD,WR:010; reverse color
  85. #define Display_All_On 0xA5 // A0,RD,WR:010
  86. #define Display_All_Normal 0xA4 // A0,RD,WR:010
  87. /*************************************************************
  88. * bias: 1/65duty | 1/49duty | 1/33duty | 1/55duty | 1/53duty *
  89. * ---------------|----------|----------|----------|--------- *
  90. * A2: 1/9 bias | 1/8 bias | 1/6 bias | 1/8 bias | 1/8 bias *
  91. * A3: 1/7 bias | 1/6 bias | 1/5 bias | 1/6 bias | 1/6 bias *
  92. **************************************************************/
  93. #define Set_LCD_Bias_7 0xA3 // A0,RD,WR:010
  94. #define Set_LCD_Bias_9 0xA2 // A0,RD,WR:010
  95. #define RMW_Mode_Enable 0xE0 // A0,RD,WR:010; the column address locked when read command operating
  96. #define RMW_Mode_End 0xEE // A0,RD,WR:010; returns to the column address when RMW was entered.
  97. #define Reset_LCD 0xE2 // A0,RD,WR:010
  98. /**************************************************************************************
  99. * Com Scan Dir: | 1/65duty | 1/49duty | 1/33duty | 1/55duty | 1/53duty *
  100. * --------------|-------------|-------------|-------------|------------------------ *
  101. * C0: Normal | COM0:COM63 | COM0:COM47 | COM0:COM31 | COM0:COM53 | COM0:COM51 *
  102. * C8: Reverse | COM63:COM0 | COM47:COM0 | COM31:COM0 | COM53:COM0 | COM51:COM0 *
  103. ***************************************************************************************/
  104. #define COM_Scan_Dir_Normal 0xC0 // A0,RD,WR:010
  105. #define COM_Scan_Dir_Reverse 0xC8 // A0,RD,WR:010
  106. // 0 0 1 0 1 | Booster On | Regulator On | Follower On
  107. #define Power_Booster_On 0x2C // A0,RD,WR:010
  108. #define Power_Regulator_On 0x2E // A0,RD,WR:010
  109. #define Power_Follower_On 0x2F // A0,RD,WR:010
  110. #define Set_Resistor_Ratio 0x20 // A0,RD,WR:010; 20~27:small~large
  111. #define Set_ElecVol_Mode 0x81 // A0,RD,WR:010; double byte command
  112. #define Set_ElecVol_Reg 0x20 // A0,RD,WR:010; the electronic volume(64 voltage levels:00~3F) function is not used.
  113. #define Sleep_Mode_Enable 0xAC // A0,RD,WR:010; double byte command, preceding command
  114. #define Sleep_Mode_Disable 0xAD // A0,RD,WR:010; preceding command
  115. #define Sleep_Mode_Deliver 0x00 // A0,RD,WR:010; following command
  116. #define Boost_Ratio_Set 0xF8 // A0,RD,WR:010; double byte command, preceding command
  117. #define Boost_Ratio_234 0x00 // A0,RD,WR:010; following command
  118. #define Boost_Ratio_5 0x01 // A0,RD,WR:010; following command
  119. #define Boost_Ratio_6 0x03 // A0,RD,WR:010; following command
  120. #define Command_Nop 0xE3 // A0,RD,WR:010
  121. #define Command_IC_Test 0xFC // A0,RD,WR:010; don't use
  122. #define RT_DEVICE_CTRL_LCD_GET_WIDTH 0
  123. #define RT_DEVICE_CTRL_LCD_GET_HEIGHT 1
  124. #define RT_DEVICE_CTRL_LCD_GET_BPP 2
  125. #define RT_DEVICE_CTRL_LCD_GET_FRAMEBUFFER 3
  126. #define RT_DEVICE_CTRL_LCD_POWER_ON 4
  127. #define RT_DEVICE_CTRL_LCD_POWER_OFF 5
  128. #define RT_DEVICE_CTRL_LCD_CLEAR_SCR 6
  129. #define RT_DEVICE_CTRL_LCD_FILL_ALL 7
  130. #define RT_DEVICE_CTRL_LCD_UPDATE_POINT 8
  131. #define RT_DEVICE_CTRL_LCD_DISPLAY_ON 9
  132. #define RT_DEVICE_CTRL_LCD_DISPLAY_OFF 10
  133. #define RT_DEVICE_CTRL_LCD_PUT_STRING 11
  134. enum
  135. {
  136. ADC_MSG,
  137. KEY_MSG,
  138. CPU_MSG,
  139. MAX_MSG,
  140. };
  141. struct lcd_msg
  142. {
  143. rt_uint8_t type;
  144. rt_uint16_t adc_value;
  145. rt_uint8_t key;
  146. rt_uint16_t major;
  147. rt_uint16_t minor;
  148. };
  149. extern rt_uint32_t x;
  150. extern rt_uint32_t y;
  151. void rt_hw_lcd_init(void);
  152. #endif