<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > ATmega16L驅(qū)動(dòng)ILI9325/9328

          ATmega16L驅(qū)動(dòng)ILI9325/9328

          作者: 時(shí)間:2016-11-20 來源:網(wǎng)絡(luò) 收藏
          首先是硬件連線:PB----8位數(shù)據(jù)口

          PA0--- 復(fù)位信號(hào)RESET

          本文引用地址:http://www.ex-cimer.com/article/201611/318937.htm

          PA1---片選CS

          PA2----寄存器選擇信號(hào)RS

          PA3---寫信號(hào)WR

          PA4---讀信號(hào)RD

          文件名:Type.h,主要定義一些數(shù)據(jù)變量的別名

          1. /****************************************Copyright(c)**************************************************
          2. **SoutheastUniversity
          3. **--------------FileInfo-------------------------------------------------------------------------------
          4. **FileName:Type.h
          5. **LastmodifiedDate:2012-03-23
          6. **LastVersion:1.0
          7. **Description:定義數(shù)據(jù)類型別名
          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)數(shù)據(jù)類型(和編譯器相關(guān))*
          17. ********************************************************************************************************/
          18. typedefunsignedcharuint8;//Unsigned8bitquantity無符號(hào)8位整型變量
          19. typedefunsignedcharuchar;//Unsigned8bitquantity無符號(hào)8位整型變量
          20. typedefsignedcharint8;//Signed8bitquantity有符號(hào)8位整型變量
          21. typedefunsignedshortuint16;//Unsigned16bitquantity無符號(hào)16位整型變量
          22. typedefsignedshortint16;//Signed16bitquantity有符號(hào)16位整型變量
          23. typedefunsignedintuint32;//Unsigned32bitquantity無符號(hào)32位整型變量
          24. typedefunsignedintuint;//Unsigned32bitquantity無符號(hào)32位整型變量
          25. typedefsignedintint32;//Signed32bitquantity有符號(hào)32位整型變量
          26. typedeffloatfp32;//Singleprecisionfloatingpoint單精度浮點(diǎn)數(shù)(32位長度)
          27. typedefdoublefp64;//Doubleprecisionfloatingpoint雙精度浮點(diǎn)數(shù)(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,串口操作函數(shù)的聲明

          1. /****************************************Copyright(c)**************************************************
          2. **SoutheastUniversity
          3. **--------------FileInfo-------------------------------------------------------------------------------
          4. **FileName:USART.h
          5. **LastmodifiedDate:2012-03-23
          6. **LastVersion:1.0
          7. **Description:串口函數(shù)聲明
          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//波特率設(shè)置
          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)//幀接收錯(cuò)誤
          22. #definePE_EERBIT(PE)//校驗(yàn)錯(cuò)誤
          23. #defineDATA_OVERBIT(DOR)//接收溢出錯(cuò)誤
          24. #defineUDR_EMPTYBIT(UDRE)//數(shù)據(jù)寄存器空
          25. #defineUSAT_TX_ENUCSRB|=BIT(TXEN)//使能USART發(fā)送
          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,延時(shí)函數(shù)的聲明


          1. /****************************************Copyright(c)**************************************************
          2. **SoutheastUniversity
          3. **--------------FileInfo-------------------------------------------------------------------------------
          4. **FileName:Delay.h
          5. **LastmodifiedDate:2012-03-23
          6. **LastVersion:1.0
          7. **Description:延時(shí)函數(shù)聲明
          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驅(qū)動(dòng)函數(shù)和應(yīng)用函數(shù)的聲明

          1. /****************************************Copyright(c)**************************************************
          2. **SoutheastUniversity
          3. **--------------FileInfo-------------------------------------------------------------------------------
          4. **FileName:LCD_Driver.h
          5. **LastmodifiedDate:2012-03-24
          6. **LastVersion:1.0
          7. **Description:LCD驅(qū)動(dòng)函數(shù)聲明
          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顯示字符的字節(jié)表
          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,延時(shí)函數(shù)的實(shí)現(xiàn)

          1. /****************************************Copyright(c)**************************************************
          2. **SoutheastUniversity
          3. **--------------FileInfo-------------------------------------------------------------------------------
          4. **FileName:Delay.c
          5. **LastmodifiedDate:2012-03-23
          6. **LastVersion:1.0
          7. **Description:延時(shí)函數(shù)實(shí)現(xiàn)
          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:延時(shí)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:延時(shí)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:延時(shí)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 串口調(diào)試函數(shù)的實(shí)現(xiàn)

          1. /****************************************Copyright(c)**************************************************
          2. **SoutheastUniversity
          3. **--------------FileInfo-------------------------------------------------------------------------------
          4. **FileName:USART.c
          5. **LastmodifiedDate:2012-03-23
          6. **LastVersion:1.0
          7. **Description:串口函數(shù)實(shí)現(xiàn)
          8. **------------------------------------------------------------------------------------------------------
          9. **CreatedBy:JianGe
          10. **Createddate:2012-03-23
          11. **Version:1.0
          12. **------------------------------------------------------------------------------------------------------*/
          13. #include
          14. #include"USART.h"
          15. /*串口初始化函數(shù)*/
          16. voidUSART_Init(void)
          17. {
          18. UCSRA=0x02;/*倍速*/
          19. UCSRB=0x18;/*允許接收和發(fā)送*/
          20. UCSRC=0x06;/*8位數(shù)據(jù)*/
          21. UBRRH=0x00;
          22. //UBRRL=12;/*9600*/
          23. //UBRRL=103;//11.0592M下9600
          24. UBRRL=207;//16MHz下9600
          25. }/*數(shù)據(jù)發(fā)送,查詢方式*/
          26. voidUart_Transmit(unsignedchari)
          27. {
          28. while(!(UCSRA&(1<
          29. UDR=i;/*發(fā)送數(shù)據(jù)*/
          30. }
          31. /*數(shù)據(jù)接收,查詢方式*/
          32. unsignedcharUart_Receive(void)
          33. {while(!(UCSRA&(1<
          34. returnUDR;/*獲取并返回?cái)?shù)據(jù)*/
          35. }
          36. /*********************************************************************************************************
          37. *EndOfFile*
          38. *********************************************************************************************************/

          文件名:LCDDriver.c LCD驅(qū)動(dòng)函數(shù)以及上層函數(shù)的實(shí)現(xiàn)

          1. /****************************************Copyright(c)**************************************************
          2. **SoutheastUniversity
          3. **--------------FileInfo-------------------------------------------------------------------------------
          4. **FileName:LCDDriver.c
          5. **LastmodifiedDate:2012-04-12
          6. **LastVersion:1.0
          7. **Description:LCD驅(qū)動(dòng)函數(shù)的實(shí)現(xiàn)
          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. ///////////屏顯示參數(shù)設(shè)置///////////////
          20. //設(shè)置屏顯示像素大小
          21. #defineX_SIZE240
          22. #defineY_SIZE320
          23. //x和y的最大坐標(biāo)值,坐標(biāo)原點(diǎn)為(0,0)
          24. #defineX_END(X_SIZE-1)
          25. #defineY_END(Y_SIZE-1)
          26. //一個(gè)字符x*y的分別大小
          27. #defineCHAR_X_SIZE8
          28. #defineCHAR_Y_SIZE16
          29. //橫坐標(biāo)能顯示的字符數(shù)X_SIZE/CHAR_X_SIZE
          30. #defineCHAR_X_NUM30
          31. //縱坐標(biāo)能顯示的字符數(shù)Y_SIZE/CHAR_Y_SIZE
          32. #defineCHAR_Y_NUM20
          33. ////////////////////////////////////////
          34. //LCD控制端口動(dòng)作宏定義
          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位數(shù)據(jù)口
          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時(shí)需要一個(gè)虛晃的讀(DummyRead)
          61. #defineDUMMY_READ()LCD_RD_L;LCD_RD_H;LCD_RD_L;LCD_RD_H;
          62. //片選,開始9328的某種操作前調(diào)用
          63. #defineLCD_SELECT()LCD_CS_L
          64. //片選,結(jié)束9328的某項(xiàng)操作后調(diào)用
          65. #defineLCD_DIS_SELECT()LCD_CS_H
          66. /*********************************************************************************************************
          67. **Functionname:LCD_Port_Init
          68. **Descriptions:LCD的控制端口和數(shù)據(jù)端口的初始化
          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:寫寄存器命令,選擇一個(gè)寄存器
          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寫數(shù)據(jù)
          112. **inputparameters:待寫入的數(shù)據(jù)data
          113. **outputparameters:無
          114. **Returnedvalue:無
          115. *********************************************************************************************************/
          116. ////////////////////////////////////////////////////////////////////////////////////////////////////
          117. //nCS----__________________________________________/-----------------------------//
          118. //RS-----------------------------------------------------------------------------//
          119. //nRD-------------------------------------------------------------------------//
          120. //nWR--------______/--------_____/-----------------------------------------//
          121. //DB[10:17]-----[數(shù)據(jù)高8位]-----[數(shù)據(jù)低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:向一個(gè)寄存器寫入數(shù)據(jù)
          135. **inputparameters:寄存器地址:regID待寫入的數(shù)據(jù)regData
          136. **outputparameters:無
          137. **Returnedvalue:無
          138. *********************************************************************************************************/
          139. ////////////////////////////////////////////////////////////////////////////////////////////////////
          140. //nCS----_____________________________________________________________/--------//
          141. //RS----____________________________/-----------------------------------------//
          142. //nRD-------------------------------------------------------------------------//
          143. //nWR------______/--------_____/--------______/-----______/----------------//
          144. //DB[10:17]---[寄存器高8位]---[寄存器低8位]---[數(shù)據(jù)高8位]----[數(shù)據(jù)低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:讀取指定寄存器的數(shù)據(jù)
          166. **inputparameters:寄存器地址:regID
          167. **outputparameters:無
          168. **Returnedvalue:讀出數(shù)據(jù)(16位)
          169. *********************************************************************************************************/
          170. ////////////////////////////////////////////////////////////////////////////////////////////////////
          171. //nCS----_____________________________________________________________/--------//
          172. //RS----____________________________/-----------------------------------------//
          173. //nRD-----------------------------------_____/------_____/------------------//
          174. //nWR------______/--------_____/----------------------------------------------//
          175. //DB[10:17]---[寄存器高8位]--[寄存器低8位]--[數(shù)據(jù)高8位]--[數(shù)據(jù)低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內(nèi)部寄存器的初始化
          198. **inputparameters:無
          199. **outputparameters:無
          200. **Returnedvalue:無
          201. *********************************************************************************************************/
          202. voidLCD_ILI9325_Init(void)
          203. {
          204. uint32ID=0x0000;
          205. LCD_Port_Init();
          206. LCD_REST_L;//復(fù)位
          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);//轉(zhuǎn)換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:起始坐標(biāo)(x0,y0),終止坐標(biāo)(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緩沖區(qū)
          291. }
          292. /*******************************************************************************************************************/
          293. /*******************************************************************************************************************/
          294. /**************************************************以下為LCD的應(yīng)用函數(shù)**********************************************/
          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);//320x240的屏
          309. for(i=0;i<320;i++)
          310. {
          311. for(j=0;j<240;j++)
          312. {
          313. LCD_WriteData(color);//向GRAM寫入RGB數(shù)據(jù)
          314. }
          315. }
          316. LCD_DIS_SELECT();//操作完畢
          317. }
          318. /*********************************************************************************************************
          319. **Functionname:LCD_Fill
          320. **Descriptions:填充一個(gè)矩形區(qū)域
          321. **inputparameters:矩形起始坐標(biāo)----(x0,y0),矩形終點(diǎn)坐標(biāo)--(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:獲取字節(jié)的偏移量
          340. **inputparameters:輸入字節(jié)
          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:設(shè)置字節(jié)窗口
          359. **inputparameters:每個(gè)字符8X16像素,共30行20列,lineNum----字符所在行號(hào),rowLine----字符所在列號(hào)
          360. **outputparameters:無
          361. **Returnedvalue:無
          362. *********************************************************************************************************/
          363. //例如顯示2這個(gè)字節(jié)窗口,為一個(gè)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像素坐標(biāo)
          385. y0=lineNum<<4;//其實(shí)Y像素坐標(biāo)
          386. LCD_SetWindow(x0,x0+7,y0,y0+15);
          387. }
          388. /*********************************************************************************************************
          389. **Functionname:LCD_WriteChar
          390. **Descriptions:向屏幕寫一個(gè)字節(jié)
          391. **inputparameters:lineNum表示字符開始的行數(shù),rowNum表字符開始的列數(shù),共30X20個(gè)字符,背景色bkColor,寫入的字節(jié)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);//設(shè)置起始坐標(biāo),xy是8*16的方格坐標(biāo)
          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,字節(jié)顏色---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. //計(jì)算坐標(biāo)
          440. if(*p_str==n)//換行
          441. {
          442. rowNum=0;
          443. lineNum++;
          444. p_str++;//調(diào)過換行符,不用顯示
          445. continue;//查詢下一個(gè)字符
          446. }
          447. else//未遇到換行符則按正常顯示坐標(biāo)自加
          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 主函數(shù)測試

          1. /****************************************Copyright(c)**************************************************
          2. **SoutheastUniversity
          3. **--------------FileInfo-------------------------------------------------------------------------------
          4. **FileName:main.c
          5. **LastmodifiedDate:2012-04-11
          6. **LastVersion:1.0
          7. **Description:測試函數(shù)
          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. }



          關(guān)鍵詞: ATmega16LILI9325932

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();