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

📄 remote.s

📁 硬盘MP3播放器-MEGA128-VS1001K-USB-遥控-LCD-ICCAVR代码-硬盘-支持FAT32-单面PCB 第二部分
💻 S
📖 第 1 页 / 共 3 页
字号:
	.module remote.c
	.area data(ram, con, rel)
_TimeOut::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile C:\DATA\MP3\Remote\Code\remote.c
	.dbsym e TimeOut _TimeOut i
_Key::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile C:\DATA\MP3\Remote\Code\remote.c
	.dbsym e Key _Key c
_LinePtr::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile C:\DATA\MP3\Remote\Code\remote.c
	.dbsym e LinePtr _LinePtr C
_ListType::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile C:\DATA\MP3\Remote\Code\remote.c
	.dbsym e ListType _ListType c
_NewMessage::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile C:\DATA\MP3\Remote\Code\remote.c
	.dbsym e NewMessage _NewMessage c
_Refresh::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile C:\DATA\MP3\Remote\Code\remote.c
	.dbsym e Refresh _Refresh c
_Light::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile C:\DATA\MP3\Remote\Code\remote.c
	.dbsym e Light _Light i
_Cont::
	.blkb 1
	.area idata
	.byte 25
	.area data(ram, con, rel)
	.dbfile C:\DATA\MP3\Remote\Code\remote.c
	.dbsym e Cont _Cont c
	.area text(rom, con, rel)
	.dbfile C:\DATA\MP3\Remote\Code\remote.c
	.dbfunc e main _main fV
	.even
_main::
	sbiw R28,2
	.dbline -1
	.dbline 35
; // Check Remote hardware version in Remote.h
; 
; #include <iom8v.h>
; #include <macros.h>
; #include <string.h>
; #include <stdio.h>
; #include "NokiaLCD.h"
; #include "remote.h"
; #include "eeprom.h"
; 
; //#define NOTIMEOUT
; 
; //******************************************************************
; //*	MAIN Global Variable
; //******************************************************************
; unsigned int TimeOut = 0;
; unsigned char Key = NONE;
; char Line[5][MAXLEN];
; unsigned char RxData[MAXLEN*2];
; signed char LinePtr = 0;
; unsigned char ListType = SONG;
; unsigned char NewMessage = FALSE;
; unsigned char Refresh = FALSE;
; unsigned int Light = 0; 
; unsigned char Cont = 25;
; 
; unsigned char UpdateLcd;
; 
; 
; unsigned char buffer[10];
; //*************************************
; // void main(void)
; //*************************************
; void main(void)
; {
	.dbline 41
; // PortB is setup by LcdInit() 
; // PB1 is share for LCD and 38khz oscilator
; // PB6..7 is for external Xtal
; 
; // PortC is for KeyPad and set as input
; DDRC = 0x00;        // PC as input
	clr R2
	out 0x14,R2
	.dbline 42
; PORTC = 0xff;       // Pull up on PC pin	
	ldi R24,255
	out 0x15,R24
	.dbline 45
; 
; // PortD is for Serial TX&RX, and Int0 input
; DDRD = 0x18;        // All input exept PD4 output VRX, PD3 output LIGHT
	ldi R24,24
	out 0x11,R24
	.dbline 46
; PORTD = 0xe4;       // Pull up on all PD exept TX & RX & LIGHT
	ldi R24,228
	out 0x12,R24
	.dbline 49
; 
; // Int0 is for Keypress interrupt done via diode on each key 
; MCUCR = 0x02;       // int0 on falling eage level
	ldi R24,2
	out 0x35,R24
	.dbline 50
; GICR = 0x40;        // int0 enable
	ldi R24,64
	out 0x3b,R24
	.dbline 53
; 
; // Timer 0
; TCCR0 = 0x04;       // Timer1 / 256
	ldi R24,4
	out 0x33,R24
	.dbline 56
; 
; // Timer 1
; TCCR1B = 0x09;		// Timer 1 prescaler at /1
	ldi R24,9
	out 0x2e,R24
	.dbline 57
; OCR1A  = 0x17;		// for 38khz
	ldi R24,23
	ldi R25,0
	out 0x2b,R25
	out 0x2a,R24
	.dbline 60
; 
; // Serial
; UCSRA = 0x00;  		// Clear flags, single speed, No multi processor
	out 0xb,R2
	.dbline 61
; UCSRC = 0x8e;  		// Asynch, No parity, 2 stopbit, 8bit
	ldi R24,142
	out 0x20,R24
	.dbline 62
; UBRRL = 47;    		// 2400bps at 1.8432Mhz
	ldi R24,47
	out 0x9,R24
	.dbline 63
; UBRRH = 0x00;  
	out 0x20,R2
	.dbline 64
; UCSRB = 0x98;  		// RX & TX Enable
	ldi R24,152
	out 0xa,R24
	.dbline 66
; 
; Line[0][0] = 0x00;
	sts _Line,R2
	.dbline 67
; Line[1][0] = 0x00;
	sts _Line+40,R2
	.dbline 68
; Line[2][0] = 0x00;
	sts _Line+80,R2
	.dbline 69
; Line[3][0] = 0x00;
	sts _Line+120,R2
	.dbline 70
; Line[4][0] = 0x00;
	sts _Line+160,R2
	.dbline 72
; 
; TIMSK = 0x01;       // Timer0 overflow interrupt enable
	ldi R24,1
	out 0x39,R24
	.dbline 74
; 
; LcdInit();
	rcall _LcdInit
	.dbline 75
; EEPROM_READ(0x10, Cont);	
	ldi R24,1
	ldi R25,0
	std y+1,R25
	std y+0,R24
	ldi R18,<_Cont
	ldi R19,>_Cont
	ldi R16,16
	ldi R17,0
	rcall _EEPROMReadBytes
	.dbline 76
; LcdContrast(Cont);
	lds R16,_Cont
	rcall _LcdContrast
	.dbline 77
; Presentation();
	rcall _Presentation
	.dbline 78
; LineDisplay();
	rcall _LineDisplay
	.dbline 79
; SEI();
	sei
	.dbline 81
; 
; PORTD |= VRX;
	sbi 0x12,4
	rjmp L10
L9:
	.dbline 84
; 
; while(1)
; 		{
	.dbline 85
; 		_StackCheck();
	rcall __StackCheck
	.dbline 87
; 
; 		if (TimeOut <= 10000)
	ldi R24,10000
	ldi R25,39
	lds R2,_TimeOut
	lds R3,_TimeOut+1
	cp R24,R2
	cpc R25,R3
	brsh X1
	rjmp L12
X1:
	.dbline 88
; 		   {
	.dbline 89
; 		   if (NewMessage == TRUE)
	lds R24,_NewMessage
	cpi R24,1
	brne L14
	.dbline 90
;    		   	  {
	.dbline 91
; 			  CLI();
	cli
	.dbline 92
; 		   	  AnalyseData();
	rcall _AnalyseData
	.dbline 93
; 		   	  NewMessage = FALSE;
	clr R2
	sts _NewMessage,R2
	.dbline 94
; 			  SEI();
	sei
	.dbline 95
;    		   	  }
L14:
	.dbline 97
;  
; 		   if (Light > 1000) 
	ldi R24,1000
	ldi R25,3
	lds R2,_Light
	lds R3,_Light+1
	cp R24,R2
	cpc R25,R3
	brsh L16
	.dbline 98
; 		   	  {
	.dbline 99
; 		   	  PORTD &= ~LIGHT;
	cbi 0x12,3
	.dbline 100
; 		   	  Light = 1001;
	ldi R24,233
	sts _Light+1,R25
	sts _Light,R24
	.dbline 101
; 		   	  }
L16:
	.dbline 103
; 
; 		   if (Key != NONE)
	lds R2,_Key
	tst R2
	brne X2
	rjmp L13
X2:
	.dbline 104
; 		   	  {
	.dbline 105
; 			  TimeOut = 0;
	clr R2
	clr R3
	sts _TimeOut+1,R3
	sts _TimeOut,R2
	.dbline 106
; 			  Light = 0;
	sts _Light+1,R3
	sts _Light,R2
	.dbline 107
; 			  PORTD |= LIGHT;
	sbi 0x12,3
	.dbline 109
; 			  
; 			  if (Key == RESET) 
	lds R24,_Key
	cpi R24,38
	brne L20
	.dbline 110
; 			  	 {
	.dbline 111
; 				 CLI();
	cli
	.dbline 112
; 				 TIMSK = 0x00;
	out 0x39,R2
	.dbline 113
; 				 UCSRB = 0x18;  		// RX & TX Enable
	ldi R24,24
	out 0xa,R24
	.dbline 114
; 				 asm("jmp 0x0000");
	jmp 0x0000
	.dbline 115
; 				 }
L20:
	.dbline 117
; 				 
; 			  if (Key == DOWN)
	lds R24,_Key
	cpi R24,4
	brne L22
	.dbline 118
; 			  	 {
	.dbline 119
; 				 SendKey(0x01);
	ldi R16,1
	rcall _SendKey
	.dbline 120
; 				 }
L22:
	.dbline 122
; 				 
; 			  if (Key == SHIFT_DOWN)
	lds R24,_Key
	cpi R24,132
	brne L24
	.dbline 123
; 			  	 {
	.dbline 124
; 				 SendKey(0x81);
	ldi R16,129
	rcall _SendKey
	.dbline 125
; 				 }			 
L24:
	.dbline 127
; 				 
; 			  if (Key == UP)
	lds R24,_Key
	cpi R24,32
	brne L26
	.dbline 128
; 			  	 {
	.dbline 129
; 				 SendKey(0x02);
	ldi R16,2
	rcall _SendKey
	.dbline 130
; 				 }
L26:
	.dbline 132
; 				 
; 			  if (Key == SHIFT_UP)
	lds R24,_Key
	cpi R24,144
	brne L28
	.dbline 133
; 			  	 {
	.dbline 134
; 				 SendKey(0x82);
	ldi R16,130
	rcall _SendKey
	.dbline 135
; 				 }
L28:
	.dbline 137
; 				 
; 			  if (Key == LEFT)
	lds R24,_Key
	cpi R24,2
	brne L30
	.dbline 138
; 			  	 {
	.dbline 139
; 				 SendKey(0x04);
	ldi R16,4
	rcall _SendKey
	.dbline 140
; 				 } 
L30:
	.dbline 142
; 				 
; 			  if (Key == RIGHT)
	lds R24,_Key
	cpi R24,8
	brne L32
	.dbline 143
; 			  	 {
	.dbline 144
; 				 SendKey(0x08);
	ldi R16,8
	rcall _SendKey
	.dbline 145
; 				 }	
L32:
	.dbline 147
; 				 
; 			  if (Key == SHIFT_RIGHT)
	lds R24,_Key
	cpi R24,136
	brne L34
	.dbline 148
; 			  	 {
	.dbline 149
; 				 Cont++;
	lds R24,_Cont
	subi R24,255    ; addi 1
	sts _Cont,R24
	.dbline 150
; 				 if (Cont > 0x7f) Cont = 0;
	ldi R24,127
	lds R2,_Cont
	cp R24,R2
	brsh L36
	.dbline 150
	clr R2
	sts _Cont,R2
L36:
	.dbline 151
; 				 LcdContrast(Cont);
	lds R16,_Cont
	rcall _LcdContrast
	.dbline 152
; 				 EEPROM_WRITE(0x10, Cont);	
	ldi R24,1
	ldi R25,0
	std y+1,R25
	std y+0,R24
	ldi R18,<_Cont
	ldi R19,>_Cont
	ldi R16,16
	ldi R17,0
	rcall _EEPROMWriteBytes
	.dbline 153
; 				 }
L34:
	.dbline 155
; 				 
; 			  if (Key == SHIFT_LEFT)
	lds R24,_Key
	cpi R24,130
	brne L38
	.dbline 156
; 			  	 {
	.dbline 157
; 				 Cont--;
	lds R24,_Cont
	subi R24,1
	sts _Cont,R24
	.dbline 158
; 				 if (Cont == 0x00) Cont = 0x7f;
	tst R24
	brne L40
	.dbline 158
	ldi R24,127
	sts _Cont,R24
L40:
	.dbline 159
; 				 LcdContrast(Cont);
	lds R16,_Cont
	rcall _LcdContrast
	.dbline 160
; 				 EEPROM_WRITE(0x10, Cont);	
	ldi R24,1
	ldi R25,0
	std y+1,R25
	std y+0,R24
	ldi R18,<_Cont
	ldi R19,>_Cont
	ldi R16,16
	ldi R17,0
	rcall _EEPROMWriteBytes
	.dbline 161
; 				 }				 
L38:
	.dbline 163
; 				 
; 			  Key = NONE;	 
	clr R2
	sts _Key,R2
	.dbline 164
; 		   	  }
	.dbline 165
; 		   }
	rjmp L13
L12:
	.dbline 167
; 		else
; 		   {
	.dbline 169
; 		   // Go in DEEP SLEEP
; 		   LcdClear();
	rcall _LcdClear
	.dbline 170
; 		   LcdPower(FALSE);
	clr R16
	rcall _LcdPower
	.dbline 171
; 		   PORTD &= ~VRX;     // Disable Receiver
	cbi 0x12,4
	.dbline 174
; 		   // Disable Timer0 overflow because the LCD must be init first 
; 		   // after wake up
; 		   TIMSK &= ~0x01;
	in R24,0x39
	andi R24,254
	out 0x39,R24
	.dbline 176
; 
; 		   MCUCR = 0xa0;      // Power Down MCU and int0 low level
	ldi R24,160
	out 0x35,R24
	.dbline 177
; 		   SLEEP();
	sleep
	.dbline 179
; 
; 		   TimeOut = 0;
	clr R2
	clr R3
	sts _TimeOut+1,R3
	sts _TimeOut,R2
	.dbline 180
; 		   LcdPower(TRUE);
	ldi R16,1
	rcall _LcdPower
	.dbline 181
; 		   LcdContrast(Cont);
	lds R16,_Cont
	rcall _LcdContrast
	.dbline 182
; 		   PORTD |= VRX;      // Enable Receiver
	sbi 0x12,4
	.dbline 183
; 		   Presentation();
	rcall _Presentation
	.dbline 184
; 		   LineDisplay();
	rcall _LineDisplay
	.dbline 185
; 		   TIMSK |= 0x01;  	  // Timer0 overflow interrupt enable
	in R24,0x39
	ori R24,1
	out 0x39,R24
	.dbline 186
; 		   MCUCR = 0x02;  	  // int0 on falling eage level
	ldi R24,2
	out 0x35,R24
	.dbline 187
; 		   }
L13:
	.dbline 188
L10:
	.dbline 83
	rjmp L9
X0:
	.dbline -2
	.dbline 189
; 		}
; }
L4:
	adiw R28,2
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e _StackOverflowed __StackOverflowed fV
;              c -> R20
	.even
