?? lcm.lst
字號:
C51 COMPILER V7.50 LCM 05/12/2009 22:59:47 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE LCM
OBJECT MODULE PLACED IN lcm.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE lcm.c LARGE OPTIMIZE(7,SPEED) BROWSE DEBUG OBJECTEXTEND
line level source
1
2 #include "LCM.h"
3 #include "reg51.h"
4 //#include "font.h"
5 #define SOFT_RESET 0x01
6 #define SLEEP_OUT 0x11
7 #define DISPLAY_ON 0x29
8 #define BOOSTER_ON 0x03
9 #define COLOR_INTERFACE 0x3A
10 #define COLOR_8_BIT 0x02
11 #define COLOR_12_BIT 0x03
12 #define COLOR_16_BIT 0x05
13 #define COLOR_SET 0x2D
14 #define MEM_ACCESS_CTRL 0x36
15 #define MIRROR_X 6
16 #define MIRROR_Y 7
17 #define VERT_WRITE 5
18 #define RGB 3
19 #define MEM_WRITE 0x2C
20 #define SET_X_ADDR 0x2A
21 #define SET_Y_ADDR 0x2B
22 #define backc 0xff
23 #define DISP_X_START 0
24 #define DISP_Y_START 0
25 #define DISP_X_END 131
26 #define DISP_Y_END 131
27 #define RED 0xE0
28 #define GREEN 0x1C
29 #define BLUE 0x03
30 #define YELLOW 0xFC
31 #define MAGENTA 0xE3
32 #define CYAN 0x1F
33 #define BLACK 0x00
34 #define WHITE 0xFF
35
36
37 void delay5ms(void)
38 {
39 1 uint i;
40 1 for(i=0; i<2200; i++);
41 1 }
42
43 void n6100SendCommand(uint8_t dat)
44 {
45 1 uchar i=0;
46 1 CS=0;
47 1 SCLK=0;
48 1 SDATA=0;
49 1 SCLK=1;
50 1 SCLK=0;
51 1 if(dat&0x80)
52 1 SDATA=1;
53 1 else
54 1 SDATA=0;
55 1 SCLK=1;
C51 COMPILER V7.50 LCM 05/12/2009 22:59:47 PAGE 2
56 1 SCLK=0;
57 1 if(dat&0x40)
58 1 SDATA=1;//set(PORTB,SDATA);
59 1 else
60 1 SDATA=0;//cli(PORTB,SDATA);
61 1 SCLK=1;//set(PORTB,SCLK);
62 1
63 1 SCLK=0;//cli(PORTB,SCLK);
64 1 if(dat&0x20)
65 1 SDATA=1;//set(PORTB,SDATA);
66 1 else
67 1 SDATA=0;//cli(PORTB,SDATA);
68 1 SCLK=1;//set(PORTB,SCLK);
69 1
70 1 SCLK=0;//cli(PORTB,SCLK);
71 1 if(dat&0x10)
72 1 SDATA=1;//set(PORTB,SDATA);
73 1 else
74 1 SDATA=0;//cli(PORTB,SDATA);
75 1 SCLK=1;//set(PORTB,SCLK);
76 1
77 1 SCLK=0;//cli(PORTB,SCLK);
78 1 if(dat&0x08)
79 1 SDATA=1;//set(PORTB,SDATA);
80 1 else
81 1 SDATA=0;//cli(PORTB,SDATA);
82 1 SCLK=1;//set(PORTB,SCLK);
83 1
84 1 SCLK=0;//cli(PORTB,SCLK);
85 1 if(dat&0x04)
86 1 SDATA=1;//set(PORTB,SDATA);
87 1 else
88 1 SDATA=0;//cli(PORTB,SDATA);
89 1 SCLK=1;//set(PORTB,SCLK);
90 1
91 1 SCLK=0;//cli(PORTB,SCLK);
92 1 if(dat&0x02)
93 1 SDATA=1;//set(PORTB,SDATA);
94 1 else
95 1 SDATA=0;//cli(PORTB,SDATA);
96 1 SCLK=1;//set(PORTB,SCLK);
97 1
98 1 SCLK=0;//cli(PORTB,SCLK);
99 1 if(dat&0x01)
100 1 SDATA=1;//set(PORTB,SDATA);
101 1 else
102 1 SDATA=0;//cli(PORTB,SDATA);
103 1 SCLK=1;
104 1 CS=1; // CS wieder auf 1
105 1 //SPCR = 0x00; // SPI wieder disablen
106 1 }
107
108 void n6100SendData(uint8_t dat)
109 {
110 1 uchar i=0;
111 1 // CS auf Low setzen
112 1 CS=0;
113 1 // 1. Bit (Command/Data) per Software erzeugen
114 1 SCLK=0;
115 1 SDATA=1; // logisch 1 f黵 Daten
116 1 SCLK=1;
117 1 SCLK=0;
C51 COMPILER V7.50 LCM 05/12/2009 22:59:47 PAGE 3
118 1 if(dat&0x80)
119 1 SDATA=1;//set(PORTB,SDATA);
120 1 else
121 1 SDATA=0;//cli(PORTB,SDATA);
122 1 SCLK=1;//set(PORTB,SCLK);
123 1
124 1 SCLK=0;//cli(PORTB,SCLK);
125 1 if(dat&0x40)
126 1 SDATA=1;//set(PORTB,SDATA);
127 1 else
128 1 SDATA=0;//cli(PORTB,SDATA);
129 1 SCLK=1;//set(PORTB,SCLK);
130 1
131 1 SCLK=0;//cli(PORTB,SCLK);
132 1 if(dat&0x20)
133 1 SDATA=1;//set(PORTB,SDATA);
134 1 else
135 1 SDATA=0;//cli(PORTB,SDATA);
136 1 SCLK=1;//set(PORTB,SCLK);
137 1
138 1 SCLK=0;//cli(PORTB,SCLK);
139 1 if(dat&0x10)
140 1 SDATA=1;//set(PORTB,SDATA);
141 1 else
142 1 SDATA=0;//cli(PORTB,SDATA);
143 1 SCLK=1;//set(PORTB,SCLK);
144 1
145 1 SCLK=0;//cli(PORTB,SCLK);
146 1 if(dat&0x08)
147 1 SDATA=1;//set(PORTB,SDATA);
148 1 else
149 1 SDATA=0;//cli(PORTB,SDATA);
150 1 SCLK=1;//set(PORTB,SCLK);
151 1
152 1 SCLK=0;//cli(PORTB,SCLK);
153 1 if(dat&0x04)
154 1 SDATA=1;//set(PORTB,SDATA);
155 1 else
156 1 SDATA=0;//cli(PORTB,SDATA);
157 1 SCLK=1;//set(PORTB,SCLK);
158 1
159 1 SCLK=0;//cli(PORTB,SCLK);
160 1 if(dat&0x02)
161 1 SDATA=1;//set(PORTB,SDATA);
162 1 else
163 1 SDATA=0;//cli(PORTB,SDATA);
164 1 SCLK=1;//set(PORTB,SCLK);
165 1
166 1 SCLK=0;//cli(PORTB,SCLK);
167 1 if(dat&0x01)
168 1 SDATA=1;//set(PORTB,SDATA);
169 1 else
170 1 SDATA=0;//cli(PORTB,SDATA);
171 1 SCLK=1;
172 1 CS=1;
173 1 }
174
175 uint8_t memAccessCtrl=0;
176 void n6100SetDrawRect(uint8_t startX, uint8_t endX, uint8_t startY, uint8_t endY) {
177 1 n6100SendCommand(SET_X_ADDR);
178 1 n6100SendData(startX+1);
179 1 n6100SendData(endX+1);
C51 COMPILER V7.50 LCM 05/12/2009 22:59:47 PAGE 4
180 1
181 1 n6100SendCommand(SET_Y_ADDR);
182 1 n6100SendData(startY+1);
183 1 n6100SendData(endY+1);
184 1 }
185 void n6100Clear(void)
186 {
187 1 uint i;
188 1 n6100SetDrawRect(DISP_X_START, DISP_X_END, DISP_Y_START, DISP_Y_END);
189 1 n6100SendCommand(MEM_WRITE);
190 1 for(i=0; i<18000; i++)
191 1 {
192 2 n6100SendData(backc);
193 2 }
194 1 }
195
196 void n6100Init(void)
197 {
198 1 uint8_t i;
199 1 SDATA=0;
200 1 SCLK=0;
201 1 SDATA=1;
202 1 SCLK=1;
203 1 SDATA=0;
204 1 SCLK=0;
205 1 SDATA=1;
206 1 SCLK=1;
207 1 CS=1;
208 1 REST=1;
209 1 delay5ms();
210 1 REST=0;
211 1 delay5ms();
212 1 REST=1;
213 1 SDATA=1;
214 1 SCLK=1;
215 1 CS=1;
216 1 n6100SendCommand(SOFT_RESET);
217 1 n6100SendCommand(SLEEP_OUT);
218 1 n6100SendCommand(DISPLAY_ON);
219 1 n6100SendCommand(BOOSTER_ON);
220 1 for(i=0; i<10; i++) {
221 2 delay5ms();
222 2 }
223 1
224 1 n6100SendCommand(COLOR_INTERFACE);
225 1 n6100SendData(COLOR_8_BIT);
226 1 n6100SendCommand(COLOR_SET);
227 1 // red
228 1 n6100SendData(0x00);
229 1 n6100SendData(0x02);
230 1 n6100SendData(0x03);
231 1 n6100SendData(0x04);
232 1 n6100SendData(0x05);
233 1 n6100SendData(0x06);
234 1 n6100SendData(0x08);
235 1 n6100SendData(0x0f);
236 1 // green
237 1 n6100SendData(0x00);
238 1 n6100SendData(0x02);
239 1 n6100SendData(0x03);
240 1 n6100SendData(0x04);
241 1 n6100SendData(0x05);
C51 COMPILER V7.50 LCM 05/12/2009 22:59:47 PAGE 5
242 1 n6100SendData(0x06);
243 1 n6100SendData(0x08);
244 1 n6100SendData(0x0F);
245 1 // blue
246 1 n6100SendData(0x00);
247 1 n6100SendData(0x03);
248 1 n6100SendData(0x06);
249 1 n6100SendData(0x0F);
250 1
251 1 n6100SendCommand(MEM_ACCESS_CTRL);
252 1 memAccessCtrl = (0x01 << RGB);
253 1 n6100SendData(memAccessCtrl|0x80);
254 1 n6100SendCommand(0X25);//light
255 1 n6100SendData(40); //
256 1 n6100Clear();
257 1 }
258
259
260 void lcd_setxy(uchar x,uchar x1,uchar y,uchar y1)
261 {
262 1 n6100SendCommand(SET_X_ADDR);
263 1 n6100SendData(x);
264 1 n6100SendData(x1);
265 1
266 1 n6100SendCommand(SET_Y_ADDR);
267 1 n6100SendData(y);
268 1 n6100SendData(y1);
269 1 }
270
271
272 void display_china1(char *p,uchar f_cl,uchar b_cl,uchar x,uchar y)
273 {
274 1 uchar i=0;
275 1 uchar m=0;
276 1 uchar j=0;
277 1
278 1
279 1
280 1 for(i=0;i<16;i++)
281 1 {
282 2 lcd_setxy(x,131,y+i,131);
283 2 n6100SendCommand(MEM_WRITE);
284 2
285 2 j=*(p+i*2);
286 2 for(m=0;m<8;m++)
287 2 {
288 3 if(j&0x80)
289 3 n6100SendData(f_cl);
290 3 else
291 3 n6100SendData(b_cl);
292 3 j=j<<1;}
293 2 j=*(p+i*2+1);
294 2 for(m=0;m<8;m++)
295 2 {
296 3 if(j&0x80)
297 3 n6100SendData(f_cl);
298 3 else
299 3 n6100SendData(b_cl);
300 3 j=j<<1;
301 3 }
302 2 }
303 1
C51 COMPILER V7.50 LCM 05/12/2009 22:59:47 PAGE 6
304 1 }
305
306 void display_picture(char *p,uchar f_cl,uchar b_cl,uchar x,uchar y)
307 {
308 1 uchar i,k=0;
309 1 uchar m=0;
310 1 uchar j=0;
311 1 for(i=0;i<32;i++)
312 1 {
313 2 lcd_setxy(x,131,y+i,131);
314 2 n6100SendCommand(MEM_WRITE);
315 2 for(k=0;k<4;k++)
316 2 {j=*(p+i*4+k);
317 3 for(m=0;m<8;m++)
318 3 {
319 4 if(j&0x80)
320 4 n6100SendData(f_cl);
321 4 else
322 4 n6100SendData(b_cl);
323 4 j=j<<1;} }
324 2
325 2 }
326 1 }
327 void display_char(char *p,uchar f_cl,uchar b_cl,uchar x,uchar y)
328 {
329 1 uchar i=0;
330 1 uchar m=0;
331 1 uchar j=0;
332 1 for(i=0;i<16;i++)
333 1 {
334 2 lcd_setxy(x,131,y+i,131);
335 2 n6100SendCommand(MEM_WRITE);
336 2
337 2 j=*(p+i);
338 2 for(m=0;m<8;m++)
339 2 {
340 3 if(j&0x80)
341 3 n6100SendData(f_cl);
342 3 else
343 3 n6100SendData(b_cl);
344 3 j=j<<1;}
345 2 }
346 1 }
347
348
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1045 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 1 34
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -