⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1335.s

📁 AVR单片机
💻 S
📖 第 1 页 / 共 3 页
字号:
	.module _1335.c
	.area text(rom, con, rel)
	.dbfile F:\avr\lcdsd1330\1335.c
	.dbfunc e lcd_delay _lcd_delay fV
;              x -> R20,R21
;              y -> R22,R23
;              i -> R16,R17
	.even
_lcd_delay::
	xcall push_xgsetF000
	.dbline -1
	.dbline 55
; 
; /*
; *******************************************************************************
; *
; *                                 保定建通制造有限责任公司
; *
; *                  BAODING JIANTONG ELECTRICAL APPLIANCE MANUFACTURING CO.,LTD.
; *
; *                  http://www.jtdq.com.cn/
; *                  email:jtdq@jtdq.com.cn
; *
; *文件名称:
; *
; *包含函数:
; *
; *函数说明:
; *
; *
; *
; *
; *
; *
; *作者:段胜柱     duanshengzhu@126.com
; *
; *时间:
; ***************************************************************************
; */ 
; 
; /***********************************************************************
; Content: Graphic library for Epson SED-1335 based LCD displays.
; Last modified: 15.05.2003
; Copyrights: Free to use, free to change, free to delete :-)
; Compiler: ImageCraft AVR
; Written by: Knut Baardsen @ Baardsen Software, Norway
; Updates: http://www.baso.no
; ***********************************************************************/
; 
; /***********************************************************************
; This software is provided "as is"; Without warranties either express or
; implied, including any warranty regarding merchantability, fitness for 
; a particular purpose or noninfringement. 
; In no event shall Baardsen Software or its suppliers be liable for any 
; special,indirect,incidential or concequential damages resulting from 
; the use or inability to use this software.
; ***********************************************************************/
; 
; #include"global.h"
; 
; 
; 
; /***********************************************************************
; Makes a delay at approximate 2mS at 8MHz
; ***********************************************************************/
; void lcd_delay(unsigned int i)
; {
	.dbline 57
;   int x ,y;
;   for (x = 0; x < i; x++)
	clr R20
	clr R21
	xjmp L5
L2:
	.dbline 58
;   {
	.dbline 59
;      for (y = 0; y <200; y++)
	clr R22
	clr R23
L6:
	.dbline 60
;      asm("WDR");
	WDR
L7:
	.dbline 59
	subi R22,255  ; offset = 1
	sbci R23,255
	.dbline 59
	cpi R22,200
	ldi R30,0
	cpc R23,R30
	brlt L6
X0:
	.dbline 61
;   }
L3:
	.dbline 57
	subi R20,255  ; offset = 1
	sbci R21,255
L5:
	.dbline 57
	cp R20,R16
	cpc R21,R17
	brlo L2
X1:
	.dbline -2
L1:
	.dbline 0 ; func end
	xjmp pop_xgsetF000
	.dbsym r x 20 I
	.dbsym r y 22 I
	.dbsym r i 16 i
	.dbend
	.dbfunc e lcd_write_command _lcd_write_command fV
;        command -> R16
	.even
_lcd_write_command::
	.dbline -1
	.dbline 70
; }
; 
; 
; /***********************************************************************
; Write specified command to LCD panel.
; This is an internal function...
; ***********************************************************************/
; void lcd_write_command(unsigned char command)
; {
	.dbline 71
;   LCDDATAPORT = command;
	out 0x1b,R16
	.dbline 72
;   LCDCTLPORT |= A0;   
	sbi 0x15,5
	.dbline 73
;   LCDCTLPORT &= ~(WR);
	cbi 0x15,4
	.dbline 74
;   LCDCTLPORT |= WR;   
	sbi 0x15,4
	.dbline -2
L10:
	.dbline 0 ; func end
	ret
	.dbsym r command 16 c
	.dbend
	.dbfunc e lcd_write_data _lcd_write_data fV
;           data -> R16
	.even
_lcd_write_data::
	.dbline -1
	.dbline 83
; }
; 
; 
; /***********************************************************************
; Write specified data to LCD panel.
; This is an internal function...
; ***********************************************************************/
; void lcd_write_data(unsigned char data)
; {
	.dbline 84
;   LCDDATAPORT = data;
	out 0x1b,R16
	.dbline 85
;   LCDCTLPORT &= ~(A0);
	cbi 0x15,5
	.dbline 86
;   LCDCTLPORT &= ~(WR);
	cbi 0x15,4
	.dbline 87
;   LCDCTLPORT |= WR;   
	sbi 0x15,4
	.dbline -2
L11:
	.dbline 0 ; func end
	ret
	.dbsym r data 16 c
	.dbend
	.dbfunc e lcd_read_data _lcd_read_data fc
;              i -> <dead>
;           data -> R16
	.even
_lcd_read_data::
	.dbline -1
	.dbline 96
; }
; 
; 
; /***********************************************************************
; Read data from LCD panel at position given by lcd_pixel command.
; This is an internal function...
; ***********************************************************************/
; unsigned char lcd_read_data(void)
; {
	.dbline 99
;   unsigned char data;
;   int i;
;   LCDDATADDR = 0x00;    
	clr R2
	out 0x1a,R2
	.dbline 100
;   LCDCTLPORT |= A0;     
	sbi 0x15,5
	.dbline 101
;   LCDCTLPORT &= ~(RD);  
	cbi 0x15,3
	.dbline 102
;   data = LCDDATAPIN;    
	in R16,0x19
	.dbline 103
;   data = LCDDATAPIN;    
	in R16,0x19
	.dbline 104
;   data = LCDDATAPIN;    
	in R16,0x19
	.dbline 105
;   LCDCTLPORT |= RD;     
	sbi 0x15,3
	.dbline 106
;   LCDDATADDR = 0xff;    
	ldi R24,255
	out 0x1a,R24
	.dbline 107
;   return data;
	.dbline -2
L12:
	.dbline 0 ; func end
	ret
	.dbsym l i 1 I
	.dbsym r data 16 c
	.dbend
	.dbfunc e lcd_init _lcd_init fV
;              i -> R20,R21
	.even
_lcd_init::
	st -y,R20
	st -y,R21
	.dbline -1
	.dbline 116
; }
; 
; 
; /***********************************************************************
; Initialize the LCD controller. Read the documentation for the 
; controller in use. If any other than SED1335 values can be wrong ! 
; ***********************************************************************/
; void lcd_init(void)
; {
	.dbline 119
;   int i;
;   // Setup LCD Data bus port as output
;   LCDDATAPORT  = 0xff;
	ldi R24,255
	out 0x1b,R24
	.dbline 120
;   LCDDATADDR   = 0xff; 
	out 0x1a,R24
	.dbline 123
;    
;   // Setup LCD control bus port as output
;   LCDCTLDDR |= 0xff; 
	in R24,0x14
	ori R24,255
	out 0x14,R24
	.dbline 124
;   LCDCTLPORT = 0xff;
	ldi R24,255
	out 0x15,R24
	.dbline 125
;   LCDCTLPORT = LCDCTLPORT&CSEL;
	in R24,0x15
	andi R24,127
	out 0x15,R24
	.dbline 128
; 
;           
;   LCDCTLPORT |= WR;           
	sbi 0x15,4
	.dbline 129
;   LCDCTLPORT |= RD;           
	sbi 0x15,3
	.dbline 131
;   // Reset the LCD
;   LCDCTLPORT |= RST;
	sbi 0x15,6
	.dbline 132
;   lcd_delay(5);
	ldi R16,5
	ldi R17,0
	xcall _lcd_delay
	.dbline 133
;   LCDCTLPORT &= ~RST;
	cbi 0x15,6
	.dbline 134
;   for (i=0; i<50; i++) lcd_delay(5);
	clr R20
	clr R21
L14:
	.dbline 134
	ldi R16,5
	ldi R17,0
	xcall _lcd_delay
L15:
	.dbline 134
	subi R20,255  ; offset = 1
	sbci R21,255
	.dbline 134
	cpi R20,50
	ldi R30,0
	cpc R21,R30
	brlt L14
X2:
	.dbline 135
;   LCDCTLPORT |= RST; 
	sbi 0x15,6
	.dbline 139
;   
;  
;   // System
;   lcd_write_command(0x40); 
	ldi R16,64
	xcall _lcd_write_command
	.dbline 140
;   lcd_write_data(0x30);////////////////////////////P1   0  0 B 1 WS M2 M1 M0
	ldi R16,48
	xcall _lcd_write_data
	.dbline 141
;   lcd_write_data(0x87);////////////////////////////P2   WF 0 0 0 0    FX(0-7)
	ldi R16,135
	xcall _lcd_write_data
	.dbline 142
;   lcd_write_data(0x07);////////////////////////////P3   0  0 0 0     FY(0-F)
	ldi R16,7
	xcall _lcd_write_data
	.dbline 143
;   lcd_write_data((LCD_X_SIZE/8)-1); ///////////////P4          C/R
	ldi R16,39
	xcall _lcd_write_data
	.dbline 144
;   lcd_write_data(0x42); ///////////////////////////P5          TC/R>cr+4
	ldi R16,66
	xcall _lcd_write_data
	.dbline 145
;   lcd_write_data(LCD_Y_SIZE - 1);//////////////////P6          L/F  240-1
	ldi R16,239
	xcall _lcd_write_data
	.dbline 146
;   lcd_write_data(LCD_X_SIZE/8);////////////////////P7          APL  40
	ldi R16,40
	xcall _lcd_write_data
	.dbline 147
;   lcd_write_data(0x00);//////////////////////////////P8          APH    
	clr R16
	xcall _lcd_write_data
	.dbline 149
;   // Scroll
;   lcd_write_command(0x44); 
	ldi R16,68
	xcall _lcd_write_command
	.dbline 150
;   lcd_write_data(0x00);    
	clr R16
	xcall _lcd_write_data
	.dbline 151
;   lcd_write_data(0x00);    
	clr R16
	xcall _lcd_write_data
	.dbline 152
;   lcd_write_data(LCD_Y_SIZE);
	ldi R16,240
	xcall _lcd_write_data
	.dbline 153
;   lcd_write_data(0x00);      
	clr R16
	xcall _lcd_write_data
	.dbline 154
;   lcd_write_data(0x10);      
	ldi R16,16
	xcall _lcd_write_data
	.dbline 155
;   lcd_write_data(LCD_Y_SIZE);
	ldi R16,240
	xcall _lcd_write_data
	.dbline 157
;   // Horizontal scroll
;   lcd_write_command(0x5a);  
	ldi R16,90
	xcall _lcd_write_command
	.dbline 158
;   lcd_write_data(0x00);     
	clr R16
	xcall _lcd_write_data
	.dbline 160
;   // Overlay
;   lcd_write_command(0x5b);  
	ldi R16,91
	xcall _lcd_write_command
	.dbline 161
;   lcd_write_data(0x03);    
	ldi R16,3
	xcall _lcd_write_data
	.dbline 163
;   // Display On/Off I
;   lcd_write_command(0x58);
	ldi R16,88
	xcall _lcd_write_command
	.dbline 164
;   lcd_write_data(0x14);     
	ldi R16,20
	xcall _lcd_write_data
	.dbline 166
;   // Cursor format
;   lcd_write_command(0x5d); 
	ldi R16,93
	xcall _lcd_write_command
	.dbline 167
;   lcd_write_data(0x07);    
	ldi R16,7
	xcall _lcd_write_data
	.dbline 168
;   lcd_write_data(0x87);    
	ldi R16,135
	xcall _lcd_write_data
	.dbline 170
;   // Display On/Off II 
;   lcd_write_command(0x59);   
	ldi R16,89
	xcall _lcd_write_command
	.dbline 171
;   lcd_write_data(0x14); // 0 0 0 1 0 1 0 0     
	ldi R16,20
	xcall _lcd_write_data
	.dbline 173
;   // Curson direction  
;   lcd_write_command(0x4c);          
	ldi R16,76
	xcall _lcd_write_command
	.dbline 175
;   // CUrsor write  
;   lcd_write_command(0x46);
	ldi R16,70
	xcall _lcd_write_command
	.dbline 176
;   lcd_write_data(0x00); 
	clr R16
	xcall _lcd_write_data
	.dbline 177
;   lcd_write_data(0x00);  
	clr R16
	xcall _lcd_write_data
	.dbline -2
L13:
	.dbline 0 ; func end
	ld R21,y+
	ld R20,y+
	ret
	.dbsym r i 20 I
	.dbend
	.dbfunc e lcd_clear_text _lcd_clear_text fV
;              i -> R20,R21
	.even
_lcd_clear_text::
	st -y,R20
	st -y,R21
	.dbline -1
	.dbline 183
; }
; /***********************************************************************
; Clears the text layer / screen.
; ***********************************************************************/
; void lcd_clear_text(void)
; {
	.dbline 185
;   int i;
;   lcd_write_command(0x46);
	ldi R16,70
	xcall _lcd_write_command
	.dbline 186
;   lcd_write_data(0x00);
	clr R16
	xcall _lcd_write_data
	.dbline 187
;   lcd_write_data(0x00);
	clr R16
	xcall _lcd_write_data
	.dbline 188
;   lcd_write_command(0x42); 
	ldi R16,66
	xcall _lcd_write_command
	.dbline 189
;   for (i=0; i<((LCD_X_SIZE/8)*(LCD_Y_SIZE/8)); i++) lcd_write_data(' ');
	clr R20
	clr R21
L19:
	.dbline 189
	ldi R16,32
	xcall _lcd_write_data
L20:
	.dbline 189
	subi R20,255  ; offset = 1
	sbci R21,255
	.dbline 189
	cpi R20,176
	ldi R30,4
	cpc R21,R30
	brlt L19
X3:
	.dbline 190
;   lcd_write_command(0x46); 
	ldi R16,70
	xcall _lcd_write_command
	.dbline 191
;   lcd_write_data(0x00);
	clr R16
	xcall _lcd_write_data
	.dbline 192
;   lcd_write_data(0x00);
	clr R16
	xcall _lcd_write_data
	.dbline -2
L18:
	.dbline 0 ; func end
	ld R21,y+
	ld R20,y+
	ret
	.dbsym r i 20 I
	.dbend
	.dbfunc e lcd_goto _lcd_goto fV
;             hi -> R10
;             lo -> R12
;           addr -> R20,R21
;           line -> R12
;         column -> R10
	.even
_lcd_goto::
	xcall push_xgset303C
	mov R12,R18
	mov R10,R16
	.dbline -1
	.dbline 200
; }
; 
; 
; /***********************************************************************
; Goto specified column and line. 1,1 is the upper left corner.
; ***********************************************************************/
; void lcd_goto(unsigned char column, unsigned char line)
; {
	.dbline 204
;   int addr;
;   unsigned char lo;
;   unsigned char hi;
;   column--;
	dec R10
	.dbline 205
;   line--;
	dec R12
	.dbline 206
;   addr = (line * (LCD_X_SIZE/8)) + column;
	ldi R24,40
	mul R24,R12
	movw R20,R0
	mov R2,R10
	clr R3
	add R20,R2
	adc R21,R3
	.dbline 207
;   lo = (unsigned char) (addr & 0x00ff);
	movw R24,R20
	andi R25,0
	mov R12,R24
	.dbline 208
;   hi = (unsigned char) ((addr & 0xff00) >> 8);
	movw R24,R20
	andi R24,0
	movw R10,R24
	mov R10,R11
	clr R11
	.dbline 209
;   lcd_write_command(0x46);
	ldi R16,70
	xcall _lcd_write_command
	.dbline 210
;   lcd_write_data(lo);
	mov R16,R12
	xcall _lcd_write_data
	.dbline 211
;   lcd_write_data(hi);
	mov R16,R10
	xcall _lcd_write_data
	.dbline -2
L23:
	.dbline 0 ; func end
	xjmp pop_xgset303C
	.dbsym r hi 10 c
	.dbsym r lo 12 c
	.dbsym r addr 20 I
	.dbsym r line 12 c
	.dbsym r column 10 c
	.dbend
	.dbfunc e lcd_write_string _lcd_write_string fV
;              i -> <dead>
;            ptr -> R10,R11
	.even
_lcd_write_string::
	st -y,R10
	st -y,R11
	movw R10,R16
	.dbline -1
	.dbline 220
; }
; 
; 
; /***********************************************************************
; Write strings to the text layer. Set position with lcd_goto.
; Text will wrap if to long to show on one line.
; ***********************************************************************/
; void lcd_write_string(char *ptr)
; {
	.dbline 222
;   int i;
;   lcd_write_command(0x42);
	ldi R16,66
	xcall _lcd_write_command
	xjmp L26
L25:
	.dbline 223
;   while (*ptr != 0x00) lcd_write_data(*ptr++);
	movw R30,R10
	ld R16,Z+
	movw R10,R30
	xcall _lcd_write_data
L26:
	.dbline 223
	movw R30,R10
	ldd R2,z+0
	tst R2
	brne L25
X4:
	.dbline -2
L24:
	.dbline 0 ; func end
	ld R11,y+
	ld R10,y+
	ret
	.dbsym l i 1 I
	.dbsym r ptr 10 pc
	.dbend
	.dbfunc e lcd_show_cursor _lcd_show_cursor fV
;           show -> R10
	.even
_lcd_show_cursor::
	st -y,R10
	mov R10,R16
	.dbline -1
	.dbline 231
; }
; 
; 
; /***********************************************************************
; Show or hide cursor. 0=Hide, 1=Show.
; ***********************************************************************/
; void lcd_show_cursor(unsigned char show)
; {
	.dbline 232
;   lcd_write_command(0x59); 
	ldi R16,89
	xcall _lcd_write_command
	.dbline 233
;   if (show == 0) lcd_write_data(0x14);
	tst R10
	brne L29
X5:
	.dbline 233
	ldi R16,20
	xcall _lcd_write_data
	xjmp L30
L29:
	.dbline 234
;   else lcd_write_data(0x16);
	ldi R16,22
	xcall _lcd_write_data
L30:
	.dbline -2
L28:
	.dbline 0 ; func end
	ld R10,y+
	ret
	.dbsym r show 10 c
	.dbend
	.dbfunc e lcd_clear_graphics _lcd_clear_graphics fV
;              i -> R20,R21

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -