ok6410的LCD裸机范例

Posted chd_zhang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ok6410的LCD裸机范例相关的知识,希望对你有一定的参考价值。

/******************************************
        实验步骤
1.配置引脚功能,将其GPI、GPJ引脚设置为VD数据输出模式,及GPJ后几位设置成LCD时钟输出;
2.设置LCD时序值,初始化时序值。
    (1)需要初始化时序:VSPW、VBPD、LINEVAL、VFPD、HSPW、HBPB、HOZVAL、HFPD、
    CLKVAL(在LCD芯片手册中找到初始化时序图,然后找到对应的时序参数)
    (2)找到初始化这些时序信号相应的寄存器(在芯片手册中找到相应的寄存器,并对其初始化)
    (3)结合LCD芯片手册和时序图将对应参数的是设置出来
3.帧缓存初始化(帧缓冲指的是在内存中开辟出来的用来存储图像数据空间,并告知给LCD的CMA。)
    (1)设置窗口大小对应的寄存器
    (2)告诉ADM寄存器内存起始地址和大小
4.杂项初始化()
5.画点
6.画线
7.绘制QQ图
8.单色显示
**********************************************************/    
#define GPICON (*(volatile unsigned long *)0x7F008100)
#define GPJCON (*(volatile unsigned long *)0x7F008120)
#define MOFPCON (*(volatile unsigned long *)0x7410800C)
#define SPCON (*(volatile unsigned long *)0x7F0081A0)
#define VIDCON0 (*(volatile unsigned long *)0x77100000)
#define VIDCON1 (*(volatile unsigned long *)0x77100004)
#define VIDTCON0 (*(volatile unsigned long *)0x77100010)
#define VIDTCON1 (*(volatile unsigned long *)0x77100014)
#define VIDTCON2 (*(volatile unsigned long *)0x77100018)
#define WINCON0 (*(volatile unsigned long *)0x77100020)
#define VIDOSD0A (*(volatile unsigned long *)0x77100040)
#define VIDOSD0B (*(volatile unsigned long *)0x77100044)
#define VIDOSD0C (*(volatile unsigned long *)0x77100048)
#define VIDW00ADD0B0 (*(volatile unsigned long *)0x771000A0)
#define VIDW00ADD1B0 (*(volatile unsigned long *)0x771000D0)

#define VSPW 9
#define VBPD 1
#define LINEVAL 271
#define VFPD 1
//#define CLKVAL 4   //10 = 100/((CLKVAL+1)*2)
#define HSPW 40
#define HBPD 1
#define HOZVAL 479
#define HFPD 1

#define LeftTopX 0
#define LeftTopY 0
#define RightBotX 479
#define RightBotY 271

#define FRAME_BUFFER 0x54000000

extern unsigned char bmp[135300];/* 导出的时候切记不要包含图像头数据!!!!!! */

void lcd_port_init()
{
    GPICON = 0xaaaaaaaa;
    GPJCON = 0xaaaaaaaa;
}
void lcd_contral_init()
{
    MOFPCON = 0<<3;   /* 这一位必须设置为0 */
    SPCON = 0x01;    /* RGB模式下必须设置为1 */
    
    VIDCON0 = (14<<6)|(1<<4)|(3<<0); /* 禁止视频输出和控制信号 选择视频时钟源 确定VCLK和CLKVAL[7:0]的值[VCLK=视频时钟源/(CLKVAL+1)] */
    VIDCON1 = (1<<5)|(1<<6);

    VIDTCON0 = (VBPD<<16)|(VFPD<<8)|(VSPW<<0); /* 时钟初始化 */
    VIDTCON1 = (HBPD<<16)|(HFPD<<8)|(HSPW<<0);
    VIDTCON2 = (LINEVAL<<11)|(HOZVAL<<0);
    
    WINCON0 = (1<<16)|(0xb<<2)|(1<<0);   /* 禁止视频输出和视频控制信号 选择BPP图像窗口模式(24bpp) 打开半字交换控制位 */

    
    VIDOSD0A = (LeftTopX<<11)|(LeftTopY<<0);  /* 设置视频窗口0的位置 */
    VIDOSD0B = (RightBotX<<11)|(RightBotY<<0);
    VIDOSD0C = (LINEVAL+1)|(HOZVAL+1);  /* 设置视频窗口0的尺寸 */
    
    VIDW00ADD0B0 = FRAME_BUFFER;         /* 设置缓存区开始地址 */
    VIDW00ADD1B0 = ((FRAME_BUFFER+(HOZVAL+1)*4*(LINEVAL+1)))&(0xffffff); /* 设置缓存区结束地址 ????*/
}

void lcd_init()
{
    lcd_port_init();
    lcd_contral_init();
    
    //打开LCD电源
}

void point(int row, int col, int color) 
{
    int red, green, blue;
    unsigned long *point = (unsigned long*)FRAME_BUFFER;
    red = (color>>16) & 0xff;
    green = (color>>8) & 0xff;
    blue = (color>>0) & 0xff;
    *(point + row*480 + col) = (green<<24) | (blue<<16) | red; /* 具体不知原因 试出来的 */

}

void paint_bmp(const unsigned char bmp[])
{
    int i,j;
    unsigned char *p = (unsigned char *)bmp;
    int blue, green,red;
    int color;
    
    for(i=0;i<205;i++)  /* 必须和导出的尺寸一致!!! */
    {
        for(j=0;j<220;j++)
        {                            
            red = *p++;    /* 必须和导出的颜色顺序一模一样!!!!!! */
            blue = *p++;            
            green = *p++;

            color = (red<<16)|(green<<8)|(blue<<0); 
                        
            point(i,j,color);
        }
    }
}

void lcd_test()
{
    int y;
    for(y=1;y<470;y++)
        point(110,y,0xFF0000);
        
    paint_bmp(bmp);
}

 

以上是关于ok6410的LCD裸机范例的主要内容,如果未能解决你的问题,请参考以下文章

Ok6410裸机驱动学习C语言内嵌汇编

ok6410[000] 搭建裸机开发环境

ok6410[002] ubuntu1604系统下搭配ckermit和dnw基于RAM的裸机程序调试环境

修改飞凌OK6410的默认LCD显示设备

S3C6410基于SD卡的裸机开发

Linux异常处理体系结构