浅谈STM32的FSMC的TFT笔记

控制/MCU

1878人已加入

描述

1、FSMC初初了解:

FSMC 包括4个模块:

(1)AHB接口(包括FSMC配置寄存器)

(2)NOR闪存和PSRAM控制器(驱动LCD的时候LCD就好像一个PSRAM的里面只有2个16位的存储空间,一个是DATA RAM 一个是CMD RAM)

(3)NAND闪存和PC卡控制器

(4)外部设备接口

我们驱动TFT很明显用的是第二个模块:NOR闪存。

2、FSMC的外设地址选择

FSMC _Bank 用来选择外接存储器的地址,FSMC所控制的外存储器所映射的地址是0x6000 0000 ~ 0x9fff ffff

其中属于NOR FLASH 的是0x6000 0000 ~ 0x6fff ffff ,然后这部分的地址空间又被分为四份,每份64MB, 编号是BANK1 ~ BANK 4 ,每个BANK 都有一个片选引脚。

而这四个分存储块的片选,则使用NE[4:1]来选择。数据线/地址线/控制线是共享的。

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 驱动LCD

FSMC提供了所有的LCD控制器的信号:

FSMC_D[16:0]:16bit的数据总线

FSMC NEx:分配给NOR的256M,再分为4个区,每个区用来分配一个外设,这四个外设的片选分为是NE1-NE4,对应的引脚为:PD7—NE1,PG9—NE2,PG10-NE3,PG12—NE4

FSMC NOE:输出使能,连接LCD的RD脚。

FSMC NWE:写使能,连接LCD的RW脚。

FSMC Ax:用在LCD显示RAM和寄存器之间进行选择的地址线,即该线用于选择LCD的RS脚,该线可用地址线的任意一根线,范围:FSMC_A[25:0]。

正如我们操作12864的命令/数据选择端口RS一样,对于FSMC驱动TFT :RS = 0时,表示读写寄存器;RS = 1表示读写数据RAM。

4、GPIO端口配置

由于是使用FSMC来驱动TFT的,所以除了背光用的PD13和复位用的PC1要设置为通用推挽输出之外,其他引脚都必须设置为复用推挽输出。然而,很奇怪的是。当我配置好PD13时,我发现程序下载进去后是一片漆黑的,后来再三检查是背光的PD13的问题。必须把PD13置高才可以亮,否则默认低电平,就是一片黑了。

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寄存器数据

* Input          : - index: 寄存器数据

* 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    : 读取控制器数据

* Input          : None

* Output         : None

* Return         : 返回读取到的数据

* 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);   /* 打开晶振 ,内部晶振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);   /* 驱动输出控制320*240 0x2B3F */

LCD_WriteReg(0x0002,0x0600);    delay_ms(50);

LCD_WriteReg(0x0010,0x0000);    delay_ms(50);

