日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > 單片機(jī) > 單片機(jī)
[導(dǎo)讀]ili9320.h1 #ifndef __ILI9320_H__2 #define __ILI9320_H__3 #include "reg52.h"45 #define u8 unsigned char6 #define u16 unsigned int7 #define uchar unsigned char8 #define uint unsigned int910 //#define LC

ili9320.h

1 #ifndef __ILI9320_H__

2 #define __ILI9320_H__

3 #include "reg52.h"

4

5 #define u8 unsigned char

6 #define u16 unsigned int

7 #define uchar unsigned char

8 #define uint unsigned int

9

10 //#define LCD_COLORS_NUM 65536

11 #define LCD_SIZE_X 240

12 #define LCD_SIZE_Y 320

13

14

15

16 //-------------------------------------------------------

17 //-----------------------端口定義------------------------

18

19 #define LCD_DataH P0//高8位數(shù)據(jù)

20 #define LCD_DataL P1//低8位數(shù)據(jù)

21

22 sbit LCD_RST= P2^0 ;//復(fù)位

23 sbit LCD_CS =P2^1;//使能端

24

25 sbit LCD_RS= P3^5; //數(shù)據(jù)|指令

26 sbit LCD_WR= P3^6; //寫

27 sbit LCD_RD =P3^7; //讀

28

29 //---------------------------------------------------------

30 //-------------------函數(shù)聲明------------------------------

31

32 //////RGB轉(zhuǎn)換,888->565/////

33 u16 LCD_RGB(u8 R,u8 G,u8 B);

34

35 /////////延時(shí)//////////

36 void LCD_Delay(uint t);

37

38 ///////寫索引寄存器////////

39 void LCD_WriteIndex(u8 index);

40

41 ///////寫數(shù)據(jù)////////

42 void LCD_WriteData(u16 Data);

43

44 ///////寫寄存器//////////

45 void LCD_WriteCOM(u8 index,u16 Data);

46

47 /////讀芯片ID,0x9320/////

48 u16 LCD_ReadID(void);

49

50 //////讀像素////////

51 u16 LCD_ReadPixel(u16 x,u16 y);

52

53 //////設(shè)置像素////////

54 void LCD_SetPixel(u16 color);

55

56 //////設(shè)置顯示窗口/////

57 void LCD_SetWindow(uint x1,uint y1,uint x2,uint y2);

58

59 ///////設(shè)置光標(biāo)//////

60 //void LCD_SetCursor(uint x,uint y);

61

62 ///////LCD初始化///////

63 void LCD_Init(void);

64

65 #endif


ili9320.c

1 #include "reg52.h"

2 #include "ili9320.h"

3

4

5 //-----------------------------------------------------

6 //讀取芯片型號,型號:0X9320

7

8 u16 LCD_ReadID(void)

9 {

10 u16 t;

11 LCD_WriteIndex(0x00);

12 LCD_DataH=0xff;

13 LCD_DataL=0xff;

14 LCD_RS=1;

15 LCD_RD=1;

16 LCD_RD=0; //RD不需要變換兩次

17 t=(LCD_DataH<<8)|LCD_DataL ;

18 return t;

19 }

20

21

22 //-----------------------------------------------------

23 //在65536色彩下,讀取像素點(diǎn)

24

25 u16 LCD_ReadPixel(u16 x,u16 y)

26 {

27 u16 t;

28 LCD_WriteCOM(0x20,x);

29 LCD_WriteCOM(0x21,y);

30 LCD_WriteIndex(0x22);

31

32 LCD_DataH=0xff;

33 LCD_DataL=0xff;

34 LCD_RS=1;

35 LCD_RD=1;

36 LCD_RD=0;

37 LCD_RD=1;

38 LCD_RD=0; //RD需要變換兩次

39 t=(LCD_DataH<<8)|LCD_DataL ;

40 return t;

41 }

42

43 //------------------------------------------------------

