142day:LCD驱动1


2013年10月14日
LCD
1.LCD==>/dev/fb0
2.LCD是一种折射光的液体 ==>最好的LCD公司夏普
3.LCD:长宽比例:
4:3
16:9
16:10

s3c6410:480:272
30:17
4.


app
-------------------------

os
-------------------------

hw
-------------------------


5.注:
触屏:/home/linux_you/drivers/input/touchscreen
    做任何事,都需要一个时钟。运动,转变的一个快慢。
6.
pixel
\n:跳到下一行    
\r :回到行首

下面是Lcd 的裸版程序:


#include "up.h"



void clean_screen(unsigned short *addr);


int main()
{
// clean_screen(0x56000000);

GPECON &= ~0xf;
GPECON |= 1;
GPEDAT |= 1;

GPFCON &= ~(3 << 28);
GPFCON |= (1 << 28);
GPFDAT |= (1 << 14);

GPICON = 0xaaaaaaaa;
GPJCON = 0xaaaaaa;

//s3c6410 p491
//step 1:
MOFPCON &= ~(1 << 3);
//step 2:
SPCON &= ~0x3;
SPCON |= 0x1;
//step 3:
/*
Frame Rate = 1/ [ { (VSPW+1) + (VBPD+1) + (LIINEVAL + 1) + (VFPD+1) } x {(HSPW+1) + (HBPD +1)
    + (HFPD+1) + (HOZVAL + 1) } x { ( CLKVAL+1 ) / ( Frequency of Clock source ) } ]
40 = 1 / [{10 + 2 + 272 + 2} * {41 + 2 + 480 + 255} * X /133M]
40 = 1 / [286 * 778 * X / 133M]
1 = 40 * 286 * 778 * X / 133M
133M = 40 * 286 * 778 * X 
X = 133M / (40 * 286 * 778)
X = 133M / 8900320
X = 15
*/
VIDCON0 = 1 | (1 << 1) | (1 << 4) | (15 << 6);
//step 4:
VIDCON1 = (1 << 5) | (1 << 6);
//step 5,6:
//step 7:
VIDTCON0 = 9 | (1 << 8) | (1 << 16);
VIDTCON1 = 40 | (254 << 8) | (1 << 16);
VIDTCON2 = 479 | (271 << 11);
//step 8:
WINCON0 = 1 | (5 << 2) | (1 << 16);
//step 9:
VIDOSD0A = 0;
//VIDOSD0B = 479 | (271 << 11);
VIDOSD0B = 271 | (479 << 11);
//step 10:
VIDOSD0C = 480 * 272 * 2 >> 2;
//step 11:
VIDW00ADD0B0 = 0x56000000;
VIDW00ADD1B0 = 0x56000000 + 480 * 272 * 2;
VIDW00ADD2 = 480 * 2;
VIDCON0 |= 1 | (1 << 1);
}

void clean_screen(unsigned short *addr)
{
int i = 0;
for(i=0; i<480 * 272; i++)
addr[i] = 0xf800;//红屏

}



up.c文件:

#define GPICON    (*(volatile unsigned long *)0x7F008100) 

#define GPIDAT    (*(volatile unsigned long *)0x7F008104) 
#define GPJCON    (*(volatile unsigned long *)0x7F008120) 
#define GPJDAT    (*(volatile unsigned long *)0x7F008124)
#define GPECON    (*(volatile unsigned long *)0x7F008080) 
#define GPEDAT    (*(volatile unsigned long *)0x7F008084) 
#define GPFCON    (*(volatile unsigned long *)0x7F0080A0) 
#define GPFDAT    (*(volatile unsigned long *)0x7F0080A4)
#define VIDCON0   (*(volatile unsigned long *)0x77100000) 
#define VIDCON1   (*(volatile unsigned long *)0x77100004) 
#define VIDCON2   (*(volatile unsigned long *)0x77100008) 
#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 WINCON1   (*(volatile unsigned long *)0x77100024) 
#define WINCON2   (*(volatile unsigned long *)0x77100028) 
#define WINCON3   (*(volatile unsigned long *)0x7710002C) 
#define WINCON4   (*(volatile unsigned long *)0x77100030) 
#define VIDOSD0A (*(volatile unsigned long *)0x77100040) 
#define VIDOSD0B (*(volatile unsigned long *)0x77100044) 
#define VIDOSD0C (*(volatile unsigned long *)0x77100048) 
#define VIDOSD1A (*(volatile unsigned long *)0x77100050) 
#define VIDOSD1B (*(volatile unsigned long *)0x77100054) 
#define VIDOSD1C (*(volatile unsigned long *)0x77100058)
#define VIDOSD1D     (*(volatile unsigned long *)0x7710005C)
#define VIDOSD2A     (*(volatile unsigned long *)0x77100060)
#define VIDOSD2B     (*(volatile unsigned long *)0x77100064)
#define VIDOSD2C     (*(volatile unsigned long *)0x77100068)
#define VISOSD2D     (*(volatile unsigned long *)0x7710006C)
#define VIDOSD3A     (*(volatile unsigned long *)0x77100070)
#define VIDOSD3B     (*(volatile unsigned long *)0x77100074)
#define VIDOSD3C     (*(volatile unsigned long *)0x77100078)
#define VIDOSD4A     (*(volatile unsigned long *)0x77100080)
#define VIDOSD4B     (*(volatile unsigned long *)0x77100084)
#define VIDOSD4C     (*(volatile unsigned long *)0x77100088)
#define VIDW00ADD0B0 (*(volatile unsigned long *)0x771000A0)
#define VIDW00ADD0B1 (*(volatile unsigned long *)0x771000A4)
#define VIDW01ADD0B0 (*(volatile unsigned long *)0x771000A8)
#define VIDW01ADD0B1 (*(volatile unsigned long *)0x771000AC)
#define VIDW02ADD0   (*(volatile unsigned long *)0x771000B0)
#define VIDW03ADD0   (*(volatile unsigned long *)0x771000B8)
#define VIDW04ADD0   (*(volatile unsigned long *)0x771000C0)
#define VIDW00ADD1B0 (*(volatile unsigned long *)0x771000D0)
#define VIDW00ADD1B1 (*(volatile unsigned long *)0x771000D4)
#define VIDW01ADD1B0 (*(volatile unsigned long *)0x771000D8)
#define VIDW01ADD1B1 (*(volatile unsigned long *)0x771000DC)
#define VIDW02ADD1   (*(volatile unsigned long *)0x771000E0)
#define VIDW03ADD1   (*(volatile unsigned long *)0x771000E8)
#define VIDW04ADD1   (*(volatile unsigned long *)0x771000F0)
#define VIDW00ADD2   (*(volatile unsigned long *)0x77100100)
#define VIDW01ADD2   (*(volatile unsigned long *)0x77100104)
#define VIDW02ADD2   (*(volatile unsigned long *)0x77100108)
#define VIDW03ADD2   (*(volatile unsigned long *)0x7710010C)
#define VIDW04ADD2   (*(volatile unsigned long *)0x77100110)
#define VIDINTCON0   (*(volatile unsigned long *)0x77100130)
#define VIDINTCON1   (*(volatile unsigned long *)0x77100134)
#define W1KEYCON0     (*(volatile unsigned long *)0x77100140)
#define W1KEYCON1     (*(volatile unsigned long *)0x77100144)
#define W2KEYCON0     (*(volatile unsigned long *)0x77100148)
#define W2KEYCON1     (*(volatile unsigned long *)0x7710014C)
#define W3KEYCON0     (*(volatile unsigned long *)0x77100150)
#define W3KEYCON1     (*(volatile unsigned long *)0x77100154)
#define W4KEYCON0     (*(volatile unsigned long *)0x77100158)
#define W4KEYCON1     (*(volatile unsigned long *)0x7710015C)
#define DITHMODE       (*(volatile unsigned long *)0x77100170)
#define WIN0MAP       (*(volatile unsigned long *)0x77100180)
#define WIN1MAP       (*(volatile unsigned long *)0x77100184)
#define WIN2MAP       (*(volatile unsigned long *)0x77100188)
#define WIN3MAP       (*(volatile unsigned long *)0x7710018C)
#define WIN4MAP       (*(volatile unsigned long *)0x77100190)
#define WPALCON       (*(volatile unsigned long *)0x771001A0)
#define TRIGCON       (*(volatile unsigned long *)0x771001A4)
#define ITUIFCON0     (*(volatile unsigned long *)0x771001A8)
#define I80IFCONA0     (*(volatile unsigned long *)0x771001B0)
#define I80IFCONA1     (*(volatile unsigned long *)0x771001B4)
#define I80IFCONB0     (*(volatile unsigned long *)0x771001B8)
#define I80IFCONB1     (*(volatile unsigned long *)0x771001BC)
#define LDI_CMDCON0   (*(volatile unsigned long *)0x771001D0)
#define LDI_CMDCON1   (*(volatile unsigned long *)0x771001D4)
#define SIFCCON0       (*(volatile unsigned long *)0x771001E0)
#define SIFCCON1       (*(volatile unsigned long *)0x771001E4)
#define SIFCCON2       (*(volatile unsigned long *)0x771001E8)
#define LDI_CMD0       (*(volatile unsigned long *)0x77100280)
#define LDI_CMD1       (*(volatile unsigned long *)0x77100284)
#define LDI_CMD2       (*(volatile unsigned long *)0x77100288)
#define LDI_CMD3       (*(volatile unsigned long *)0x7710028C)
#define LDI_CMD4       (*(volatile unsigned long *)0x77100290)
#define LDI_CMD5       (*(volatile unsigned long *)0x77100294)
#define LDI_CMD6       (*(volatile unsigned long *)0x77100298)
#define LDI_CMD7       (*(volatile unsigned long *)0x7710029C)
#define LDI_CMD8       (*(volatile unsigned long *)0x771002A0)
#define LDI_CMD9       (*(volatile unsigned long *)0x771002A4)
#define LDI_CMD10     (*(volatile unsigned long *)0x771002A8)
#define LDI_CMD11     (*(volatile unsigned long *)0x771002AC)
#define W2PDATA01     (*(volatile unsigned long *)0x77100300)
#define W2PDATA23     (*(volatile unsigned long *)0x77100304)
#define W2PDATA45     (*(volatile unsigned long *)0x77100308)
#define W2PDATA67     (*(volatile unsigned long *)0x7710030C)
#define W2PDATA89     (*(volatile unsigned long *)0x77100310)
#define W2PDATACD (*(volatile unsigned long *)0x77100318) 
#define W2PDATAEF (*(volatile unsigned long *)0x7710031C) 
#define W3PDATA01 (*(volatile unsigned long *)0x77100320) 
#define W3PDATA23 (*(volatile unsigned long *)0x77100324) 
#define W3PDATA45 (*(volatile unsigned long *)0x77100328) 
#define W3PDATA67 (*(volatile unsigned long *)0x7710032C) 
#define W3PDATA89 (*(volatile unsigned long *)0x77100330) 
#define W3PDATAAB (*(volatile unsigned long *)0x77100334) 
#define W3PDATACD (*(volatile unsigned long *)0x77100338) 
#define W3PDATAEF (*(volatile unsigned long *)0x7710033C) 
#define W4PDATA01 (*(volatile unsigned long *)0x77100340) 
#define W4PDATA23 (*(volatile unsigned long *)0x77100344)


#define MOFPCON (*(volatile unsigned long *)0x7410800C)
#define SPCON (*(volatile unsigned long *)0x7F0081A0)


Makefile

all:
arm-none-linux-gnueabi-gcc -c test.c -o test.o
arm-none-linux-gnueabi-ld -Ttext=0x50000000 test.o -o test
arm-none-linux-gnueabi-objcopy -Ielf32-littlearm -Obinary test /tftpboot/test.bin


clean:
rm test.o test /tftpboot/test.bin




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值