LCD_WriteReg(0x0011,0x6070);    delay_ms(50);   /* 定义数据格式 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;//点亮背光

  LCD_Clear(WHITE);

  }

  //清屏函数

  //Color:要清屏的填充色

  void LCD_Clear(u16 Color)

  {

  u32 index=0;

  LCD_SetCursor(0x00,0x0000);//设置光标位置

  LCD_WriteRAM_Prepare(); //开始写入GRAM

  for(index=0;index《76800;index++)

  {

  LCD_WR_DATA(Color); //向每个GRAM写入数据

  }

  }

  //在指定区域内填充指定颜色

  //区域大小:

  // (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;

  //设置窗口

  LCD_WriteReg(R80, xsta); //水平方向GRAM起始地址

  LCD_WriteReg(R81, xend); //水平方向GRAM结束地址

  LCD_WriteReg(R82, ysta); //垂直方向GRAM起始地址

  LCD_WriteReg(R83, yend); //垂直方向GRAM结束地址

  LCD_SetCursor(xsta,ysta);//设置光标位置

  LCD_WriteRAM_Prepare(); //开始写入GRAM

  n=(u32)(yend-ysta+1)*(xend-xsta+1);

  while(n--){LCD_WR_DATA(color);}//显示所填充的颜色。

  //恢复设置

  LCD_WriteReg(R80, 0x0000); //水平方向GRAM起始地址

  LCD_WriteReg(R81, (LCD_WIDTH-1)); //水平方向GRAM结束地址

  LCD_WriteReg(R82, 0x0000); //垂直方向GRAM起始地址

  LCD_WriteReg(R83, (LCD_HEIGHT-1)); //垂直方向GRAM结束地址

  #endif

  }

  //画线

  //x1,y1:起点坐标

  //x2,y2:终点坐标

  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; //计算坐标增量

  delta_y=y2-y1;

  uRow=x1;

  uCol=y1;

  if(delta_x》0)incx=1; //设置单步方向

  else if(delta_x==0)incx=0;//垂直线

  else {incx=-1;delta_x=-delta_x;} //终点坐标小于起始坐标,反方向,将坐标重新定位为正坐标

  if(delta_y》0)incy=1;

  else if(delta_y==0)incy=0;//水平线

  else{incy=-1;delta_y=-delta_y;} //终点坐标小于起始坐标,反方向,将坐标重新定位为正坐标

  if( delta_x》delta_y)distance=delta_x; //选取基本增量坐标轴

  else distance=delta_y;

  for(t=0;t《=distance+1;t++ )//画线输出

  {

  LCD_DrawPoint(uRow,uCol);//根据坐标画点

  xerr+=delta_x ; //X坐标增量

  yerr+=delta_y ; //Y坐标增量

  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);

  }

  //在指定位置画一个指定大小的圆

  //(x,y):中心点

  //r :半径

  void Draw_Circle(u8 x0,u16 y0,u8 r)

  {

  int a,b;

  int di;

  a=0;b=r;

  di=3-(r《《1); //判断下个点位置的标志

  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);

  }

  }

  //在指定位置显示一个字符

  //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;

  //设置窗口

  num=num-‘ ’;//得到偏移后的值

  if(!mode) //非叠加方式

  {

  for(pos=0;pos《size;pos++)

  {

  if(size==12)

  temp=asc2_1206[num][pos];//调用1206字体

  else

  temp=asc2_1608[num][pos]; //调用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];//调用1206字体

  else

  temp=asc2_1608[num][pos]; //调用1608字体

  for(t=0;t《size/2;t++)

  {

  if(temp&0x01)LCD_DrawPoint(x+t,y+pos);//画一个点

  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;

  //设置窗口

  LCD_WriteReg(R80,x); //水平方向GRAM起始地址

  LCD_WriteReg(R81,x+(size/2-1));//水平方向GRAM结束地址

  LCD_WriteReg(R82,y); //垂直方向GRAM起始地址

  LCD_WriteReg(R83,y+size-1); //垂直方向GRAM结束地址

  LCD_SetCursor(x,y); //设置光标位置

  LCD_WriteRAM_Prepare(); //开始写入GRAM

  num=num-‘ ’;//得到偏移后的值

  if(!mode) //非叠加方式

  {

  for(pos=0;pos《size;pos++)

  {

  if(size==12)

  temp=asc2_1206[num][pos];//调用1206字体

  else

  temp=asc2_1608[num][pos]; //调用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]; //调用1206字体

  else

  temp=asc2_1608[num][pos]; //调用1608字体

  for(t=0;t《size/2;t++)

  {

  if(temp&0x01)

  LCD_DrawPoint(x+t,y+pos);//画一个点

  temp》》=1;

  }

  }

  }

  //恢复窗体大小

  LCD_WriteReg(R80, 0x0000); //水平方向GRAM起始地址

  LCD_WriteReg(R81, (LCD_WIDTH-1)); //水平方向GRAM结束地址

  LCD_WriteReg(R82, 0x0000); //垂直方向GRAM起始地址

  LCD_WriteReg(R83, (LCD_HEIGHT-1)); //垂直方向GRAM结束地址

  #endif

  }

  //m^n函数

  u32 mypow(u8 m,u8 n)

  {

  u32 result=1;

  while(n--)result*=m;

  return result;

  }

  //显示数字

  //x,y :起点坐标

  //len :数字的位数

  //size:字体大小

  //color:颜色

  //num:数值(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:起点坐标

  //*p:字符串起始地址

  //用16字体

  void LCD_ShowString(u8 x,u16 y,const u8 *p)

  {

  while(*p!=‘\0’) //字符串到达结束

  {

  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 (相关I/O操作在此文件中以宏定义的方式实现)

  [cpp] view plain copy#include “stm32f10x.h”

  //TFTLCD部分外要调用的函数

  extern u16 POINT_COLOR;//默认红色

  extern u16 BACK_COLOR; //背景颜色。默认为白色

  //定义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

  /*硬件相关的宏定义*/

  #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位数据所在端口,PB0~15作为数据线

  #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 //数据/命令 PC8

  #define Set_Wr GPIOC-》BSRR=1《《7 //写数据 PC7

  #define Set_Rd GPIOC-》BSRR=1《《6 //读数据 PC6

  #define Clr_Cs GPIOC-》BRR=1《《9 //片选端口 PC9

  #define Clr_Rs GPIOC-》BRR=1《《8 //数据/命令 PC8

  #define Clr_Wr GPIOC-》BRR=1《《7 //写数据 PC7

  #define Clr_Rd GPIOC-》BRR=1《《6 //读数据 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);}

  //直接操作寄存器读取,使用库函数读取I/O有问题,原因不详

  #define Read_Data() (LCD_GPIO_DATA_PORT -》IDR) //必须使用宏定义,写成函数会有问题

  //#define Read_Data() (GPIO_ReadInputData(LCD_GPIO_DATA_PORT)) //这句有问题

  //写8位数据函数

  //用宏定义,提高速度。

  #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 //深蓝色

  #define LIGHTBLUE 0X7D7C //浅蓝色

  #define GRAYBLUE 0X5458 //灰蓝色

  //以上三色为PANEL的颜色

  #define LIGHTGREEN 0X841F //浅绿色

  //#define LIGHTGRAY 0XEF5B //浅灰色(PANNEL)

  #define LGRAY 0XC618 //浅灰色(PANNEL),窗体背景色

  #define LGRAYBLUE 0XA651 //浅灰蓝色(中间层颜色)

  #define LBBLUE 0X2B12 //浅棕蓝色(选择条目的反色)

  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);//画点

  u16 LCD_ReadPoint(u16 x,u16 y); //读点

  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);//显示一个字符

  void LCD_ShowNum(u8 x,u16 y,u32 num,u8 len,u8 size); //显示一个数字

  void LCD_ShowString(u8 x,u16 y,const u8 *p); //显示一个字符串,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 (字库文件)

  [cpp] 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},/*”。“,14*/

  {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“,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”,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*/

  };

  配置好相应的IO为推挽输出,硬件初始化即可。不过这里需要注意的是,这里使用GPIOB作为I80总线数据口,所以和Jtag口冲突(详见:stm32 最小系统 中jtag说明)。所以在配置IO时要将 jtag口的IO复用关闭:

  [cpp] view plain copy在GPIO_Configuration()配置中:

  GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);

  // 改变指定管脚的映射 GPIO_Remap_SWJ_Disable SWJ 完全禁用(JTAG+SW-DP);必须加上这句,否则会导致串口无法使用 被折腾了很久 原因不详

  GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE);

  // 改变指定管脚的映射 GPIO_Remap_SWJ_JTAGDisable ,JTAG-DP 禁用 + SW-DP 使能

  注意:不要忘记在RCC_Configuration()中开启AFIO时钟,//AFIO时钟

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

  在main.c中直接调用相关函数:

  [cpp] view plain copyint main(void)

  {

  //stm32 初始化

  RCC_Configuration();

  NVIC_Configuration();

  USART_Configuration();

  SPI_Configuration();

  GPIO_Configuration();

  LCD_Init();

  POINT_COLOR = BLACK; //设置字体颜色

  LCD_ShowString(30,50,“Hello Dog 。. ”);

  printf(“\r\n test.。 \r\n”);

  while(1);

  }

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分