44 //設(shè)置顯示窗口

45

46 void LCD_SetWindow(uint x1,uint y1,uint x2,uint y2)

47 {

48 LCD_WriteCOM(0x20,x1);

49 LCD_WriteCOM(0x21,y1);

50 LCD_WriteCOM(0x50,x1);

51 LCD_WriteCOM(0x52,y1);

52 LCD_WriteCOM(0x51,x2);

53 LCD_WriteCOM(0x53,y2);

54 LCD_WriteIndex(0x22);

55 }

56

57 //-------------------------------------------------------

58 //設(shè)置光標(biāo)

59 void LCD_SetCursor(uint x,uint y)

60 {

61 LCD_WriteCOM(0x20,x);

62 LCD_WriteCOM(0x21,y);

63 LCD_WriteIndex(0x22);

64 }

65

66

67

68

69 //----------------------------------------------------------

70 //在65536色彩下,將18位顏色數(shù)據(jù)轉(zhuǎn)化為16位

71 u16 LCD_RGB(u8 R,u8 G,u8 B)

72 {

73 u16 tRGB;

74 tRGB=0x00;

75 tRGB=tRGB|R;

76 tRGB=tRGB<<6;

77 tRGB=tRGB|G;

78 tRGB=tRGB<<5;

79 tRGB=tRGB|B;

80 return tRGB;

81 }

82

83 //---------------------------------------------------------

84 //延時(shí)函數(shù)

85 void LCD_Delay(uint t)

86 {

87 for(;t>0;t--);

88 }

89

90 //----------------------------------------------------------

91 //寫入索引寄存器

92 void LCD_WriteIndex(u8 index)

93 {

94 LCD_RS=0;

95 LCD_RD=1;

96 LCD_WR=0;

97 LCD_DataH=0x00;

98 LCD_DataL=index;

99 LCD_WR=1;

100 }

101

102 //-----------------------------------------

103 //寫入數(shù)據(jù)

104

105 void LCD_WriteData(u16 Data)

106 {

107 LCD_RS=1;

108 LCD_WR=0;

109 LCD_DataH=Data>>8;

110 LCD_DataL=Data;

111 LCD_WR=1;

112

113 }

114

115 //-----------------------------------------

116 //寫寄存器

117

118 void LCD_WriteCOM(u8 index,u16 Data)

119 {

120 LCD_WriteIndex(index);

121 LCD_WriteData(Data);

122 }

123

124

125

126 //-----------------------------------------------

127 //LCD初始化函數(shù)

128

129 void LCD_Init(void)

