stm32 驱动 TFT LCD
时间:11-26
来源:互联网
点击:
062 | #define R59 0x3B |
063 | #define R60 0x3C |
064 | #define R61 0x3D |
065 | #define R62 0x3E |
066 | #define R63 0x3F |
067 | #define R64 0x40 |
068 | #define R65 0x41 |
069 | #define R66 0x42 |
070 | #define R67 0x43 |
071 | #define R68 0x44 |
072 | #define R69 0x45 |
073 | #define R70 0x46 |
074 | #define R71 0x47 |
075 | #define R72 0x48 |
076 | #define R73 0x49 |
077 | #define R74 0x4A |
078 | #define R75 0x4B |
079 | #define R76 0x4C |
080 | #define R77 0x4D |
081 | #define R78 0x4E |
082 | #define R79 0x4F |
083 | #define R80 0x50 |
084 | #define R81 0x51 |
085 | #define R82 0x52 |
086 | #define R83 0x53 |
087 | #define R96 0x60 |
088 | #define R97 0x61 |
089 | #define R106 0x6A |
090 | #define R118 0x76 |
091 | #define R128 0x80 |
092 | #define R129 0x81 |
093 | #define R130 0x82 |
094 | #define R131 0x83 |
095 | #define R132 0x84 |
096 | #define R133 0x85 |
097 | #define R134 0x86 |
098 | #define R135 0x87 |
099 | #define R136 0x88 |
100 | #define R137 0x89 |
101 | #define R139 0x8B |
102 | #define R140 0x8C |
103 | #define R141 0x8D |
104 | #define R143 0x8F |
105 | #define R144 0x90 |
106 | #define R145 0x91 |
107 | #define R146 0x92 |
108 | #define R147 0x93 |
109 | #define R148 0x94 |
110 | #define R149 0x95 |
111 | #define R150 0x96 |
112 | #define R151 0x97 |
113 | #define R152 0x98 |
114 | #define R153 0x99 |
115 | #define R154 0x9A |
116 | #define R157 0x9D |
117 | #define R192 0xC0 |
118 | #define R193 0xC1 |
119 | #define R229 0xE5 |
120 |
121 |
122 | /*硬件相关的宏定义*/ |
123 | #define LCD_FAST_IO 1 //定义是否使用快速IO 建议使用快速IO,效率更高 |
124 |
125 | //-----------------LCD端口定义---------------- |
126 | /********************************************************************************/ |
127 |
128 | #define LCD_GPIO_LED_PORT GPIOC |
129 | #define LCD_GPIO_LED_PIN GPIO_Pin_10 |
130 |
131 | #define LCD_GPIO_CS_PORT GPIOC |
132 | #define LCD_GPIO_CS_PIN GPIO_Pin_9 |
133 |
134 |
135 | #define LCD_GPIO_RS_PORT GPIOC |
136 | #define LCD_GPIO_RS_PIN GPIO_Pin_8 |
137 |
138 |
139 | #define LCD_GPIO_WR_PORT GPIOC |
140 | #define LCD_GPIO_WR_PIN GPIO_Pin_7 |
141 |
142 |
143 | #define LCD_GPIO_RD_PORT GPIOC |
144 | #define LCD_GPIO_RD_PIN GPIO_Pin_6 |
145 |
146 | //16位数据所在端口,PB0~15作为数据线 |
147 | #define LCD_GPIO_DATA_PORT GPIOB |
148 | #define LCD_GPIO_DATA_PIN GPIO_Pin_All |
149 |
150 | #if LCD_FAST_IO == 1 //快速IO |
151 |
152 | #define Set_Cs GPIOC->BSRR=1<9 //片选端口 PC9 |
153 | #define Set_Rs GPIOC->BSRR=1<8 //数据/命令 PC8 |
154 | #define Set_Wr GPIOC->BSRR=1<7 //写数据 PC7 |
155 | #define Set_Rd GPIOC->BSRR=1<6 //读数据 PC6 |
156 |
157 | #define Clr_Cs GPIOC->BRR=1<9 //片选端口 PC9 |
158 | #define Clr_Rs GPIOC->BRR=1<8 //数据/命令 PC8 |
159 | #define Clr_Wr GPIOC->BRR=1<7 //写数据 PC7 |
160 | #define Clr_Rd GPIOC->BRR=1<6 //读数据 PC6 |
161 |
162 |
163 | #else |
164 |
165 | #define Set_Cs {GPIO_SetBits(LCD_GPIO_CS_PORT,LCD_GPIO_CS_PIN);} |
166 | #define Clr_Cs {GPIO_ResetBits(LCD_GPIO_CS_PORT,LCD_GPIO_CS_PIN);} |
167 | #define Set_Rs {GPIO_SetBits(LCD_GPIO_RS_PORT,LCD_GPIO_RS_PIN);} |
168 | #define Clr_Rs {GPIO_ResetBits(LCD_GPIO_RS_PORT,LCD_GPIO_RS_PIN);} |
169 | #define Set_Wr {GPIO_SetBits(LCD_GPIO_WR_PORT,LCD_GPIO_WR_PIN);} |
170 | #define Clr_Wr {GPIO_ResetBits(LCD_GPIO_WR_PORT,LCD_GPIO_WR_PIN);} |
171 | #define Set_Rd {GPIO_SetBits(LCD_GPIO_RD_PORT,LCD_GPIO_RD_PIN);} |
172 | #define Clr_Rd {GPIO_ResetBits(LCD_GPIO_RD_PORT,LCD_GPIO_RD_PIN);} |
173 |
174 | #endif |
175 |
176 | #define Set_LED {GPIO_SetBits(LCD_GPIO_LED_PORT,LCD_GPIO_LED_PIN);} |
177 | #define Clr_LED {GPIO_ResetBits(LCD_GPIO_LED_PORT,LCD_GPIO_LED_PIN);} |
178 |
179 | #define Write_Data(DataValue) {GPIO_Write(LCD_GPIO_DATA_PORT,DataValue);} |
180 |
181 | //直接操作寄存器读取,使用库函数读取I/O有问题,原因不详 |
182 | #define Read_Data() (LCD_GPIO_DATA_PORT ->IDR) //必须使用宏定义,写成函数会有问题 |
183 | //#define Read_Data() (GPIO_ReadInputData(LCD_GPIO_DATA_PORT)) //这句有问题 |
184 |
185 |
186 |
187 | //写8位数据函数 |
188 | //用宏定义,提高速度. |
189 | #define LCD_WR_DATA(data){ |
190 | Set_Rs; |
191 | Clr_Cs; |
192 | Write_Data(data); |
193 | Clr_Wr; |
194 | Set_Wr; |
195 | Set_Cs; |
196 | } |
197 |
198 |
199 | /********************************************************************************/ |
200 |
201 | //画笔颜色 |
202 | #define WHITE 0xFFFF |
203 | #define BLACK 0x0000 |
204 | #define BLUE 0x001F |
205 | #define BRED 0XF81F |
206 | #define GRED 0XFFE0 |
207 | #define GBLUE 0X07FF |
208 | #define RED 0xF800 |
209 | #define MAGENTA 0xF81F |
stm32TFTLC 相关文章:
- Stm32的TFT LCD显示器控制学习笔记(12-01)
- STM32之TFT-LCD液晶(11-13)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)