本帖最后由 qiancheng2014 于 2016-7-3 15:11 编辑
[mw_shl_code=c,true]#include "lcd.h"
#include "stdlib.h"
#include "font.h"
#include "usart.h"
#include "delay.h"
#include "stm32f7xx_hal_sram.h"
SRAM_HandleTypeDef SRAM_Handler;
u32 POINT_COLOR=0xFF000000;
u32 BACK_COLOR =0xFFFFFFFF;
_lcd_dev lcddev;
void LCD_WR_REG(vu16 regval)
{
regval=regval;
LCD->LCD_REG=regval;
}
void LCD_WR_DATA(vu16 data)
{
data=data;
LCD->LCD_RAM=data;
}
u16 LCD_RD_DATA(void)
{
vu16 ram;
ram=LCD->LCD_RAM;
return ram;
}
void LCD_WriteReg(u16 LCD_Reg,u16 LCD_RegValue)
{
LCD->LCD_REG = LCD_Reg;
LCD->LCD_RAM = LCD_RegValue;/
}
u16 LCD_ReadReg(u16 LCD_Reg)
{
LCD_WR_REG(LCD_Reg);
delay_us(5);
return LCD_RD_DATA();
}
void LCD_WriteRAM_Prepare(void)
{
LCD->LCD_REG=lcddev.wramcmd;
}
void LCD_WriteRAM(u16 RGB_Code)
{
LCD->LCD_RAM = RGB_Code;
}
u16 LCD_BGR2RGB(u16 c)
{
u16 r,g,b,rgb;
b=(c>>0)&0x1f;
g=(c>>5)&0x3f;
r=(c>>11)&0x1f;
rgb=(b<<11)+(g<<5)+(r<<0);
return(rgb);
}
void opt_delay(u8 i)
{
while(i--);
}
u32 LCD_ReadPoint(u16 x,u16 y)
{
u16 r=0,g=0,b=0;
if(x>=lcddev.width||y>=lcddev.height)return 0;
LCD_SetCursor(x,y);
if(lcddev.id==0X9341||lcddev.id==0X5310||lcddev.id==0X1963)LCD_WR_REG(0X2E);
else if(lcddev.id==0X5510)LCD_WR_REG(0X2E00);
r=LCD_RD_DATA(); //dummy Read
if(lcddev.id==0X1963)return r;
opt_delay(2);
r=LCD_RD_DATA();
opt_delay(2);
b=LCD_RD_DATA();
g=r&0XFF;
g<<=8;
return (((r>>11)<<11)|((g>>10)<<5)|(b>>11)); //ILI9341/NT35310/NT35510ÐèÒª¹«Ê½×ª»»Ò»ÏÂ
}
void LCD_DisplayOn(void)
{
if(lcddev.id==0X9341||lcddev.id==0X5310||lcddev.id==0X1963)LCD_WR_REG(0X29);
else if(lcddev.id==0X5510)LCD_WR_REG(0X2900);
}
void LCD_DisplayOff(void)
{
if(lcddev.id==0X9341||lcddev.id==0X5310||lcddev.id==0X1963)LCD_WR_REG(0X28);
else if(lcddev.id==0X5510)LCD_WR_REG(0X2800);
}
void LCD_SetCursor(u16 Xpos, u16 Ypos)
{
if(lcddev.id==0X9341||lcddev.id==0X5310)
{
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(Xpos>>8);LCD_WR_DATA(Xpos&0XFF);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(Ypos>>8);LCD_WR_DATA(Ypos&0XFF);
}else if(lcddev.id==0X1963)
{
if(lcddev.dir==0)
{
Xpos=lcddev.width-1-Xpos;
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(0);LCD_WR_DATA(0);
LCD_WR_DATA(Xpos>>8);LCD_WR_DATA(Xpos&0XFF);
}else
{
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(Xpos>>8);LCD_WR_DATA(Xpos&0XFF);
LCD_WR_DATA((lcddev.width-1)>>8);LCD_WR_DATA((lcddev.width-1)&0XFF);
}
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(Ypos>>8);LCD_WR_DATA(Ypos&0XFF);
LCD_WR_DATA((lcddev.height-1)>>8);LCD_WR_DATA((lcddev.height-1)&0XFF);
}else if(lcddev.id==0X5510)
{
LCD_WR_REG(lcddev.setxcmd);LCD_WR_DATA(Xpos>>8);
LCD_WR_REG(lcddev.setxcmd+1);LCD_WR_DATA(Xpos&0XFF);
LCD_WR_REG(lcddev.setycmd);LCD_WR_DATA(Ypos>>8);
LCD_WR_REG(lcddev.setycmd+1);LCD_WR_DATA(Ypos&0XFF);
}
}
void LCD_Scan_Dir(u8 dir)
{
u16 regval=0;
u16 dirreg=0;
u16 temp;
if((lcddev.dir==1&&lcddev.id!=0X1963)||(lcddev.dir==0&&lcddev.id==0X1963))
{
switch(dir)//·½Ïòת»»
{
case 0:dir=6;break;
case 1:dir=7;break;
case 2:dir=4;break;
case 3:dir=5;break;
case 4:dir=1;break;
case 5:dir=0;break;
case 6:dir=3;break;
case 7:dir=2;break;
}
}
if(lcddev.id==0x9341||lcddev.id==0X5310||lcddev.id==0X5510||lcddev.id==0X1963)//9341/5310/5510/1963,ÌØÊâ´¦Àí
{
switch(dir)
{
case L2R_U2D://´Ó×óµ½ÓÒ,´ÓÉϵ½ÏÂ
regval|=(0<<7)|(0<<6)|(0<<5);
break;
case L2R_D2U://´Ó×óµ½ÓÒ,´Óϵ½ÉÏ
regval|=(1<<7)|(0<<6)|(0<<5);
break;
case R2L_U2D://´ÓÓÒµ½×ó,´ÓÉϵ½ÏÂ
regval|=(0<<7)|(1<<6)|(0<<5);
break;
case R2L_D2U://´ÓÓÒµ½×ó,´Óϵ½ÉÏ
regval|=(1<<7)|(1<<6)|(0<<5);
break;
case U2D_L2R://´ÓÉϵ½ÏÂ,´Ó×óµ½ÓÒ
regval|=(0<<7)|(0<<6)|(1<<5);
break;
case U2D_R2L://´ÓÉϵ½ÏÂ,´ÓÓÒµ½×ó
regval|=(0<<7)|(1<<6)|(1<<5);
break;
case D2U_L2R://´Óϵ½ÉÏ,´Ó×óµ½ÓÒ
regval|=(1<<7)|(0<<6)|(1<<5);
break;
case D2U_R2L://´Óϵ½ÉÏ,´ÓÓÒµ½×ó
regval|=(1<<7)|(1<<6)|(1<<5);
break;
}
if(lcddev.id==0X5510)dirreg=0X3600;
else dirreg=0X36;
if((lcddev.id!=0X5310)&&(lcddev.id!=0X5510)&&(lcddev.id!=0X1963))regval|=0X08;//5310/5510/1963²»ÐèÒªBGR
LCD_WriteReg(dirreg,regval);
if(lcddev.id!=0X1963)//1963²»×ö×ø±ê´¦Àí
{
if(regval&0X20)
{
if(lcddev.width<lcddev.height)//½»»»X,Y
{
temp=lcddev.width;
lcddev.width=lcddev.height;
lcddev.height=temp;
}
}else
{
if(lcddev.width>lcddev.height)//½»»»X,Y
{
temp=lcddev.width;
lcddev.width=lcddev.height;
lcddev.height=temp;
}
}
}
if(lcddev.id==0X5510)
{
LCD_WR_REG(lcddev.setxcmd);LCD_WR_DATA(0);
LCD_WR_REG(lcddev.setxcmd+1);LCD_WR_DATA(0);
LCD_WR_REG(lcddev.setxcmd+2);LCD_WR_DATA((lcddev.width-1)>>8);
LCD_WR_REG(lcddev.setxcmd+3);LCD_WR_DATA((lcddev.width-1)&0XFF);
LCD_WR_REG(lcddev.setycmd);LCD_WR_DATA(0);
LCD_WR_REG(lcddev.setycmd+1);LCD_WR_DATA(0);
LCD_WR_REG(lcddev.setycmd+2);LCD_WR_DATA((lcddev.height-1)>>8);
LCD_WR_REG(lcddev.setycmd+3);LCD_WR_DATA((lcddev.height-1)&0XFF);
}else
{
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(0);LCD_WR_DATA(0);
LCD_WR_DATA((lcddev.width-1)>>8);LCD_WR_DATA((lcddev.width-1)&0XFF);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(0);LCD_WR_DATA(0);
LCD_WR_DATA((lcddev.height-1)>>8);LCD_WR_DATA((lcddev.height-1)&0XFF);
}
}
}
//»­µã
//x,y:×ø±ê
//POINT_COLOR:´ËµãµÄÑÕÉ«
void LCD_DrawPoint(u16 x,u16 y)
{
LCD_SetCursor(x,y); //ÉèÖùâ±êλÖÃ
LCD_WriteRAM_Prepare(); //¿ªÊ¼Ð´ÈëGRAM
LCD->LCD_RAM=POINT_COLOR;
}
//¿ìËÙ»­µã
//x,y:×ø±ê
//color:ÑÕÉ«
void LCD_Fast_DrawPoint(u16 x,u16 y,u32 color)
{
if(lcddev.id==0X9341||lcddev.id==0X5310)
{
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(x>>8);LCD_WR_DATA(x&0XFF);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(y>>8);LCD_WR_DATA(y&0XFF);
}else if(lcddev.id==0X5510)
{
LCD_WR_REG(lcddev.setxcmd);LCD_WR_DATA(x>>8);
LCD_WR_REG(lcddev.setxcmd+1);LCD_WR_DATA(x&0XFF);
LCD_WR_REG(lcddev.setycmd);LCD_WR_DATA(y>>8);
LCD_WR_REG(lcddev.setycmd+1);LCD_WR_DATA(y&0XFF);
}else if(lcddev.id==0X1963)
{
if(lcddev.dir==0)x=lcddev.width-1-x;
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(x>>8);LCD_WR_DATA(x&0XFF);
LCD_WR_DATA(x>>8);LCD_WR_DATA(x&0XFF);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(y>>8);LCD_WR_DATA(y&0XFF);
LCD_WR_DATA(y>>8);LCD_WR_DATA(y&0XFF);
}
LCD->LCD_REG=lcddev.wramcmd;
LCD->LCD_RAM=color;
}
//SSD1963 ±³¹âÉèÖÃ
//pwm:±³¹âµÈ¼¶,0~100.Ô½´óÔ½ÁÁ.
void LCD_SSD_BackLightSet(u8 pwm)
{
LCD_WR_REG(0xBE); //ÅäÖÃ
WMÊä³ö
LCD_WR_DATA(0x05); //1ÉèÖÃ
WMƵÂÊ
LCD_WR_DATA(pwm*2.55);//2ÉèÖÃ
WMÕ¼¿Õ±È
LCD_WR_DATA(0x01); //3ÉèÖÃC
LCD_WR_DATA(0xFF); //4ÉèÖÃD
LCD_WR_DATA(0x00); //5ÉèÖÃE
LCD_WR_DATA(0x00); //6ÉèÖÃF
}
//ÉèÖÃLCDÏÔʾ·½Ïò
//dir:0,ÊúÆÁ£»1,ºáÆÁ
void LCD_Display_Dir(u8 dir)
{
lcddev.dir=dir; //ÊúÆÁ/ºáÆÁ
if(dir==0) //ÊúÆÁ
{
lcddev.width=240;
lcddev.height=320;
if(lcddev.id==0X9341||lcddev.id==0X5310)
{
lcddev.wramcmd=0X2C;
lcddev.setxcmd=0X2A;
lcddev.setycmd=0X2B;
if(lcddev.id==0X5310)
{
lcddev.width=320;
lcddev.height=480;
}
}else if(lcddev.id==0x5510)
{
lcddev.wramcmd=0X2C00;
lcddev.setxcmd=0X2A00;
lcddev.setycmd=0X2B00;
lcddev.width=480;
lcddev.height=800;
}else if(lcddev.id==0X1963)
{
lcddev.wramcmd=0X2C; //ÉèÖÃдÈëGRAMµÄÖ¸Áî
lcddev.setxcmd=0X2B; //ÉèÖÃдX×ø±êÖ¸Áî
lcddev.setycmd=0X2A; //ÉèÖÃдY×ø±êÖ¸Áî
lcddev.width=480; //ÉèÖÿí¶È480
lcddev.height=800; //ÉèÖø߶È800
}
}else //ºáÆÁ
{
lcddev.width=320;
lcddev.height=240;
if(lcddev.id==0X9341||lcddev.id==0X5310)
{
lcddev.wramcmd=0X2C;
lcddev.setxcmd=0X2A;
lcddev.setycmd=0X2B;
}else if(lcddev.id==0x5510)
{
lcddev.wramcmd=0X2C00;
lcddev.setxcmd=0X2A00;
lcddev.setycmd=0X2B00;
lcddev.width=800;
lcddev.height=480;
}else if(lcddev.id==0X1963)
{
lcddev.wramcmd=0X2C; //ÉèÖÃдÈëGRAMµÄÖ¸Áî
lcddev.setxcmd=0X2A; //ÉèÖÃдX×ø±êÖ¸Áî
lcddev.setycmd=0X2B; //ÉèÖÃдY×ø±êÖ¸Áî
lcddev.width=800; //ÉèÖÿí¶È800
lcddev.height=480; //ÉèÖø߶È480
}
if(lcddev.id==0X5310)
{
lcddev.width=480;
lcddev.height=320;
}
}
LCD_Scan_Dir(DFT_SCAN_DIR); //ĬÈÏɨÃè·½Ïò
}
//ÉèÖô°¿Ú(¶ÔRGBÆÁÎÞЧ),²¢×Ô¶¯ÉèÖû­µã×ø±êµ½´°¿Ú×óÉϽÇ(sx,sy).
//sx,sy:´°¿ÚÆðʼ×ø±ê(×óÉϽÇ)
//width,height:´°¿Ú¿í¶ÈºÍ¸ß¶È,±ØÐë´óÓÚ0!!
//´°Ìå´óС:width*height.
void LCD_Set_Window(u16 sx,u16 sy,u16 width,u16 height)
{
u16 twidth,theight;
twidth=sx+width-1;
theight=sy+height-1;
if(lcddev.id==0X9341||lcddev.id==0X5310||(lcddev.dir==1&&lcddev.id==0X1963))
{
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(sx>>8);
LCD_WR_DATA(sx&0XFF);
LCD_WR_DATA(twidth>>8);
LCD_WR_DATA(twidth&0XFF);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(sy>>8);
LCD_WR_DATA(sy&0XFF);
LCD_WR_DATA(theight>>8);
LCD_WR_DATA(theight&0XFF);
}else if(lcddev.id==0X1963)//1963ÊúÆÁÌØÊâ´¦Àí
{
sx=lcddev.width-width-sx;
height=sy+height-1;
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(sx>>8);
LCD_WR_DATA(sx&0XFF);
LCD_WR_DATA((sx+width-1)>>8);
LCD_WR_DATA((sx+width-1)&0XFF);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(sy>>8);
LCD_WR_DATA(sy&0XFF);
LCD_WR_DATA(height>>8);
LCD_WR_DATA(height&0XFF);
}else if(lcddev.id==0X5510)
{
LCD_WR_REG(lcddev.setxcmd);LCD_WR_DATA(sx>>8);
LCD_WR_REG(lcddev.setxcmd+1);LCD_WR_DATA(sx&0XFF);
LCD_WR_REG(lcddev.setxcmd+2);LCD_WR_DATA(twidth>>8);
LCD_WR_REG(lcddev.setxcmd+3);LCD_WR_DATA(twidth&0XFF);
LCD_WR_REG(lcddev.setycmd);LCD_WR_DATA(sy>>8);
LCD_WR_REG(lcddev.setycmd+1);LCD_WR_DATA(sy&0XFF);
LCD_WR_REG(lcddev.setycmd+2);LCD_WR_DATA(theight>>8);
LCD_WR_REG(lcddev.setycmd+3);LCD_WR_DATA(theight&0XFF);
}
}
//SRAMµ×²ãÇý¶¯£¬Ê±ÖÓʹÄÜ£¬Òý½Å·ÖÅä
//´Ëº¯Êý»á±»HAL_SRAM_Init()µ÷ÓÃ
//hsram:SRAM¾ä±ú
void HAL_SRAM_MspInit(SRAM_HandleTypeDef *hsram)
{
GPIO_InitTypeDef GPIO_Initure;
__HAL_RCC_FMC_CLK_ENABLE(); //ʹÄÜFMCʱÖÓ
__HAL_RCC_GPIOB_CLK_ENABLE(); //ʹÄÜGPIODʱÖÓ B 0
__HAL_RCC_GPIOD_CLK_ENABLE(); //ʹÄÜGPIODʱÖÓ D 0 1 4 5 7 8 9 10 14 15
__HAL_RCC_GPIOE_CLK_ENABLE(); //ʹÄÜGPIOEʱÖÓ E 7 8 9 10 11 12 13 14 15
__HAL_RCC_GPIOF_CLK_ENABLE(); //ʹÄÜGPIOFʱÖÓ F0
//³õʼ»¯
B0
GPIO_Initure.Pin=GPIO_PIN_0;
GPIO_Initure.Mode=GPIO_MODE_OUTPUT_PP; //ÍÆÍ츴ÓÃ
GPIO_Initure.Pull=GPIO_PULLUP; //ÉÏÀ­
GPIO_Initure.Speed=GPIO_SPEED_HIGH; //¸ßËÙ
HAL_GPIO_Init(GPIOB,&GPIO_Initure); //³õʼ»¯
//³õʼ»¯
D0,1,4,5,7,8,9,10,14,15
GPIO_Initure.Pin=GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7|GPIO_PIN_8|
GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14|GPIO_PIN_15;
GPIO_Initure.Mode=GPIO_MODE_AF_PP; //ÍÆÍ츴ÓÃ
GPIO_Initure.Pull=GPIO_PULLUP; //ÉÏÀ­
GPIO_Initure.Speed=GPIO_SPEED_HIGH; //¸ßËÙ
GPIO_Initure.Alternate=GPIO_AF12_FMC; //¸´ÓÃΪFMC
HAL_GPIO_Init(GPIOD,&GPIO_Initure); //³õʼ»¯
GPIO_Initure.Pin=GPIO_PIN_0; // F0 A0
GPIO_Initure.Mode=GPIO_MODE_AF_PP; //ÍÆÍ츴ÓÃ
GPIO_Initure.Pull=GPIO_PULLUP; //ÉÏÀ­
GPIO_Initure.Speed=GPIO_SPEED_HIGH; //¸ßËÙ
GPIO_Initure.Alternate=GPIO_AF12_FMC; //¸´ÓÃΪFMC
HAL_GPIO_Init(GPIOF,&GPIO_Initure); //³õʼ»¯
//³õʼ»¯
E7,8,9,10,11,12,13,14,15
GPIO_Initure.Pin=GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|
GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
HAL_GPIO_Init(GPIOE,&GPIO_Initure);
}
//³õʼ»¯lcd
//¸Ã³õʼ»¯º¯Êý¿ÉÒÔ³õʼ»¯¸÷ÖÖÐͺŵÄLCD(Ïê¼û±¾.cÎļþ×îÇ°ÃæµÄÃèÊö)
void LCD_Init(void)
{
GPIO_InitTypeDef GPIO_Initure;
FMC_NORSRAM_TimingTypeDef FMC_ReadWriteTim;
FMC_NORSRAM_TimingTypeDef FMC_WriteTim;
SRAM_Handler.Instance=FMC_NORSRAM_DEVICE;
SRAM_Handler.Extended=FMC_NORSRAM_EXTENDED_DEVICE;
SRAM_Handler.Init.NSBank=FMC_NORSRAM_BANK1; //ʹÓÃNE1
SRAM_Handler.Init.DataAddressMux=FMC_DATA_ADDRESS_MUX_DISABLE; //µØÖ·/Êý¾ÝÏß²»¸´ÓÃ
SRAM_Handler.Init.MemoryType=FMC_MEMORY_TYPE_SRAM; //SRAM
SRAM_Handler.Init.MemoryDataWidth=FMC_NORSRAM_MEM_BUS_WIDTH_16; //16λÊý¾Ý¿í¶È
SRAM_Handler.Init.BurstAccessMode=FMC_BURST_ACCESS_MODE_DISABLE; //ÊÇ·ñʹÄÜÍ»·¢·ÃÎÊ,½ö¶Ôͬ²½Í»·¢´æ´¢Æ÷ÓÐЧ,´Ë´¦Î´Óõ½
SRAM_Handler.Init.WaitSignalPolarity=FMC_WAIT_SIGNAL_POLARITY_LOW;//µÈ´ýÐźŵļ«ÐÔ,½öÔÚÍ»·¢Ä£Ê½·ÃÎÊÏÂÓÐÓÃ
SRAM_Handler.Init.WaitSignalActive=FMC_WAIT_TIMING_BEFORE_WS; //´æ´¢Æ÷ÊÇÔڵȴýÖÜÆÚ֮ǰµÄÒ»¸öʱÖÓÖÜÆÚ»¹ÊǵȴýÖÜÆÚÆÚ¼äʹÄÜNWAIT
SRAM_Handler.Init.WriteOperation=FMC_WRITE_OPERATION_ENABLE; //´æ´¢Æ÷дʹÄÜ
SRAM_Handler.Init.WaitSignal=FMC_WAIT_SIGNAL_DISABLE; //µÈ´ýʹÄÜλ,´Ë´¦Î´Óõ½
SRAM_Handler.Init.ExtendedMode=FMC_EXTENDED_MODE_ENABLE; //¶ÁдʹÓò»Í¬µÄʱÐò
SRAM_Handler.Init.AsynchronousWait=FMC_ASYNCHRONOUS_WAIT_DISABLE;//ÊÇ·ñʹÄÜͬ²½´«ÊäģʽϵĵȴýÐźÅ,´Ë´¦Î´Óõ½
SRAM_Handler.Init.WriteBurst=FMC_WRITE_BURST_DISABLE; //½ûֹͻ·¢Ð´
SRAM_Handler.Init.ContinuousClock=FMC_CONTINUOUS_CLOCK_SYNC_ASYNC;
//FMC¶ÁʱÐò¿ØÖƼĴæÆ÷
FMC_ReadWriteTim.AddressSetupTime=0x0F; //µØÖ·½¨Á¢Ê±¼ä(ADDSET)Ϊ15¸öHCLK 1/180M*15=5.5ns*15=82.5ns
FMC_ReadWriteTim.AddressHoldTime=0x00;
FMC_ReadWriteTim.DataSetupTime=0x46; //Êý¾Ý±£´æʱ¼ä(DATAST)Ϊ70¸öHCLK =5.5*70=385ns
FMC_ReadWriteTim.AccessMode=FMC_ACCESS_MODE_A; //ģʽA
//FMCдʱÐò¿ØÖƼĴæÆ÷
FMC_WriteTim.AddressSetupTime=0x0F; //µØÖ·½¨Á¢Ê±¼ä(ADDSET)Ϊ15¸öHCLK=82.5ns
FMC_WriteTim.AddressHoldTime=0x00;
FMC_WriteTim.DataSetupTime=0x0F; //Êý¾Ý±£´æʱ¼ä(DATAST)Ϊ5.5ns*15¸öHCLK=82.5ns
FMC_WriteTim.AccessMode=FMC_ACCESS_MODE_A; //ģʽA
HAL_SRAM_Init(&SRAM_Handler,&FMC_ReadWriteTim,&FMC_WriteTim);
delay_ms(50); // delay 50 ms
lcddev.id=0X5510;
if(lcddev.id==0X9341) //9341³õʼ»¯
{
;
}else if(lcddev.id==0x5310)
{
;
}else if(lcddev.id==0x5510)
{
LCD_WriteReg(0xF000,0x55);
LCD_WriteReg(0xF001,0xAA);
LCD_WriteReg(0xF002,0x52);
LCD_WriteReg(0xF003,0x08);
LCD_WriteReg(0xF004,0x01);
//AVDD Set AVDD 5.2V
LCD_WriteReg(0xB000,0x0D);
LCD_WriteReg(0xB001,0x0D);
LCD_WriteReg(0xB002,0x0D);
//AVDD ratio
LCD_WriteReg(0xB600,0x34);
LCD_WriteReg(0xB601,0x34);
LCD_WriteReg(0xB602,0x34);
//AVEE -5.2V
LCD_WriteReg(0xB100,0x0D);
LCD_WriteReg(0xB101,0x0D);
LCD_WriteReg(0xB102,0x0D);
//AVEE ratio
LCD_WriteReg(0xB700,0x34);
LCD_WriteReg(0xB701,0x34);
LCD_WriteReg(0xB702,0x34);
//VCL -2.5V
LCD_WriteReg(0xB200,0x00);
LCD_WriteReg(0xB201,0x00);
LCD_WriteReg(0xB202,0x00);
//VCL ratio
LCD_WriteReg(0xB800,0x24);
&n
都用上了 f7了啊,土豪啊
一周热门 更多>