ok6410之lcd驱动程序设计


 

#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))
//以下时序是在4.3寸屏手册中查找的
#define VSPW 9
#define VBPD 1
#define LINEVAL 271
#define VFPD 1
#define HSPW 40
#define HBPD 1
#define HOZVAL 479
#define HFPD 1

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


#define FRAME_BUFFER      0x59000000  //如果是58000000和50000000的话就只会显示上一半;

 
void lcd_port_init()
{
    GPICON = 0xaaaaaaaa;
    GPJCON = 0xaaaaaa;
}

void lcd_control_init()
{
        MOFPCON = 0<<3; 
        SPCON   = 0x01;  
	VIDCON0 =  (14<<6) |(1<<4); 

	VIDCON1 = 1<<5 | 1<<6; 
   
	VIDTCON0 = (VBPD<<16)|(VFPD<<8)|(VSPW<<0);
	VIDTCON1 = (HBPD<<16)|(HFPD<<8)|(HSPW<<0);
	VIDTCON2 = (LINEVAL<<11) |(HOZVAL<<0);
	
       //24bpp 24位真彩色
	WINCON0 = (1<<16)|(0xb<<2)|(1<<0);
	
	VIDOSD0A = (LeftTopX<<11) |(LeftTopY<<0);
	VIDOSD0B = (RightBotX<<11)|(RigntBotY<<0);
	VIDOSD0C = (LINEVAL+1)*(HOZVAL+1);
	
	VIDW00ADD0B0 = FRAME_BUFFER;           //下面的*4有点模糊,
	VIDW00ADD1B0 = (FRAME_BUFFER+((HOZVAL+1)*4+0)*(LINEVAL+1))&(0xffffff);
	//VIDW00ADD1B0 = (FRAME_BUFFER+((HOZVAL+1)+0)*(LINEVAL+1))&(0xffffff);		
}

void lcd_init()
{
    lcd_port_init();
    lcd_control_init();
}


void point(int row, int col, int color)
{
    unsigned long *point = (unsigned long*)FRAME_BUFFER;
    *(point + row*480+col) = color;//不咋懂!
      //p[row][col] = color;
    
}

extern unsigned char bmp[135300];
/*void lcd_bmp( const unsigned char bmp)
   {
   	int x,y;
   	 int color;
   	unsigned char *p = (unsigned char *)bmp;
   	 int  red,green,blue;
   	for(y=0;y<240;y++)
   	 for(x=0;x<240;x++)
   	   {
   	   	 blue = *p++;
   	   	 green = *p++;
   	   	 red = *p++;
   	   	 color = (red<<18)|(green<<10)|(blue<<2);
   	   	 point(x,y,color);
   	   }
   }*/
   void lcd_bmp( unsigned char gImage_bmp[])
{
	int i, j;
	unsigned char *p = gImage_bmp;
	int blue, green, red;
	int color;

	// 图片大小220x205像素
	for (i = 0; i < 205; i++)
		for (j = 0; j < 220; j++)  //注意在这的205和220,我测试时用的其他或大或小的值都显示不正常!
		{
			red   = *p++;
			green = *p++;
			blue  = *p++;
			//green = *p++;
			
			
			// D[23:16] = Red data, D[15:8] = Green data,D[7:0] = Blue data
			
			color = (red << 16)| (green << 8)|( blue << 0); 
			point(i, j, color);
			 /*unsigned long *point = FRAME_BUFFER;
			*(point+ i*480+j) = color;*/   //也行!
		}
}

void lcd_clean(unsigned int color )
{
	int x,y;
	for(x=0;x<272;x++)
	  for(y=0;y<480;y++)
	      point(x,y,color);
}

void lcd_test()
{
	int y,x;
	
	 
	for(y=100;y<380;y++)
	   for(x=100;x<270;x++)

		point(210,y,0xFFFF00);	
	
	lcd_bmp(bmp);
	lcd_clean(0x0000ff);
	
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值