您的位置 首页 硬件

ATmega16L驱动ILI9325/9328

首先是硬件连线:PB—-8位数据口PA0—复位信号RESETPA1—片选CSPA2—-寄存器选择信号RSPA3—写信号WRPA4—读信号RD文…

首先是硬件连线:PB—-8位数据口

PA0— 复位信号RESET

PA1—片选CS

PA2—-寄存器挑选信号RS

PA3—写信号WR

PA4—读信号RD

文件名:Type.h,首要界说一些数据变量的别号

  1. /****************************************Copyright(c)**************************************************
  2. **SoutheastUniversity
  3. **————–FileInfo——————————————————————————-
  4. **FileName:Type.h
  5. **LastmodifiedDate:2012-03-23
  6. **LastVersion:1.0
  7. **Description:界说数据类型别号
  8. **——————————————————————————————————
  9. **CreatedBy:JianGe
  10. **Createddate:2012-03-23
  11. **Version:1.0
  12. **——————————————————————————————————*/
  13. #ifndef__TYPE_H__
  14. #define__TYPE_H__
  15. /********************************************************************************************************
  16. *Datetypes(Compilerspecific)数据类型(和编译器相关)*
  17. ********************************************************************************************************/
  18. typedefunsignedcharuint8;//Unsigned8bitquantity无符号8位整型变量
  19. typedefunsignedcharuchar;//Unsigned8bitquantity无符号8位整型变量
  20. typedefsignedcharint8;//Signed8bitquantity有符号8位整型变量
  21. typedefunsignedshortuint16;//Unsigned16bitquantity无符号16位整型变量
  22. typedefsignedshortint16;//Signed16bitquantity有符号16位整型变量
  23. typedefunsignedintuint32;//Unsigned32bitquantity无符号32位整型变量
  24. typedefunsignedintuint;//Unsigned32bitquantity无符号32位整型变量
  25. typedefsignedintint32;//Signed32bitquantity有符号32位整型变量
  26. typedeffloatfp32;//Singleprecisionfloatingpoint单精度浮点数(32位长度)
  27. typedefdoublefp64;//Doubleprecisionfloatingpoint双精度浮点数(64位长度)
  28. #ifndefTRUE
  29. #defineTRUE1
  30. #endif
  31. #ifndefFALSE
  32. #defineFALSE0
  33. #endif
  34. #ifndefNULL
  35. #defineNULL0
  36. #endif
  37. #endif
  38. /*********************************************************************************************************
  39. *EndOfFile*
  40. *********************************************************************************************************/

文件名:USART.h,串口操作函数的声明

  1. /****************************************Copyright(c)**************************************************
  2. **SoutheastUniversity
  3. **————–FileInfo——————————————————————————-
  4. **FileName:USART.h
  5. **LastmodifiedDate:2012-03-23
  6. **LastVersion:1.0
  7. **Description:串口函数声明
  8. **——————————————————————————————————
  9. **CreatedBy:JianGe
  10. **Createddate:2012-03-23
  11. **Version:1.0
  12. **——————————————————————————————————*/
  13. #ifndef_USART_H
  14. #define_USART_H
  15. #include”Type.h”
  16. #defineBAUD9600//波特率设置
  17. #defineCRYSTAL4000000//11059200//晶振频率
  18. #defineBAUD_SET(uint16)((uint32)CRYSTAL/(16*(uint32)BAUD)-1)
  19. #defineBAUD_H(uint8)(BAUD_SET>>8)
  20. #defineBAUD_L(uint8)(BAUD_SET)
  21. #defineFE_EERBIT(FE)//帧接纳过错
  22. #definePE_EERBIT(PE)//校验过错
  23. #defineDATA_OVERBIT(DOR)//接纳溢出过错
  24. #defineUDR_EMPTYBIT(UDRE)//数据寄存器空
  25. #defineUSAT_TX_ENUCSRB|=BIT(TXEN)//使能USART发送
  26. #defineUSAT_TX_NO_ENUCSRB&=~BIT(TXEN)
  27. #defineUSAT_RX_ENUCSRB|=BIT(RXEN)//使能USART接纳
  28. #defineUSAT_RX_NO_ENUCSRB&=~BIT(RXEN)
  29. externvoidUSART_Init(void);
  30. externvoidUart_Transmit(unsignedchari);
  31. externunsignedcharUart_Receive(void);
  32. #endif
  33. /*********************************************************************************************************
  34. *EndOfFile*
  35. *********************************************************************************************************/

文件名:Delay.h,延时函数的声明

  1. /****************************************Copyright(c)**************************************************
  2. **SoutheastUniversity
  3. **————–FileInfo——————————————————————————-
  4. **FileName:Delay.h
  5. **LastmodifiedDate:2012-03-23
  6. **LastVersion:1.0
  7. **Description:延时函数声明
  8. **——————————————————————————————————
  9. **CreatedBy:JianGe
  10. **Createddate:2012-03-23
  11. **Version:1.0
  12. **——————————————————————————————————*/
  13. #ifndefDELAY_H_H_
  14. #defineDELAY_H_H_
  15. #defineDELAY_USasm(“nop”);asm(“nop”);asm(“nop”);asm(“nop”);\
  16. asm(“nop”);asm(“nop”);asm(“nop”);asm(“nop”);
  17. externvoidDelay_nUS(unsignedintn);
  18. externvoidDelay_MS(void);
  19. externvoidDelay_nMS(unsignedintn);
  20. #endif
  21. /*********************************************************************************************************
  22. *EndOfFile*
  23. *********************************************************************************************************/

