<pre name="code" class="objc"><pre name="code" class="objc">#define LADDR 0x30800000
#define HMIX 240
#define VMIX 320
unsigned short * addrbuf = (unsigned short *)LADDR;
/*************************************************
Function name : lcd_init
Description : Init
Input parameter : NONE
Return : none
Others : none
*************************************************/
void lcd_init(void)
{
lcd_pin_init();
lcd_reg_init();
lcd_enable();
}
/*************************************************
Function name : lcd_pin_init
Description : 配置lcd引脚
Input parameter : none
Return : none
Others : none
*************************************************/
void lcd_pin_init(void)
{
rGPCCON = 0xaaaaaaaa;//配置为特殊功能寄存器
rGPDCON = 0xaaaaaaaa;//配置为特殊功能寄存器
rGPGCON |= 0x3<<8;
}
/*************************************************
Function name : lcd_reg_init
Description : 配置lcd的寄存器
Input parameter : none
Return : none
Others : none
*************************************************/
void lcd_reg_init(void)
{
// CLKVAL PNRMODE BPPMODE ENVID
rLCDCON1 = ((0x9<<8)|(0x3<<5)|(0xc<<1));
//4 319 4 5
rLCDCON2 = ((0x4<<24)|(0x13f<<14)|(0x4<<6)|(0x5));
//HBPD = 10 HOZVAL = 239 HFPD = 10
rLCDCON3 = ((0xa<<19)|(0xef<<8)|(0xa));
//HSPW = 9
rLCDCON4 = 0x9;
//看手册398页
rLCDCON5 = ((0x1<<11)|(0x1<<6)|(0x1<<3)|(0x1<<2)|(0x1));
//配置图像缓存地址
rLCDSADDR1 = (((LADDR>>1) & 0x1fffff) | (((LADDR>>22) & 0x1ff)<<21));
rLCDSADDR2 = (((LADDR+VMIX*HMIX*2)>>1)&0x1fffff);
}
/*************************************************
Function name : lcd_enable
Description : 开关
Input parameter : none
Return : none
Others : none
*************************************************/
void lcd_enable(void)
{
rLCDCON1 |= 0x1;//电源使能
}
/*************************************************
Function name : clr_lcd
Description : 清屏函数
Input parameter : const unsigned char c要显示的颜色
Return : none
Others : none
*************************************************/
void clr_lcd(const unsigned int c)//
{
int i,j;
for(i = 0;i<VMIX;i++)
{
for(j = 0;j<HMIX;j++)
{
addrbuf[HMIX*i+j] = c;
}
}
}