upsd3300_lcd.lst
来自「增强型8位单片机upsd33xx系列芯片PWM结合ADC例程」· LST 代码 · 共 1,169 行 · 第 1/4 页
LST
1,169 行
C51 COMPILER V7.50 UPSD3300_LCD 07/11/2005 15:30:33 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE UPSD3300_LCD
OBJECT MODULE PLACED IN upsd3300_lcd.OBJ
COMPILER INVOKED BY: C:\keil\C51\BIN\C51.EXE upsd3300_lcd.c OPTIMIZE(9,SIZE) BROWSE DEBUG OBJECTEXTEND
line level source
1 /*------------------------------------------------------------------------------
2 upsd3300_lcd.c
3
4 Version:
5 November 30, 2004 - 2.0 - Initial Release.
6
7
8 Dependencies:
9 English font loaded into flash mapped into XDATA space at: ENGLISH_FONT_PAGE,
10 FONT_BASE_ADDRESS
11 Chinese font loaded into flash mapped into XDATA space at:
12 CHINESE_FONT_PAGE, FONT_BASE_ADDRESS
13 Note: The Chinese font only needs to be loaded into flash if the option
14 ENGLISH_CHINESE_FONT is specified.
15
16 Description:
17 The uPSD3300 Enhanced LCD (ELCD) device driver is intended to provide functions
18 to initialize the ELCD (GXM12232-1SL) and to display English ASCII characters
19 only or also Chinese characters. The default compile option is for English
20 only, but defining "ENGLISH_CHINESE_FONT" results in code compiled to support
21 English characters and Chinese characters.
22
23 The font bit maps for English ASCII characters (0 to 127) are stored in flash
24 memory and is accessed via a standard lookup. The font bit maps for user
25 defined Chinese characters are accessed via a special lookup operation.
26
27 Note: The lcd_init() function checks the first couple of bytes in the appropriate
28 location in flash memory to determine if the English font (and Chinese font, if
29 ENGLISH_CHINESE_FONT is defined) is loaded. If it is not, the message "no font"
30 is displayed on the LCD and the program execution loops forever in the lcd_init()
31 function. In this case, the English font file (and the Chinese font file, if
32 ENGLISH_CHINESE_FONT is defined) should be specified for placement in the
33 appropriate flash sector in the PSDsoft project under "Merge MCU / DSP Firmware
34 with PSD". For messages to be displayed on the LCD, the appropriate font files
35 must be programmed into the flash for use by the printfLCD() function.
36
37
38 Copyright (c) 2004 STMicroelectronics Inc.
39
40 This example demo code is provided as is and has no warranty,
41 implied or otherwise. You are free to use/modify any of the provided
42 code at your own risk in your applications with the expressed limitation
43 of liability (see below) so long as your product using the code contains
44 at least one uPSD product (device).
45
46 LIMITATION OF LIABILITY: NEITHER STMicroelectronics NOR ITS VENDORS OR
47 AGENTS SHALL BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF USE, LOSS OF DATA,
48 INTERRUPTION OF BUSINESS, NOR FOR INDIRECT, SPECIAL, INCIDENTAL OR
49 CONSEQUENTIAL DAMAGES OF ANY KIND WHETHER UNDER THIS AGREEMENT OR
50 OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
51 ------------------------------------------------------------------------------*/
52
53 #include "upsd3300.h"
54 #include "upsd3300_hardware.h"
55 #include "stdarg.h"
C51 COMPILER V7.50 UPSD3300_LCD 07/11/2005 15:30:33 PAGE 2
56
57 //#define ENGLISH_CHINESE_FONT // This should be defined if the English/Chinese font
58 // is supported. If this is not defined, then the
59 // default is English only support.
60
61 //#define ST_LOGO_SUPPORT // This should be defined if the ST logo will be
62 // displayed on the LCD.
63
64 //#define FONT_BASE_ADDRESS 0x8000L
65 #define FONT_BASE_ADDRESS 0xE000L
66
67 #define E_FONT_DETECT_BYTE_0 0x1F //English font
68 #define E_FONT_DETECT_BYTE_1 0xE0
69
70 #define C_FONT_DETECT_BYTE_0 0x80 //Chinese font
71 #define C_FONT_DETECT_BYTE_1 0x00
72
73 //#define ENGLISH_FONT_PAGE 5
74 #define ENGLISH_FONT_PAGE 0
75 #define CHINESE_FONT_PAGE 6
76
77 xdata unsigned char wm_data _at_ LCD_BASE_ADDR + 0x02; //write data address
78 xdata unsigned char rm_status _at_ LCD_BASE_ADDR + 0x01; //read command status address
79 xdata unsigned char wm_command _at_ LCD_BASE_ADDR + 0x00; //write command address
80
81 xdata unsigned char ws_data _at_ LCD_BASE_ADDR + 0x06; //write data address
82 xdata unsigned char rs_status _at_ LCD_BASE_ADDR + 0x05; //read command status address
83 xdata unsigned char ws_command _at_ LCD_BASE_ADDR + 0x04; //write command address
84
85
86 #ifndef ENGLISH_CHINESE_FONT
87 unsigned char dot_buffer[14];
88 #else
unsigned char dot_buffer[32];
#endif
91
92 unsigned char ucol = 0; //ucol is a global variable,this point is very important.
93 unsigned char ulayer = 0; //ulayer is also a global variable,this point is very important.
94 unsigned char mode = 0; //set the positive or negative display here
95
96 #ifdef ST_LOGO_SUPPORT
code unsigned char STlogo[32] = {0x03,0x40,0xc3,0x40,0xe3,0x41,0x33,0x43,0x33,0x46,0x33,0x6c,0x33,0x38,0x3
-3,0x00,0x33,
0x60,0x33,0x7c,0x33,0x1f,0xf3,0x03,0xf3,0x00,0x33,0x00,0x33,0x00,0x33,0x0
-0};
#endif
101
102
103
104 // Define the bitmaps for letters used to display "no font" if the font is not detected in memory.
105 code unsigned char nn[14] = {0x80,0x10,0x80,0x1f,0x00,0x11,0x80,0x00,0x80,0x10,0x00,0x1f,0x00,0x10}; // n
106 code unsigned char oo[14] = {0x00,0x00,0x00,0x0f,0x80,0x10,0x80,0x10,0x80,0x10,0x00,0x0f,0x00,0x00}; // o
107 code unsigned char ff[14] = {0x00,0x00,0x80,0x10,0xc0,0x1f,0xa0,0x10,0xa0,0x10,0xa0,0x10,0x00,0x00}; // f
108 code unsigned char tt[14] = {0x00,0x00,0x80,0x00,0xc0,0x0f,0x80,0x10,0x80,0x10,0x80,0x10,0x00,0x08}; // t
109
110 #ifdef ENGLISH_CHINESE_FONT
code unsigned char index[159]={//0xB1 & 0xB0 is the internal code of the Chinese character "备" which is
-the first one in the user self-defined lib
0xB1, 0xB8, 0x00, 0xB1, 0xCF, 0x01, 0xB1, 0xE0, 0x02, 0xB2, 0xE9, 0x03, 0xB4, 0xA2, 0x04, 0xB4, 0xA5, 0
-x05, 0xB4, 0xD3, 0x06, 0xB4, 0xE6, 0x07, //备毕编查储触从存
0xB5, 0xBD, 0x08, 0xB5, 0xDA, 0x09, 0xB5, 0xF7, 0x0a, 0xB6, 0xAF, 0x0b, 0xB7, 0xA2, 0x0c, 0xB9, 0xAB, 0
C51 COMPILER V7.50 UPSD3300_LCD 07/11/2005 15:30:33 PAGE 3
-x0d, 0xB9, 0xB2, 0x0e, 0xBA, 0xCD, 0x0f, //到第调动发公共和
0xBA, 0xCF, 0x10, 0xBB, 0xBB, 0x11, 0xBB, 0xD8, 0x12, 0xBB, 0xF9, 0x13, 0xBC, 0xC7, 0x14, 0xBC, 0xE4, 0
-x15, 0xBC, 0xFE, 0x16, 0xBE, 0xAD, 0x17, //合换回基记间件经
0xBF, 0xB4, 0x18, 0xC1, 0xEE, 0x19, 0xC2, 0xBC, 0x1a, 0xC2, 0xEB, 0x1b, 0xC3, 0xC7, 0x1c, 0xC6, 0xDA, 0
-x1d, 0xC6, 0xF7, 0x1e, 0xC7, 0xD0, 0x1f, //看令录码们期器切
0xC7, 0xF8, 0x20, 0xC8, 0xD5, 0x21, 0xC9, 0xBE, 0x22, 0xC9, 0xE8, 0x23, 0xCA, 0xB1, 0x24, 0xCA, 0xBE, 0
-x25, 0xCA, 0xC2, 0x26, 0xCD, 0xEA, 0x27, //区日删设时示事完
0xCE, 0xC4, 0x28, 0xCE, 0xD2, 0x29, 0xCF, 0xD6, 0x2a, 0xD0, 0xC2, 0x2b, 0xD1, 0xDD, 0x2c, 0xD2, 0xD1, 0
-x2d, 0xD4, 0xDA, 0x2e, 0xD6, 0xB8, 0x2f, //文我现新演已在指
0xD6, 0xC3, 0x30, 0xD6, 0xD0, 0x31, 0xD7, 0xAA, 0x32, 0xD7, 0xBC, 0x33, 0xD7, 0xE9, 0x34
- //置中转准组
};
#endif
121
122
123
124 //-----------------------------------------------------FOR LCD68------------------------------
125
126 /*---------------------------------------------------------------------------------------
127 Function:
128 check whether master LCD is busy or not .
129 Parameters:
130 none
131 Note:
132 none
133
134 ----------------------------------------------------------------------------------------*/
135 void BusyCheck(void) // wait until BF is cleared
136 {
137 1 while ((rm_status & 0X80));
138 1
139 1 }
140
141 /*---------------------------------------------------------------------------------------
142 Function:
143 check whether slave LCD is busy or not .
144 Parameters:
145 none
146 Note:
147 none
148
149 ----------------------------------------------------------------------------------------*/
150 void BusyCheckSlave(void) // wait until BF is cleared
151 {
152 1 while ((rs_status & 0X80));
153 1
154 1 }
155
156 /*---------------------------------------------------------------------------------------
157 Function:
158 send one byte command to master LCD.
159 Parameters:
160 i is the user expected command to send to master LCD.
161 Note:
162 none
163
164 ----------------------------------------------------------------------------------------*/
165 void OutMasterCom( unsigned char i ) // write master command
166 {
167 1
168 1 BusyCheck();
169 1 wm_command = i;
C51 COMPILER V7.50 UPSD3300_LCD 07/11/2005 15:30:33 PAGE 4
170 1
171 1 }
172
173 /*---------------------------------------------------------------------------------------
174 Function:
175 send one byte command to slave LCD.
176 Parameters:
177 i is the user expected command to send to slave LCD.
178 Note:
179 none
180
181 ----------------------------------------------------------------------------------------*/
182 void OutSlaveCom( unsigned char i ) //write slave command
183 {
184 1
185 1 BusyCheckSlave();
186 1 ws_command = i;
187 1
188 1 }
189
190 /*---------------------------------------------------------------------------------------
191 Function:
192 display one byte data to master LCD.
193 Parameters:
194 i is the user expected data to disply on master LCD.
195 Note:
196 none
197
198 ----------------------------------------------------------------------------------------*/
199 void OutMasterDat( unsigned char i ) //write master data
200 {
201 1
202 1 BusyCheck();
203 1 wm_data = i;
204 1
205 1 }
206
207 /*---------------------------------------------------------------------------------------
208 Function:
209 display one byte data to slave LCD.
210 Parameters:
211 i is the user expected data to disply on slave LCD.
212 Note:
213 none
214
215 ----------------------------------------------------------------------------------------*/
216 void OutSlaveDat( unsigned char i ) //write slave data
217 {
218 1
219 1 BusyCheckSlave();
220 1 ws_data = i;
221 1
222 1 }
223
224
225
226 /*---------------------------------------------------------------------------------------
227 Function:
228 this function is used to initialize master and slave LCD.
229 Parameters:
230 none
231 Note:
C51 COMPILER V7.50 UPSD3300_LCD 07/11/2005 15:30:33 PAGE 5
232 none
233
234 ----------------------------------------------------------------------------------------*/
235 void LcdConfig ( void ) //lcd initialization
236 {
237 1
238 1 OutMasterCom ( 0xE2 );//software reset
239 1 OutSlaveCom ( 0xE2 );
240 1
241 1 OutMasterCom ( 0xAE );//display off
242 1 OutSlaveCom ( 0xAE );
243 1
244 1 OutMasterCom ( 0xA4 );//dynamic drive(normal)
245 1 OutSlaveCom ( 0xA4 );
246 1
247 1 OutMasterCom ( 0xA9 );//duty cycle
248 1 OutSlaveCom ( 0xA9 );
249 1
250 1 OutMasterCom ( 0xA0 );//clockwise output
251 1 OutSlaveCom ( 0xA0 );
252 1
253 1 OutMasterCom ( 0xEE );//read-modify-write off
254 1 OutSlaveCom ( 0xEE );
255 1
256 1 OutMasterCom( 0x00 ); //display column address
257 1 OutMasterCom ( 0xC0 );//display start line
258 1
259 1 OutSlaveCom ( 0x00 );
260 1 OutSlaveCom ( 0xC0 );
261 1
262 1 OutMasterCom ( 0xAF ); //display on
263 1 OutSlaveCom ( 0xAF );
264 1
265 1 }
266
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?