文件名:LCDDriver.h,LCD驱动函数和使用函数的声明

  1. /****************************************Copyright(c)**************************************************
  2. **SoutheastUniversity
  3. **————–FileInfo——————————————————————————-
  4. **FileName:LCD_Driver.h
  5. **LastmodifiedDate:2012-03-24
  6. **LastVersion:1.0
  7. **Description:LCD驱动函数声明
  8. **——————————————————————————————————
  9. **CreatedBy:JianGe
  10. **Createddate:2012-03-24
  11. **Version:1.0
  12. **——————————————————————————————————*/
  13. #ifndefLCD_DRIVER_H_H_
  14. #defineLCD_DRIVER_H_H_
  15. #include”Type.h”
  16. #include
  17. externvoidLCD_Port_Init(void);
  18. externvoidLCD_WriteCmd(uint32regID);
  19. externvoidLCD_WriteData(uint32data);
  20. externvoidLCD_WriteReg(uint32regID,uint32regData);
  21. externunsignedintLCD_ReadReg(uint32regID);
  22. externvoidLCD_ILI9325_Init(void);
  23. externvoidLCD_SetWindow(unsignedintx0,unsignedintx1,unsignedinty0,unsignedinty1);
  24. externvoidLCD_ClearScreen(unsignedintcolor);
  25. externvoidLCD_Fill_Rectangle(unsignedintx0,unsignedinty0,unsignedintx1,unsignedinty1,unsignedintcolor);
  26. externunsignedcharGet_CharOffset(unsignedcharchar_data);
  27. externvoidSet_CharWindow(unsignedintlineNum,unsignedintrowNum);
  28. externvoidLCD_WriteChar(unsignedintlineNum,
  29. unsignedintrowNum,
  30. unsignedintcharColor,
  31. unsignedintbkColor,
  32. unsignedcharchChar)
  33. externvoidLCD_WriteString(unsignedcharlineNum,unsignedcharrowNum,
  34. unsignedintcharColor,
  35. unsignedintbkColor,
  36. unsignedchar*p_str)
  37. #endif
  38. /*********************************************************************************************************
  39. *EndOfFile*
  40. *********************************************************************************************************/