__StackOverflowed::
	rcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 195
; 
; //*************************************
; // void _StackOverflowed(char c)
; //*************************************
; void _StackOverflowed(char c)
; 	{
	.dbline 196
; 	CLI();
	cli
	.dbline 197
; 	LcdClear();
	rcall _LcdClear
	.dbline 198
; 	LcdGotoXY(1,3);
	ldi R18,3
	ldi R16,1
	rcall _LcdGotoXY
	.dbline 199
; 	LcdStrConst(1,"Stack Crash...\0");
	ldi R18,<L43
	ldi R19,>L43
	ldi R16,1
	rcall _LcdStrConst
	.dbline 200
; 	LcdUpdate();
	rcall _LcdUpdate
L44:
	.dbline 201
L45:
	.dbline 201
	rjmp L44
X3:
	.dbline -2
	.dbline 202
; 	while(1);
; 	}
L42:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r c 20 c
	.dbend
	.dbfunc e Presentation _Presentation fV
;              i -> R20
	.even
_Presentation::
	rcall push_gset1
	sbiw R28,5
	.dbline -1
	.dbline 208
; 
; //*************************************
; // void Presentation(void)
; //*************************************
; void Presentation(void)
; {
	.dbline 211
; unsigned char i;
; 
; LcdClear();
	rcall _LcdClear
	.dbline 212
; LcdGotoXY(3,1);
	ldi R18,1
	ldi R16,3
	rcall _LcdGotoXY
	.dbline 213
; LcdStrConst(1,"MP3 Player" );
	ldi R18,<L48
	ldi R19,>L48
	ldi R16,1
	rcall _LcdStrConst
	.dbline 214
	clr R20
	rjmp L52
L49:
	.dbline 214
	ldi R24,2
	std y+4,R24
	std y+2,R20
	ldi R24,83
	std y+0,R24
	mov R18,R20
	clr R16
	rcall _LcdLine

⌨️ 快捷键说明

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