130 {

131 //************* Reset LCD Driver ****************//

132 LCD_CS=0;

133 LCD_RST=1;

134 LCD_RD=1;

135 LCD_Delay(10);

136 LCD_RST=0;

137 LCD_Delay(100);

138 LCD_RST=1;

139 LCD_Delay(10);

140 //************* Start Initial Sequence **********//

141 LCD_WriteCOM(0x00, 0x0001); // 開始內(nèi)部振蕩

142 LCD_WriteCOM(0x01, 0x0100); // set SS and SM bit

143 LCD_WriteCOM(0x02, 0x0400); // set 1 line inversion

144 LCD_WriteCOM(0x03, 0x1030);

145 LCD_WriteCOM(0x04, 0x0000); // Resize register

146 LCD_WriteCOM(0x08, 0x0202); // set the back porch and front porch

147 LCD_WriteCOM(0x09, 0x0000); // set non-display area refresh cycle ISC[3:0]

148 LCD_WriteCOM(0x0A, 0x0000); // FMARK function

149 LCD_WriteCOM(0x0C, 0x0000); // RGB interface setting

150 LCD_WriteCOM(0x0D, 0x0000); // Frame marker Position

151 LCD_WriteCOM(0x0F, 0x0000); // RGB interface polarity

152

153 LCD_WriteCOM(0x07, 0x0101); // Display Control 1

154 LCD_Delay(500);

155

156 //*************Power On sequence ****************// LCD_WriteCOM(0x51, 0x00, 0xEF);

157

158 LCD_WriteCOM(0x10, 0x16b0);

159 LCD_WriteCOM(0x11, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]

160 LCD_WriteCOM(0x12, 0x0138);

161 LCD_WriteCOM(0x13, 0x0b00);

162 LCD_WriteCOM(0x2B, 0x2008);

163 // ---------- Gamma Control ---------- //

164 LCD_WriteCOM(0x30, 0x0000);

165 LCD_WriteCOM(0x31, 0x0306);

166 LCD_WriteCOM(0x32, 0x0200);

167 LCD_WriteCOM(0x35, 0x0107);

168 LCD_WriteCOM(0x36, 0x0404);

169 LCD_WriteCOM(0x37, 0x0606);

170 LCD_WriteCOM(0x38, 0x0105);

171 LCD_WriteCOM(0x39, 0x0707);

172 LCD_WriteCOM(0x3C, 0x0600);

173 LCD_WriteCOM(0x3D, 0x0807);

174 // ---------- Window Address Area ---------- //

175 LCD_WriteCOM(0x50, 0x0000); // Horizontal GRAM Start Address-----HSA[7:0]

176 LCD_WriteCOM(0x51, 0x00EF); // Horizontal GRAM End Address-----HEA[7:0]

177 LCD_WriteCOM(0x52, 0x0000); // Vertical GRAM Start Address-----VSA[8:0]

178 LCD_WriteCOM(0x53, 0x013F); // Vertical GRAM Start Address-----VEA[8:0]

179 // ---------- Gate Scan Control ---------- //

180 LCD_WriteCOM(0x60, 0x2700); // GS, NL[5:0], SCN[5:0]

181 LCD_WriteCOM(0x61, 0x0001); // NDL,VLE, REV

182 LCD_WriteCOM(0x6A, 0x0000); // VL[8:0]

183 // ---------- Partial Display Control ---------- //

184 LCD_WriteCOM(0x80, 0x0000); // Partial Image 1 Display Position-----PTDP0[8:0]

185 LCD_WriteCOM(0x81, 0x0000); // Partial Image 1 Start Address-----PTSA0[8:0]

186 LCD_WriteCOM(0x82, 0x0000); // Partial Image 1 End Address-----PTEA0[8:0]

187 LCD_WriteCOM(0x83, 0x0000); // Partial Image 2 Display Position-----PTDP1[8:0]

188 LCD_WriteCOM(0x84, 0x0000); // Partial Image 2 Start Address-----PTSA1[8:0]

189 LCD_WriteCOM(0x85, 0x0000); // Partial Image 2 Start Address-----PTEA1[8:0]

190 // ---------- Panel Interface Control ---------- //

191 LCD_WriteCOM(0x90, 0x0013); // Panel Interface Control 1-----DIVI[1:0], RTNI[4:0]

192 LCD_WriteCOM(0x92, 0x0000); // Panel Interface Control 2-----NOWI[2:0]

193

194 LCD_WriteCOM(0x93, 0x0001); //Panel Interface Control 3-----MCPI[2:0]

195

196 LCD_WriteCOM(0x95, 0x0110); // Panel Interface Control 4-----DIVE[1:0], RTNE[5:0]

197 LCD_WriteCOM(0x97, 0x0000); // Panel Interface Control 5-----NOWE[3:0]

198 LCD_WriteCOM(0x98, 0x0000); // Panel Interface Control 6-----MCPE[2:0]

199

200 LCD_WriteCOM(0x07, 0x0173); // Display Control 1----- display ON

201 LCD_Delay(500);

202

203 }





本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