文件名:LCD_Font.h LCD字体库的声明

  1. /****************************************Copyright(c)**************************************************
  2. **SoutheastUniversity
  3. **————–FileInfo——————————————————————————-
  4. **FileName:LCD_Font.h
  5. **LastmodifiedDate:2012-03-27
  6. **LastVersion:1.0
  7. **Description:LCD显现字符的字节表
  8. **——————————————————————————————————
  9. **CreatedBy:JianGe
  10. **Createddate:2012-03-27
  11. **Version:1.0
  12. **——————————————————————————————————*/
  13. #ifndefLCD_FONT_H_H_
  14. #defineLCD_FONT_H_H_
  15. //常用ASCII字符码表
  16. constunsignedcharLetter[][16]=
  17. {
  18. //榜首栏从到?
  19. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*””,0*/
  20. {0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x18,0x18,0x00,0x00},/*”!”,1*/
  21. {0x00,0x12,0x36,0x24,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”””,2*/
  22. {0x00,0x00,0x00,0x24,0x24,0x24,0xFE,0x48,0x48,0x48,0xFE,0x48,0x48,0x48,0x00,0x00},/*”#”,3*/
  23. {0x00,0x00,0x10,0x38,0x54,0x54,0x50,0x30,0x18,0x14,0x14,0x54,0x54,0x38,0x10,0x10},/*”$”,4*/
  24. {0x00,0x00,0x00,0x44,0xA4,0xA8,0xA8,0xA8,0x54,0x1A,0x2A,0x2A,0x2A,0x44,0x00,0x00},/*”%”,5*/
  25. {0x00,0x00,0x00,0x30,0x48,0x48,0x48,0x50,0x6E,0xA4,0x94,0x88,0x89,0x76,0x00,0x00},/*”&”,6*/
  26. {0x00,0x60,0x60,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*””,7*/
  27. {0x00,0x02,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x02,0x00},/*”(“,8*/
  28. {0x00,0x40,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x40,0x00},/*”)”,9*/
  29. {0x00,0x00,0x00,0x00,0x10,0x10,0xD6,0x38,0x38,0xD6,0x10,0x10,0x00,0x00,0x00,0x00},/*”*”,10*/
  30. {0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0xFE,0x10,0x10,0x10,0x10,0x00,0x00,0x00},/*”+”,11*/
  31. {0x00,0x60,0x60,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*””,12*/
  32. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”-“,13*/
  33. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00},/*”.”,14*/
  34. {0x00,0x00,0x01,0x02,0x02,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x00},/*”/”,15*/
  35. {0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*”0″,16*/
  36. {0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*”1″,17*/
  37. {0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x04,0x04,0x08,0x10,0x20,0x42,0x7E,0x00,0x00},/*”2″,18*/
  38. {0x00,0x00,0x00,0x3C,0x42,0x42,0x04,0x18,0x04,0x02,0x02,0x42,0x44,0x38,0x00,0x00},/*”3″,19*/
  39. {0x00,0x00,0x00,0x04,0x0C,0x14,0x24,0x24,0x44,0x44,0x7E,0x04,0x04,0x1E,0x00,0x00},/*”4″,20*/
  40. {0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x58,0x64,0x02,0x02,0x42,0x44,0x38,0x00,0x00},/*”5″,21*/
  41. {0x00,0x00,0x00,0x1C,0x24,0x40,0x40,0x58,0x64,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*”6″,22*/
  42. {0x00,0x00,0x00,0x7E,0x44,0x44,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00},/*”7″,23*/
  43. {0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00},/*”8″,24*/
  44. {0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x26,0x1A,0x02,0x02,0x24,0x38,0x00,0x00},/*”9″,25*/
  45. {0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00},/*”:”,26*/
  46. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x20},/*”;”,27*/
  47. {0x00,0x00,0x00,0x02,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x02,0x00,0x00},/*”<",28*/
  48. {0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00},/*”=”,29*/
  49. {0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x40,0x00,0x00},/*”>”,30*/
  50. {0x00,0x00,0x00,0x3C,0x42,0x42,0x62,0x02,0x04,0x08,0x08,0x00,0x18,0x18,0x00,0x00},/*”?”,31*/
  51. //第二栏从@开端
  52. {0x00,0x00,0x00,0x38,0x44,0x5A,0xAA,0xAA,0xAA,0xAA,0xB4,0x42,0x44,0x38,0x00,0x00},/*”@”,32*/
  53. {0x00,0x00,0x00,0x10,0x10,0x18,0x28,0x28,0x24,0x3C,0x44,0x42,0x42,0xE7,0x00,0x00},/*”A”,33*/
  54. {0x00,0x00,0x00,0xF8,0x44,0x44,0x44,0x78,0x44,0x42,0x42,0x42,0x44,0xF8,0x00,0x00},/*”B”,34*/
  55. {0x00,0x00,0x00,0x3E,0x42,0x42,0x80,0x80,0x80,0x80,0x80,0x42,0x44,0x38,0x00,0x00},/*”C”,35*/
  56. {0x00,0x00,0x00,0xF8,0x44,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x44,0xF8,0x00,0x00},/*”D”,36*/
  57. {0x00,0x00,0x00,0xFC,0x42,0x48,0x48,0x78,0x48,0x48,0x40,0x42,0x42,0xFC,0x00,0x00},/*”E”,37*/
  58. {0x00,0x00,0x00,0xFC,0x42,0x48,0x48,0x78,0x48,0x48,0x40,0x40,0x40,0xE0,0x00,0x00},/*”F”,38*/
  59. {0x00,0x00,0x00,0x3C,0x44,0x44,0x80,0x80,0x80,0x8E,0x84,0x44,0x44,0x38,0x00,0x00},/*”G”,39*/
  60. {0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*”H”,40*/
  61. {0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*”I”,41*/
  62. {0x00,0x00,0x00,0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x88,0xF0},/*”J”,42*/
  63. {0x00,0x00,0x00,0xEE,0x44,0x48,0x50,0x70,0x50,0x48,0x48,0x44,0x44,0xEE,0x00,0x00},/*”K”,43*/
  64. {0x00,0x00,0x00,0xE0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x42,0xFE,0x00,0x00},/*”L”,44*/
  65. {0x00,0x00,0x00,0xEE,0x6C,0x6C,0x6C,0x6C,0x54,0x54,0x54,0x54,0x54,0xD6,0x00,0x00},/*”M”,45*/
  66. {0x00,0x00,0x00,0xC7,0x62,0x62,0x52,0x52,0x4A,0x4A,0x4A,0x46,0x46,0xE2,0x00,0x00},/*”N”,46*/
  67. {0x00,0x00,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x44,0x38,0x00,0x00},/*”O”,47*/
  68. {0x00,0x00,0x00,0xFC,0x42,0x42,0x42,0x42,0x7C,0x40,0x40,0x40,0x40,0xE0,0x00,0x00},/*”P”,48*/
  69. {0x00,0x00,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0x82,0xB2,0xCA,0x4C,0x38,0x06,0x00},/*”Q”,49*/
  70. {0x00,0x00,0x00,0xFC,0x42,0x42,0x42,0x7C,0x48,0x48,0x44,0x44,0x42,0xE3,0x00,0x00},/*”R”,50*/
  71. {0x00,0x00,0x00,0x3E,0x42,0x42,0x40,0x20,0x18,0x04,0x02,0x42,0x42,0x7C,0x00,0x00},/*”S”,51*/
  72. {0x00,0x00,0x00,0xFE,0x92,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00},/*”T”,52*/
  73. {0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00},/*”U”,53*/
  74. {0x00,0x00,0x00,0xE7,0x42,0x42,0x44,0x24,0x24,0x28,0x28,0x18,0x10,0x10,0x00,0x00},/*”V”,54*/
  75. {0x00,0x00,0x00,0xD6,0x92,0x92,0x92,0x92,0xAA,0xAA,0x6C,0x44,0x44,0x44,0x00,0x00},/*”W”,55*/
  76. {0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x18,0x18,0x18,0x24,0x24,0x42,0xE7,0x00,0x00},/*”X”,56*/
  77. {0x00,0x00,0x00,0xEE,0x44,0x44,0x28,0x28,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00},/*”Y”,57*/
  78. {0x00,0x00,0x00,0x7E,0x84,0x04,0x08,0x08,0x10,0x20,0x20,0x42,0x42,0xFC,0x00,0x00},/*”Z”,58*/
  79. {0x00,0x1E,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1E,0x00},/*”[“,59*/
  80. {0x00,0x00,0x40,0x40,0x20,0x20,0x10,0x10,0x10,0x08,0x08,0x04,0x04,0x04,0x02,0x02},/*”\”,60*/
  81. {0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x78,0x00},/*”]”,61*/
  82. {0x00,0x1C,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”^”,62*/
  83. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”-“,63*/
  84. //第三栏从开端
  85. {0x00,0x60,0x60,0x20,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*””,64*/
  86. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x1E,0x22,0x42,0x42,0x3F,0x00,0x00},/*”a”,65*/
  87. {0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0x58,0x64,0x42,0x42,0x42,0x64,0x58,0x00,0x00},/*”b”,66*/
  88. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x40,0x40,0x40,0x22,0x1C,0x00,0x00},/*”c”,67*/
  89. {0x00,0x00,0x00,0x06,0x02,0x02,0x02,0x1E,0x22,0x42,0x42,0x42,0x26,0x1B,0x00,0x00},/*”d”,68*/
  90. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x7E,0x40,0x40,0x42,0x3C,0x00,0x00},/*”e”,69*/
  91. {0x00,0x00,0x00,0x0F,0x11,0x10,0x10,0x7E,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*”f”,70*/
  92. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x44,0x44,0x38,0x40,0x3C,0x42,0x42,0x3C},/*”g”,71*/
  93. {0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0x5C,0x62,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*”h”,72*/
  94. {0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*”i”,73*/
  95. {0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x1C,0x04,0x04,0x04,0x04,0x04,0x04,0x44,0x78},/*”j”,74*/
  96. {0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0x4E,0x48,0x50,0x68,0x48,0x44,0xEE,0x00,0x00},/*”k”,75*/
  97. {0x00,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00},/*”l”,76*/
  98. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x49,0x49,0x49,0x49,0x49,0xED,0x00,0x00},/*”m”,77*/
  99. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDC,0x62,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*”n”,78*/
  100. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00},/*”o”,79*/
  101. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD8,0x64,0x42,0x42,0x42,0x44,0x78,0x40,0xE0},/*”p”,80*/
  102. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x22,0x42,0x42,0x42,0x22,0x1E,0x02,0x07},/*”q”,81*/
  103. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEE,0x32,0x20,0x20,0x20,0x20,0xF8,0x00,0x00},/*”r”,82*/
  104. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x42,0x40,0x3C,0x02,0x42,0x7C,0x00,0x00},/*”s”,83*/
  105. {0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x10,0x10,0x10,0x0C,0x00,0x00},/*”t”,84*/
  106. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC6,0x42,0x42,0x42,0x42,0x46,0x3B,0x00,0x00},/*”u”,85*/
  107. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x28,0x10,0x10,0x00,0x00},/*”v”,86*/
  108. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD7,0x92,0x92,0xAA,0xAA,0x44,0x44,0x00,0x00},/*”w”,87*/
  109. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6E,0x24,0x18,0x18,0x18,0x24,0x76,0x00,0x00},/*”x”,88*/
  110. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x28,0x18,0x10,0x10,0xE0},/*”y”,89*/
  111. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x44,0x08,0x10,0x10,0x22,0x7E,0x00,0x00},/*”z”,90*/
  112. {0x00,0x03,0x04,0x04,0x04,0x04,0x04,0x08,0x04,0x04,0x04,0x04,0x04,0x04,0x03,0x00},/*”{“,91*/
  113. {0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00},/*”:”,92*/
  114. {0x00,0x60,0x10,0x10,0x10,0x10,0x10,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x60,0x00},/*”}”,93*/
  115. {0x30,0x4C,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”~”,94*/
  116. {0x00,0x1C,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*”^”,95*/
  117. };
  118. #endif
  119. /*********************************************************************************************************
  120. *EndOfFile*
  121. *********************************************************************************************************/

文件名: Delay.c,延时函数的完成

  1. /****************************************Copyright(c)**************************************************
  2. **SoutheastUniversity
  3. **————–FileInfo——————————————————————————-
  4. **FileName:Delay.c
  5. **LastmodifiedDate:2012-03-23
  6. **LastVersion:1.0
  7. **Description:延时函数完成
  8. **——————————————————————————————————
  9. **CreatedBy:JianGe
  10. **Createddate:2012-03-23
  11. **Version:1.0
  12. **——————————————————————————————————*/
  13. #include”Delay.h”
  14. #include”Type.h”
  15. /*********************************************************************************************************
  16. **Functionname:Delay_nUS
  17. **Descriptions:延时n微秒
  18. **inputparameters:无
  19. **outputparameters:无
  20. **Returnedvalue:无
  21. *********************************************************************************************************/
  22. voidDelay_nUS(uint32n)
  23. {
  24. uint32i=0;
  25. for(i=0;i
  26. {
  27. DELAY_US;
  28. }
  29. }
  30. /*********************************************************************************************************
  31. **Functionname:Delay_MS
  32. **Descriptions:延时1毫秒
  33. **inputparameters:无
  34. **outputparameters:无
  35. **Returnedvalue:无
  36. *********************************************************************************************************/
  37. voidDelay_MS(void)
  38. {
  39. uint32i=0;
  40. for(i=0;i<1000;i++)
  41. {
  42. DELAY_US;
  43. }
  44. }
  45. /*********************************************************************************************************
  46. **Functionname:Delay_nMS
  47. **Descriptions:延时n毫秒
  48. **inputparameters:无
  49. **outputparameters:无
  50. **Returnedvalue:无
  51. *********************************************************************************************************/
  52. voidDelay_nMS(uint32n)
  53. {
  54. uint32i=0;
  55. for(i=0;i
  56. {
  57. Delay_MS();
  58. }
  59. }
  60. /*********************************************************************************************************
  61. *EndOfFile*
  62. *********************************************************************************************************/

文件名:USART.c 串口调试函数的完成

  1. /****************************************Copyright(c)**************************************************
  2. **SoutheastUniversity
  3. **————–FileInfo——————————————————————————-
  4. **FileName:USART.c
  5. **LastmodifiedDate:2012-03-23
  6. **LastVersion:1.0
  7. **Description:串口函数完成
  8. **——————————————————————————————————
  9. **CreatedBy:JianGe
  10. **Createddate:2012-03-23
  11. **Version:1.0
  12. **——————————————————————————————————*/
  13. #include
  14. #include”USART.h”
  15. /*串口初始化函数*/
  16. voidUSART_Init(void)
  17. {
  18. UCSRA=0x02;/*倍速*/
  19. UCSRB=0x18;/*答应接纳和发送*/
  20. UCSRC=0x06;/*8位数据*/
  21. UBRRH=0x00;
  22. //UBRRL=12;/*9600*/
  23. //UBRRL=103;//11.0592M下9600
  24. UBRRL=207;//16MHz下9600
  25. }/*数据发送,查询方法*/
  26. voidUart_Transmit(unsignedchari)
  27. {
  28. while(!(UCSRA&(1<
  29. UDR=i;/*发送数据*/
  30. }
  31. /*数据接纳,查询方法*/
  32. unsignedcharUart_Receive(void)
  33. {while(!(UCSRA&(1<
  34. returnUDR;/*获取并回来数据*/
  35. }
  36. /*********************************************************************************************************
  37. *EndOfFile*
  38. *********************************************************************************************************/

文件名:LCDDriver.c LCD驱动函数以及上层函数的完成

  1. /****************************************Copyright(c)**************************************************
  2. **SoutheastUniversity
  3. **————–FileInfo——————————————————————————-
  4. **FileName:LCDDriver.c
  5. **LastmodifiedDate:2012-04-12
  6. **LastVersion:1.0
  7. **Description:LCD驱动函数的完成
  8. **——————————————————————————————————
  9. **CreatedBy:JianGe
  10. **Createddate:2012-03-24
  11. **Version:1.0
  12. **——————————————————————————————————*/
  13. #include”Delay.h”
  14. #include
  15. #include
  16. #include”USART.h”
  17. #include”LCD_Font.h”
  18. #include”Type.h”
  19. ///////////屏显现参数设置///////////////
  20. //设置屏显现像素巨细
  21. #defineX_SIZE240
  22. #defineY_SIZE320
  23. //x和y的最大坐标值,坐标原点为(0,0)
  24. #defineX_END(X_SIZE-1)
  25. #defineY_END(Y_SIZE-1)
  26. //一个字符x*y的别离巨细
  27. #defineCHAR_X_SIZE8
  28. #defineCHAR_Y_SIZE16
  29. //横坐标能显现的字符数X_SIZE/CHAR_X_SIZE
  30. #defineCHAR_X_NUM30
  31. //纵坐标能显现的字符数Y_SIZE/CHAR_Y_SIZE
  32. #defineCHAR_Y_NUM20
  33. ////////////////////////////////////////
  34. //LCD操控端口动作宏界说
  35. #defineLCD_CS_BITPA1
  36. #defineLCD_RS_BITPA2
  37. #defineLCD_WR_BITPA3
  38. #defineLCD_RD_BITPA4
  39. #defineLCD_REST_BITPA0
  40. #defineLCD_CLT_PORTPORTA
  41. #defineLCD_CLT_PINPINA
  42. #defineLCD_CLT_DDRDDRA
  43. #defineLCD_CS_LLCD_CLT_PORT&=~BIT(LCD_CS_BIT)
  44. #defineLCD_CS_HLCD_CLT_PORT|=BIT(LCD_CS_BIT)
  45. #defineLCD_RS_LLCD_CLT_PORT&=~BIT(LCD_RS_BIT)
  46. #defineLCD_RS_HLCD_CLT_PORT|=BIT(LCD_RS_BIT)
  47. #defineLCD_WR_LLCD_CLT_PORT&=~BIT(LCD_WR_BIT)
  48. #defineLCD_WR_HLCD_CLT_PORT|=BIT(LCD_WR_BIT)
  49. #defineLCD_RD_LLCD_CLT_PORT&=~BIT(LCD_RD_BIT)
  50. #defineLCD_RD_HLCD_CLT_PORT|=BIT(LCD_RD_BIT)
  51. #defineLCD_REST_LLCD_CLT_PORT&=~BIT(LCD_REST_BIT)
  52. #defineLCD_REST_HLCD_CLT_PORT|=BIT(LCD_REST_BIT)
  53. //8位数据口
  54. #defineDATA_HPB0
  55. #defineLCD_DATA_PORTPORTB
  56. #defineLCD_DATA_DDRDDRB
  57. #defineLCD_DATA_PINPINB
  58. #defineLCD_DATA_INDDRB=0x00
  59. #defineLCD_DATA_OUTDDRB=0xFF
  60. //读GRAM时需求一个虚晃的读(DummyRead)
  61. #defineDUMMY_READ()LCD_RD_L;LCD_RD_H;LCD_RD_L;LCD_RD_H;
  62. //片选,开端9328的某种操作前调用
  63. #defineLCD_SELECT()LCD_CS_L
  64. //片选,结束9328的某项操作后调用
  65. #defineLCD_DIS_SELECT()LCD_CS_H
  66. /*********************************************************************************************************
  67. **Functionname:LCD_Port_Init
  68. **Descriptions:LCD的操控端口和数据端口的初始化
  69. **inputparameters:寄存器地址regID
  70. **outputparameters:无
  71. **Returnedvalue:无
  72. *********************************************************************************************************/
  73. voidLCD_Port_Init(void)
  74. {
  75. LCD_DATA_OUT;
  76. LCD_DATA_PORT=0xFF;
  77. LCD_CLT_DDR=0xFF;
  78. LCD_CS_H;
  79. LCD_RS_H;
  80. LCD_WR_H;
  81. LCD_RD_H;
  82. LCD_REST_H;
  83. }
  84. /*********************************************************************************************************
  85. **Functionname:LCD_WriteCmd
  86. **Descriptions:写寄存器指令,挑选一个寄存器
  87. **inputparameters:寄存器地址regID
  88. **outputparameters:无
  89. **Returnedvalue:无
  90. *********************************************************************************************************/
  91. ///////////////////////////////////////////////////////////////////////////////////////////////////////
  92. //nCS—-\__________________________________________/—————————//
  93. //RS——\______________________________/————————————//
  94. //nRD—————————————————————————-//
  95. //nWR——–\______/———-\_____/——————————————-//
  96. //DB[10:17]—-[寄存器高8位]—–[寄存器低8位]——————————————-//
  97. ////////////////////////////////////////////////////////////////////////////////////////////////////////
  98. voidLCD_WriteCmd(uint32regID)
  99. {
  100. LCD_RS_L;
  101. LCD_DATA_PORT=regID>>8;
  102. LCD_WR_L;
  103. LCD_WR_H;
  104. LCD_DATA_PORT=regID;
  105. LCD_WR_L;
  106. LCD_WR_H;
  107. LCD_RS_H;
  108. }
  109. /*********************************************************************************************************
  110. **Functionname:LCD_WriteData
  111. **Descriptions:向LCD写数据
  112. **inputparameters:待写入的数据data
  113. **outputparameters:无
  114. **Returnedvalue:无
  115. *********************************************************************************************************/
  116. ////////////////////////////////////////////////////////////////////////////////////////////////////
  117. //nCS—-\__________________________________________/—————————–//
  118. //RS—————————————————————————–//
  119. //nRD————————————————————————-//
  120. //nWR——–\______/——–\_____/—————————————–//
  121. //DB[10:17]—–[数据高8位]—–[数据低8位]——————————————-//
  122. /////////////////////////////////////////////////////////////////////////////////////////////////////
  123. voidLCD_WriteData(uint32data)
  124. {
  125. LCD_DATA_PORT=data>>8;
  126. LCD_WR_L;
  127. LCD_WR_H;
  128. LCD_DATA_PORT=data;
  129. LCD_WR_L;
  130. LCD_WR_H;
  131. }
  132. /*********************************************************************************************************
  133. **Functionname:LCD_WriteReg
  134. **Descriptions:向一个寄存器写入数据
  135. **inputparameters:寄存器地址:regID待写入的数据regData
  136. **outputparameters:无
  137. **Returnedvalue:无
  138. *********************************************************************************************************/
  139. ////////////////////////////////////////////////////////////////////////////////////////////////////
  140. //nCS—-\_____________________________________________________________/——–//
  141. //RS—-\____________________________/—————————————–//
  142. //nRD————————————————————————-//
  143. //nWR——\______/——–\_____/——–\______/—–\______/—————-//
  144. //DB[10:17]—[寄存器高8位]—[寄存器低8位]—[数据高8位]—-[数据低8位]—————//
  145. /////////////////////////////////////////////////////////////////////////////////////////////////////
  146. voidLCD_WriteReg(uint32regID,uint32regData)
  147. {
  148. LCD_RS_L;
  149. LCD_DATA_PORT=regID>>8;
  150. LCD_WR_L;
  151. LCD_WR_H;
  152. LCD_DATA_PORT=regID;
  153. LCD_WR_L;
  154. LCD_WR_H;
  155. LCD_RS_H;
  156. LCD_DATA_PORT=regData>>8;
  157. LCD_WR_L;
  158. LCD_WR_H;
  159. LCD_DATA_PORT=regData;
  160. LCD_WR_L;
  161. LCD_WR_H;
  162. }
  163. /*********************************************************************************************************
  164. **Functionname:LCD_ReadReg
  165. **Descriptions:读取指定寄存器的数据
  166. **inputparameters:寄存器地址:regID
  167. **outputparameters:无
  168. **Returnedvalue:读出数据(16位)
  169. *********************************************************************************************************/
  170. ////////////////////////////////////////////////////////////////////////////////////////////////////
  171. //nCS—-\_____________________________________________________________/——–//
  172. //RS—-\____________________________/—————————————–//
  173. //nRD———————————–\_____/——\_____/——————//
  174. //nWR——\______/——–\_____/———————————————-//
  175. //DB[10:17]—[寄存器高8位]–[寄存器低8位]–[数据高8位]–[数据低8位]—————//
  176. /////////////////////////////////////////////////////////////////////////////////////////////////////
  177. unsignedintLCD_ReadReg(uint32regID)
  178. {
  179. uint32regData;
  180. LCD_WriteCmd(regID);
  181. LCD_DATA_IN;
  182. LCD_RS_H;
  183. LCD_RD_L;
  184. LCD_RD_H;
  185. regData=LCD_DATA_PIN;
  186. regData=regData<<8;
  187. LCD_RD_L;
  188. LCD_RD_H;
  189. regData|=LCD_DATA_PIN;
  190. LCD_WR_L;
  191. LCD_WR_H;
  192. LCD_DATA_OUT;
  193. returnregData;
  194. }
  195. /*********************************************************************************************************
  196. **Functionname:LCD_ILI9325_Init
  197. **Descriptions:9325/28内部寄存器的初始化
  198. **inputparameters:无
  199. **outputparameters:无
  200. **Returnedvalue:无
  201. *********************************************************************************************************/
  202. voidLCD_ILI9325_Init(void)
  203. {
  204. uint32ID=0x0000;
  205. LCD_Port_Init();
  206. LCD_REST_L;//复位
  207. Delay_nMS(50);
  208. LCD_REST_H;
  209. Delay_nMS(50);
  210. LCD_SELECT();
  211. ID=LCD_ReadReg(0x0000);//读LCD的ID,这里是9328
  212. Uart_Transmit(ID>>8);//串口调查
  213. Uart_Transmit(ID);
  214. LCD_WriteReg(0x0001,0x0100);
  215. LCD_WriteReg(0x0002,0x0700);
  216. LCD_WriteReg(0x0003,0x1030);//转化RGB至GBR,水平扫描
  217. LCD_WriteReg(0x0004,0x0000);
  218. LCD_WriteReg(0x0008,0x0207);
  219. LCD_WriteReg(0x0009,0x0000);
  220. LCD_WriteReg(0x000A,0x0000);
  221. LCD_WriteReg(0x000C,0x0000);
  222. LCD_WriteReg(0x000D,0x0000);
  223. LCD_WriteReg(0x000F,0x0000);
  224. //poweronsequenceVGHVGL
  225. LCD_WriteReg(0x0010,0x0000);
  226. LCD_WriteReg(0x0011,0x0007);
  227. LCD_WriteReg(0x0012,0x0000);
  228. LCD_WriteReg(0x0013,0x0000);
  229. //vgh
  230. LCD_WriteReg(0x0010,0x1290);
  231. LCD_WriteReg(0x0011,0x0227);
  232. //vregiout
  233. LCD_WriteReg(0x0012,0x001d);//0x001b
  234. //vomamplitude
  235. LCD_WriteReg(0x0013,0x1500);
  236. //vomH
  237. LCD_WriteReg(0x0029,0x0018);
  238. LCD_WriteReg(0x002B,0x000D);
  239. //gamma
  240. LCD_WriteReg(0x0030,0x0004);
  241. LCD_WriteReg(0x0031,0x0307);
  242. LCD_WriteReg(0x0032,0x0002);//0006
  243. LCD_WriteReg(0x0035,0x0206);
  244. LCD_WriteReg(0x0036,0x0408);
  245. LCD_WriteReg(0x0037,0x0507);
  246. LCD_WriteReg(0x0038,0x0204);//0200
  247. LCD_WriteReg(0x0039,0x0707);
  248. LCD_WriteReg(0x003C,0x0405);//0504
  249. LCD_WriteReg(0x003D,0x0F02);
  250. //ram
  251. LCD_WriteReg(0x0050,0x0000);
  252. LCD_WriteReg(0x0051,0x00EF);
  253. LCD_WriteReg(0x0052,0x0000);
  254. LCD_WriteReg(0x0053,0x013F);
  255. LCD_WriteReg(0x0060,0xA700);
  256. LCD_WriteReg(0x0061,0x0001);
  257. LCD_WriteReg(0x006A,0x0000);
  258. //
  259. LCD_WriteReg(0x0080,0x0000);
  260. LCD_WriteReg(0x0081,0x0000);
  261. LCD_WriteReg(0x0082,0x0000);
  262. LCD_WriteReg(0x0083,0x0000);
  263. LCD_WriteReg(0x0084,0x0000);
  264. LCD_WriteReg(0x0085,0x0000);
  265. //
  266. LCD_WriteReg(0x0090,0x0010);
  267. LCD_WriteReg(0x0092,0x0600);
  268. LCD_WriteReg(0x0093,0x0003);
  269. LCD_WriteReg(0x0095,0x0110);
  270. LCD_WriteReg(0x0097,0x0000);
  271. LCD_WriteReg(0x0098,0x0000);
  272. LCD_WriteReg(0x0007,0x0133);
  273. LCD_DIS_SELECT();
  274. }
  275. /*********************************************************************************************************
  276. **Functionname:LCD_SetWindow
  277. **Descriptions:界说刷屏窗口
  278. **inputparameters:开端坐标(x0,y0),停止坐标(x1,y1)
  279. **outputparameters:无
  280. **Returnedvalue:无
  281. *********************************************************************************************************/
  282. staticvoidLCD_SetWindow(unsignedintx0,unsignedintx1,unsignedinty0,unsignedinty1)
  283. {
  284. LCD_WriteReg(0x0050,x0);
  285. LCD_WriteReg(0x0051,x1);
  286. LCD_WriteReg(0x0052,y0);
  287. LCD_WriteReg(0x0053,y1);
  288. LCD_WriteReg(0x0020,x0);
  289. LCD_WriteReg(0x0021,y0);
  290. LCD_WriteCmd(0x0022);//GRAM寄存器,之后能够写GRAM缓冲区
  291. }
  292. /*******************************************************************************************************************/
  293. /*******************************************************************************************************************/
  294. /**************************************************以下为LCD的使用函数**********************************************/
  295. /*******************************************************************************************************************/
  296. /*******************************************************************************************************************/
  297. /*********************************************************************************************************
  298. **Functionname:LCD_ClearScreen
  299. **Descriptions:刷整屏为一种色彩
  300. **inputparameters:色彩的RGB值color
  301. **outputparameters:无
  302. **Returnedvalue:无
  303. *********************************************************************************************************/
  304. voidLCD_ClearScreen(unsignedintcolor)
  305. {
  306. unsignedinti,j;
  307. LCD_SELECT();//挑选9328
  308. LCD_SetWindow(0,240,0,320);//320×240的屏
  309. for(i=0;i<320;i++)
  310. {
  311. for(j=0;j<240;j++)
  312. {
  313. LCD_WriteData(color);//向GRAM写入RGB数据
  314. }
  315. }
  316. LCD_DIS_SELECT();//操作结束
  317. }
  318. /*********************************************************************************************************
  319. **Functionname:LCD_Fill
  320. **Descriptions:填充一个矩形区域
  321. **inputparameters:矩形开端坐标—-(x0,y0),矩形结尾坐标–(x1,y1)
  322. **outputparameters:无
  323. **Returnedvalue:无
  324. *********************************************************************************************************/
  325. //
  326. voidLCD_Fill_Rectangle(unsignedintx0,unsignedinty0,unsignedintx1,unsignedinty1,unsignedintcolor)
  327. {
  328. unsignedlongi;
  329. LCD_SELECT();//挑选9328
  330. LCD_SetWindow(x0,x1,y0,y1);
  331. for(i=0;i<(x1-x0+1)*(y1-y0+1);i++)
  332. {
  333. LCD_WriteData(color);//填充色彩
  334. }
  335. LCD_DIS_SELECT();//操作结束
  336. }
  337. /*********************************************************************************************************
  338. **Functionname:Get_CharOffset
  339. **Descriptions:获取字节的偏移量
  340. **inputparameters:输入字节
  341. **outputparameters:无
  342. **Returnedvalue:偏移量
  343. *********************************************************************************************************/
  344. unsignedcharGet_CharOffset(unsignedcharchar_data)
  345. {
  346. if(char_data>=&&char_data<=})
  347. {
  348. char_data-=;//字符偏移从空格开端
  349. }
  350. else
  351. {
  352. char_data=;//如无匹配字符以空格替代
  353. }
  354. returnchar_data;//回来字符地点字符表的方位
  355. }
  356. /*********************************************************************************************************
  357. **Functionname:Set_CharWindow
  358. **Descriptions:设置字节窗口
  359. **inputparameters:每个字符8X16像素,共30行20列,lineNum—-字符地点行号,rowLine—-字符地点列号
  360. **outputparameters:无
  361. **Returnedvalue:无
  362. *********************************************************************************************************/
  363. //例如显现2这个字节窗口,为一个8X16的像素矩形
  364. //________,
  365. //________,
  366. //________,
  367. //__XXX___,
  368. //_X___X__,//lineNum
  369. //_____X__,
  370. //_____X__,
  371. //____X___,
  372. //___X____,
  373. //__X_____,
  374. //_X______,
  375. //_XXXXX__,
  376. //________,
  377. //________,
  378. //________,
  379. //________,
  380. voidSet_CharWindow(unsignedintlineNum,unsignedintrowNum)
  381. {
  382. unsignedintx0=0;
  383. unsignedinty0=0;
  384. x0=rowNum<<3;//开端X像素坐标
  385. y0=lineNum<<4;//其实Y像素坐标
  386. LCD_SetWindow(x0,x0+7,y0,y0+15);
  387. }
  388. /*********************************************************************************************************
  389. **Functionname:LCD_WriteChar
  390. **Descriptions:向屏幕写一个字节
  391. **inputparameters:lineNum一共字符开端的行数,rowNum表字符开端的列数,共30X20个字符,背景色bkColor,写入的字节chChar
  392. 字符色彩—-charColor
  393. 待显现的字符ch_char
  394. **outputparameters:无
  395. **Returnedvalue:无
  396. *********************************************************************************************************/
  397. voidLCD_WriteChar(unsignedintlineNum,
  398. unsignedintrowNum,
  399. unsignedintcharColor,
  400. unsignedintbkColor,
  401. unsignedcharchChar)
  402. {
  403. unsignedcharshow_cnt=0;
  404. unsignedcharbit_cnt=0;
  405. unsignedintcharPos=0;//字符在字符表中地点的方位
  406. LCD_SELECT();
  407. charPos=Get_CharOffset(chChar);//获取字模显现的偏移量
  408. Set_CharWindow(lineNum,rowNum);//设置开端坐标,xy是8*16的方格坐标
  409. for(show_cnt=0;show_cnt<16;show_cnt++)
  410. {
  411. for(bit_cnt=0;bit_cnt<8;bit_cnt++)
  412. {
  413. if(Letter[charPos][show_cnt]&BIT(7-bit_cnt))
  414. {
  415. LCD_WriteData(charColor);//字符色彩
  416. }
  417. else
  418. {
  419. LCD_WriteData(bkColor);//背景色
  420. }
  421. }
  422. }
  423. LCD_DIS_SELECT();
  424. }
  425. /*******************************************************************************************************************
  426. **Functionname:LCD_WriteString
  427. **Descriptions:向屏幕写字符串
  428. **inputparameters:字符开端队伍(lineNum,rowLine),背景色—bkColor,字节色彩—charColor,字符串指针p_str
  429. **outputparameters:无
  430. **Returnedvalue:无
  431. ********************************************************************************************************************/
  432. voidLCD_WriteString(unsignedcharlineNum,unsignedcharrowNum,
  433. unsignedintcharColor,
  434. unsignedintbkColor,
  435. unsignedchar*p_str)
  436. {
  437. while(*p_str)
  438. {
  439. //核算坐标
  440. if(*p_str==\n)//换行
  441. {
  442. rowNum=0;
  443. lineNum++;
  444. p_str++;//调过换行符,不必显现
  445. continue;//查询下一个字符
  446. }
  447. else//未遇到换行符则按正常显现坐标自加
  448. {
  449. LCD_WriteChar(lineNum,rowNum,charColor,bkColor,*p_str);
  450. rowNum++;
  451. if(rowNum==CHAR_X_NUM)
  452. {
  453. rowNum=0;
  454. lineNum++;
  455. if(lineNum==CHAR_Y_NUM)
  456. {
  457. lineNum=0;
  458. }
  459. }
  460. }
  461. p_str++;//字符串指针++
  462. }
  463. }
  464. /*********************************************************************************************************
  465. *EndOfFile*
  466. *********************************************************************************************************/

文件名:main.c 主函数测验

  1. /****************************************Copyright(c)**************************************************
  2. **SoutheastUniversity
  3. **————–FileInfo——————————————————————————-
  4. **FileName:main.c
  5. **LastmodifiedDate:2012-04-11
  6. **LastVersion:1.0
  7. **Description:测验函数
  8. **——————————————————————————————————
  9. **CreatedBy:JianGe
  10. **Createddate:2012-03-23
  11. **Version:1.0
  12. **——————————————————————————————————*/
  13. #include
  14. #include
  15. #include”Type.h”
  16. #include”Delay.h”
  17. #include”USART.h”
  18. voidmain(void)
  19. {
  20. unsignedchar*ptr=”ABCDEFGHIJKLMNOPQRSTUVWXYZ”;
  21. USART_Init();
  22. LCD_ILI9325_Init();
  23. LCD_ClearScreen(0xF800);
  24. LCD_Fill_Rectangle(0,0,200,200,0xF800);
  25. LCD_WriteChar(1,1,0xF800,0xFFFF,1);//显现字符
  26. LCD_WriteString(0,0,0xF800,0xFFFF,ptr);//显现字符串
  27. }


声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qianrushi/yingjian/264430.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部