1、FSMC初初了解:
FSMC 包括4個(gè)模塊:
(2)NOR閃存和PSRAM控制器(驅(qū)動(dòng)LCD的時(shí)候LCD就好像一個(gè)PSRAM的里面只有2個(gè)16位的存儲(chǔ)空間,一個(gè)是DATA RAM 一個(gè)是CMD RAM)
(3)NAND閃存和PC卡控制器
(4)外部設(shè)備接口
我們驅(qū)動(dòng)TFT很明顯用的是第二個(gè)模塊:NOR閃存。
2、FSMC的外設(shè)地址選擇
FSMC _Bank 用來選擇外接存儲(chǔ)器的地址,F(xiàn)SMC所控制的外存儲(chǔ)器所映射的地址是0x6000 0000 ~ 0x9fff ffff
其中屬于NOR FLASH 的是0x6000 0000 ~ 0x6fff ffff ,然后這部分的地址空間又被分為四份,每份64MB, 編號(hào)是BANK1 ~ BANK 4 ,每個(gè)BANK 都有一個(gè)片選引腳。
而這四個(gè)分存儲(chǔ)塊的片選,則使用NE[4:1]來選擇。數(shù)據(jù)線/地址線/控制線是共享的。
NE1 ->Bank1 ? NE2->Bank2 ?NE3->Bank3 ?NE4->Bank4
第一塊:6000 0000h--63ff ffffh?
第二塊:6400 0000h--67ff ffffh
第三塊:6800 0000h--6bff ffffh
第四塊:6c00 0000h--6fff ffffh
3、FSMC 驅(qū)動(dòng)LCD
FSMC提供了所有的LCD控制器的信號(hào):
FSMC_D[16:0]:16bit的數(shù)據(jù)總線
FSMC NEx:分配給NOR的256M,再分為4個(gè)區(qū),每個(gè)區(qū)用來分配一個(gè)外設(shè),這四個(gè)外設(shè)的片選分為是NE1-NE4,對(duì)應(yīng)的引腳為:PD7—NE1,PG9—NE2,PG10-NE3,PG12—NE4
FSMC NOE:輸出使能,連接LCD的RD腳。
FSMC NWE:寫使能,連接LCD的RW腳。
FSMC Ax:用在LCD顯示RAM和寄存器之間進(jìn)行選擇的地址線,即該線用于選擇LCD的RS腳,該線可用地址線的任意一根線,范圍:FSMC_A[25:0]。
正如我們操作12864的命令/數(shù)據(jù)選擇端口RS一樣,對(duì)于FSMC驅(qū)動(dòng)TFT :RS = 0時(shí),表示讀寫寄存器;RS = 1表示讀寫數(shù)據(jù)RAM。
4、GPIO端口配置
由于是使用FSMC來驅(qū)動(dòng)TFT的,所以除了背光用的PD13和復(fù)位用的PC1要設(shè)置為通用推挽輸出之外,其他引腳都必須設(shè)置為復(fù)用推挽輸出。然而,很奇怪的是。當(dāng)我配置好PD13時(shí),我發(fā)現(xiàn)程序下載進(jìn)去后是一片漆黑的,后來再三檢查是背光的PD13的問題。必須把PD13置高才可以亮,否則默認(rèn)低電平,就是一片黑了。
5、 具體程序
/*******************************************************************************
* Function Name ?: Lcd_Configuration
* Description ? ?: Configures LCD Control lines
* Input ? ? ? ? ?: None
* Output ? ? ? ? : None
* Return ? ? ? ? : None
* Attention ?: None
*******************************************************************************/
static void LCD_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable GPIOD and GPIOE clocks */
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE, ENABLE); ?
/* PE.00(D0), PE.01(D1), PE.02(D2), PE.03(D3), PE.04(D4), PE.05(D5), PE.06(D6), PE.07(D7), PE.08(D8)
PE.09(D9), PE.10(D10), PE.11(D11), PE.12(D12), PE.13(D13), PE.14(D14), PE.15(D15) ? */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/* PD.13(RS), PD.14(WR), PD.15(RD) */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* PD.12(CS)*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
}
/*******************************************************************************
* Function Name ?: LCD_WriteReg
* Description ? ?: LCD控制器寄存器地址
* Input ? ? ? ? ?: - index: 寄存器地址
* Output ? ? ? ? : None
* Return ? ? ? ? : None
* Attention ?: None
*******************************************************************************/
__inline void LCD_WriteIndex(uint16_t index)
{
Clr_Rs;
Set_nRd;
GPIOE->ODR = index; ?/* GPIO_Write(GPIOE,index); */
Clr_nWr;
Set_nWr;
}
/*******************************************************************************
* Function Name ?: LCD_WriteReg
* Description ? ?: LCD寄存器數(shù)據(jù)
* Input ? ? ? ? ?: - index: 寄存器數(shù)據(jù)
* Output ? ? ? ? : None
* Return ? ? ? ? : None
* Attention ?: None
*******************************************************************************/
__inline void LCD_WriteData(uint16_t data)
{
Set_Rs;
GPIOE->ODR = data; ?/* GPIO_Write(GPIOE,data); */
Clr_nWr;
Set_nWr;
}
/*******************************************************************************
* Function Name ?: LCD_ReadData
* Description ? ?: 讀取控制器數(shù)據(jù)
* Input ? ? ? ? ?: None
* Output ? ? ? ? : None
* Return ? ? ? ? : 返回讀取到的數(shù)據(jù)
* Attention ?: None
*******************************************************************************/
__inline uint16_t LCD_ReadData(void)
{?
uint16_t value;
Set_Rs;
Set_nWr;
Clr_nRd;
GPIOE->CRH = 0x44444444;
GPIOE->CRL = 0x44444444;
value = GPIOE->IDR;
value = GPIOE->IDR;
GPIOE->CRH = 0x33333333;
GPIOE->CRL = 0x33333333;
Set_nRd;
return value;
}
__inline void LCD_WriteReg(uint16_t LCD_Reg,uint16_t LCD_RegValue)
{?
/* Write 16-bit Index, then Write Reg */ ?
Clr_Cs;
LCD_WriteIndex(LCD_Reg); ? ? ? ??
/* Write 16-bit Reg */
LCD_WriteData(LCD_RegValue); ?
Set_Cs;?
}
__inline uint16_t LCD_ReadReg(uint16_t LCD_Reg)
{
uint16_t LCD_RAM;
/* Write 16-bit Index (then Read Reg) */
Clr_Cs;
LCD_WriteIndex(LCD_Reg);
/* Read 16-bit Reg */
LCD_RAM = LCD_ReadData(); ? ? ??
Set_Cs;
return LCD_RAM;
}
static void LCD_SetCursor( uint16_t Xpos, uint16_t Ypos )
{
#if ?( DISP_ORIENTATION == 90 ) || ( DISP_ORIENTATION == 270 )
uint16_t temp = Xpos;
Xpos = Ypos;
Ypos = ( MAX_X - 1 ) - temp; ?
#elif ?( DISP_ORIENTATION == 0 ) || ( DISP_ORIENTATION == 180 )
#endif
LCD_WriteReg(0x004e, Xpos ); ? ? ?
LCD_WriteReg(0x004f, Ypos ); ? ? ? ? ?
}
static void delay_ms(uint16_t ms) ? ?
{?
uint16_t i,j;?
for( i = 0; i < ms; i++ )
{?
for( j = 0; j < 1141; j++ );
}
}?
void LCD_Initializtion(void)
{
LCD_Configuration();
// DeviceCode = LCD_ReadReg(0x0000);
/* 讀取屏ID */
LCD_WriteReg(0x0000,0x0001); ? ?delay_ms(50); ? /* 打開晶振 ,內(nèi)部晶振500k*/
LCD_WriteReg(0x0003,0xA8A4); ? ?delay_ms(50); ??
LCD_WriteReg(0x000C,0x0000); ? ?delay_ms(50); ??
LCD_WriteReg(0x000D,0x080C); ? ?delay_ms(50); ??
LCD_WriteReg(0x000E,0x2B00); ? ?delay_ms(50); ??
LCD_WriteReg(0x001E,0x00B0); ? ?delay_ms(50); ??
LCD_WriteReg(0x0001,0x2B3F); ? ?delay_ms(50); ? /* 驅(qū)動(dòng)輸出控制320*240 0x2B3F */
LCD_WriteReg(0x0002,0x0600); ? ?delay_ms(50);
LCD_WriteReg(0x0010,0x0000); ? ?delay_ms(50);
LCD_WriteReg(0x0011,0x6070); ? ?delay_ms(50); ? /* 定義數(shù)據(jù)格式 16位色 橫屏 0x6070 */
LCD_WriteReg(0x0005,0x0000); ? ?delay_ms(50);
LCD_WriteReg(0x0006,0x0000); ? ?delay_ms(50);
LCD_WriteReg(0x0016,0xEF1C); ? ?delay_ms(50);
LCD_WriteReg(0x0017,0x0003); ? ?delay_ms(50);
LCD_WriteReg(0x0007,0x0133); ? ?delay_ms(50); ? ? ? ??
LCD_WriteReg(0x000B,0x0000); ? ?delay_ms(50);
LCD_WriteReg(0x000F,0x0000); ? ?delay_ms(50); ? /* 掃描開始地址 */
LCD_WriteReg(0x0041,0x0000); ? ?delay_ms(50);
LCD_WriteReg(0x0042,0x0000); ? ?delay_ms(50);
LCD_WriteReg(0x0048,0x0000); ? ?delay_ms(50);
LCD_WriteReg(0x0049,0x013F); ? ?delay_ms(50);
LCD_WriteReg(0x004A,0x0000); ? ?delay_ms(50);
LCD_WriteReg(0x004B,0x0000); ? ?delay_ms(50);
LCD_WriteReg(0x0044,0xEF00); ? ?delay_ms(50);
LCD_WriteReg(0x0045,0x0000); ? ?delay_ms(50);
LCD_WriteReg(0x0046,0x013F); ? ?delay_ms(50);
LCD_WriteReg(0x0030,0x0707); ? ?delay_ms(50);
LCD_WriteReg(0x0031,0x0204); ? ?delay_ms(50);
LCD_WriteReg(0x0032,0x0204); ? ?delay_ms(50);
LCD_WriteReg(0x0033,0x0502); ? ?delay_ms(50);
LCD_WriteReg(0x0034,0x0507); ? ?delay_ms(50);
LCD_WriteReg(0x0035,0x0204); ? ?delay_ms(50);
LCD_WriteReg(0x0036,0x0204); ? ?delay_ms(50);
LCD_WriteReg(0x0037,0x0502); ? ?delay_ms(50);
LCD_WriteReg(0x003A,0x0302); ? ?delay_ms(50);
LCD_WriteReg(0x003B,0x0302); ? ?delay_ms(50);
LCD_WriteReg(0x0023,0x0000); ? ?delay_ms(50);
LCD_WriteReg(0x0024,0x0000); ? ?delay_ms(50);
LCD_WriteReg(0x0025,0x8000); ? ?delay_ms(50);
LCD_WriteReg(0x004f,0); ? ? ? ?/* 行首址0 */
LCD_WriteReg(0x004e,0); //列首址0
}else if(DeviceCode==0x4531){
LCD_WriteReg(0X00,0X0001);
LCD_Delay(50);
LCD_WriteReg(0X10,0X1628);
LCD_WriteReg(0X12,0X000e);//0x0006
LCD_WriteReg(0X13,0X0A39);
LCD_Delay(10);
LCD_WriteReg(0X11,0X0040);
LCD_WriteReg(0X15,0X0050);
LCD_Delay(40);
LCD_WriteReg(0X12,0X001e);//16
LCD_Delay(40);
LCD_WriteReg(0X10,0X1620);
LCD_WriteReg(0X13,0X2A39);
LCD_Delay(10);
LCD_WriteReg(0X01,0X0100);
LCD_WriteReg(0X02,0X0300);
LCD_WriteReg(0X03,0X1030);//改變方向的
LCD_WriteReg(0X08,0X0202);
LCD_WriteReg(0X0A,0X0008);
LCD_WriteReg(0X30,0X0000);
LCD_WriteReg(0X31,0X0402);
LCD_WriteReg(0X32,0X0106);
LCD_WriteReg(0X33,0X0503);
LCD_WriteReg(0X34,0X0104);
LCD_WriteReg(0X35,0X0301);
LCD_WriteReg(0X36,0X0707);
LCD_WriteReg(0X37,0X0305);
LCD_WriteReg(0X38,0X0208);
LCD_WriteReg(0X39,0X0F0B);
LCD_WriteReg(0X41,0X0002);
LCD_WriteReg(0X60,0X2700);
LCD_WriteReg(0X61,0X0001);
LCD_WriteReg(0X90,0X0210);
LCD_WriteReg(0X92,0X010A);
LCD_WriteReg(0X93,0X0004);
LCD_WriteReg(0XA0,0X0100);
LCD_WriteReg(0X07,0X0001);
LCD_WriteReg(0X07,0X0021);
LCD_WriteReg(0X07,0X0023);
LCD_WriteReg(0X07,0X0033);
LCD_WriteReg(0X07,0X0133);
LCD_WriteReg(0XA0,0X0000);
}
LCD_Delay(5000);
Set_LED;//點(diǎn)亮背光
LCD_Clear(WHITE);
}
//清屏函數(shù)
//Color:要清屏的填充色
void LCD_Clear(u16 Color)
{
u32 index=0;
LCD_SetCursor(0x00,0x0000);//設(shè)置光標(biāo)位置
LCD_WriteRAM_Prepare(); //開始寫入GRAM
for(index=0;index《76800;index++)
{
LCD_WR_DATA(Color); //向每個(gè)GRAM寫入數(shù)據(jù)
}
}
//在指定區(qū)域內(nèi)填充指定顏色
//區(qū)域大?。?/p>
// (xend-xsta)*(yend-ysta)
void LCD_Fill(u8 xsta,u16 ysta,u8 xend,u16 yend,u16 color)
{
#if USE_HORIZONTAL //橫屏
u16 colortemp=POINT_COLOR;
u16 ytemp=ysta;
POINT_COLOR=color;
for(;xsta《=xend;xsta++)
{
for(;ysta《=yend;ysta++)LCD_DrawPoint(xsta,ysta);
ysta=ytemp;
}
POINT_COLOR=colortemp;
#else //豎屏
u32 n;
//設(shè)置窗口
LCD_WriteReg(R80, xsta); //水平方向GRAM起始地址
LCD_WriteReg(R81, xend); //水平方向GRAM結(jié)束地址
LCD_WriteReg(R82, ysta); //垂直方向GRAM起始地址
LCD_WriteReg(R83, yend); //垂直方向GRAM結(jié)束地址
LCD_SetCursor(xsta,ysta);//設(shè)置光標(biāo)位置
LCD_WriteRAM_Prepare(); //開始寫入GRAM
n=(u32)(yend-ysta+1)*(xend-xsta+1);
while(n--){LCD_WR_DATA(color);}//顯示所填充的顏色。
//恢復(fù)設(shè)置
LCD_WriteReg(R80, 0x0000); //水平方向GRAM起始地址
LCD_WriteReg(R81, (LCD_WIDTH-1)); //水平方向GRAM結(jié)束地址
LCD_WriteReg(R82, 0x0000); //垂直方向GRAM起始地址
LCD_WriteReg(R83, (LCD_HEIGHT-1)); //垂直方向GRAM結(jié)束地址
#endif
}
//畫線
//x1,y1:起點(diǎn)坐標(biāo)
//x2,y2:終點(diǎn)坐標(biāo)
void LCD_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2)
{
u16 t;
int xerr=0,yerr=0,delta_x,delta_y,distance;
int incx,incy,uRow,uCol;
delta_x=x2-x1; //計(jì)算坐標(biāo)增量
delta_y=y2-y1;
uRow=x1;
uCol=y1;
if(delta_x》0)incx=1; //設(shè)置單步方向
else if(delta_x==0)incx=0;//垂直線
else {incx=-1;delta_x=-delta_x;} //終點(diǎn)坐標(biāo)小于起始坐標(biāo),反方向,將坐標(biāo)重新定位為正坐標(biāo)
if(delta_y》0)incy=1;
else if(delta_y==0)incy=0;//水平線
else{incy=-1;delta_y=-delta_y;} //終點(diǎn)坐標(biāo)小于起始坐標(biāo),反方向,將坐標(biāo)重新定位為正坐標(biāo)
if( delta_x》delta_y)distance=delta_x; //選取基本增量坐標(biāo)軸
else distance=delta_y;
for(t=0;t《=distance+1;t++ )//畫線輸出
{
LCD_DrawPoint(uRow,uCol);//根據(jù)坐標(biāo)畫點(diǎn)
xerr+=delta_x ; //X坐標(biāo)增量
yerr+=delta_y ; //Y坐標(biāo)增量
if(xerr》distance)
{
xerr-=distance;
uRow+=incx;
}
if(yerr》distance)
{
yerr-=distance;
uCol+=incy;
}
}
}
//畫矩形
void LCD_DrawRectangle(u8 x1, u16 y1, u8 x2, u16 y2)
{
LCD_DrawLine(x1,y1,x2,y1);
LCD_DrawLine(x1,y1,x1,y2);
LCD_DrawLine(x1,y2,x2,y2);
LCD_DrawLine(x2,y1,x2,y2);
}
//在指定位置畫一個(gè)指定大小的圓
//(x,y):中心點(diǎn)
//r :半徑
void Draw_Circle(u8 x0,u16 y0,u8 r)
{
int a,b;
int di;
a=0;b=r;
di=3-(r《《1); //判斷下個(gè)點(diǎn)位置的標(biāo)志
while(a《=b)
{
LCD_DrawPoint(x0-b,y0-a); //3
LCD_DrawPoint(x0+b,y0-a); //0
LCD_DrawPoint(x0-a,y0+b); //1
LCD_DrawPoint(x0-b,y0-a); //7
LCD_DrawPoint(x0-a,y0-b); //2
LCD_DrawPoint(x0+b,y0+a); //4
LCD_DrawPoint(x0+a,y0-b); //5
LCD_DrawPoint(x0+a,y0+b); //6
LCD_DrawPoint(x0-b,y0+a);
a++;
//使用Bresenham算法畫圓
if(di《0){
di +=4*a+6;
}else{
di+=10+4*(a-b);
b--;
}
LCD_DrawPoint(x0+a,y0+b);
}
}
//在指定位置顯示一個(gè)字符
//x:0~234
//y:0~308
//num:要顯示的字符:“ ”---》“~”
//size:字體大小 12/16
//mode:疊加方式(1)還是非疊加方式(0)
void LCD_ShowChar(u8 x,u16 y,u8 num,u8 size,u8 mode)
{
#if USE_HORIZONTAL
#define MAX_CHAR_POSX 312
#define MAX_CHAR_POSY 232
u8 temp;
u8 pos,t;
u16 x0=x;
u16 colortemp=POINT_COLOR;
if(x》MAX_CHAR_POSX||y》MAX_CHAR_POSY)return;
//設(shè)置窗口
num=num-‘ ’;//得到偏移后的值
if(!mode) //非疊加方式
{
for(pos=0;pos《size;pos++)
{
if(size==12)
temp=asc2_1206[num][pos];//調(diào)用1206字體
else
temp=asc2_1608[num][pos]; //調(diào)用1608字體
for(t=0;t《size/2;t++)
{
if(temp&0x01)
POINT_COLOR=colortemp;
else
POINT_COLOR=BACK_COLOR;
LCD_DrawPoint(x,y);
temp》》=1;
x++;
}
x=x0;
y++;
}
}else{ //疊加方式
for(pos=0;pos《size;pos++)
{
if(size==12)
temp=asc2_1206[num][pos];//調(diào)用1206字體
else
temp=asc2_1608[num][pos]; //調(diào)用1608字體
for(t=0;t《size/2;t++)
{
if(temp&0x01)LCD_DrawPoint(x+t,y+pos);//畫一個(gè)點(diǎn)
temp》》=1;
}
}
}
POINT_COLOR=colortemp;
#else
#define MAX_CHAR_POSX 232
#define MAX_CHAR_POSY 304
u8 temp;
u8 pos,t;
if(x》MAX_CHAR_POSX||y》MAX_CHAR_POSY)return;
//設(shè)置窗口
LCD_WriteReg(R80,x); //水平方向GRAM起始地址
LCD_WriteReg(R81,x+(size/2-1));//水平方向GRAM結(jié)束地址
LCD_WriteReg(R82,y); //垂直方向GRAM起始地址
LCD_WriteReg(R83,y+size-1); //垂直方向GRAM結(jié)束地址
LCD_SetCursor(x,y); //設(shè)置光標(biāo)位置
LCD_WriteRAM_Prepare(); //開始寫入GRAM
num=num-‘ ’;//得到偏移后的值
if(!mode) //非疊加方式
{
for(pos=0;pos《size;pos++)
{
if(size==12)
temp=asc2_1206[num][pos];//調(diào)用1206字體
else
temp=asc2_1608[num][pos]; //調(diào)用1608字體
for(t=0;t《size/2;t++)
{
if(temp&0x01){
LCD_WR_DATA(POINT_COLOR);
}else{
LCD_WR_DATA(BACK_COLOR);
}
temp》》=1;
}
}
}else{ //疊加方式
for(pos=0;pos《size;pos++)
{
if(size==12)
temp=asc2_1206[num][pos]; //調(diào)用1206字體
else
temp=asc2_1608[num][pos]; //調(diào)用1608字體
for(t=0;t《size/2;t++)
{
if(temp&0x01)
LCD_DrawPoint(x+t,y+pos);//畫一個(gè)點(diǎn)
temp》》=1;
}
}
}
//恢復(fù)窗體大小
LCD_WriteReg(R80, 0x0000); //水平方向GRAM起始地址
LCD_WriteReg(R81, (LCD_WIDTH-1)); //水平方向GRAM結(jié)束地址
LCD_WriteReg(R82, 0x0000); //垂直方向GRAM起始地址
LCD_WriteReg(R83, (LCD_HEIGHT-1)); //垂直方向GRAM結(jié)束地址
#endif
}
//m^n函數(shù)
u32 mypow(u8 m,u8 n)
{
u32 result=1;
while(n--)result*=m;
return result;
}
//顯示數(shù)字
//x,y :起點(diǎn)坐標(biāo)
//len :數(shù)字的位數(shù)
//size:字體大小
//color:顏色
//num:數(shù)值(0~4294967295);
void LCD_ShowNum(u8 x,u16 y,u32 num,u8 len,u8 size)
{
u8 t,temp;
u8 enshow=0;
for(t=0;t《len;t++)
{
temp=(num/mypow(10,len-t-1))%10;
if(enshow==0&&t《(len-1))
{
if(temp==0)
{
LCD_ShowChar(x+(size/2)*t,y,‘ ’,size,0);
continue;
}else{
enshow=1;
}
}
LCD_ShowChar(x+(size/2)*t,y,temp+‘0’,size,0);
}
}
//顯示字符串
//x,y:起點(diǎn)坐標(biāo)
//*p:字符串起始地址
//用16字體
void LCD_ShowString(u8 x,u16 y,const u8 *p)
{
while(*p!=‘\0’) //字符串到達(dá)結(jié)束
{
if(x》MAX_CHAR_POSX){x=0;y+=16;} //換行
if(y》MAX_CHAR_POSY){y=x=0;LCD_Clear(WHITE);} //超出屏幕顯示范圍
LCD_ShowChar(x,y,*p,16,0);
x+=8;
p++;
}
}
LCD/ili93xx.h (相關(guān)I/O操作在此文件中以宏定義的方式實(shí)現(xiàn))
?。踓pp] view plain copy#include “stm32f10x.h”
//TFTLCD部分外要調(diào)用的函數(shù)
extern u16 POINT_COLOR;//默認(rèn)紅色
extern u16 BACK_COLOR; //背景顏色。默認(rèn)為白色
//定義LCD的尺寸
#define LCD_WIDTH 240
#define LCD_HEIGHT 320
//9320/9325 LCD寄存器
#define R0 0x00
#define R1 0x01
#define R2 0x02
#define R3 0x03
#define R4 0x04
#define R5 0x05
#define R6 0x06
#define R7 0x07
#define R8 0x08
#define R9 0x09
#define R10 0x0A
#define R12 0x0C
#define R13 0x0D
#define R14 0x0E
#define R15 0x0F
#define R16 0x10
#define R17 0x11
#define R18 0x12
#define R19 0x13
#define R20 0x14
#define R21 0x15
#define R22 0x16
#define R23 0x17
#define R24 0x18
#define R25 0x19
#define R26 0x1A
#define R27 0x1B
#define R28 0x1C
#define R29 0x1D
#define R30 0x1E
#define R31 0x1F
#define R32 0x20
#define R33 0x21
#define R34 0x22
#define R36 0x24
#define R37 0x25
#define R40 0x28
#define R41 0x29
#define R43 0x2B
#define R45 0x2D
#define R48 0x30
#define R49 0x31
#define R50 0x32
#define R51 0x33
#define R52 0x34
#define R53 0x35
#define R54 0x36
#define R55 0x37
#define R56 0x38
#define R57 0x39
#define R59 0x3B
#define R60 0x3C
#define R61 0x3D
#define R62 0x3E
#define R63 0x3F
#define R64 0x40
#define R65 0x41
#define R66 0x42
#define R67 0x43
#define R68 0x44
#define R69 0x45
#define R70 0x46
#define R71 0x47
#define R72 0x48
#define R73 0x49
#define R74 0x4A
#define R75 0x4B
#define R76 0x4C
#define R77 0x4D
#define R78 0x4E
#define R79 0x4F
#define R80 0x50
#define R81 0x51
#define R82 0x52
#define R83 0x53
#define R96 0x60
#define R97 0x61
#define R106 0x6A
#define R118 0x76
#define R128 0x80
#define R129 0x81
#define R130 0x82
#define R131 0x83
#define R132 0x84
#define R133 0x85
#define R134 0x86
#define R135 0x87
#define R136 0x88
#define R137 0x89
#define R139 0x8B
#define R140 0x8C
#define R141 0x8D
#define R143 0x8F
#define R144 0x90
#define R145 0x91
#define R146 0x92
#define R147 0x93
#define R148 0x94
#define R149 0x95
#define R150 0x96
#define R151 0x97
#define R152 0x98
#define R153 0x99
#define R154 0x9A
#define R157 0x9D
#define R192 0xC0
#define R193 0xC1
#define R229 0xE5
/*硬件相關(guān)的宏定義*/
#define LCD_FAST_IO 1 //定義是否使用快速IO 建議使用快速IO,效率更高
//-----------------LCD端口定義----------------
/********************************************************************************/
#define LCD_GPIO_LED_PORT GPIOC
#define LCD_GPIO_LED_PIN GPIO_Pin_10
#define LCD_GPIO_CS_PORT GPIOC
#define LCD_GPIO_CS_PIN GPIO_Pin_9
#define LCD_GPIO_RS_PORT GPIOC
#define LCD_GPIO_RS_PIN GPIO_Pin_8
#define LCD_GPIO_WR_PORT GPIOC
#define LCD_GPIO_WR_PIN GPIO_Pin_7
#define LCD_GPIO_RD_PORT GPIOC
#define LCD_GPIO_RD_PIN GPIO_Pin_6
//16位數(shù)據(jù)所在端口,PB0~15作為數(shù)據(jù)線
#define LCD_GPIO_DATA_PORT GPIOB
#define LCD_GPIO_DATA_PIN GPIO_Pin_All
#if LCD_FAST_IO == 1 //快速IO
#define Set_Cs GPIOC-》BSRR=1《《9 //片選端口 PC9
#define Set_Rs GPIOC-》BSRR=1《《8 //數(shù)據(jù)/命令 PC8
#define Set_Wr GPIOC-》BSRR=1《《7 //寫數(shù)據(jù) PC7
#define Set_Rd GPIOC-》BSRR=1《《6 //讀數(shù)據(jù) PC6
#define Clr_Cs GPIOC-》BRR=1《《9 //片選端口 PC9
#define Clr_Rs GPIOC-》BRR=1《《8 //數(shù)據(jù)/命令 PC8
#define Clr_Wr GPIOC-》BRR=1《《7 //寫數(shù)據(jù) PC7
#define Clr_Rd GPIOC-》BRR=1《《6 //讀數(shù)據(jù) PC6
#else
#define Set_Cs {GPIO_SetBits(LCD_GPIO_CS_PORT,LCD_GPIO_CS_PIN);}
#define Clr_Cs {GPIO_ResetBits(LCD_GPIO_CS_PORT,LCD_GPIO_CS_PIN);}
#define Set_Rs {GPIO_SetBits(LCD_GPIO_RS_PORT,LCD_GPIO_RS_PIN);}
#define Clr_Rs {GPIO_ResetBits(LCD_GPIO_RS_PORT,LCD_GPIO_RS_PIN);}
#define Set_Wr {GPIO_SetBits(LCD_GPIO_WR_PORT,LCD_GPIO_WR_PIN);}
#define Clr_Wr {GPIO_ResetBits(LCD_GPIO_WR_PORT,LCD_GPIO_WR_PIN);}
#define Set_Rd {GPIO_SetBits(LCD_GPIO_RD_PORT,LCD_GPIO_RD_PIN);}
#define Clr_Rd {GPIO_ResetBits(LCD_GPIO_RD_PORT,LCD_GPIO_RD_PIN);}
#endif
#define Set_LED {GPIO_SetBits(LCD_GPIO_LED_PORT,LCD_GPIO_LED_PIN);}
#define Clr_LED {GPIO_ResetBits(LCD_GPIO_LED_PORT,LCD_GPIO_LED_PIN);}
#define Write_Data(DataValue) {GPIO_Write(LCD_GPIO_DATA_PORT,DataValue);}
//直接操作寄存器讀取,使用庫函數(shù)讀取I/O有問題,原因不詳
#define Read_Data() (LCD_GPIO_DATA_PORT -》IDR) //必須使用宏定義,寫成函數(shù)會(huì)有問題
//#define Read_Data() (GPIO_ReadInputData(LCD_GPIO_DATA_PORT)) //這句有問題
//寫8位數(shù)據(jù)函數(shù)
//用宏定義,提高速度。
#define LCD_WR_DATA(data){\
Set_Rs;\
Clr_Cs;\
Write_Data(data);\
Clr_Wr;\
Set_Wr;\
Set_Cs;\
}
/********************************************************************************/
//畫筆顏色
#define WHITE 0xFFFF
#define BLACK 0x0000
#define BLUE 0x001F
#define BRED 0XF81F
#define GRED 0XFFE0
#define GBLUE 0X07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define GREEN 0x07E0
#define CYAN 0x7FFF
#define YELLOW 0xFFE0
#define BROWN 0XBC40 //棕色
#define BRRED 0XFC07 //棕紅色
#define GRAY 0X8430 //灰色
//GUI顏色
#define DARKBLUE 0X01CF //深藍(lán)色
#define LIGHTBLUE 0X7D7C //淺藍(lán)色
#define GRAYBLUE 0X5458 //灰藍(lán)色
//以上三色為PANEL的顏色
#define LIGHTGREEN 0X841F //淺綠色
//#define LIGHTGRAY 0XEF5B //淺灰色(PANNEL)
#define LGRAY 0XC618 //淺灰色(PANNEL),窗體背景色
#define LGRAYBLUE 0XA651 //淺灰藍(lán)色(中間層顏色)
#define LBBLUE 0X2B12 //淺棕藍(lán)色(選擇條目的反色)
void LCD_Delay(u32 nCount);
void LCD_Config(void);
void LCD_DisplayOn(void);
void LCD_DisplayOff(void);
void LCD_Clear(u16 Color);
void LCD_SetCursor(u8 Xpos, u16 Ypos);
void LCD_DrawPoint(u16 x,u16 y);//畫點(diǎn)
u16 LCD_ReadPoint(u16 x,u16 y); //讀點(diǎn)
void Draw_Circle(u8 x0,u16 y0,u8 r);
void LCD_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2);
void LCD_DrawRectangle(u8 x1, u16 y1, u8 x2, u16 y2);
void LCD_Fill(u8 xsta,u16 ysta,u8 xend,u16 yend,u16 color);
void LCD_ShowChar(u8 x,u16 y,u8 num,u8 size,u8 mode);//顯示一個(gè)字符
void LCD_ShowNum(u8 x,u16 y,u32 num,u8 len,u8 size); //顯示一個(gè)數(shù)字
void LCD_ShowString(u8 x,u16 y,const u8 *p); //顯示一個(gè)字符串,16字體
void LCD_WriteReg(u8 LCD_Reg, u16 LCD_RegValue);
u16 LCD_ReadReg(u8 LCD_Reg);
void LCD_WriteRAM_Prepare(void);
void LCD_WriteRAM(u16 RGB_Code);
u16 LCD_ReadRAM(void);
font.h (字庫文件)
?。踓pp] view plain copy
//常用ASCII表
//偏移量32
//ASCII字符集
//偏移量32
//大小:12*6
const unsigned char asc2_1206[95][12]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*“ ”,0*/
{0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x04,0x00,0x00},/*“!”,1*/
{0x00,0x14,0x0A,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*“”“,2*/
{0x00,0x00,0x14,0x14,0x3F,0x14,0x0A,0x3F,0x0A,0x0A,0x00,0x00},/*”#“,3*/
{0x00,0x04,0x1E,0x15,0x05,0x06,0x0C,0x14,0x15,0x0F,0x04,0x00},/*”$“,4*/
{0x00,0x00,0x12,0x15,0x0D,0x0A,0x14,0x2C,0x2A,0x12,0x00,0x00},/*”%“,5*/
{0x00,0x00,0x04,0x0A,0x0A,0x1E,0x15,0x15,0x09,0x36,0x00,0x00},/*”&“,6*/
{0x00,0x02,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”‘“,7*/
{0x00,0x20,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x20,0x00},/*”(“,8*/
{0x00,0x02,0x04,0x08,0x08,0x08,0x08,0x08,0x08,0x04,0x02,0x00},/*”)“,9*/
{0x00,0x00,0x00,0x04,0x15,0x0E,0x0E,0x15,0x04,0x00,0x00,0x00},/*”*“,10*/
{0x00,0x00,0x04,0x04,0x04,0x1F,0x04,0x04,0x04,0x00,0x00,0x00},/*”+“,11*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x01},/*”,“,12*/
{0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00},/*”-“,13*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00},/*”?!埃?4*/
{0x00,0x10,0x08,0x08,0x08,0x04,0x04,0x02,0x02,0x02,0x01,0x00},/*”/“,15*/
{0x00,0x00,0x0E,0x11,0x11,0x11,0x11,0x11,0x11,0x0E,0x00,0x00},/*”0“,16*/
{0x00,0x00,0x04,0x06,0x04,0x04,0x04,0x04,0x04,0x0E,0x00,0x00},/*”1“,17*/
{0x00,0x00,0x0E,0x11,0x11,0x08,0x04,0x02,0x01,0x1F,0x00,0x00},/*”2“,18*/
{0x00,0x00,0x0E,0x11,0x10,0x0C,0x10,0x10,0x11,0x0E,0x00,0x00},/*”3“,19*/
{0x00,0x00,0x08,0x0C,0x0A,0x0A,0x09,0x1E,0x08,0x18,0x00,0x00},/*”4“,20*/
{0x00,0x00,0x1F,0x01,0x01,0x0F,0x10,0x10,0x11,0x0E,0x00,0x00},/*”5“,21*/
{0x00,0x00,0x0E,0x09,0x01,0x0F,0x11,0x11,0x11,0x0E,0x00,0x00},/*”6“,22*/
{0x00,0x00,0x1F,0x09,0x08,0x04,0x04,0x04,0x04,0x04,0x00,0x00},/*”7“,23*/
{0x00,0x00,0x0E,0x11,0x11,0x0E,0x11,0x11,0x11,0x0E,0x00,0x00},/*”8“,24*/
{0x00,0x00,0x0E,0x11,0x11,0x11,0x1E,0x10,0x12,0x0E,0x00,0x00},/*”9“,25*/
{0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x04,0x00,0x00},/*”:“,26*/
{0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x04,0x00},/*”;“,27*/
{0x00,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x00,0x00},/*”《“,28*/
{0x00,0x00,0x00,0x00,0x1F,0x00,0x00,0x1F,0x00,0x00,0x00,0x00},/*”=“,29*/
{0x00,0x02,0x04,0x08,0x10,0x20,0x10,0x08,0x04,0x02,0x00,0x00},/*”》“,30*/
{0x00,0x00,0x0E,0x11,0x11,0x08,0x04,0x04,0x00,0x04,0x00,0x00},/*”?“,31*/
{0x00,0x00,0x0E,0x11,0x19,0x15,0x15,0x1D,0x01,0x1E,0x00,0x00},/*”@“,32*/
{0x00,0x00,0x04,0x04,0x0C,0x0A,0x0A,0x1E,0x12,0x33,0x00,0x00},/*”A“,33*/
{0x00,0x00,0x0F,0x12,0x12,0x0E,0x12,0x12,0x12,0x0F,0x00,0x00},/*”B“,34*/
{0x00,0x00,0x1E,0x11,0x01,0x01,0x01,0x01,0x11,0x0E,0x00,0x00},/*”C“,35*/
{0x00,0x00,0x0F,0x12,0x12,0x12,0x12,0x12,0x12,0x0F,0x00,0x00},/*”D“,36*/
{0x00,0x00,0x1F,0x12,0x0A,0x0E,0x0A,0x02,0x12,0x1F,0x00,0x00},/*”E“,37*/
{0x00,0x00,0x1F,0x12,0x0A,0x0E,0x0A,0x02,0x02,0x07,0x00,0x00},/*”F“,38*/
{0x00,0x00,0x1C,0x12,0x01,0x01,0x39,0x11,0x12,0x0C,0x00,0x00},/*”G“,39*/
{0x00,0x00,0x33,0x12,0x12,0x1E,0x12,0x12,0x12,0x33,0x00,0x00},/*”H“,40*/
{0x00,0x00,0x1F,0x04,0x04,0x04,0x04,0x04,0x04,0x1F,0x00,0x00},/*”I“,41*/
{0x00,0x00,0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x09,0x07,0x00},/*”J“,42*/
{0x00,0x00,0x37,0x12,0x0A,0x06,0x0A,0x0A,0x12,0x37,0x00,0x00},/*”K“,43*/
{0x00,0x00,0x07,0x02,0x02,0x02,0x02,0x02,0x22,0x3F,0x00,0x00},/*”L“,44*/
{0x00,0x00,0x1B,0x1B,0x1B,0x1B,0x15,0x15,0x15,0x15,0x00,0x00},/*”M“,45*/
{0x00,0x00,0x3B,0x12,0x16,0x16,0x1A,0x1A,0x12,0x17,0x00,0x00},/*”N“,46*/
{0x00,0x00,0x0E,0x11,0x11,0x11,0x11,0x11,0x11,0x0E,0x00,0x00},/*”O(jiān)“,47*/
{0x00,0x00,0x0F,0x12,0x12,0x0E,0x02,0x02,0x02,0x07,0x00,0x00},/*”P“,48*/
{0x00,0x00,0x0E,0x11,0x11,0x11,0x11,0x17,0x19,0x0E,0x18,0x00},/*”Q“,49*/
{0x00,0x00,0x0F,0x12,0x12,0x0E,0x0A,0x12,0x12,0x37,0x00,0x00},/*”R“,50*/
{0x00,0x00,0x1E,0x11,0x01,0x06,0x08,0x10,0x11,0x0F,0x00,0x00},/*”S“,51*/
{0x00,0x00,0x1F,0x15,0x04,0x04,0x04,0x04,0x04,0x0E,0x00,0x00},/*”T“,52*/
{0x00,0x00,0x33,0x12,0x12,0x12,0x12,0x12,0x12,0x0C,0x00,0x00},/*”U“,53*/
{0x00,0x00,0x33,0x12,0x12,0x0A,0x0A,0x0C,0x04,0x04,0x00,0x00},/*”V“,54*/
{0x00,0x00,0x15,0x15,0x15,0x0E,0x0A,0x0A,0x0A,0x0A,0x00,0x00},/*”W“,55*/
{0x00,0x00,0x1B,0x0A,0x0A,0x04,0x04,0x0A,0x0A,0x1B,0x00,0x00},/*”X“,56*/
{0x00,0x00,0x1B,0x0A,0x0A,0x04,0x04,0x04,0x04,0x0E,0x00,0x00},/*”Y“,57*/
{0x00,0x00,0x1F,0x09,0x08,0x04,0x04,0x02,0x12,0x1F,0x00,0x00},/*”Z“,58*/
{0x00,0x1C,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x1C,0x00},/*”[“,59*/
{0x00,0x02,0x02,0x02,0x04,0x04,0x08,0x08,0x08,0x10,0x00,0x00},/*”\“,60*/
{0x00,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0E,0x00},/*”]“,61*/
{0x00,0x04,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”^“,62*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F},/*”_“,63*/
{0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”`“,64*/
{0x00,0x00,0x00,0x00,0x00,0x0C,0x12,0x1C,0x12,0x3C,0x00,0x00},/*”a“,65*/
{0x00,0x00,0x03,0x02,0x02,0x0E,0x12,0x12,0x12,0x0E,0x00,0x00},/*”b“,66*/
{0x00,0x00,0x00,0x00,0x00,0x1C,0x12,0x02,0x02,0x1C,0x00,0x00},/*”c“,67*/
{0x00,0x00,0x18,0x10,0x10,0x1C,0x12,0x12,0x12,0x3C,0x00,0x00},/*”d“,68*/
{0x00,0x00,0x00,0x00,0x00,0x0C,0x12,0x1E,0x02,0x1C,0x00,0x00},/*”e“,69*/
{0x00,0x00,0x38,0x04,0x04,0x1E,0x04,0x04,0x04,0x1E,0x00,0x00},/*”f“,70*/
{0x00,0x00,0x00,0x00,0x00,0x3C,0x12,0x0C,0x02,0x1E,0x22,0x1C},/*”g“,71*/
{0x00,0x00,0x03,0x02,0x02,0x0E,0x12,0x12,0x12,0x37,0x00,0x00},/*”h“,72*/
{0x00,0x00,0x04,0x00,0x00,0x06,0x04,0x04,0x04,0x0E,0x00,0x00},/*”i“,73*/
{0x00,0x00,0x08,0x00,0x00,0x0C,0x08,0x08,0x08,0x08,0x08,0x07},/*”j“,74*/
{0x00,0x00,0x03,0x02,0x02,0x3A,0x0A,0x0E,0x12,0x37,0x00,0x00},/*”k“,75*/
{0x00,0x00,0x07,0x04,0x04,0x04,0x04,0x04,0x04,0x1F,0x00,0x00},/*”l“,76*/
{0x00,0x00,0x00,0x00,0x00,0x0F,0x15,0x15,0x15,0x15,0x00,0x00},/*”m“,77*/
{0x00,0x00,0x00,0x00,0x00,0x0F,0x12,0x12,0x12,0x37,0x00,0x00},/*”n“,78*/
{0x00,0x00,0x00,0x00,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00,0x00},/*”o“,79*/
{0x00,0x00,0x00,0x00,0x00,0x0F,0x12,0x12,0x12,0x0E,0x02,0x07},/*”p“,80*/
{0x00,0x00,0x00,0x00,0x00,0x1C,0x12,0x12,0x12,0x1C,0x10,0x38},/*”q“,81*/
{0x00,0x00,0x00,0x00,0x00,0x1B,0x06,0x02,0x02,0x07,0x00,0x00},/*”r“,82*/
{0x00,0x00,0x00,0x00,0x00,0x1E,0x02,0x0C,0x10,0x1E,0x00,0x00},/*”s“,83*/
{0x00,0x00,0x00,0x04,0x04,0x0E,0x04,0x04,0x04,0x18,0x00,0x00},/*”t“,84*/
{0x00,0x00,0x00,0x00,0x00,0x1B,0x12,0x12,0x12,0x3C,0x00,0x00},/*”u“,85*/
{0x00,0x00,0x00,0x00,0x00,0x37,0x12,0x0A,0x0C,0x04,0x00,0x00},/*”v“,86*/
{0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x0E,0x0A,0x0A,0x00,0x00},/*”w“,87*/
{0x00,0x00,0x00,0x00,0x00,0x1B,0x0A,0x04,0x0A,0x1B,0x00,0x00},/*”x“,88*/
{0x00,0x00,0x00,0x00,0x00,0x37,0x12,0x0A,0x0C,0x04,0x04,0x03},/*”y“,89*/
{0x00,0x00,0x00,0x00,0x00,0x1E,0x08,0x04,0x04,0x1E,0x00,0x00},/*”z“,90*/
{0x00,0x18,0x08,0x08,0x08,0x04,0x08,0x08,0x08,0x08,0x18,0x00},/*”{“,91*/
{0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08},/*”|“,92*/
{0x00,0x06,0x04,0x04,0x04,0x08,0x04,0x04,0x04,0x04,0x06,0x00},/*”}“,93*/
{0x02,0x25,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} /*”~“,94*/
};
const unsigned char asc2_1608[95][16]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*” “,0*/
{0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x18,0x18,0x00,0x00},/*”!“,1*/
{0x00,0x48,0x6C,0x24,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”“”,2*/
{0x00,0x00,0x00,0x24,0x24,0x24,0x7F,0x12,0x12,0x12,0x7F,0x12,0x12,0x12,0x00,0x00},/*“#”,3*/
{0x00,0x00,0x08,0x1C,0x2A,0x2A,0x0A,0x0C,0x18,0x28,0x28,0x2A,0x2A,0x1C,0x08,0x08},/*“$”,4*/
{0x00,0x00,0x00,0x22,0x25,0x15,0x15,0x15,0x2A,0x58,0x54,0x54,0x54,0x22,0x00,0x00},/*“%”,5*/
{0x00,0x00,0x00,0x0C,0x12,0x12,0x12,0x0A,0x76,0x25,0x29,0x11,0x91,0x6E,0x00,0x00},/*“&”,6*/
{0x00,0x06,0x06,0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*“’”,7*/
{0x00,0x40,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x40,0x00},/*“(”,8*/
{0x00,0x02,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x02,0x00},/*“)”,9*/
{0x00,0x00,0x00,0x00,0x08,0x08,0x6B,0x1C,0x1C,0x6B,0x08,0x08,0x00,0x00,0x00,0x00},/*“*”,10*/
{0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x7F,0x08,0x08,0x08,0x08,0x00,0x00,0x00},/*“+”,11*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x04,0x03},/*“,”,12*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*“-”,13*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x00,0x00},/*“?!?,14*/
{0x00,0x00,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x00},/*“/”,15*/
{0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*“0”,16*/
{0x00,0x00,0x00,0x08,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*“1”,17*/
{0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x20,0x20,0x10,0x08,0x04,0x42,0x7E,0x00,0x00},/*“2”,18*/
{0x00,0x00,0x00,0x3C,0x42,0x42,0x20,0x18,0x20,0x40,0x40,0x42,0x22,0x1C,0x00,0x00},/*“3”,19*/
{0x00,0x00,0x00,0x20,0x30,0x28,0x24,0x24,0x22,0x22,0x7E,0x20,0x20,0x78,0x00,0x00},/*“4”,20*/
{0x00,0x00,0x00,0x7E,0x02,0x02,0x02,0x1A,0x26,0x40,0x40,0x42,0x22,0x1C,0x00,0x00},/*“5”,21*/
{0x00,0x00,0x00,0x38,0x24,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*“6”,22*/
{0x00,0x00,0x00,0x7E,0x22,0x22,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00},/*“7”,23*/
{0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00},/*“8”,24*/
{0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x64,0x58,0x40,0x40,0x24,0x1C,0x00,0x00},/*“9”,25*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00},/*“:”,26*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x04},/*“;”,27*/
{0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x40,0x00,0x00},/*“《”,28*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00},/*“=”,29*/
{0x00,0x00,0x00,0x02,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x02,0x00,0x00},/*“》”,30*/
{0x00,0x00,0x00,0x3C,0x42,0x42,0x46,0x40,0x20,0x10,0x10,0x00,0x18,0x18,0x00,0x00},/*“?”,31*/
{0x00,0x00,0x00,0x1C,0x22,0x5A,0x55,0x55,0x55,0x55,0x2D,0x42,0x22,0x1C,0x00,0x00},/*“@”,32*/
{0x00,0x00,0x00,0x08,0x08,0x18,0x14,0x14,0x24,0x3C,0x22,0x42,0x42,0xE7,0x00,0x00},/*“A”,33*/
{0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x1E,0x22,0x42,0x42,0x42,0x22,0x1F,0x00,0x00},/*“B”,34*/
{0x00,0x00,0x00,0x7C,0x42,0x42,0x01,0x01,0x01,0x01,0x01,0x42,0x22,0x1C,0x00,0x00},/*“C”,35*/
{0x00,0x00,0x00,0x1F,0x22,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x22,0x1F,0x00,0x00},/*“D”,36*/
{0x00,0x00,0x00,0x3F,0x42,0x12,0x12,0x1E,0x12,0x12,0x02,0x42,0x42,0x3F,0x00,0x00},/*“E”,37*/
{0x00,0x00,0x00,0x3F,0x42,0x12,0x12,0x1E,0x12,0x12,0x02,0x02,0x02,0x07,0x00,0x00},/*“F”,38*/
{0x00,0x00,0x00,0x3C,0x22,0x22,0x01,0x01,0x01,0x71,0x21,0x22,0x22,0x1C,0x00,0x00},/*“G”,39*/
{0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*“H”,40*/
{0x00,0x00,0x00,0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*“I”,41*/
{0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x11,0x0F},/*“J”,42*/
{0x00,0x00,0x00,0x77,0x22,0x12,0x0A,0x0E,0x0A,0x12,0x12,0x22,0x22,0x77,0x00,0x00},/*“K”,43*/
{0x00,0x00,0x00,0x07,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x7F,0x00,0x00},/*“L”,44*/
{0x00,0x00,0x00,0x77,0x36,0x36,0x36,0x36,0x2A,0x2A,0x2A,0x2A,0x2A,0x6B,0x00,0x00},/*“M”,45*/
{0x00,0x00,0x00,0xE3,0x46,0x46,0x4A,0x4A,0x52,0x52,0x52,0x62,0x62,0x47,0x00,0x00},/*“N”,46*/
{0x00,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x22,0x1C,0x00,0x00},/*“O”,47*/
{0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x42,0x3E,0x02,0x02,0x02,0x02,0x07,0x00,0x00},/*“P”,48*/
{0x00,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,0x41,0x41,0x4D,0x53,0x32,0x1C,0x60,0x00},/*“Q”,49*/
{0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x3E,0x12,0x12,0x22,0x22,0x42,0xC7,0x00,0x00},/*“R”,50*/
{0x00,0x00,0x00,0x7C,0x42,0x42,0x02,0x04,0x18,0x20,0x40,0x42,0x42,0x3E,0x00,0x00},/*“S”,51*/
{0x00,0x00,0x00,0x7F,0x49,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00},/*“T”,52*/
{0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00},/*“U”,53*/
{0x00,0x00,0x00,0xE7,0x42,0x42,0x22,0x24,0x24,0x14,0x14,0x18,0x08,0x08,0x00,0x00},/*“V”,54*/
{0x00,0x00,0x00,0x6B,0x49,0x49,0x49,0x49,0x55,0x55,0x36,0x22,0x22,0x22,0x00,0x00},/*“W”,55*/
{0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x18,0x18,0x18,0x24,0x24,0x42,0xE7,0x00,0x00},/*“X”,56*/
{0x00,0x00,0x00,0x77,0x22,0x22,0x14,0x14,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00},/*“Y”,57*/
{0x00,0x00,0x00,0x7E,0x21,0x20,0x10,0x10,0x08,0x04,0x04,0x42,0x42,0x3F,0x00,0x00},/*“Z”,58*/
{0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x78,0x00},/*“[”,59*/
{0x00,0x00,0x02,0x02,0x04,0x04,0x08,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x40,0x40},/*“\”,60*/
{0x00,0x1E,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1E,0x00},/*“]”,61*/
{0x00,0x38,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*“^”,62*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF},/*“_”,63*/
{0x00,0x06,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*“`”,64*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x78,0x44,0x42,0x42,0xFC,0x00,0x00},/*“a”,65*/
{0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x26,0x1A,0x00,0x00},/*“b”,66*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x02,0x02,0x02,0x44,0x38,0x00,0x00},/*“c”,67*/
{0x00,0x00,0x00,0x60,0x40,0x40,0x40,0x78,0x44,0x42,0x42,0x42,0x64,0xD8,0x00,0x00},/*“d”,68*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x7E,0x02,0x02,0x42,0x3C,0x00,0x00},/*“e”,69*/
{0x00,0x00,0x00,0xF0,0x88,0x08,0x08,0x7E,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*“f”,70*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x22,0x22,0x1C,0x02,0x3C,0x42,0x42,0x3C},/*“g”,71*/
{0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x3A,0x46,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*“h”,72*/
{0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x0E,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*“i”,73*/
{0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x22,0x1E},/*“j”,74*/
{0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x72,0x12,0x0A,0x16,0x12,0x22,0x77,0x00,0x00},/*“k”,75*/
{0x00,0x00,0x00,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*“l(fā)”,76*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x92,0x92,0x92,0x92,0x92,0xB7,0x00,0x00},/*“m”,77*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3B,0x46,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*“n”,78*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00},/*“o”,79*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1B,0x26,0x42,0x42,0x42,0x22,0x1E,0x02,0x07},/*“p”,80*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x44,0x42,0x42,0x42,0x44,0x78,0x40,0xE0},/*“q”,81*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0x4C,0x04,0x04,0x04,0x04,0x1F,0x00,0x00},/*“r”,82*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x42,0x02,0x3C,0x40,0x42,0x3E,0x00,0x00},/*“s”,83*/
{0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x3E,0x08,0x08,0x08,0x08,0x08,0x30,0x00,0x00},/*“t”,84*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x42,0x42,0x42,0x42,0x62,0xDC,0x00,0x00},/*“u”,85*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x14,0x08,0x08,0x00,0x00},/*“v”,86*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEB,0x49,0x49,0x55,0x55,0x22,0x22,0x00,0x00},/*“w”,87*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x24,0x18,0x18,0x18,0x24,0x6E,0x00,0x00},/*“x”,88*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x14,0x18,0x08,0x08,0x07},/*“y”,89*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x22,0x10,0x08,0x08,0x44,0x7E,0x00,0x00},/*“z”,90*/
{0x00,0xC0,0x20,0x20,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0x20,0x20,0xC0,0x00},/*“{”,91*/
{0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10},/*“|”,92*/
{0x00,0x06,0x08,0x08,0x08,0x08,0x08,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x06,0x00},/*“}”,93*/
{0x0C,0x32,0xC2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*“~”,94*/
};
配置好相應(yīng)的IO為推挽輸出,硬件初始化即可。不過這里需要注意的是,這里使用GPIOB作為I80總線數(shù)據(jù)口,所以和Jtag口沖突(詳見:stm32 最小系統(tǒng) 中jtag說明)。所以在配置IO時(shí)要將 jtag口的IO復(fù)用關(guān)閉:
?。踓pp] view plain copy在GPIO_Configuration()配置中:
GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
// 改變指定管腳的映射 GPIO_Remap_SWJ_Disable SWJ 完全禁用(JTAG+SW-DP);必須加上這句,否則會(huì)導(dǎo)致串口無法使用 被折騰了很久 原因不詳
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE);
// 改變指定管腳的映射 GPIO_Remap_SWJ_JTAGDisable ,JTAG-DP 禁用 + SW-DP 使能
注意:不要忘記在RCC_Configuration()中開啟AFIO時(shí)鐘,//AFIO時(shí)鐘
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
在main.c中直接調(diào)用相關(guān)函數(shù):
?。踓pp] view plain copyint main(void)
{
//stm32 初始化
RCC_Configuration();
NVIC_Configuration();
USART_Configuration();
SPI_Configuration();
GPIO_Configuration();
LCD_Init();
POINT_COLOR = BLACK; //設(shè)置字體顏色
LCD_ShowString(30,50,“Hello Dog 。. ”);
printf(“\r\n test.。 \r\n”);
while(1);
}
評(píng)論
查看更多