void LCD_Initializtion void uint16_t DeviceCode LCD_Configuration dela

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
void LCD_Initializtion(void)
{
uint16_t DeviceCode;
LCD_Configuration();
delay_ms(100);
DeviceCode = LCD_ReadReg(0x0000); /* ¶БИЎЖБID */
/* І»Н¬ЖБЗэ¶ЇIC іхКј»ЇІ»Н¬ */
if( DeviceCode == 0x9325 || DeviceCode == 0x9328 )
{
LCD_Code = ILI9325;
LCD_WriteReg(0x00e7,0x0010);
LCD_WriteReg(0x0000,0x0001); /* start internal osc */
LCD_WriteReg(0x0001,0x0100);
LCD_WriteReg(0x0002,0x0700); /* power on sequence */
LCD_WriteReg(0x0003,(1<<12)|(1<<5)|(1<<4)|(0<<3) ); /* importance */
LCD_WriteReg(0x0004,0x0000);
LCD_WriteReg(0x0008,0x0207);
LCD_WriteReg(0x0009,0x0000);
LCD_WriteReg(0x000a,0x0000); /* display setting */
LCD_WriteReg(0x000c,0x0001); /* display setting */
LCD_WriteReg(0x000d,0x0000);
LCD_WriteReg(0x000f,0x0000);
/* Power On sequence */
LCD_WriteReg(0x0010,0x0000);
LCD_WriteReg(0x0011,0x0007);
LCD_WriteReg(0x0012,0x0000);
LCD_WriteReg(0x0013,0x0000);
delay_ms(50); /* delay 50 ms */
LCD_WriteReg(0x0010,0x1590);
LCD_WriteReg(0x0011,0x0227);
delay_ms(50); /* delay 50 ms */
LCD_WriteReg(0x0012,0x009c);
delay_ms(50); /* delay 50 ms */
LCD_WriteReg(0x0013,0x1900);
LCD_WriteReg(0x0029,0x0023);
LCD_WriteReg(0x002b,0x000e);
delay_ms(50); /* delay 50 ms */
LCD_WriteReg(0x0020,0x0000);
LCD_WriteReg(0x0021,0x0000);
delay_ms(50); /* delay 50 ms */
LCD_WriteReg(0x0030,0x0007);
LCD_WriteReg(0x0031,0x0707);
LCD_WriteReg(0x0032,0x0006);
LCD_WriteReg(0x0035,0x0704);
LCD_WriteReg(0x0036,0x1f04);
LCD_WriteReg(0x0037,0x0004);
LCD_WriteReg(0x0038,0x0000);
LCD_WriteReg(0x0039,0x0706);
LCD_WriteReg(0x003c,0x0701);
LCD_WriteReg(0x003d,0x000f);
delay_ms(50); /* delay 50 ms */
LCD_WriteReg(0x0050,0x0000);
LCD_WriteReg(0x0051,0x00ef);
LCD_WriteReg(0x0052,0x0000);
LCD_WriteReg(0x0053,0x013f);
LCD_WriteReg(0x0060,0xa700);
LCD_WriteReg(0x0061,0x0001);
LCD_WriteReg(0x006a,0x0000);
LCD_WriteReg(0x0080,0x0000);
LCD_WriteReg(0x0081,0x0000);
LCD_WriteReg(0x0082,0x0000);
LCD_WriteReg(0x0083,0x0000);
LCD_WriteReg(0x0084,0x0000);
LCD_WriteReg(0x0085,0x0000);
LCD_WriteReg(0x0090,0x0010);
LCD_WriteReg(0x0092,0x0000);
LCD_WriteReg(0x0093,0x0003);
LCD_WriteReg(0x0095,0x0110);
LCD_WriteReg(0x0097,0x0000);
LCD_WriteReg(0x0098,0x0000);
/* display on sequence */
LCD_WriteReg(0x0007,0x0133);
LCD_WriteReg(0x0020,0x0000); /* РРКЧЦ·0 */
LCD_WriteReg(0x0021,0x0000); /* БРКЧЦ·0 */
}
else if( DeviceCode == 0x9320 || DeviceCode == 0x9300 )
{
LCD_Code = ILI9320;
LCD_WriteReg(0x00,0x0000);
LCD_WriteReg(0x01,0x0100); /* Driver Output Contral */
LCD_WriteReg(0x02,0x0700); /* LCD Driver Waveform Contral */
LCD_WriteReg(0x03,0x1018); /* Entry Mode Set */
LCD_WriteReg(0x04,0x0000); /* Scalling Contral */
LCD_WriteReg(0x08,0x0202); /* Display Contral */
LCD_WriteReg(0x09,0x0000); /* Display Contral 3.(0x0000) */
LCD_WriteReg(0x0a,0x0000); /* Frame Cycle Contal.(0x0000) */
LCD_WriteReg(0x0c,(1<<0)); /* Extern Display Interface Contral */
LCD_WriteReg(0x0d,0x0000); /* Frame Maker Position */
LCD_WriteReg(0x0f,0x0000); /* Extern Display Interface Contral 2. */
delay_ms(100); /* delay 100 ms */
LCD_WriteReg(0x07,0x0101); /* Display Contral */
delay_ms(100); /* delay 100 ms */
LCD_WriteReg(0x10,(1<<12)|(0<<8)|(1<<7)|(1<<6)|(0<<4)); /* Power Control 1.(0x16b0) */
LCD_WriteReg(0x11,0x0007); /* Power Control 2 */
LCD_WriteReg(0x12,(1<<8)|(1<<4)|(0<<0)); /* Power Control 3.(0x0138) */
LCD_WriteReg(0x13,0x0b00); /* Power Control 4 */
LCD_WriteReg(0x29,0x0000); /* Power Control 7 */
LCD_WriteReg(0x2b,(1<<14)|(1<<4));
LCD_WriteReg(0x50,0); /* Set X Start */
LCD_WriteReg(0x51,239); /* Set X End */
LCD_WriteReg(0x52,0); /* Set Y Start */
LCD_WriteReg(0x53,319); /* Set Y End */
LCD_WriteReg(0x60,0x2700); /* Driver Output Control */
LCD_WriteReg(0x61,0x0001); /* Driver Output Control */
LCD_WriteReg(0x6a,0x0000); /* Vertical Srcoll Control */
LCD_WriteReg(0x80,0x0000); /* Display Position? Partial Display 1 */
LCD_WriteReg(0x81,0x0000); /* RAM Address Start? Partial Display 1 */
LCD_WriteReg(0x82,0x0000); /* RAM Address End-Partial Display 1 */
LCD_WriteReg(0x83,0x0000); /* Displsy Position? Partial Display 2 */
LCD_WriteReg(0x84,0x0000); /* RAM Address Start? Partial Display 2 */
LCD_WriteReg(0x85,0x0000); /* RAM Address End? Partial Display 2 */
LCD_WriteReg(0x90,(0<<7)|(16<<0)); /* Frame Cycle Contral.(0x0013) */
LCD_WriteReg(0x92,0x0000); /* Panel Interface Contral 2.(0x0000) */
LCD_WriteReg(0x93,0x0001); /* Panel Interface Contral 3. */
LCD_WriteReg(0x95,0x0110); /* Frame Cycle Contral.(0x0110) */
LCD_WriteReg(0x97,(0<<8));
LCD_WriteReg(0x98,0x0000); /* Frame Cycle Contral */
LCD_WriteReg(0x07,0x0173);
}
else if( DeviceCode == 0x9331 )
{
LCD_Code = ILI9331;
LCD_WriteReg(0x00E7, 0x1014);
LCD_WriteReg(0x0001, 0x0100); /* set SS and SM bit */
LCD_WriteReg(0x0002, 0x0200); /* set 1 line inversion */
LCD_WriteReg(0x0003, 0x1030); /* set GRAM write direction and BGR=1 */
LCD_WriteReg(0x0008, 0x0202); /* set the back porch and front porch */
LCD_WriteReg(0x0009, 0x0000); /* set non-display area refresh cycle ISC[3:0] */
LCD_WriteReg(0x000A, 0x0000); /* FMARK function */
LCD_WriteReg(0x000C, 0x0000); /* RGB interface setting */
LCD_WriteReg(0x000D, 0x0000); /* Frame marker Position */
LCD_WriteReg(0x000F, 0x0000); /* RGB interface polarity */
/* Power On sequence */
LCD_WriteReg(0x0010, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
LCD_WriteReg(0x0011, 0x0007); /* DC1[2:0], DC0[2:0], VC[2:0] */
LCD_WriteReg(0x0012, 0x0000); /* VREG1OUT voltage */
LCD_WriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
delay_ms(200); /* delay 200 ms */
LCD_WriteReg(0x0010, 0x1690); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
LCD_WriteReg(0x0011, 0x0227); /* DC1[2:0], DC0[2:0], VC[2:0] */
delay_ms(50); /* delay 50 ms */
LCD_WriteReg(0x0012, 0x000C); /* Internal reference voltage= Vci */
delay_ms(50); /* delay 50 ms */
LCD_WriteReg(0x0013, 0x0800); /* Set VDV[4:0] for VCOM amplitude */
LCD_WriteReg(0x0029, 0x0011); /* Set VCM[5:0] for VCOMH */
LCD_WriteReg(0x002B, 0x000B); /* Set Frame Rate */
delay_ms(50); /* delay 50 ms */
LCD_WriteReg(0x0020, 0x0000); /* GRAM horizontal Address */
LCD_WriteReg(0x0021, 0x0000); /* GRAM Vertical Address */
/* Adjust the Gamma Curve */
LCD_WriteReg(0x0030, 0x0000);
LCD_WriteReg(0x0031, 0x0106);
LCD_WriteReg(0x0032, 0x0000);
LCD_WriteReg(0x0035, 0x0204);
LCD_WriteReg(0x0036, 0x160A);
LCD_WriteReg(0x0037, 0x0707);
LCD_WriteReg(0x0038, 0x0106);
LCD_WriteReg(0x0039, 0x0707);
LCD_WriteReg(0x003C, 0x0402);
LCD_WriteReg(0x003D, 0x0C0F);
/* Set GRAM area */
LCD_WriteReg(0x0050, 0x0000); /* Horizontal GRAM Start Address */
LCD_WriteReg(0x0051, 0x00EF); /* Horizontal GRAM End Address */
LCD_WriteReg(0x0052, 0x0000); /* Vertical GRAM Start Address */
LCD_WriteReg(0x0053, 0x013F); /* Vertical GRAM Start Address */
LCD_WriteReg(0x0060, 0x2700); /* Gate Scan Line */
LCD_WriteReg(0x0061, 0x0001); /* NDL,VLE, REV */
LCD_WriteReg(0x006A, 0x0000); /* set scrolling line */
/* Partial Display Control */
LCD_WriteReg(0x0080, 0x0000);
LCD_WriteReg(0x0081, 0x0000);
LCD_WriteReg(0x0082, 0x0000);
LCD_WriteReg(0x0083, 0x0000);
LCD_WriteReg(0x0084, 0x0000);
LCD_WriteReg(0x0085, 0x0000);
/* Panel Control */
LCD_WriteReg(0x0090, 0x0010);
LCD_WriteReg(0x0092, 0x0600);
LCD_WriteReg(0x0007,0x0021);
delay_ms(50); /* delay 50 ms */
LCD_WriteReg(0x0007,0x0061);
delay_ms(50); /* delay 50 ms */
LCD_WriteReg(0x0007,0x0133); /* 262K color and display ON */
}
else if( DeviceCode == 0x9919 )
{
LCD_Code = SSD2119;
/* POWER ON &RESET DISPLAY OFF */
LCD_WriteReg(0x28,0x0006);
LCD_WriteReg(0x00,0x0001);
LCD_WriteReg(0x10,0x0000);
LCD_WriteReg(0x01,0x72ef);
LCD_WriteReg(0x02,0x0600);
LCD_WriteReg(0x03,0x6a38);
LCD_WriteReg(0x11,0x6874);
LCD_WriteReg(0x0f,0x0000); /* RAM WRITE DATA MASK */
LCD_WriteReg(0x0b,0x5308); /* RAM WRITE DATA MASK */
LCD_WriteReg(0x0c,0x0003);
LCD_WriteReg(0x0d,0x000a);
LCD_WriteReg(0x0e,0x2e00);
LCD_WriteReg(0x1e,0x00be);
LCD_WriteReg(0x25,0x8000);
LCD_WriteReg(0x26,0x7800);
LCD_WriteReg(0x27,0x0078);
LCD_WriteReg(0x4e,0x0000);
LCD_WriteReg(0x4f,0x0000);
LCD_WriteReg(0x12,0x08d9);
/* Adjust the Gamma Curve */
LCD_WriteReg(0x30,0x0000);
LCD_WriteReg(0x31,0x0104);
LCD_WriteReg(0x32,0x0100);
LCD_WriteReg(0x33,0x0305);
LCD_WriteReg(0x34,0x0505);
LCD_WriteReg(0x35,0x0305);
LCD_WriteReg(0x36,0x0707);
LCD_WriteReg(0x37,0x0300);
LCD_WriteReg(0x3a,0x1200);
LCD_WriteReg(0x3b,0x0800);
LCD_WriteReg(0x07,0x0033);
}
else if( DeviceCode == 0x1505 || DeviceCode == 0x0505 )
{
LCD_Code = R61505U;
/* initializing funciton */
LCD_WriteReg(0xe5,0x8000); /* Set the internal vcore voltage */
LCD_WriteReg(0x00,0x0001); /* start OSC */
LCD_WriteReg(0x2b,0x0010); /* Set the frame rate as 80 when the internal resistor is used for oscillator circuit */
LCD_WriteReg(0x01,0x0100); /* s720 to s1 ; G1 to G320 */
LCD_WriteReg(0x02,0x0700); /* set the line inversion */
LCD_WriteReg(0x03,0x1018); /* 65536 colors */
LCD_WriteReg(0x04,0x0000);
LCD_WriteReg(0x08,0x0202); /* specify the line number of front and back porch periods respectively */
LCD_WriteReg(0x09,0x0000);
LCD_WriteReg(0x0a,0x0000);
LCD_WriteReg(0x0c,0x0000); /* select internal system clock */
LCD_WriteReg(0x0d,0x0000);
LCD_WriteReg(0x0f,0x0000);
LCD_WriteReg(0x50,0x0000); /* set windows adress */
LCD_WriteReg(0x51,0x00ef);
LCD_WriteReg(0x52,0x0000);
LCD_WriteReg(0x53,0x013f);
LCD_WriteReg(0x60,0x2700);
LCD_WriteReg(0x61,0x0001);
LCD_WriteReg(0x6a,0x0000);
LCD_WriteReg(0x80,0x0000);
LCD_WriteReg(0x81,0x0000);
LCD_WriteReg(0x82,0x0000);
LCD_WriteReg(0x83,0x0000);
LCD_WriteReg(0x84,0x0000);
LCD_WriteReg(0x85,0x0000);
LCD_WriteReg(0x90,0x0010);
LCD_WriteReg(0x92,0x0000);
LCD_WriteReg(0x93,0x0003);
LCD_WriteReg(0x95,0x0110);
LCD_WriteReg(0x97,0x0000);
LCD_WriteReg(0x98,0x0000);
/* power setting function */
LCD_WriteReg(0x10,0x0000);
LCD_WriteReg(0x11,0x0000);
LCD_WriteReg(0x12,0x0000);
LCD_WriteReg(0x13,0x0000);
delay_ms(100);
LCD_WriteReg(0x10,0x17b0);
LCD_WriteReg(0x11,0x0004);
delay_ms(50);
LCD_WriteReg(0x12,0x013e);
delay_ms(50);
LCD_WriteReg(0x13,0x1f00);
LCD_WriteReg(0x29,0x000f);
delay_ms(50);
LCD_WriteReg(0x20,0x0000);
LCD_WriteReg(0x21,0x0000);
/* initializing function */
LCD_WriteReg(0x30,0x0204);
LCD_WriteReg(0x31,0x0001);
LCD_WriteReg(0x32,0x0000);
LCD_WriteReg(0x35,0x0206);
LCD_WriteReg(0x36,0x0600);
LCD_WriteReg(0x37,0x0500);
LCD_WriteReg(0x38,0x0505);
LCD_WriteReg(0x39,0x0407);
LCD_WriteReg(0x3c,0x0500);
LCD_WriteReg(0x3d,0x0503);
/* display on */
LCD_WriteReg(0x07,0x0173);
}
else if( DeviceCode == 0x8989 )
{
LCD_Code = SSD1289;
LCD_WriteReg(0x0000,0x0001); delay_ms(50); /* ґтїЄѕ§Хс */
LCD_WriteReg(0x0003,0xA8A4); delay_ms(50);
LCD_WriteReg(0x000C,0x0000); delay_ms(50);
LCD_WriteReg(0x000D,0x080C); delay_ms(50);
LCD_WriteReg(0x000E,0x2B00); delay_ms(50);
LCD_WriteReg(0x001E,0x00B0); delay_ms(50);
LCD_WriteReg(0x0001,0x2B3F); delay_ms(50); /* Зэ¶ЇКдіцїШЦЖ320*240 0x2B3F */
LCD_WriteReg(0x0002,0x0600); delay_ms(50);
LCD_WriteReg(0x0010,0x0000); delay_ms(50);
LCD_WriteReg(0x0011,0x6070); delay_ms(50); /* ¶ЁТеКэѕЭёсКЅ 16О»Й« єбЖБ 0x6070 */
LCD_WriteReg(0x0005,0x0000); delay_ms(50);
LCD_WriteReg(0x0006,0x0000); delay_ms(50);
LCD_WriteReg(0x0016,0xEF1C); delay_ms(50);
LCD_WriteReg(0x0017,0x0003); delay_ms(50);
LCD_WriteReg(0x0007,0x0133); delay_ms(50);
LCD_WriteReg(0x000B,0x0000); delay_ms(50);
LCD_WriteReg(0x000F,0x0000); delay_ms(50); /* ЙЁГиїЄКјµШЦ· */
LCD_WriteReg(0x0041,0x0000); delay_ms(50);
LCD_WriteReg(0x0042,0x0000); delay_ms(50);
LCD_WriteReg(0x0048,0x0000); delay_ms(50);
LCD_WriteReg(0x0049,0x013F); delay_ms(50);
LCD_WriteReg(0x004A,0x0000); delay_ms(50);
LCD_WriteReg(0x004B,0x0000); delay_ms(50);
LCD_WriteReg(0x0044,0xEF00); delay_ms(50);
LCD_WriteReg(0x0045,0x0000); delay_ms(50);
LCD_WriteReg(0x0046,0x013F); delay_ms(50);
LCD_WriteReg(0x0030,0x0707); delay_ms(50);
LCD_WriteReg(0x0031,0x0204); delay_ms(50);
LCD_WriteReg(0x0032,0x0204); delay_ms(50);
LCD_WriteReg(0x0033,0x0502); delay_ms(50);
LCD_WriteReg(0x0034,0x0507); delay_ms(50);
LCD_WriteReg(0x0035,0x0204); delay_ms(50);
LCD_WriteReg(0x0036,0x0204); delay_ms(50);
LCD_WriteReg(0x0037,0x0502); delay_ms(50);
LCD_WriteReg(0x003A,0x0302); delay_ms(50);
LCD_WriteReg(0x003B,0x0302); delay_ms(50);
LCD_WriteReg(0x0023,0x0000); delay_ms(50);
LCD_WriteReg(0x0024,0x0000); delay_ms(50);
LCD_WriteReg(0x0025,0x8000); delay_ms(50);
LCD_WriteReg(0x004f,0); /* РРКЧЦ·0 */
LCD_WriteReg(0x004e,0); /* БРКЧЦ·0 */
}
else if( DeviceCode == 0x8999 )
{
LCD_Code = SSD1298;
LCD_WriteReg(0x0028,0x0006);
LCD_WriteReg(0x0000,0x0001);
LCD_WriteReg(0x0003,0xaea4); /* power control 1---line frequency and VHG,VGL voltage */
LCD_WriteReg(0x000c,0x0004); /* power control 2---VCIX2 output voltage */
LCD_WriteReg(0x000d,0x000c); /* power control 3---Vlcd63 voltage */
LCD_WriteReg(0x000e,0x2800); /* power control 4---VCOMA voltage VCOML=VCOMH*0.9475-VCOMA */
LCD_WriteReg(0x001e,0x00b5); /* POWER CONTROL 5---VCOMH voltage */
LCD_WriteReg(0x0001,0x3b3f);
LCD_WriteReg(0x0002,0x0600);
LCD_WriteReg(0x0010,0x0000);
LCD_WriteReg(0x0011,0x6830);
LCD_WriteReg(0x0005,0x0000);
LCD_WriteReg(0x0006,0x0000);
LCD_WriteReg(0x0016,0xef1c);
LCD_WriteReg(0x0007,0x0033); /* Display control 1 */
/* when GON=1 and DTE=0,all gate outputs become VGL */
/* when GON=1 and DTE=0,all gate outputs become VGH */
/* non-selected gate wires become VGL */
LCD_WriteReg(0x000b,0x0000);
LCD_WriteReg(0x000f,0x0000);
LCD_WriteReg(0x0041,0x0000);
LCD_WriteReg(0x0042,0x0000);
LCD_WriteReg(0x0048,0x0000);
LCD_WriteReg(0x0049,0x013f);
LCD_WriteReg(0x004a,0x0000);
LCD_WriteReg(0x004b,0x0000);
LCD_WriteReg(0x0044,0xef00); /* Horizontal RAM start and end address */
LCD_WriteReg(0x0045,0x0000); /* Vretical RAM start address */
LCD_WriteReg(0x0046,0x013f); /* Vretical RAM end address */
LCD_WriteReg(0x004e,0x0000); /* set GDDRAM x address counter */
LCD_WriteReg(0x004f,0x0000); /* set GDDRAM y address counter */
/* y control */
LCD_WriteReg(0x0030,0x0707);
LCD_WriteReg(0x0031,0x0202);
LCD_WriteReg(0x0032,0x0204);
LCD_WriteReg(0x0033,0x0502);
LCD_WriteReg(0x0034,0x0507);
LCD_WriteReg(0x0035,0x0204);
LCD_WriteReg(0x0036,0x0204);
LCD_WriteReg(0x0037,0x0502);
LCD_WriteReg(0x003a,0x0302);
LCD_WriteReg(0x003b,0x0302);
LCD_WriteReg(0x0023,0x0000);
LCD_WriteReg(0x0024,0x0000);
LCD_WriteReg(0x0025,0x8000);
LCD_WriteReg(0x0026,0x7000);
LCD_WriteReg(0x0020,0xb0eb);
LCD_WriteReg(0x0027,0x007c);
}
else if( DeviceCode == 0x5408 )
{
LCD_Code = SPFD5408B;
LCD_WriteReg(0x0001,0x0100); /* Driver Output Contral Register */
LCD_WriteReg(0x0002,0x0700); /* LCD Driving Waveform Contral */
LCD_WriteReg(0x0003,0x1030); /* Entry ModeЙиЦГ */
LCD_WriteReg(0x0004,0x0000); /* Scalling Control register */
LCD_WriteReg(0x0008,0x0207); /* Display Control 2 */
LCD_WriteReg(0x0009,0x0000); /* Display Control 3 */
LCD_WriteReg(0x000A,0x0000); /* Frame Cycle Control */
LCD_WriteReg(0x000C,0x0000); /* External Display Interface Control 1 */
LCD_WriteReg(0x000D,0x0000); /* Frame Maker Position */
LCD_WriteReg(0x000F,0x0000); /* External Display Interface Control 2 */
delay_ms(50);
LCD_WriteReg(0x0007,0x0101); /* Display Control */
delay_ms(50);
LCD_WriteReg(0x0010,0x16B0); /* Power Control 1 */
LCD_WriteReg(0x0011,0x0001); /* Power Control 2 */
LCD_WriteReg(0x0017,0x0001); /* Power Control 3 */
LCD_WriteReg(0x0012,0x0138); /* Power Control 4 */
LCD_WriteReg(0x0013,0x0800); /* Power Control 5 */
LCD_WriteReg(0x0029,0x0009); /* NVM read data 2 */
LCD_WriteReg(0x002a,0x0009); /* NVM read data 3 */
LCD_WriteReg(0x00a4,0x0000);
LCD_WriteReg(0x0050,0x0000); /* ЙиЦГІЩЧчґ°їЪµДXЦбїЄКјБР */
LCD_WriteReg(0x0051,0x00EF); /* ЙиЦГІЩЧчґ°їЪµДXЦбЅбКшБР */
LCD_WriteReg(0x0052,0x0000); /* ЙиЦГІЩЧчґ°їЪµДYЦбїЄКјРР */
LCD_WriteReg(0x0053,0x013F); /* ЙиЦГІЩЧчґ°їЪµДYЦбЅбКшРР */
LCD_WriteReg(0x0060,0x2700); /* Driver Output Control */
/* ЙиЦГЖБД»µДµгКэТФј°ЙЁГиµДЖрКјРР */
LCD_WriteReg(0x0061,0x0003); /* Driver Output Control */
LCD_WriteReg(0x006A,0x0000); /* Vertical Scroll Control */
LCD_WriteReg(0x0080,0x0000); /* Display Position ЁC Partial Display 1 */
LCD_WriteReg(0x0081,0x0000); /* RAM Address Start ЁC Partial Display 1 */
LCD_WriteReg(0x0082,0x0000); /* RAM address End - Partial Display 1 */
LCD_WriteReg(0x0083,0x0000); /* Display Position ЁC Partial Display 2 */
LCD_WriteReg(0x0084,0x0000); /* RAM Address Start ЁC Partial Display 2 */
LCD_WriteReg(0x0085,0x0000); /* RAM address End ЁC Partail Display2 */
LCD_WriteReg(0x0090,0x0013); /* Frame Cycle Control */
LCD_WriteReg(0x0092,0x0000); /* Panel Interface Control 2 */
LCD_WriteReg(0x0093,0x0003); /* Panel Interface control 3 */
LCD_WriteReg(0x0095,0x0110); /* Frame Cycle Control */
LCD_WriteReg(0x0007,0x0173);
}
else if( DeviceCode == 0x4531 )
{
LCD_Code = LGDP4531;
/* Setup display */
LCD_WriteReg(0x00,0x0001);
LCD_WriteReg(0x10,0x0628);
LCD_WriteReg(0x12,0x0006);
LCD_WriteReg(0x13,0x0A32);
LCD_WriteReg(0x11,0x0040);
LCD_WriteReg(0x15,0x0050);
LCD_WriteReg(0x12,0x0016);
delay_ms(50);
LCD_WriteReg(0x10,0x5660);
delay_ms(50);
LCD_WriteReg(0x13,0x2A4E);
LCD_WriteReg(0x01,0x0100);
LCD_WriteReg(0x02,0x0300);
LCD_WriteReg(0x03,0x1030);
LCD_WriteReg(0x08,0x0202);
LCD_WriteReg(0x0A,0x0000);
LCD_WriteReg(0x30,0x0000);
LCD_WriteReg(0x31,0x0402);
LCD_WriteReg(0x32,0x0106);
LCD_WriteReg(0x33,0x0700);
LCD_WriteReg(0x34,0x0104);
LCD_WriteReg(0x35,0x0301);
LCD_WriteReg(0x36,0x0707);
LCD_WriteReg(0x37,0x0305);
LCD_WriteReg(0x38,0x0208);
LCD_WriteReg(0x39,0x0F0B);
delay_ms(50);
LCD_WriteReg(0x41,0x0002);
LCD_WriteReg(0x60,0x2700);
LCD_WriteReg(0x61,0x0001);
LCD_WriteReg(0x90,0x0119);
LCD_WriteReg(0x92,0x010A);
LCD_WriteReg(0x93,0x0004);
LCD_WriteReg(0xA0,0x0100);
delay_ms(50);
LCD_WriteReg(0x07,0x0133);
delay_ms(50);
LCD_WriteReg(0xA0,0x0000);
}
else if( DeviceCode == 0x4535 )
{
LCD_Code = LGDP4535;
LCD_WriteReg(0x15, 0x0030); /* Set the internal vcore voltage */
LCD_WriteReg(0x9A, 0x0010); /* Start internal OSC */
LCD_WriteReg(0x11, 0x0020); /* set SS and SM bit */
LCD_WriteReg(0x10, 0x3428); /* set 1 line inversion */
LCD_WriteReg(0x12, 0x0002); /* set GRAM write direction and BGR=1 */
LCD_WriteReg(0x13, 0x1038); /* Resize register */
delay_ms(40);
LCD_WriteReg(0x12, 0x0012); /* set the back porch and front porch */
delay_ms(40);
LCD_WriteReg(0x10, 0x3420); /* set non-display area refresh cycle ISC[3:0] */
LCD_WriteReg(0x13, 0x3045); /* FMARK function */
delay_ms(70);
LCD_WriteReg(0x30, 0x0000); /* RGB interface setting */
LCD_WriteReg(0x31, 0x0402); /* Frame marker Position */
LCD_WriteReg(0x32, 0x0307); /* RGB interface polarity */
LCD_WriteReg(0x33, 0x0304); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
LCD_WriteReg(0x34, 0x0004); /* DC1[2:0], DC0[2:0], VC[2:0] */
LCD_WriteReg(0x35, 0x0401); /* VREG1OUT voltage */
LCD_WriteReg(0x36, 0x0707); /* VDV[4:0] for VCOM amplitude */
LCD_WriteReg(0x37, 0x0305); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
LCD_WriteReg(0x38, 0x0610); /* DC1[2:0], DC0[2:0], VC[2:0] */
LCD_WriteReg(0x39, 0x0610); /* VREG1OUT voltage */
LCD_WriteReg(0x01, 0x0100); /* VDV[4:0] for VCOM amplitude */
LCD_WriteReg(0x02, 0x0300); /* VCM[4:0] for VCOMH */
LCD_WriteReg(0x03, 0x1030); /* GRAM horizontal Address */
LCD_WriteReg(0x08, 0x0808); /* GRAM Vertical Address */
LCD_WriteReg(0x0A, 0x0008);
LCD_WriteReg(0x60, 0x2700); /* Gate Scan Line */
LCD_WriteReg(0x61, 0x0001); /* NDL,VLE, REV */
LCD_WriteReg(0x90, 0x013E);
LCD_WriteReg(0x92, 0x0100);
LCD_WriteReg(0x93, 0x0100);
LCD_WriteReg(0xA0, 0x3000);
LCD_WriteReg(0xA3, 0x0010);
LCD_WriteReg(0x07, 0x0001);
LCD_WriteReg(0x07, 0x0021);
LCD_WriteReg(0x07, 0x0023);
LCD_WriteReg(0x07, 0x0033);
LCD_WriteReg(0x07, 0x0133);
}
else if( DeviceCode == 0x0047 )
{
LCD_Code = HX8347D;
/* Start Initial Sequence */
LCD_WriteReg(0xEA,0x00);
LCD_WriteReg(0xEB,0x20);
LCD_WriteReg(0xEC,0x0C);
LCD_WriteReg(0xED,0xC4);
LCD_WriteReg(0xE8,0x40);
LCD_WriteReg(0xE9,0x38);
LCD_WriteReg(0xF1,0x01);
LCD_WriteReg(0xF2,0x10);
LCD_WriteReg(0x27,0xA3);
/* GAMMA SETTING */
LCD_WriteReg(0x40,0x01);
LCD_WriteReg(0x41,0x00);
LCD_WriteReg(0x42,0x00);
LCD_WriteReg(0x43,0x10);
LCD_WriteReg(0x44,0x0E);
LCD_WriteReg(0x45,0x24);
LCD_WriteReg(0x46,0x04);
LCD_WriteReg(0x47,0x50);
LCD_WriteReg(0x48,0x02);
LCD_WriteReg(0x49,0x13);
LCD_WriteReg(0x4A,0x19);
LCD_WriteReg(0x4B,0x19);
LCD_WriteReg(0x4C,0x16);
LCD_WriteReg(0x50,0x1B);
LCD_WriteReg(0x51,0x31);
LCD_WriteReg(0x52,0x2F);
LCD_WriteReg(0x53,0x3F);
LCD_WriteReg(0x54,0x3F);
LCD_WriteReg(0x55,0x3E);
LCD_WriteReg(0x56,0x2F);
LCD_WriteReg(0x57,0x7B);
LCD_WriteReg(0x58,0x09);
LCD_WriteReg(0x59,0x06);
LCD_WriteReg(0x5A,0x06);
LCD_WriteReg(0x5B,0x0C);
LCD_WriteReg(0x5C,0x1D);
LCD_WriteReg(0x5D,0xCC);
/* Power Voltage Setting */
LCD_WriteReg(0x1B,0x18);
LCD_WriteReg(0x1A,0x01);
LCD_WriteReg(0x24,0x15);
LCD_WriteReg(0x25,0x50);
LCD_WriteReg(0x23,0x8B);
LCD_WriteReg(0x18,0x36);
LCD_WriteReg(0x19,0x01);
LCD_WriteReg(0x01,0x00);
LCD_WriteReg(0x1F,0x88);
delay_ms(50);
LCD_WriteReg(0x1F,0x80);
delay_ms(50);
LCD_WriteReg(0x1F,0x90);
delay_ms(50);
LCD_WriteReg(0x1F,0xD0);
delay_ms(50);
LCD_WriteReg(0x17,0x05);
LCD_WriteReg(0x36,0x00);
LCD_WriteReg(0x28,0x38);
delay_ms(50);
LCD_WriteReg(0x28,0x3C);
}
else if( DeviceCode == 0x7783 )
{
LCD_Code = ST7781;
/* Start Initial Sequence */
LCD_WriteReg(0x00FF,0x0001);
LCD_WriteReg(0x00F3,0x0008);
LCD_WriteReg(0x0001,0x0100);
LCD_WriteReg(0x0002,0x0700);
LCD_WriteReg(0x0003,0x1030);
LCD_WriteReg(0x0008,0x0302);
LCD_WriteReg(0x0008,0x0207);
LCD_WriteReg(0x0009,0x0000);
LCD_WriteReg(0x000A,0x0000);
LCD_WriteReg(0x0010,0x0000);
LCD_WriteReg(0x0011,0x0005);
LCD_WriteReg(0x0012,0x0000);
LCD_WriteReg(0x0013,0x0000);
delay_ms(50);
LCD_WriteReg(0x0010,0x12B0);
delay_ms(50);
LCD_WriteReg(0x0011,0x0007);
delay_ms(50);
LCD_WriteReg(0x0012,0x008B);
delay_ms(50);
LCD_WriteReg(0x0013,0x1700);
delay_ms(50);
LCD_WriteReg(0x0029,0x0022);
LCD_WriteReg(0x0030,0x0000);
LCD_WriteReg(0x0031,0x0707);
LCD_WriteReg(0x0032,0x0505);
LCD_WriteReg(0x0035,0x0107);
LCD_WriteReg(0x0036,0x0008);
LCD_WriteReg(0x0037,0x0000);
LCD_WriteReg(0x0038,0x0202);
LCD_WriteReg(0x0039,0x0106);
LCD_WriteReg(0x003C,0x0202);
LCD_WriteReg(0x003D,0x0408);
delay_ms(50);
LCD_WriteReg(0x0050,0x0000);
LCD_WriteReg(0x0051,0x00EF);
LCD_WriteReg(0x0052,0x0000);
LCD_WriteReg(0x0053,0x013F);
LCD_WriteReg(0x0060,0xA700);
LCD_WriteReg(0x0061,0x0001);
LCD_WriteReg(0x0090,0x0033);
LCD_WriteReg(0x002B,0x000B);
LCD_WriteReg(0x0007,0x0133);
}
else /* special ID */
{
DeviceCode = LCD_ReadReg(0x67);
if( DeviceCode == 0x0046 )
{
LCD_Code = HX8346A;
/* Gamma for CMO 3.2 */
LCD_WriteReg(0x46,0x94);
LCD_WriteReg(0x47,0x41);
LCD_WriteReg(0x48,0x00);
LCD_WriteReg(0x49,0x33);
LCD_WriteReg(0x4a,0x23);
LCD_WriteReg(0x4b,0x45);
LCD_WriteReg(0x4c,0x44);
LCD_WriteReg(0x4d,0x77);
LCD_WriteReg(0x4e,0x12);
LCD_WriteReg(0x4f,0xcc);
LCD_WriteReg(0x50,0x46);
LCD_WriteReg(0x51,0x82);
/* 240x320 window setting */
LCD_WriteReg(0x02,0x00);
LCD_WriteReg(0x03,0x00);
LCD_WriteReg(0x04,0x01);
LCD_WriteReg(0x05,0x3f);
LCD_WriteReg(0x06,0x00);
LCD_WriteReg(0x07,0x00);
LCD_WriteReg(0x08,0x00);
LCD_WriteReg(0x09,0xef);
/* Display Setting */
LCD_WriteReg(0x01,0x06);
LCD_WriteReg(0x16,0xC8); /* MY(1) MX(1) MV(0) */
LCD_WriteReg(0x23,0x95);
LCD_WriteReg(0x24,0x95);
LCD_WriteReg(0x25,0xff);
LCD_WriteReg(0x27,0x02);
LCD_WriteReg(0x28,0x02);
LCD_WriteReg(0x29,0x02);
LCD_WriteReg(0x2a,0x02);
LCD_WriteReg(0x2c,0x02);
LCD_WriteReg(0x2d,0x02);
LCD_WriteReg(0x3a,0x01);
LCD_WriteReg(0x3b,0x01);
LCD_WriteReg(0x3c,0xf0);
LCD_WriteReg(0x3d,0x00);
delay_ms(2);
LCD_WriteReg(0x35,0x38);
LCD_WriteReg(0x36,0x78);
LCD_WriteReg(0x3e,0x38);
LCD_WriteReg(0x40,0x0f);
LCD_WriteReg(0x41,0xf0);
/* Power Supply Setting */
LCD_WriteReg(0x19,0x49);
LCD_WriteReg(0x93,0x0f);
delay_ms(1);
LCD_WriteReg(0x20,0x30);
LCD_WriteReg(0x1d,0x07);
LCD_WriteReg(0x1e,0x00);
LCD_WriteReg(0x1f,0x07);
/* VCOM Setting for CMO 3.2Ў± Panel */
LCD_WriteReg(0x44,0x4d);
LCD_WriteReg(0x45,0x13);
delay_ms(1);
LCD_WriteReg(0x1c,0x04);
delay_ms(2);
LCD_WriteReg(0x43,0x80);
delay_ms(5);
LCD_WriteReg(0x1b,0x08);
delay_ms(4);
LCD_WriteReg(0x1b,0x10);
delay_ms(4);
/* Display ON Setting */
LCD_WriteReg(0x90,0x7f);
LCD_WriteReg(0x26,0x04);
delay_ms(4);
LCD_WriteReg(0x26,0x24);
LCD_WriteReg(0x26,0x2c);
delay_ms(4);
LCD_WriteReg(0x26,0x3c);
/* Set internal VDDD voltage */
LCD_WriteReg(0x57,0x02);
LCD_WriteReg(0x55,0x00);
LCD_WriteReg(0x57,0x00);
}
if( DeviceCode == 0x0047 )
{
LCD_Code = HX8347A;
LCD_WriteReg(0x0042,0x0008);
/* Gamma setting */
LCD_WriteReg(0x0046,0x00B4);
LCD_WriteReg(0x0047,0x0043);
LCD_WriteReg(0x0048,0x0013);
LCD_WriteReg(0x0049,0x0047);
LCD_WriteReg(0x004A,0x0014);
LCD_WriteReg(0x004B,0x0036);
LCD_WriteReg(0x004C,0x0003);
LCD_WriteReg(0x004D,0x0046);
LCD_WriteReg(0x004E,0x0005);
LCD_WriteReg(0x004F,0x0010);
LCD_WriteReg(0x0050,0x0008);
LCD_WriteReg(0x0051,0x000a);
/* Window Setting */
LCD_WriteReg(0x0002,0x0000);
LCD_WriteReg(0x0003,0x0000);
LCD_WriteReg(0x0004,0x0000);
LCD_WriteReg(0x0005,0x00EF);
LCD_WriteReg(0x0006,0x0000);
LCD_WriteReg(0x0007,0x0000);
LCD_WriteReg(0x0008,0x0001);
LCD_WriteReg(0x0009,0x003F);
delay_ms(10);
LCD_WriteReg(0x0001,0x0006);
LCD_WriteReg(0x0016,0x00C8);
LCD_WriteReg(0x0023,0x0095);
LCD_WriteReg(0x0024,0x0095);
LCD_WriteReg(0x0025,0x00FF);
LCD_WriteReg(0x0027,0x0002);
LCD_WriteReg(0x0028,0x0002);
LCD_WriteReg(0x0029,0x0002);
LCD_WriteReg(0x002A,0x0002);
LCD_WriteReg(0x002C,0x0002);
LCD_WriteReg(0x002D,0x0002);
LCD_WriteReg(0x003A,0x0001);
LCD_WriteReg(0x003B,0x0001);
LCD_WriteReg(0x003C,0x00F0);
LCD_WriteReg(0x003D,0x0000);
delay_ms(20);
LCD_WriteReg(0x0035,0x0038);
LCD_WriteReg(0x0036,0x0078);
LCD_WriteReg(0x003E,0x0038);
LCD_WriteReg(0x0040,0x000F);
LCD_WriteReg(0x0041,0x00F0);
LCD_WriteReg(0x0038,0x0000);
/* Power Setting */
LCD_WriteReg(0x0019,0x0049);
LCD_WriteReg(0x0093,0x000A);
delay_ms(10);
LCD_WriteReg(0x0020,0x0020);
LCD_WriteReg(0x001D,0x0003);
LCD_WriteReg(0x001E,0x0000);
LCD_WriteReg(0x001F,0x0009);
LCD_WriteReg(0x0044,0x0053);
LCD_WriteReg(0x0045,0x0010);
delay_ms(10);
LCD_WriteReg(0x001C,0x0004);
delay_ms(20);
LCD_WriteReg(0x0043,0x0080);
delay_ms(5);
LCD_WriteReg(0x001B,0x000a);
delay_ms(40);
LCD_WriteReg(0x001B,0x0012);
delay_ms(40);
/* Display On Setting */
LCD_WriteReg(0x0090,0x007F);
LCD_WriteReg(0x0026,0x0004);
delay_ms(40);
LCD_WriteReg(0x0026,0x0024);
LCD_WriteReg(0x0026,0x002C);
delay_ms(40);
LCD_WriteReg(0x0070,0x0008);
LCD_WriteReg(0x0026,0x003C);
LCD_WriteReg(0x0057,0x0002);
LCD_WriteReg(0x0055,0x0000);
LCD_WriteReg(0x0057,0x0000);
}
}
delay_ms(50); /* delay 50 ms */
}