• LCD裸板驱动


        打开电路图观察到相应的寄存器:

          

     可以观察到 LCD1由45根线来控制,主要配置的寄存器是24根RGB以及TOU1 EINT10  以及VDEN VYNC HSYNC VCLK驱动;

      在核心板中找到网标,找出相应的寄存器;

        

                        

            

             在核心板子里面找出对应寄存器,配置好;

            

            

            

            其中,详细寄存器的描述如以下代码:

            

      1 #include "regs.h"
      2 
      3 int (*printf)(char *, ...) = 0xc3e114d8;
      4 
      5 void clean_screen(unsigned long *addr);
      6 
      7 int main()
      8 {
      9 
     10     unsigned long addr = 0x52000000;
     11     clean_screen(addr);
     12 /////////   
     13 //准备:打开时钟
     14     printf("hahahah
    ");
     15     LCDBLK_CFG = 2;
     16     CLK_SRC_LCD0 = 6;
     17     CLK_DIV_LCD = 0;
     18     CLK_GATE_IP_LCD = 1;
     19     //配时钟
     20 
     21 #if 0
     22     GPD0CON &= ~(0xf << 4);
     23     GPD0CON |= (0x3 << 4);
     24 #else
     25 
     26 ////////////////////
     27 //第一步:配置 OUT1 EINT10 以及24根RGB
     28     GPD0CON = (1 << 4);
     29     GPD0DAT = (1 << 1);
     30     //配置CPD0 OUT1
     31 #endif
     32     GPX1CON &= ~(0xf << 8);
     33     GPX1CON |= (0x2 << 8);
     34     //EINT10寄存器
     35     //
     36     GPF0CON = 0x22222222;
     37     GPF1CON = 0x22222222;
     38     GPF2CON = 0x22222222;
     39     GPF3CON = 0x2222;
     40     //RGB lcd dv 
     41 
     42     printf("heheheh
    ");
     43 
     44 ///////////////////////
     45 //第二步:看时序图配置相关寄存器
     46     //pages 1860
     47     //使能video 以及显示控制信号 28为时钟频率 详见 注释1
     48     VIDCON0 = 1 | (1 << 1) | (1 << 5) | (28 << 6);
     49     //配置IVDEN IVSYNC IHSYNC IVCLK
     50     VIDCON1 = (1 << 5) | (1 << 6) | (1 << 7);
     51     VIDCON2 = 0;
     52 
     53     //配置 VSPW VFPD VBPD VBPDE VFPDE HBPD HFPD HSPW
     54     VIDTCON0 = 9 | (21 << 8) | (12 << 16);
     55     VIDTCON1 = 19 | (209 << 8) | (25 << 16);
     56     VIDTCON2 = 799 | (479 << 11);
     57     VIDTCON3 = 0;
     58 
     59 ///////////////////
     60 //第三步配置窗口
     61     //开启频道0
     62     SHADOWCON = 0x1;
     63     //指定输出的开关 以及BBP模式为RGB 888
     64     WINCON0 = 1 | (13 << 2);
     65     //窗口左上,右下以及窗口大小
     66     VIDOSD0A = 0 | (0 << 11);
     67     VIDOSD0B = 479 | (799 << 11);
     68     VIDOSD0C = 800 * 480;
     69     //定义取数据的详细地址
     70     VIDW00ADD0B0 = addr;
     71     VIDW00ADD1B0 = addr + 800 * 480 * 4;
     72     //定义是横屏还是竖屏
     73     VIDW00ADD2 = 800;
     74 }
     75 
     76 void clean_screen(unsigned long *addr)
     77 {
     78     int i = 0;
     79     for(i=0; i<480*800; i++)
     80         addr[i] = 0x00f0000f;
     81         ///开始时候打印图片的值
     82 }
     83 
     84 

          其中第二步,对应时序图,列出各个时间表:

          

       

                 

            其中,页面频率的值计算公式是:

            

          第三步,配置相关窗口寄存器的值,以及取数据的地址。

    驱动代码:

        

      1 #include "regs.h"
      2 
      3 int (*printf)(char *, ...) = 0xc3e114d8;
      4 
      5 void clean_screen(unsigned long *addr);
      6 
      7 int main()
      8 {
      9     unsigned long addr = 0x52000000;
     10     clean_screen(addr);
     11 
     12     printf("hahahah
    ");
     13     CLK_SRC_LCD0 = 6;
     14     CLK_DIV_LCD = 0;
     15     CLK_GATE_IP_LCD = 1;
     16 
     17 #if 0
     18     GPD0CON &= ~(0xf << 4);
     19     GPD0CON |= (0x3 << 4);
     20 #else
     21     GPD0CON = (1 << 4);
     22     GPD0DAT = (1 << 1);
     23 #endif
     24     GPX1CON &= ~(0xf << 8);
     25     GPX1CON |= (0x2 << 8);
     26     GPF0CON = 0x22222222;
     27     GPF1CON = 0x22222222;
     28     GPF2CON = 0x22222222;
     29     GPF3CON = 0x2222;
     30 
     31     printf("heheheh
    ");
     32     //pages 1860
     33     VIDCON0 = 1 | (1 << 1) | (1 << 5) | (28 << 6);
     34     VIDCON1 = (1 << 5) | (1 << 6) | (1 << 7);
     35     VIDCON2 = 0;
     36     VIDTCON0 = 9 | (21 << 8) | (12 << 16);
     37     VIDTCON1 = 19 | (209 << 8) | (25 << 16);
     38     VIDTCON2 = 799 | (479 << 11);
     39     VIDTCON3 = 0;
     40     WINCON0 = 1 | (13 << 2);
     41     VIDOSD0A = 0 | (0 << 11);
     42     VIDOSD0B = 479 | (799 << 11);
     43     VIDOSD0C = 800 * 480;
     44     VIDW00ADD0B0 = addr;
     45     VIDW00ADD1B0 = addr + 800 * 480 * 4;
     46     VIDW00ADD2 = 480;
     47 }
     48 
     49 void clean_screen(unsigned long *addr)
     50 {
     51     int i = 0;
     52     for(i=0; i<480*800; i++)
     53         addr[i] = 0x00ff0000;
     54 }
     55 
     56 
     57 
     58 
      1 #define CLK_SRC_LCD0    (*(volatile unsigned long *)0x1003c234)
      2 #define CLK_DIV_LCD     (*(volatile unsigned long *)0x1003c534)
      3 #define CLK_GATE_IP_LCD (*(volatile unsigned long *)0x1003c934)
      4 
      5 #define GPIO_BASE 0x11400000
      6 
      7 #define GPD0CON (*(volatile unsigned long *)(GPIO_BASE + 0x00A0))
      8 #define GPD0DAT (*(volatile unsigned long *)(GPIO_BASE + 0x00A4))
      9 #define GPX1CON (*(volatile unsigned long *)(GPIO_BASE + 0x0C20))
     10 #define GPF0CON (*(volatile unsigned long *)(GPIO_BASE + 0x0180))
     11 #define GPF1CON (*(volatile unsigned long *)(GPIO_BASE + 0x01A0))
     12 #define GPF2CON (*(volatile unsigned long *)(GPIO_BASE + 0x01C0))
     13 #define GPF3CON (*(volatile unsigned long *)(GPIO_BASE + 0x01E0))
     14 
     15 #define LCD_BASE 0x11C00000
     16 
     17 #define VIDCON0         (*(volatile unsigned long *)(LCD_BASE + 0x0000))
     18 #define VIDCON1         (*(volatile unsigned long *)(LCD_BASE + 0x0004))
     19 #define VIDCON2         (*(volatile unsigned long *)(LCD_BASE + 0x0008))
     20 #define VIDCON3         (*(volatile unsigned long *)(LCD_BASE + 0x000C))
     21 #define VIDTCON0        (*(volatile unsigned long *)(LCD_BASE + 0x0010))
     22 #define VIDTCON1        (*(volatile unsigned long *)(LCD_BASE + 0x0014))
     23 #define VIDTCON2        (*(volatile unsigned long *)(LCD_BASE + 0x0018))
     24 #define VIDTCON3        (*(volatile unsigned long *)(LCD_BASE + 0x001C))
     25 #define WINCON0         (*(volatile unsigned long *)(LCD_BASE + 0x0020))
     26 #define WINCON1         (*(volatile unsigned long *)(LCD_BASE + 0x0024))
     27 #define WINCON2         (*(volatile unsigned long *)(LCD_BASE + 0x0028))
     28 #define WINCON3         (*(volatile unsigned long *)(LCD_BASE + 0x002C))
     29 #define WINCON4         (*(volatile unsigned long *)(LCD_BASE + 0x0030))
     30 #define SHADOWCON       (*(volatile unsigned long *)(LCD_BASE + 0x0034))
     31 #define WINCHMAP2       (*(volatile unsigned long *)(LCD_BASE + 0x003C))
     32 #define VIDOSD0A        (*(volatile unsigned long *)(LCD_BASE + 0x0040))
     33 #define VIDOSD0B        (*(volatile unsigned long *)(LCD_BASE + 0x0044))
     34 #define VIDOSD0C        (*(volatile unsigned long *)(LCD_BASE + 0x0048))
     35 #define VIDOSD1A        (*(volatile unsigned long *)(LCD_BASE + 0x0050))
     36 #define VIDOSD1B        (*(volatile unsigned long *)(LCD_BASE + 0x0054))
     37 #define VIDOSD1C        (*(volatile unsigned long *)(LCD_BASE + 0x0058))
     38 #define VIDOSD1D        (*(volatile unsigned long *)(LCD_BASE + 0x005C))
     39 #define VIDOSD2A        (*(volatile unsigned long *)(LCD_BASE + 0x0060))
     40 #define VIDOSD2B        (*(volatile unsigned long *)(LCD_BASE + 0x0064))
     41 #define VIDOSD2C        (*(volatile unsigned long *)(LCD_BASE + 0x0068))
     42 #define VIDOSD2D        (*(volatile unsigned long *)(LCD_BASE + 0x006C))
     43 #define VIDOSD3A        (*(volatile unsigned long *)(LCD_BASE + 0x0070))
     44 #define VIDOSD3B        (*(volatile unsigned long *)(LCD_BASE + 0x0074))
     45 #define VIDOSD3C        (*(volatile unsigned long *)(LCD_BASE + 0x0078))
     46 #define VIDOSD4A        (*(volatile unsigned long *)(LCD_BASE + 0x0080))
     47 #define VIDOSD4B        (*(volatile unsigned long *)(LCD_BASE + 0x0084))
     48 #define VIDOSD4C        (*(volatile unsigned long *)(LCD_BASE + 0x0088))
     49 #define VIDW00ADD0B0    (*(volatile unsigned long *)(LCD_BASE + 0x00A0))
     50 #define VIDW00ADD0B1    (*(volatile unsigned long *)(LCD_BASE + 0x00A4))
     51 #define VIDW00ADD0B2    (*(volatile unsigned long *)(LCD_BASE + 0x20A0))
     52 #define VIDW01ADD0B0    (*(volatile unsigned long *)(LCD_BASE + 0x00A8))
     53 #define VIDW01ADD0B1    (*(volatile unsigned long *)(LCD_BASE + 0x00AC))
     54 #define VIDW01ADD0B2    (*(volatile unsigned long *)(LCD_BASE + 0x20A8))
     55 #define VIDW02ADD0B0    (*(volatile unsigned long *)(LCD_BASE + 0x00B0))
     56 #define VIDW02ADD0B1    (*(volatile unsigned long *)(LCD_BASE + 0x00B4))
     57 #define VIDW02ADD0B2    (*(volatile unsigned long *)(LCD_BASE + 0x20B0))
     58 #define VIDW03ADD0B0    (*(volatile unsigned long *)(LCD_BASE + 0x00B8))
     59 #define VIDW03ADD0B1    (*(volatile unsigned long *)(LCD_BASE + 0x00BC))
     60 #define VIDW03ADD0B2    (*(volatile unsigned long *)(LCD_BASE + 0x20B8))
     61 #define VIDW04ADD0B0    (*(volatile unsigned long *)(LCD_BASE + 0x00C0))
     62 #define VIDW04ADD0B1    (*(volatile unsigned long *)(LCD_BASE + 0x00C4))
     63 #define VIDW04ADD0B2    (*(volatile unsigned long *)(LCD_BASE + 0x20C0))
     64 #define VIDW00ADD1B0    (*(volatile unsigned long *)(LCD_BASE + 0x00D0))
     65 #define VIDW00ADD1B1    (*(volatile unsigned long *)(LCD_BASE + 0x00D4))
     66 #define VIDW00ADD1B2    (*(volatile unsigned long *)(LCD_BASE + 0x20D0))
     67 #define VIDW01ADD1B0    (*(volatile unsigned long *)(LCD_BASE + 0x00D8))
     68 #define VIDW01ADD1B1    (*(volatile unsigned long *)(LCD_BASE + 0x00DC))
     69 #define VIDW01ADD1B2    (*(volatile unsigned long *)(LCD_BASE + 0x20D8))
     70 #define VIDW02ADD1B0    (*(volatile unsigned long *)(LCD_BASE + 0x00E0))
     71 #define VIDW02ADD1B1    (*(volatile unsigned long *)(LCD_BASE + 0x00E4))
     72 #define VIDW02ADD1B2    (*(volatile unsigned long *)(LCD_BASE + 0x20E0))
     73 #define VIDW03ADD1B0    (*(volatile unsigned long *)(LCD_BASE + 0x00E8))
     74 #define VIDW03ADD1B1    (*(volatile unsigned long *)(LCD_BASE + 0x00EC))
     75 #define VIDW03ADD1B2    (*(volatile unsigned long *)(LCD_BASE + 0x20E8))
     76 #define VIDW04ADD1B0    (*(volatile unsigned long *)(LCD_BASE + 0x00F0))
     77 #define VIDW04ADD1B1    (*(volatile unsigned long *)(LCD_BASE + 0x00F4))
     78 #define VIDW04ADD1B2    (*(volatile unsigned long *)(LCD_BASE + 0x20F0))
     79 #define VIDW00ADD2      (*(volatile unsigned long *)(LCD_BASE + 0x0100))
     80 #define VIDW01ADD2      (*(volatile unsigned long *)(LCD_BASE + 0x0104))
     81 #define VIDW02ADD2      (*(volatile unsigned long *)(LCD_BASE + 0x0108))
     82 #define VIDW03ADD2      (*(volatile unsigned long *)(LCD_BASE + 0x010C))
     83 #define VIDW04ADD2      (*(volatile unsigned long *)(LCD_BASE + 0x0110))
     84 #define VIDINTCON0      (*(volatile unsigned long *)(LCD_BASE + 0x0130))
     85 #define VIDINTCON1      (*(volatile unsigned long *)(LCD_BASE + 0x0134))
     86 #define W1KEYCON0       (*(volatile unsigned long *)(LCD_BASE + 0x0140))
     87 #define W1KEYCON1       (*(volatile unsigned long *)(LCD_BASE + 0x0144))
     88 #define W2KEYCON0       (*(volatile unsigned long *)(LCD_BASE + 0x0148))
     89 #define W2KEYCON1       (*(volatile unsigned long *)(LCD_BASE + 0x014C))
     90 #define W3KEYCON0       (*(volatile unsigned long *)(LCD_BASE + 0x0150))
     91 #define W3KEYCON1       (*(volatile unsigned long *)(LCD_BASE + 0x0154))
     92 #define W4KEYCON0       (*(volatile unsigned long *)(LCD_BASE + 0x0158))
     93 #define W4KEYCON1       (*(volatile unsigned long *)(LCD_BASE + 0x015C))
     94 #define W1KEYALPHA      (*(volatile unsigned long *)(LCD_BASE + 0x0160))
     95 #define W2KEYALPHA      (*(volatile unsigned long *)(LCD_BASE + 0x0164))
     96 #define W3KEYALPHA      (*(volatile unsigned long *)(LCD_BASE + 0x0168))
     97 #define W4KEYALPHA      (*(volatile unsigned long *)(LCD_BASE + 0x016C))
     98 #define DITHMODE        (*(volatile unsigned long *)(LCD_BASE + 0x0170))
     99 #define WIN0MAP         (*(volatile unsigned long *)(LCD_BASE + 0x0180))
    100 #define WIN1MAP         (*(volatile unsigned long *)(LCD_BASE + 0x0184))
    101 #define WIN2MAP         (*(volatile unsigned long *)(LCD_BASE + 0x0188))
    102 #define WIN3MAP         (*(volatile unsigned long *)(LCD_BASE + 0x018C))
    103 #define WIN4MAP         (*(volatile unsigned long *)(LCD_BASE + 0x0190))
    104 #define WPALCON_H       (*(volatile unsigned long *)(LCD_BASE + 0x019C))
    105 #define WPALCON_L       (*(volatile unsigned long *)(LCD_BASE + 0x01A0))
    106 #define TRIGCON         (*(volatile unsigned long *)(LCD_BASE + 0x01A4))
    107 #define I80IFCONA0      (*(volatile unsigned long *)(LCD_BASE + 0x01B0))
    108 #define I80IFCONA1      (*(volatile unsigned long *)(LCD_BASE + 0x01B4))
    109 #define I80IFCONB0      (*(volatile unsigned long *)(LCD_BASE + 0x01B8))
    110 #define I80IFCONB1      (*(volatile unsigned long *)(LCD_BASE + 0x01BC))
    111 #define COLORGAINCON    (*(volatile unsigned long *)(LCD_BASE + 0x01C0))
    112 #define LDI_CMDCON0     (*(volatile unsigned long *)(LCD_BASE + 0x01D0))
    113 #define LDI_CMDCON1     (*(volatile unsigned long *)(LCD_BASE + 0x01D4))
    114 #define SIFCCON0        (*(volatile unsigned long *)(LCD_BASE + 0x01E0))
    115 #define SIFCCON1        (*(volatile unsigned long *)(LCD_BASE + 0x01E4))
    116 #define SIFCCON2        (*(volatile unsigned long *)(LCD_BASE + 0x01E8))
    117 #define HUECOEF_CR_1    (*(volatile unsigned long *)(LCD_BASE + 0x01EC))
    118 #define HUECOEF_CR_2    (*(volatile unsigned long *)(LCD_BASE + 0x01F0))
    119 #define HUECOEF_CR_3    (*(volatile unsigned long *)(LCD_BASE + 0x01F4))
    120 #define HUECOEF_CR_4    (*(volatile unsigned long *)(LCD_BASE + 0x01F8))
    121 #define HUECOEF_CB_1    (*(volatile unsigned long *)(LCD_BASE + 0x01FC))
    122 #define HUECOEF_CB_2    (*(volatile unsigned long *)(LCD_BASE + 0x0200))
    123 #define HUECOEF_CB_3    (*(volatile unsigned long *)(LCD_BASE + 0x0204))
    124 #define HUECOEF_CB_4    (*(volatile unsigned long *)(LCD_BASE + 0x0208))
    125 #define HUEOFFSET       (*(volatile unsigned long *)(LCD_BASE + 0x020C))
    126 #define VIDW0ALPHA0     (*(volatile unsigned long *)(LCD_BASE + 0x021C))
    127 #define VIDW0ALPHA1     (*(volatile unsigned long *)(LCD_BASE + 0x0220))
    128 #define VIDW1ALPHA0     (*(volatile unsigned long *)(LCD_BASE + 0x0224))
    129 #define VIDW1ALPHA1     (*(volatile unsigned long *)(LCD_BASE + 0x0228))
    130 #define VIDW2ALPHA0     (*(volatile unsigned long *)(LCD_BASE + 0x022C))
    131 #define VIDW2ALPHA1     (*(volatile unsigned long *)(LCD_BASE + 0x0230))
    132 #define VIDW3ALPHA0     (*(volatile unsigned long *)(LCD_BASE + 0x0234))
    133 #define VIDW3ALPHA1     (*(volatile unsigned long *)(LCD_BASE + 0x0238))
    134 #define VIDW4ALPHA0     (*(volatile unsigned long *)(LCD_BASE + 0x023C))
    135 #define VIDW4ALPHA1     (*(volatile unsigned long *)(LCD_BASE + 0x0240))
    136 #define BLENDEQ1        (*(volatile unsigned long *)(LCD_BASE + 0x0244))
    137 #define BLENDEQ2        (*(volatile unsigned long *)(LCD_BASE + 0x0248))
    138 #define BLENDEQ3        (*(volatile unsigned long *)(LCD_BASE + 0x024C))
    139 #define BLENDEQ4        (*(volatile unsigned long *)(LCD_BASE + 0x0250))
    140 #define BLENDCON        (*(volatile unsigned long *)(LCD_BASE + 0x0260))
    141 #define W0RTQOSCON      (*(volatile unsigned long *)(LCD_BASE + 0x0264))
    142 #define W1RTQOSCON      (*(volatile unsigned long *)(LCD_BASE + 0x0268))
    143 #define W2RTQOSCON      (*(volatile unsigned long *)(LCD_BASE + 0x026C))
    144 #define W3RTQOSCON      (*(volatile unsigned long *)(LCD_BASE + 0x0270))
    145 #define W4RTQOSCON      (*(volatile unsigned long *)(LCD_BASE + 0x0274))
    146 #define LDI_CMD0        (*(volatile unsigned long *)(LCD_BASE + 0x0280))
    147 #define LDI_CMD1        (*(volatile unsigned long *)(LCD_BASE + 0x0284))
    148 #define LDI_CMD2        (*(volatile unsigned long *)(LCD_BASE + 0x0288))
    149 #define LDI_CMD3        (*(volatile unsigned long *)(LCD_BASE + 0x028C))
    150 #define LDI_CMD4        (*(volatile unsigned long *)(LCD_BASE + 0x0290))
    151 #define LDI_CMD5        (*(volatile unsigned long *)(LCD_BASE + 0x0294))
    152 #define LDI_CMD6        (*(volatile unsigned long *)(LCD_BASE + 0x0298))
    153 #define LDI_CMD7        (*(volatile unsigned long *)(LCD_BASE + 0x029C))
    154 #define LDI_CMD8        (*(volatile unsigned long *)(LCD_BASE + 0x02A0))
    155 #define LDI_CMD9        (*(volatile unsigned long *)(LCD_BASE + 0x02A4))
    156 #define LDI_CMD10       (*(volatile unsigned long *)(LCD_BASE + 0x02A8))
    157 #define LDI_CMD11       (*(volatile unsigned long *)(LCD_BASE + 0x02AC))

        寄存器,时序图时间值:

          

      1 gpf0_0    ~   gpf0_7
      2 gpf1_0    ~   gpf1_7
      3 gpf2_0    ~   gpf2_7
      4 gpf3_0    ~   gpf3_3
      5 gpd0_1
      6 gpx1_2
      7 
      8 vspw + 1        tvpw            10
      9 vbpd + 1        tvb - tvpw      13
     10 lineval + 1     tvd             480
     11 vfpd + 1        tvfp            22
     12 
     13 hspw + 1        thpw            20
     14 hbpd + 1        thb - thpw      26
     15 hozval + 1      thd             800
     16 hfpd + 1        thfp            210
     17 
     18 Frame Rate = 1/[{(VSPW + 1) + (VBPD + 1) + (LIINEVAL + 1) + (VFPD + 1)} * {(HSPW + 1) + (    HBPD + 1) + (HFPD + 1) + (HOZVAL + 1)} * {(CLKVAL + 1)/(Frequency of Clock source)}]
     19 
     20 50 = 1 / [{10 + 13 + 480 + 22} * {20 + 26 + 800 + 210} * X / 800M]
     21 50 = 1 / [525 * 1056 * X / 800M]
     22 1 = 50 * 525 * 1056 * X / 800M
     23 800M = 50 * 525 * 1056 * X
     24 X = 800M / (50 * 525 * 1056)
     25 X = 800M / 27720000
     26 X = 28.8
     27 
     28 
     29 

      

      

        

             

  • 相关阅读:
    linux系统之tr命令
    Tmux会话-基本操作及原理
    [题解] P1552 [APIO2012]派遣
    数论学习笔记
    Splay 学习笔记
    SpringCloud---入门篇(1)
    获小黄杉有感
    2020湖湘杯-CRYPTO-简单的密码3 WriteUp (CBC字节翻转)
    ECC椭圆曲线加密算法—加解密(SageMath实现)
    栅栏密码&W型栅栏密码-加解密(python实现)
  • 原文地址:https://www.cnblogs.com/hongzhunzhun/p/4552929.html
Copyright © 2020-2023  润新知