8位單片機(jī)在嵌入式設(shè)計(jì)領(lǐng)域已經(jīng)成為半個(gè)多世紀(jì)以來的主流選擇。盡管嵌入式系統(tǒng)市場日益復(fù)雜,8位單片機(jī)依然不斷發(fā)展,積極應(yīng)對新的挑戰(zhàn)和系統(tǒng)需求。如今,Microchip推出的8位PIC?和AVR?單片機(jī)系列,配備了先進(jìn)的獨(dú)立...

關(guān)鍵字: 單片機(jī) 嵌入式 CPU

在嵌入式系統(tǒng)開發(fā)中,程序燒錄是連接軟件設(shè)計(jì)與硬件實(shí)現(xiàn)的關(guān)鍵環(huán)節(jié)。當(dāng)前主流的單片機(jī)燒錄技術(shù)已形成ICP(在電路編程)、ISP(在系統(tǒng)編程)、IAP(在應(yīng)用編程)三大技術(shù)體系,分別對應(yīng)開發(fā)調(diào)試、量產(chǎn)燒錄、遠(yuǎn)程升級等不同場景。...

關(guān)鍵字: 單片機(jī) ISP ICP IAP 嵌入式系統(tǒng)開發(fā)

在嵌入式系統(tǒng)開發(fā)中,看門狗(Watchdog Timer, WDT)是保障系統(tǒng)可靠性的核心組件,其初始化時(shí)機(jī)的選擇直接影響系統(tǒng)抗干擾能力和穩(wěn)定性。本文從硬件架構(gòu)、軟件流程、安全規(guī)范三個(gè)維度,系統(tǒng)分析看門狗初始化的最佳實(shí)踐...

關(guān)鍵字: 單片機(jī) 看門狗 嵌入式系統(tǒng)

本文中,小編將對單片機(jī)予以介紹,如果你想對它的詳細(xì)情況有所認(rèn)識,或者想要增進(jìn)對它的了解程度,不妨請看以下內(nèi)容哦。

關(guān)鍵字: 單片機(jī) 開發(fā)板 Keil

隨著單片機(jī)系統(tǒng)越來越廣泛地應(yīng)用于消費(fèi)類電子、醫(yī)療、工業(yè)自動化、智能化儀器儀表、航空航天等各領(lǐng)域,單片機(jī)系統(tǒng)面臨著電磁干擾(EMI)日益嚴(yán)重的威脅。電磁兼容性(EMC)包含系統(tǒng)的發(fā)射和敏感度兩方面的問題。

關(guān)鍵字: 單片機(jī) 電磁兼容

以下內(nèi)容中,小編將對單片機(jī)的相關(guān)內(nèi)容進(jìn)行著重介紹和闡述,希望本文能幫您增進(jìn)對單片機(jī)的了解,和小編一起來看看吧。

關(guān)鍵字: 單片機(jī) 復(fù)位電路

在這篇文章中,小編將為大家?guī)韱纹瑱C(jī)的相關(guān)報(bào)道。如果你對本文即將要講解的內(nèi)容存在一定興趣,不妨繼續(xù)往下閱讀哦。

關(guān)鍵字: 單片機(jī) 異常復(fù)位

今天,小編將在這篇文章中為大家?guī)韱纹瑱C(jī)的有關(guān)報(bào)道,通過閱讀這篇文章,大家可以對它具備清晰的認(rèn)識,主要內(nèi)容如下。

關(guān)鍵字: 單片機(jī) 仿真器

單片機(jī)將是下述內(nèi)容的主要介紹對象,通過這篇文章,小編希望大家可以對它的相關(guān)情況以及信息有所認(rèn)識和了解,詳細(xì)內(nèi)容如下。

關(guān)鍵字: 單片機(jī) 中斷 boot

一直以來,單片機(jī)都是大家的關(guān)注焦點(diǎn)之一。因此針對大家的興趣點(diǎn)所在,小編將為大家?guī)韱纹瑱C(jī)的相關(guān)介紹,詳細(xì)內(nèi)容請看下文。

關(guān)鍵字: 單片機(jī) 數(shù)字信號 模擬信號
關(guān)閉