首先是硬件连线:PB—-8位数据口
PA0— 复位信号RESET
PA1—片选CS
PA2—-寄存器挑选信号RS
PA3—写信号WR
PA4—读信号RD
文件名:Type.h,首要界说一些数据变量的别号
- /****************************************Copyright(c)**************************************************
- **SoutheastUniversity
- **————–FileInfo——————————————————————————-
- **FileName:Type.h
- **LastmodifiedDate:2012-03-23
- **LastVersion:1.0
- **Description:界说数据类型别号
- **——————————————————————————————————
- **CreatedBy:JianGe
- **Createddate:2012-03-23
- **Version:1.0
- **——————————————————————————————————*/
- #ifndef__TYPE_H__
- #define__TYPE_H__
- /********************************************************************************************************
- *Datetypes(Compilerspecific)数据类型(和编译器相关)*
- ********************************************************************************************************/
- typedefunsignedcharuint8;//Unsigned8bitquantity无符号8位整型变量
- typedefunsignedcharuchar;//Unsigned8bitquantity无符号8位整型变量
- typedefsignedcharint8;//Signed8bitquantity有符号8位整型变量
- typedefunsignedshortuint16;//Unsigned16bitquantity无符号16位整型变量
- typedefsignedshortint16;//Signed16bitquantity有符号16位整型变量
- typedefunsignedintuint32;//Unsigned32bitquantity无符号32位整型变量
- typedefunsignedintuint;//Unsigned32bitquantity无符号32位整型变量
- typedefsignedintint32;//Signed32bitquantity有符号32位整型变量
- typedeffloatfp32;//Singleprecisionfloatingpoint单精度浮点数(32位长度)
- typedefdoublefp64;//Doubleprecisionfloatingpoint双精度浮点数(64位长度)
- #ifndefTRUE
- #defineTRUE1
- #endif
- #ifndefFALSE
- #defineFALSE0
- #endif
- #ifndefNULL
- #defineNULL0
- #endif
- #endif
- /*********************************************************************************************************
- *EndOfFile*
- *********************************************************************************************************/
文件名:USART.h,串口操作函数的声明
- /****************************************Copyright(c)**************************************************
- **SoutheastUniversity
- **————–FileInfo——————————————————————————-
- **FileName:USART.h
- **LastmodifiedDate:2012-03-23
- **LastVersion:1.0
- **Description:串口函数声明
- **——————————————————————————————————
- **CreatedBy:JianGe
- **Createddate:2012-03-23
- **Version:1.0
- **——————————————————————————————————*/
- #ifndef_USART_H
- #define_USART_H
- #include”Type.h”
- #defineBAUD9600//波特率设置
- #defineCRYSTAL4000000//11059200//晶振频率
- #defineBAUD_SET(uint16)((uint32)CRYSTAL/(16*(uint32)BAUD)-1)
- #defineBAUD_H(uint8)(BAUD_SET>>8)
- #defineBAUD_L(uint8)(BAUD_SET)
- #defineFE_EERBIT(FE)//帧接纳过错
- #definePE_EERBIT(PE)//校验过错
- #defineDATA_OVERBIT(DOR)//接纳溢出过错
- #defineUDR_EMPTYBIT(UDRE)//数据寄存器空
- #defineUSAT_TX_ENUCSRB|=BIT(TXEN)//使能USART发送
- #defineUSAT_TX_NO_ENUCSRB&=~BIT(TXEN)
- #defineUSAT_RX_ENUCSRB|=BIT(RXEN)//使能USART接纳
- #defineUSAT_RX_NO_ENUCSRB&=~BIT(RXEN)
- externvoidUSART_Init(void);
- externvoidUart_Transmit(unsignedchari);
- externunsignedcharUart_Receive(void);
- #endif
- /*********************************************************************************************************
- *EndOfFile*
- *********************************************************************************************************/
文件名:Delay.h,延时函数的声明
- /****************************************Copyright(c)**************************************************
- **SoutheastUniversity
- **————–FileInfo——————————————————————————-
- **FileName:Delay.h
- **LastmodifiedDate:2012-03-23
- **LastVersion:1.0
- **Description:延时函数声明
- **——————————————————————————————————
- **CreatedBy:JianGe
- **Createddate:2012-03-23
- **Version:1.0
- **——————————————————————————————————*/
- #ifndefDELAY_H_H_
- #defineDELAY_H_H_
- #defineDELAY_USasm(“nop”);asm(“nop”);asm(“nop”);asm(“nop”);\
- asm(“nop”);asm(“nop”);asm(“nop”);asm(“nop”);
- externvoidDelay_nUS(unsignedintn);
- externvoidDelay_MS(void);
- externvoidDelay_nMS(unsignedintn);
- #endif
- /*********************************************************************************************************
- *EndOfFile*
- *********************************************************************************************************/
文件名:LCDDriver.h,LCD驱动函数和使用函数的声明
- /****************************************Copyright(c)**************************************************
- **SoutheastUniversity
- **————–FileInfo——————————————————————————-
- **FileName:LCD_Driver.h
- **LastmodifiedDate:2012-03-24
- **LastVersion:1.0
- **Description:LCD驱动函数声明
- **——————————————————————————————————
- **CreatedBy:JianGe
- **Createddate:2012-03-24
- **Version:1.0
- **——————————————————————————————————*/
- #ifndefLCD_DRIVER_H_H_
- #defineLCD_DRIVER_H_H_
- #include”Type.h”
- #include
- externvoidLCD_Port_Init(void);
- externvoidLCD_WriteCmd(uint32regID);
- externvoidLCD_WriteData(uint32data);
- externvoidLCD_WriteReg(uint32regID,uint32regData);
- externunsignedintLCD_ReadReg(uint32regID);
- externvoidLCD_ILI9325_Init(void);
- externvoidLCD_SetWindow(unsignedintx0,unsignedintx1,unsignedinty0,unsignedinty1);
- externvoidLCD_ClearScreen(unsignedintcolor);
- externvoidLCD_Fill_Rectangle(unsignedintx0,unsignedinty0,unsignedintx1,unsignedinty1,unsignedintcolor);
- externunsignedcharGet_CharOffset(unsignedcharchar_data);
- externvoidSet_CharWindow(unsignedintlineNum,unsignedintrowNum);
- externvoidLCD_WriteChar(unsignedintlineNum,
- unsignedintrowNum,
- unsignedintcharColor,
- unsignedintbkColor,
- unsignedcharchChar)
- externvoidLCD_WriteString(unsignedcharlineNum,unsignedcharrowNum,
- unsignedintcharColor,
- unsignedintbkColor,
- unsignedchar*p_str)
- #endif
- /*********************************************************************************************************
- *EndOfFile*
- *********************************************************************************************************/
文件名:LCD_Font.h LCD字体库的声明
- /****************************************Copyright(c)**************************************************
- **SoutheastUniversity
- **————–FileInfo——————————————————————————-
- **FileName:LCD_Font.h
- **LastmodifiedDate:2012-03-27
- **LastVersion:1.0
- **Description:LCD显现字符的字节表
- **——————————————————————————————————
- **CreatedBy:JianGe
- **Createddate:2012-03-27
- **Version:1.0
- **——————————————————————————————————*/
- #ifndefLCD_FONT_H_H_
- #defineLCD_FONT_H_H_
- //常用ASCII字符码表
- constunsignedcharLetter[][16]=
- {
- //榜首栏从到?
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*””,0*/
- {0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x18,0x18,0x00,0x00},/*”!”,1*/
- {0x00,0x12,0x36,0x24,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”””,2*/
- {0x00,0x00,0x00,0x24,0x24,0x24,0xFE,0x48,0x48,0x48,0xFE,0x48,0x48,0x48,0x00,0x00},/*”#”,3*/
- {0x00,0x00,0x10,0x38,0x54,0x54,0x50,0x30,0x18,0x14,0x14,0x54,0x54,0x38,0x10,0x10},/*”$”,4*/
- {0x00,0x00,0x00,0x44,0xA4,0xA8,0xA8,0xA8,0x54,0x1A,0x2A,0x2A,0x2A,0x44,0x00,0x00},/*”%”,5*/
- {0x00,0x00,0x00,0x30,0x48,0x48,0x48,0x50,0x6E,0xA4,0x94,0x88,0x89,0x76,0x00,0x00},/*”&”,6*/
- {0x00,0x60,0x60,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*””,7*/
- {0x00,0x02,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x02,0x00},/*”(“,8*/
- {0x00,0x40,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x40,0x00},/*”)”,9*/
- {0x00,0x00,0x00,0x00,0x10,0x10,0xD6,0x38,0x38,0xD6,0x10,0x10,0x00,0x00,0x00,0x00},/*”*”,10*/
- {0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0xFE,0x10,0x10,0x10,0x10,0x00,0x00,0x00},/*”+”,11*/
- {0x00,0x60,0x60,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*””,12*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”-“,13*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00},/*”.”,14*/
- {0x00,0x00,0x01,0x02,0x02,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x00},/*”/”,15*/
- {0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*”0″,16*/
- {0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*”1″,17*/
- {0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x04,0x04,0x08,0x10,0x20,0x42,0x7E,0x00,0x00},/*”2″,18*/
- {0x00,0x00,0x00,0x3C,0x42,0x42,0x04,0x18,0x04,0x02,0x02,0x42,0x44,0x38,0x00,0x00},/*”3″,19*/
- {0x00,0x00,0x00,0x04,0x0C,0x14,0x24,0x24,0x44,0x44,0x7E,0x04,0x04,0x1E,0x00,0x00},/*”4″,20*/
- {0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x58,0x64,0x02,0x02,0x42,0x44,0x38,0x00,0x00},/*”5″,21*/
- {0x00,0x00,0x00,0x1C,0x24,0x40,0x40,0x58,0x64,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*”6″,22*/
- {0x00,0x00,0x00,0x7E,0x44,0x44,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,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,0x26,0x1A,0x02,0x02,0x24,0x38,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,0x10,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x20},/*”;”,27*/
- {0x00,0x00,0x00,0x02,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x02,0x00,0x00},/*”<",28*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00},/*”=”,29*/
- {0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x40,0x00,0x00},/*”>”,30*/
- {0x00,0x00,0x00,0x3C,0x42,0x42,0x62,0x02,0x04,0x08,0x08,0x00,0x18,0x18,0x00,0x00},/*”?”,31*/
- //第二栏从@开端
- {0x00,0x00,0x00,0x38,0x44,0x5A,0xAA,0xAA,0xAA,0xAA,0xB4,0x42,0x44,0x38,0x00,0x00},/*”@”,32*/
- {0x00,0x00,0x00,0x10,0x10,0x18,0x28,0x28,0x24,0x3C,0x44,0x42,0x42,0xE7,0x00,0x00},/*”A”,33*/
- {0x00,0x00,0x00,0xF8,0x44,0x44,0x44,0x78,0x44,0x42,0x42,0x42,0x44,0xF8,0x00,0x00},/*”B”,34*/
- {0x00,0x00,0x00,0x3E,0x42,0x42,0x80,0x80,0x80,0x80,0x80,0x42,0x44,0x38,0x00,0x00},/*”C”,35*/
- {0x00,0x00,0x00,0xF8,0x44,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x44,0xF8,0x00,0x00},/*”D”,36*/
- {0x00,0x00,0x00,0xFC,0x42,0x48,0x48,0x78,0x48,0x48,0x40,0x42,0x42,0xFC,0x00,0x00},/*”E”,37*/
- {0x00,0x00,0x00,0xFC,0x42,0x48,0x48,0x78,0x48,0x48,0x40,0x40,0x40,0xE0,0x00,0x00},/*”F”,38*/
- {0x00,0x00,0x00,0x3C,0x44,0x44,0x80,0x80,0x80,0x8E,0x84,0x44,0x44,0x38,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,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*”I”,41*/
- {0x00,0x00,0x00,0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x88,0xF0},/*”J”,42*/
- {0x00,0x00,0x00,0xEE,0x44,0x48,0x50,0x70,0x50,0x48,0x48,0x44,0x44,0xEE,0x00,0x00},/*”K”,43*/
- {0x00,0x00,0x00,0xE0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x42,0xFE,0x00,0x00},/*”L”,44*/
- {0x00,0x00,0x00,0xEE,0x6C,0x6C,0x6C,0x6C,0x54,0x54,0x54,0x54,0x54,0xD6,0x00,0x00},/*”M”,45*/
- {0x00,0x00,0x00,0xC7,0x62,0x62,0x52,0x52,0x4A,0x4A,0x4A,0x46,0x46,0xE2,0x00,0x00},/*”N”,46*/
- {0x00,0x00,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x44,0x38,0x00,0x00},/*”O”,47*/
- {0x00,0x00,0x00,0xFC,0x42,0x42,0x42,0x42,0x7C,0x40,0x40,0x40,0x40,0xE0,0x00,0x00},/*”P”,48*/
- {0x00,0x00,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0x82,0xB2,0xCA,0x4C,0x38,0x06,0x00},/*”Q”,49*/
- {0x00,0x00,0x00,0xFC,0x42,0x42,0x42,0x7C,0x48,0x48,0x44,0x44,0x42,0xE3,0x00,0x00},/*”R”,50*/
- {0x00,0x00,0x00,0x3E,0x42,0x42,0x40,0x20,0x18,0x04,0x02,0x42,0x42,0x7C,0x00,0x00},/*”S”,51*/
- {0x00,0x00,0x00,0xFE,0x92,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x38,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,0x44,0x24,0x24,0x28,0x28,0x18,0x10,0x10,0x00,0x00},/*”V”,54*/
- {0x00,0x00,0x00,0xD6,0x92,0x92,0x92,0x92,0xAA,0xAA,0x6C,0x44,0x44,0x44,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,0xEE,0x44,0x44,0x28,0x28,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00},/*”Y”,57*/
- {0x00,0x00,0x00,0x7E,0x84,0x04,0x08,0x08,0x10,0x20,0x20,0x42,0x42,0xFC,0x00,0x00},/*”Z”,58*/
- {0x00,0x1E,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1E,0x00},/*”[“,59*/
- {0x00,0x00,0x40,0x40,0x20,0x20,0x10,0x10,0x10,0x08,0x08,0x04,0x04,0x04,0x02,0x02},/*”\”,60*/
- {0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x78,0x00},/*”]”,61*/
- {0x00,0x1C,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”^”,62*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”-“,63*/
- //第三栏从开端
- {0x00,0x60,0x60,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*””,64*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x1E,0x22,0x42,0x42,0x3F,0x00,0x00},/*”a”,65*/
- {0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0x58,0x64,0x42,0x42,0x42,0x64,0x58,0x00,0x00},/*”b”,66*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x40,0x40,0x40,0x22,0x1C,0x00,0x00},/*”c”,67*/
- {0x00,0x00,0x00,0x06,0x02,0x02,0x02,0x1E,0x22,0x42,0x42,0x42,0x26,0x1B,0x00,0x00},/*”d”,68*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x7E,0x40,0x40,0x42,0x3C,0x00,0x00},/*”e”,69*/
- {0x00,0x00,0x00,0x0F,0x11,0x10,0x10,0x7E,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*”f”,70*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x44,0x44,0x38,0x40,0x3C,0x42,0x42,0x3C},/*”g”,71*/
- {0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0x5C,0x62,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*”h”,72*/
- {0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*”i”,73*/
- {0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x1C,0x04,0x04,0x04,0x04,0x04,0x04,0x44,0x78},/*”j”,74*/
- {0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0x4E,0x48,0x50,0x68,0x48,0x44,0xEE,0x00,0x00},/*”k”,75*/
- {0x00,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*”l”,76*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x49,0x49,0x49,0x49,0x49,0xED,0x00,0x00},/*”m”,77*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDC,0x62,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,0xD8,0x64,0x42,0x42,0x42,0x44,0x78,0x40,0xE0},/*”p”,80*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x22,0x42,0x42,0x42,0x22,0x1E,0x02,0x07},/*”q”,81*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEE,0x32,0x20,0x20,0x20,0x20,0xF8,0x00,0x00},/*”r”,82*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x42,0x40,0x3C,0x02,0x42,0x7C,0x00,0x00},/*”s”,83*/
- {0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x10,0x10,0x10,0x0C,0x00,0x00},/*”t”,84*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC6,0x42,0x42,0x42,0x42,0x46,0x3B,0x00,0x00},/*”u”,85*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x28,0x10,0x10,0x00,0x00},/*”v”,86*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD7,0x92,0x92,0xAA,0xAA,0x44,0x44,0x00,0x00},/*”w”,87*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6E,0x24,0x18,0x18,0x18,0x24,0x76,0x00,0x00},/*”x”,88*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x28,0x18,0x10,0x10,0xE0},/*”y”,89*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x44,0x08,0x10,0x10,0x22,0x7E,0x00,0x00},/*”z”,90*/
- {0x00,0x03,0x04,0x04,0x04,0x04,0x04,0x08,0x04,0x04,0x04,0x04,0x04,0x04,0x03,0x00},/*”{“,91*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00},/*”:”,92*/
- {0x00,0x60,0x10,0x10,0x10,0x10,0x10,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x60,0x00},/*”}”,93*/
- {0x30,0x4C,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”~”,94*/
- {0x00,0x1C,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”^”,95*/
- };
- #endif
- /*********************************************************************************************************
- *EndOfFile*
- *********************************************************************************************************/
文件名: Delay.c,延时函数的完成
- /****************************************Copyright(c)**************************************************
- **SoutheastUniversity
- **————–FileInfo——————————————————————————-
- **FileName:Delay.c
- **LastmodifiedDate:2012-03-23
- **LastVersion:1.0
- **Description:延时函数完成
- **——————————————————————————————————
- **CreatedBy:JianGe
- **Createddate:2012-03-23
- **Version:1.0
- **——————————————————————————————————*/
- #include”Delay.h”
- #include”Type.h”
- /*********************************************************************************************************
- **Functionname:Delay_nUS
- **Descriptions:延时n微秒
- **inputparameters:无
- **outputparameters:无
- **Returnedvalue:无
- *********************************************************************************************************/
- voidDelay_nUS(uint32n)
- {
- uint32i=0;
- for(i=0;i
- {
- DELAY_US;
- }
- }
- /*********************************************************************************************************
- **Functionname:Delay_MS
- **Descriptions:延时1毫秒
- **inputparameters:无
- **outputparameters:无
- **Returnedvalue:无
- *********************************************************************************************************/
- voidDelay_MS(void)
- {
- uint32i=0;
- for(i=0;i<1000;i++)
- {
- DELAY_US;
- }
- }
- /*********************************************************************************************************
- **Functionname:Delay_nMS
- **Descriptions:延时n毫秒
- **inputparameters:无
- **outputparameters:无
- **Returnedvalue:无
- *********************************************************************************************************/
- voidDelay_nMS(uint32n)
- {
- uint32i=0;
- for(i=0;i
- {
- Delay_MS();
- }
- }
- /*********************************************************************************************************
- *EndOfFile*
- *********************************************************************************************************/
文件名:USART.c 串口调试函数的完成
- /****************************************Copyright(c)**************************************************
- **SoutheastUniversity
- **————–FileInfo——————————————————————————-
- **FileName:USART.c
- **LastmodifiedDate:2012-03-23
- **LastVersion:1.0
- **Description:串口函数完成
- **——————————————————————————————————
- **CreatedBy:JianGe
- **Createddate:2012-03-23
- **Version:1.0
- **——————————————————————————————————*/
- #include
- #include”USART.h”
- /*串口初始化函数*/
- voidUSART_Init(void)
- {
- UCSRA=0x02;/*倍速*/
- UCSRB=0x18;/*答应接纳和发送*/
- UCSRC=0x06;/*8位数据*/
- UBRRH=0x00;
- //UBRRL=12;/*9600*/
- //UBRRL=103;//11.0592M下9600
- UBRRL=207;//16MHz下9600
- }/*数据发送,查询方法*/
- voidUart_Transmit(unsignedchari)
- {
- while(!(UCSRA&(1<
- UDR=i;/*发送数据*/
- }
- /*数据接纳,查询方法*/
- unsignedcharUart_Receive(void)
- {while(!(UCSRA&(1<
- returnUDR;/*获取并回来数据*/
- }
- /*********************************************************************************************************
- *EndOfFile*
- *********************************************************************************************************/
文件名:LCDDriver.c LCD驱动函数以及上层函数的完成
- /****************************************Copyright(c)**************************************************
- **SoutheastUniversity
- **————–FileInfo——————————————————————————-
- **FileName:LCDDriver.c
- **LastmodifiedDate:2012-04-12
- **LastVersion:1.0
- **Description:LCD驱动函数的完成
- **——————————————————————————————————
- **CreatedBy:JianGe
- **Createddate:2012-03-24
- **Version:1.0
- **——————————————————————————————————*/
- #include”Delay.h”
- #include
- #include
- #include”USART.h”
- #include”LCD_Font.h”
- #include”Type.h”
- ///////////屏显现参数设置///////////////
- //设置屏显现像素巨细
- #defineX_SIZE240
- #defineY_SIZE320
- //x和y的最大坐标值,坐标原点为(0,0)
- #defineX_END(X_SIZE-1)
- #defineY_END(Y_SIZE-1)
- //一个字符x*y的别离巨细
- #defineCHAR_X_SIZE8
- #defineCHAR_Y_SIZE16
- //横坐标能显现的字符数X_SIZE/CHAR_X_SIZE
- #defineCHAR_X_NUM30
- //纵坐标能显现的字符数Y_SIZE/CHAR_Y_SIZE
- #defineCHAR_Y_NUM20
- ////////////////////////////////////////
- //LCD操控端口动作宏界说
- #defineLCD_CS_BITPA1
- #defineLCD_RS_BITPA2
- #defineLCD_WR_BITPA3
- #defineLCD_RD_BITPA4
- #defineLCD_REST_BITPA0
- #defineLCD_CLT_PORTPORTA
- #defineLCD_CLT_PINPINA
- #defineLCD_CLT_DDRDDRA
- #defineLCD_CS_LLCD_CLT_PORT&=~BIT(LCD_CS_BIT)
- #defineLCD_CS_HLCD_CLT_PORT|=BIT(LCD_CS_BIT)
- #defineLCD_RS_LLCD_CLT_PORT&=~BIT(LCD_RS_BIT)
- #defineLCD_RS_HLCD_CLT_PORT|=BIT(LCD_RS_BIT)
- #defineLCD_WR_LLCD_CLT_PORT&=~BIT(LCD_WR_BIT)
- #defineLCD_WR_HLCD_CLT_PORT|=BIT(LCD_WR_BIT)
- #defineLCD_RD_LLCD_CLT_PORT&=~BIT(LCD_RD_BIT)
- #defineLCD_RD_HLCD_CLT_PORT|=BIT(LCD_RD_BIT)
- #defineLCD_REST_LLCD_CLT_PORT&=~BIT(LCD_REST_BIT)
- #defineLCD_REST_HLCD_CLT_PORT|=BIT(LCD_REST_BIT)
- //8位数据口
- #defineDATA_HPB0
- #defineLCD_DATA_PORTPORTB
- #defineLCD_DATA_DDRDDRB
- #defineLCD_DATA_PINPINB
- #defineLCD_DATA_INDDRB=0x00
- #defineLCD_DATA_OUTDDRB=0xFF
- //读GRAM时需求一个虚晃的读(DummyRead)
- #defineDUMMY_READ()LCD_RD_L;LCD_RD_H;LCD_RD_L;LCD_RD_H;
- //片选,开端9328的某种操作前调用
- #defineLCD_SELECT()LCD_CS_L
- //片选,结束9328的某项操作后调用
- #defineLCD_DIS_SELECT()LCD_CS_H
- /*********************************************************************************************************
- **Functionname:LCD_Port_Init
- **Descriptions:LCD的操控端口和数据端口的初始化
- **inputparameters:寄存器地址regID
- **outputparameters:无
- **Returnedvalue:无
- *********************************************************************************************************/
- voidLCD_Port_Init(void)
- {
- LCD_DATA_OUT;
- LCD_DATA_PORT=0xFF;
- LCD_CLT_DDR=0xFF;
- LCD_CS_H;
- LCD_RS_H;
- LCD_WR_H;
- LCD_RD_H;
- LCD_REST_H;
- }
- /*********************************************************************************************************
- **Functionname:LCD_WriteCmd
- **Descriptions:写寄存器指令,挑选一个寄存器
- **inputparameters:寄存器地址regID
- **outputparameters:无
- **Returnedvalue:无
- *********************************************************************************************************/
- ///////////////////////////////////////////////////////////////////////////////////////////////////////
- //nCS—-\__________________________________________/—————————//
- //RS——\______________________________/————————————//
- //nRD—————————————————————————-//
- //nWR——–\______/———-\_____/——————————————-//
- //DB[10:17]—-[寄存器高8位]—–[寄存器低8位]——————————————-//
- ////////////////////////////////////////////////////////////////////////////////////////////////////////
- voidLCD_WriteCmd(uint32regID)
- {
- LCD_RS_L;
- LCD_DATA_PORT=regID>>8;
- LCD_WR_L;
- LCD_WR_H;
- LCD_DATA_PORT=regID;
- LCD_WR_L;
- LCD_WR_H;
- LCD_RS_H;
- }
- /*********************************************************************************************************
- **Functionname:LCD_WriteData
- **Descriptions:向LCD写数据
- **inputparameters:待写入的数据data
- **outputparameters:无
- **Returnedvalue:无
- *********************************************************************************************************/
- ////////////////////////////////////////////////////////////////////////////////////////////////////
- //nCS—-\__________________________________________/—————————–//
- //RS—————————————————————————–//
- //nRD————————————————————————-//
- //nWR——–\______/——–\_____/—————————————–//
- //DB[10:17]—–[数据高8位]—–[数据低8位]——————————————-//
- /////////////////////////////////////////////////////////////////////////////////////////////////////
- voidLCD_WriteData(uint32data)
- {
- LCD_DATA_PORT=data>>8;
- LCD_WR_L;
- LCD_WR_H;
- LCD_DATA_PORT=data;
- LCD_WR_L;
- LCD_WR_H;
- }
- /*********************************************************************************************************
- **Functionname:LCD_WriteReg
- **Descriptions:向一个寄存器写入数据
- **inputparameters:寄存器地址:regID待写入的数据regData
- **outputparameters:无
- **Returnedvalue:无
- *********************************************************************************************************/
- ////////////////////////////////////////////////////////////////////////////////////////////////////
- //nCS—-\_____________________________________________________________/——–//
- //RS—-\____________________________/—————————————–//
- //nRD————————————————————————-//
- //nWR——\______/——–\_____/——–\______/—–\______/—————-//
- //DB[10:17]—[寄存器高8位]—[寄存器低8位]—[数据高8位]—-[数据低8位]—————//
- /////////////////////////////////////////////////////////////////////////////////////////////////////
- voidLCD_WriteReg(uint32regID,uint32regData)
- {
- LCD_RS_L;
- LCD_DATA_PORT=regID>>8;
- LCD_WR_L;
- LCD_WR_H;
- LCD_DATA_PORT=regID;
- LCD_WR_L;
- LCD_WR_H;
- LCD_RS_H;
- LCD_DATA_PORT=regData>>8;
- LCD_WR_L;
- LCD_WR_H;
- LCD_DATA_PORT=regData;
- LCD_WR_L;
- LCD_WR_H;
- }
- /*********************************************************************************************************
- **Functionname:LCD_ReadReg
- **Descriptions:读取指定寄存器的数据
- **inputparameters:寄存器地址:regID
- **outputparameters:无
- **Returnedvalue:读出数据(16位)
- *********************************************************************************************************/
- ////////////////////////////////////////////////////////////////////////////////////////////////////
- //nCS—-\_____________________________________________________________/——–//
- //RS—-\____________________________/—————————————–//
- //nRD———————————–\_____/——\_____/——————//
- //nWR——\______/——–\_____/———————————————-//
- //DB[10:17]—[寄存器高8位]–[寄存器低8位]–[数据高8位]–[数据低8位]—————//
- /////////////////////////////////////////////////////////////////////////////////////////////////////
- unsignedintLCD_ReadReg(uint32regID)
- {
- uint32regData;
- LCD_WriteCmd(regID);
- LCD_DATA_IN;
- LCD_RS_H;
- LCD_RD_L;
- LCD_RD_H;
- regData=LCD_DATA_PIN;
- regData=regData<<8;
- LCD_RD_L;
- LCD_RD_H;
- regData|=LCD_DATA_PIN;
- LCD_WR_L;
- LCD_WR_H;
- LCD_DATA_OUT;
- returnregData;
- }
- /*********************************************************************************************************
- **Functionname:LCD_ILI9325_Init
- **Descriptions:9325/28内部寄存器的初始化
- **inputparameters:无
- **outputparameters:无
- **Returnedvalue:无
- *********************************************************************************************************/
- voidLCD_ILI9325_Init(void)
- {
- uint32ID=0x0000;
- LCD_Port_Init();
- LCD_REST_L;//复位
- Delay_nMS(50);
- LCD_REST_H;
- Delay_nMS(50);
- LCD_SELECT();
- ID=LCD_ReadReg(0x0000);//读LCD的ID,这里是9328
- Uart_Transmit(ID>>8);//串口调查
- Uart_Transmit(ID);
- LCD_WriteReg(0x0001,0x0100);
- LCD_WriteReg(0x0002,0x0700);
- LCD_WriteReg(0x0003,0x1030);//转化RGB至GBR,水平扫描
- LCD_WriteReg(0x0004,0x0000);
- LCD_WriteReg(0x0008,0x0207);
- LCD_WriteReg(0x0009,0x0000);
- LCD_WriteReg(0x000A,0x0000);
- LCD_WriteReg(0x000C,0x0000);
- LCD_WriteReg(0x000D,0x0000);
- LCD_WriteReg(0x000F,0x0000);
- //poweronsequenceVGHVGL
- LCD_WriteReg(0x0010,0x0000);
- LCD_WriteReg(0x0011,0x0007);
- LCD_WriteReg(0x0012,0x0000);
- LCD_WriteReg(0x0013,0x0000);
- //vgh
- LCD_WriteReg(0x0010,0x1290);
- LCD_WriteReg(0x0011,0x0227);
- //vregiout
- LCD_WriteReg(0x0012,0x001d);//0x001b
- //vomamplitude
- LCD_WriteReg(0x0013,0x1500);
- //vomH
- LCD_WriteReg(0x0029,0x0018);
- LCD_WriteReg(0x002B,0x000D);
- //gamma
- LCD_WriteReg(0x0030,0x0004);
- LCD_WriteReg(0x0031,0x0307);
- LCD_WriteReg(0x0032,0x0002);//0006
- LCD_WriteReg(0x0035,0x0206);
- LCD_WriteReg(0x0036,0x0408);
- LCD_WriteReg(0x0037,0x0507);
- LCD_WriteReg(0x0038,0x0204);//0200
- LCD_WriteReg(0x0039,0x0707);
- LCD_WriteReg(0x003C,0x0405);//0504
- LCD_WriteReg(0x003D,0x0F02);
- //ram
- LCD_WriteReg(0x0050,0x0000);
- LCD_WriteReg(0x0051,0x00EF);
- LCD_WriteReg(0x0052,0x0000);
- LCD_WriteReg(0x0053,0x013F);
- LCD_WriteReg(0x0060,0xA700);
- LCD_WriteReg(0x0061,0x0001);
- LCD_WriteReg(0x006A,0x0000);
- //
- LCD_WriteReg(0x0080,0x0000);
- LCD_WriteReg(0x0081,0x0000);
- LCD_WriteReg(0x0082,0x0000);
- LCD_WriteReg(0x0083,0x0000);
- LCD_WriteReg(0x0084,0x0000);
- LCD_WriteReg(0x0085,0x0000);
- //
- LCD_WriteReg(0x0090,0x0010);
- LCD_WriteReg(0x0092,0x0600);
- LCD_WriteReg(0x0093,0x0003);
- LCD_WriteReg(0x0095,0x0110);
- LCD_WriteReg(0x0097,0x0000);
- LCD_WriteReg(0x0098,0x0000);
- LCD_WriteReg(0x0007,0x0133);
- LCD_DIS_SELECT();
- }
- /*********************************************************************************************************
- **Functionname:LCD_SetWindow
- **Descriptions:界说刷屏窗口
- **inputparameters:开端坐标(x0,y0),停止坐标(x1,y1)
- **outputparameters:无
- **Returnedvalue:无
- *********************************************************************************************************/
- staticvoidLCD_SetWindow(unsignedintx0,unsignedintx1,unsignedinty0,unsignedinty1)
- {
- LCD_WriteReg(0x0050,x0);
- LCD_WriteReg(0x0051,x1);
- LCD_WriteReg(0x0052,y0);
- LCD_WriteReg(0x0053,y1);
- LCD_WriteReg(0x0020,x0);
- LCD_WriteReg(0x0021,y0);
- LCD_WriteCmd(0x0022);//GRAM寄存器,之后能够写GRAM缓冲区
- }
- /*******************************************************************************************************************/
- /*******************************************************************************************************************/
- /**************************************************以下为LCD的使用函数**********************************************/
- /*******************************************************************************************************************/
- /*******************************************************************************************************************/
- /*********************************************************************************************************
- **Functionname:LCD_ClearScreen
- **Descriptions:刷整屏为一种色彩
- **inputparameters:色彩的RGB值color
- **outputparameters:无
- **Returnedvalue:无
- *********************************************************************************************************/
- voidLCD_ClearScreen(unsignedintcolor)
- {
- unsignedinti,j;
- LCD_SELECT();//挑选9328
- LCD_SetWindow(0,240,0,320);//320×240的屏
- for(i=0;i<320;i++)
- {
- for(j=0;j<240;j++)
- {
- LCD_WriteData(color);//向GRAM写入RGB数据
- }
- }
- LCD_DIS_SELECT();//操作结束
- }
- /*********************************************************************************************************
- **Functionname:LCD_Fill
- **Descriptions:填充一个矩形区域
- **inputparameters:矩形开端坐标—-(x0,y0),矩形结尾坐标–(x1,y1)
- **outputparameters:无
- **Returnedvalue:无
- *********************************************************************************************************/
- //
- voidLCD_Fill_Rectangle(unsignedintx0,unsignedinty0,unsignedintx1,unsignedinty1,unsignedintcolor)
- {
- unsignedlongi;
- LCD_SELECT();//挑选9328
- LCD_SetWindow(x0,x1,y0,y1);
- for(i=0;i<(x1-x0+1)*(y1-y0+1);i++)
- {
- LCD_WriteData(color);//填充色彩
- }
- LCD_DIS_SELECT();//操作结束
- }
- /*********************************************************************************************************
- **Functionname:Get_CharOffset
- **Descriptions:获取字节的偏移量
- **inputparameters:输入字节
- **outputparameters:无
- **Returnedvalue:偏移量
- *********************************************************************************************************/
- unsignedcharGet_CharOffset(unsignedcharchar_data)
- {
- if(char_data>=&&char_data<=})
- {
- char_data-=;//字符偏移从空格开端
- }
- else
- {
- char_data=;//如无匹配字符以空格替代
- }
- returnchar_data;//回来字符地点字符表的方位
- }
- /*********************************************************************************************************
- **Functionname:Set_CharWindow
- **Descriptions:设置字节窗口
- **inputparameters:每个字符8X16像素,共30行20列,lineNum—-字符地点行号,rowLine—-字符地点列号
- **outputparameters:无
- **Returnedvalue:无
- *********************************************************************************************************/
- //例如显现2这个字节窗口,为一个8X16的像素矩形
- //________,
- //________,
- //________,
- //__XXX___,
- //_X___X__,//lineNum
- //_____X__,
- //_____X__,
- //____X___,
- //___X____,
- //__X_____,
- //_X______,
- //_XXXXX__,
- //________,
- //________,
- //________,
- //________,
- voidSet_CharWindow(unsignedintlineNum,unsignedintrowNum)
- {
- unsignedintx0=0;
- unsignedinty0=0;
- x0=rowNum<<3;//开端X像素坐标
- y0=lineNum<<4;//其实Y像素坐标
- LCD_SetWindow(x0,x0+7,y0,y0+15);
- }
- /*********************************************************************************************************
- **Functionname:LCD_WriteChar
- **Descriptions:向屏幕写一个字节
- **inputparameters:lineNum一共字符开端的行数,rowNum表字符开端的列数,共30X20个字符,背景色bkColor,写入的字节chChar
- 字符色彩—-charColor
- 待显现的字符ch_char
- **outputparameters:无
- **Returnedvalue:无
- *********************************************************************************************************/
- voidLCD_WriteChar(unsignedintlineNum,
- unsignedintrowNum,
- unsignedintcharColor,
- unsignedintbkColor,
- unsignedcharchChar)
- {
- unsignedcharshow_cnt=0;
- unsignedcharbit_cnt=0;
- unsignedintcharPos=0;//字符在字符表中地点的方位
- LCD_SELECT();
- charPos=Get_CharOffset(chChar);//获取字模显现的偏移量
- Set_CharWindow(lineNum,rowNum);//设置开端坐标,xy是8*16的方格坐标
- for(show_cnt=0;show_cnt<16;show_cnt++)
- {
- for(bit_cnt=0;bit_cnt<8;bit_cnt++)
- {
- if(Letter[charPos][show_cnt]&BIT(7-bit_cnt))
- {
- LCD_WriteData(charColor);//字符色彩
- }
- else
- {
- LCD_WriteData(bkColor);//背景色
- }
- }
- }
- LCD_DIS_SELECT();
- }
- /*******************************************************************************************************************
- **Functionname:LCD_WriteString
- **Descriptions:向屏幕写字符串
- **inputparameters:字符开端队伍(lineNum,rowLine),背景色—bkColor,字节色彩—charColor,字符串指针p_str
- **outputparameters:无
- **Returnedvalue:无
- ********************************************************************************************************************/
- voidLCD_WriteString(unsignedcharlineNum,unsignedcharrowNum,
- unsignedintcharColor,
- unsignedintbkColor,
- unsignedchar*p_str)
- {
- while(*p_str)
- {
- //核算坐标
- if(*p_str==\n)//换行
- {
- rowNum=0;
- lineNum++;
- p_str++;//调过换行符,不必显现
- continue;//查询下一个字符
- }
- else//未遇到换行符则按正常显现坐标自加
- {
- LCD_WriteChar(lineNum,rowNum,charColor,bkColor,*p_str);
- rowNum++;
- if(rowNum==CHAR_X_NUM)
- {
- rowNum=0;
- lineNum++;
- if(lineNum==CHAR_Y_NUM)
- {
- lineNum=0;
- }
- }
- }
- p_str++;//字符串指针++
- }
- }
- /*********************************************************************************************************
- *EndOfFile*
- *********************************************************************************************************/
文件名:main.c 主函数测验
- /****************************************Copyright(c)**************************************************
- **SoutheastUniversity
- **————–FileInfo——————————————————————————-
- **FileName:main.c
- **LastmodifiedDate:2012-04-11
- **LastVersion:1.0
- **Description:测验函数
- **——————————————————————————————————
- **CreatedBy:JianGe
- **Createddate:2012-03-23
- **Version:1.0
- **——————————————————————————————————*/
- #include
- #include
- #include”Type.h”
- #include”Delay.h”
- #include”USART.h”
- voidmain(void)
- {
- unsignedchar*ptr=”ABCDEFGHIJKLMNOPQRSTUVWXYZ”;
- USART_Init();
- LCD_ILI9325_Init();
- LCD_ClearScreen(0xF800);
- LCD_Fill_Rectangle(0,0,200,200,0xF800);
- LCD_WriteChar(1,1,0xF800,0xFFFF,1);//显现字符
- LCD_WriteString(0,0,0xF800,0xFFFF,ptr);//显现字符串
- }