📄 remote.lst
字号:
__text_start:
__start:
0171 E5CF LDI R28,0x5F
0172 E0D4 LDI R29,4
0173 BFCD OUT 0x3D,R28
0174 BFDE OUT 0x3E,R29
0175 52C0 SUBI R28,0x20
0176 40D0 SBCI R29,0
0177 EA0A LDI R16,0xAA
0178 8308 STD Y+0,R16
0179 2400 CLR R0
017A E6EE LDI R30,0x6E
017B E0F0 LDI R31,0
017C E013 LDI R17,3
017D 3AE1 CPI R30,0xA1
017E 07F1 CPC R31,R17
017F F011 BEQ 0x0182
0180 9201 ST R0,Z+
0181 CFFB RJMP 0x017D
0182 8300 STD Z+0,R16
0183 EDE4 LDI R30,0xD4
0184 E0F2 LDI R31,2
0185 E6A0 LDI R26,0x60
0186 E0B0 LDI R27,0
0187 E012 LDI R17,2
0188 3EE2 CPI R30,0xE2
0189 07F1 CPC R31,R17
018A F021 BEQ 0x018F
018B 95C8 LPM
018C 9631 ADIW R30,1
018D 920D ST R0,X+
018E CFF9 RJMP 0x0188
018F D001 RCALL _main
_exit:
0190 CFFF RJMP _exit
_main:
0191 9722 SBIW R28,2
FILE: C:\DATA\MP3\Remote\Code\remote.c
(0001) // Check Remote hardware version in Remote.h
(0002)
(0003) #include <iom8v.h>
(0004) #include <macros.h>
(0005) #include <string.h>
(0006) #include <stdio.h>
(0007) #include "NokiaLCD.h"
(0008) #include "remote.h"
(0009) #include "eeprom.h"
(0010)
(0011) //#define NOTIMEOUT
(0012)
(0013) //******************************************************************
(0014) //* MAIN Global Variable
(0015) //******************************************************************
(0016) unsigned int TimeOut = 0;
(0017) unsigned char Key = NONE;
(0018) char Line[5][MAXLEN];
(0019) unsigned char RxData[MAXLEN*2];
(0020) signed char LinePtr = 0;
(0021) unsigned char ListType = SONG;
(0022) unsigned char NewMessage = FALSE;
(0023) unsigned char Refresh = FALSE;
(0024) unsigned int Light = 0;
(0025) unsigned char Cont = 25;
(0026)
(0027) unsigned char UpdateLcd;
(0028)
(0029)
(0030) unsigned char buffer[10];
(0031) //*************************************
(0032) // void main(void)
(0033) //*************************************
(0034) void main(void)
(0035) {
(0036) // PortB is setup by LcdInit()
(0037) // PB1 is share for LCD and 38khz oscilator
(0038) // PB6..7 is for external Xtal
(0039)
(0040) // PortC is for KeyPad and set as input
(0041) DDRC = 0x00; // PC as input
0192 2422 CLR R2
0193 BA24 OUT 0x14,R2
(0042) PORTC = 0xff; // Pull up on PC pin
0194 EF8F LDI R24,0xFF
0195 BB85 OUT 0x15,R24
(0043)
(0044) // PortD is for Serial TX&RX, and Int0 input
(0045) DDRD = 0x18; // All input exept PD4 output VRX, PD3 output LIGHT
0196 E188 LDI R24,0x18
0197 BB81 OUT 0x11,R24
(0046) PORTD = 0xe4; // Pull up on all PD exept TX & RX & LIGHT
0198 EE84 LDI R24,0xE4
0199 BB82 OUT 0x12,R24
(0047)
(0048) // Int0 is for Keypress interrupt done via diode on each key
(0049) MCUCR = 0x02; // int0 on falling eage level
019A E082 LDI R24,2
019B BF85 OUT 0x35,R24
(0050) GICR = 0x40; // int0 enable
019C E480 LDI R24,0x40
019D BF8B OUT 0x3B,R24
(0051)
(0052) // Timer 0
(0053) TCCR0 = 0x04; // Timer1 / 256
019E E084 LDI R24,4
019F BF83 OUT 0x33,R24
(0054)
(0055) // Timer 1
(0056) TCCR1B = 0x09; // Timer 1 prescaler at /1
01A0 E089 LDI R24,0x9
01A1 BD8E OUT 0x2E,R24
(0057) OCR1A = 0x17; // for 38khz
01A2 E187 LDI R24,0x17
01A3 E090 LDI R25,0
01A4 BD9B OUT 0x2B,R25
01A5 BD8A OUT 0x2A,R24
(0058)
(0059) // Serial
(0060) UCSRA = 0x00; // Clear flags, single speed, No multi processor
01A6 B82B OUT 0x0B,R2
(0061) UCSRC = 0x8e; // Asynch, No parity, 2 stopbit, 8bit
01A7 E88E LDI R24,0x8E
01A8 BD80 OUT 0x20,R24
(0062) UBRRL = 47; // 2400bps at 1.8432Mhz
01A9 E28F LDI R24,0x2F
01AA B989 OUT 0x09,R24
(0063) UBRRH = 0x00;
01AB BC20 OUT 0x20,R2
(0064) UCSRB = 0x98; // RX & TX Enable
01AC E988 LDI R24,0x98
01AD B98A OUT 0x0A,R24
(0065)
(0066) Line[0][0] = 0x00;
01AE 922000DB STS _Line,R2
(0067) Line[1][0] = 0x00;
01B0 92200103 STS 0x103,R2
(0068) Line[2][0] = 0x00;
01B2 9220012B STS 0x12B,R2
(0069) Line[3][0] = 0x00;
01B4 92200153 STS 0x153,R2
(0070) Line[4][0] = 0x00;
01B6 9220017B STS 0x17B,R2
(0071)
(0072) TIMSK = 0x01; // Timer0 overflow interrupt enable
01B8 E081 LDI R24,1
01B9 BF89 OUT 0x39,R24
(0073)
(0074) LcdInit();
01BA D3CA RCALL _LcdInit
(0075) EEPROM_READ(0x10, Cont);
01BB E081 LDI R24,1
01BC E090 LDI R25,0
01BD 8399 STD Y+1,R25
01BE 8388 STD Y+0,R24
01BF E629 LDI R18,0x69
01C0 E030 LDI R19,0
01C1 E100 LDI R16,0x10
01C2 E010 LDI R17,0
01C3 D7FF RCALL _EEPROMReadBytes
(0076) LcdContrast(Cont);
01C4 91000069 LDS R16,0x69
01C6 D3FE RCALL _LcdContrast
(0077) Presentation();
01C7 D0D0 RCALL _Presentation
(0078) LineDisplay();
01C8 D104 RCALL _LineDisplay
(0079) SEI();
01C9 9478 BSET 7
(0080)
(0081) PORTD |= VRX;
01CA 9A94 SBI 0x12,4
01CB C0BA RJMP 0x0286
(0082)
(0083) while(1)
(0084) {
(0085) _StackCheck();
01CC D83D RCALL __StackCheck
(0086)
(0087) if (TimeOut <= 10000)
01CD E180 LDI R24,0x10
01CE E297 LDI R25,0x27
01CF 90200060 LDS R2,0x60
01D1 90300061 LDS R3,0x61
01D3 1582 CP R24,R2
01D4 0593 CPC R25,R3
01D5 F408 BCC 0x01D7
01D6 C092 RJMP 0x0269
(0088) {
(0089) if (NewMessage == TRUE)
01D7 91800065 LDS R24,0x65
01D9 3081 CPI R24,1
01DA F431 BNE 0x01E1
(0090) {
(0091) CLI();
01DB 94F8 BCLR 7
(0092) AnalyseData();
01DC D2D6 RCALL _AnalyseData
(0093) NewMessage = FALSE;
01DD 2422 CLR R2
01DE 92200065 STS 0x65,R2
(0094) SEI();
01E0 9478 BSET 7
(0095) }
(0096)
(0097) if (Light > 1000)
01E1 EE88 LDI R24,0xE8
01E2 E093 LDI R25,3
01E3 90200067 LDS R2,0x67
01E5 90300068 LDS R3,0x68
01E7 1582 CP R24,R2
01E8 0593 CPC R25,R3
01E9 F430 BCC 0x01F0
(0098) {
(0099) PORTD &= ~LIGHT;
01EA 9893 CBI 0x12,3
(0100) Light = 1001;
01EB EE89 LDI R24,0xE9
01EC 93900068 STS 0x68,R25
01EE 93800067 STS 0x67,R24
(0101) }
(0102)
(0103) if (Key != NONE)
01F0 90200062 LDS R2,0x62
01F2 2022 TST R2
01F3 F409 BNE 0x01F5
01F4 C091 RJMP 0x0286
(0104) {
(0105) TimeOut = 0;
01F5 2422 CLR R2
01F6 2433 CLR R3
01F7 92300061 STS 0x61,R3
01F9 92200060 STS 0x60,R2
(0106) Light = 0;
01FB 92300068 STS 0x68,R3
01FD 92200067 STS 0x67,R2
(0107) PORTD |= LIGHT;
01FF 9A93 SBI 0x12,3
(0108)
(0109) if (Key == RESET)
0200 91800062 LDS R24,0x62
0202 3286 CPI R24,0x26
0203 F431 BNE 0x020A
(0110) {
(0111) CLI();
0204 94F8 BCLR 7
(0112) TIMSK = 0x00;
0205 BE29 OUT 0x39,R2
(0113) UCSRB = 0x18; // RX & TX Enable
0206 E188 LDI R24,0x18
0207 B98A OUT 0x0A,R24
(0114) asm("jmp 0x0000");
0208 940C0000 JMP 0x0
(0115) }
(0116)
(0117) if (Key == DOWN)
020A 91800062 LDS R24,0x62
020C 3084 CPI R24,4
020D F411 BNE 0x0210
(0118) {
(0119) SendKey(0x01);
020E E001 LDI R16,1
020F D343 RCALL _SendKey
(0120) }
(0121)
(0122) if (Key == SHIFT_DOWN)
0210 91800062 LDS R24,0x62
0212 3884 CPI R24,0x84
0213 F411 BNE 0x0216
(0123) {
(0124) SendKey(0x81);
0214 E801 LDI R16,0x81
0215 D33D RCALL _SendKey
(0125) }
(0126)
(0127) if (Key == UP)
0216 91800062 LDS R24,0x62
0218 3280 CPI R24,0x20
0219 F411 BNE 0x021C
(0128) {
(0129) SendKey(0x02);
021A E002 LDI R16,2
021B D337 RCALL _SendKey
(0130) }
(0131)
(0132) if (Key == SHIFT_UP)
021C 91800062 LDS R24,0x62
021E 3980 CPI R24,0x90
021F F411 BNE 0x0222
(0133) {
(0134) SendKey(0x82);
0220 E802 LDI R16,0x82
0221 D331 RCALL _SendKey
(0135) }
(0136)
(0137) if (Key == LEFT)
0222 91800062 LDS R24,0x62
0224 3082 CPI R24,2
0225 F411 BNE 0x0228
(0138) {
(0139) SendKey(0x04);
0226 E004 LDI R16,4
0227 D32B RCALL _SendKey
(0140) }
(0141)
(0142) if (Key == RIGHT)
0228 91800062 LDS R24,0x62
022A 3088 CPI R24,0x8
022B F411 BNE 0x022E
(0143) {
(0144) SendKey(0x08);
022C E008 LDI R16,0x8
022D D325 RCALL _SendKey
(0145) }
(0146)
(0147) if (Key == SHIFT_RIGHT)
022E 91800062 LDS R24,0x62
0230 3888 CPI R24,0x88
0231 F4C9 BNE 0x024B
(0148) {
(0149) Cont++;
0232 91800069 LDS R24,0x69
0234 5F8F SUBI R24,0xFF
0235 93800069 STS 0x69,R24
(0150) if (Cont > 0x7f) Cont = 0;
0237 E78F LDI R24,0x7F
0238 90200069 LDS R2,0x69
023A 1582 CP R24,R2
023B F418 BCC 0x023F
023C 2422 CLR R2
023D 92200069 STS 0x69,R2
(0151) LcdContrast(Cont);
023F 91000069 LDS R16,0x69
0241 D383 RCALL _LcdContrast
(0152) EEPROM_WRITE(0x10, Cont);
0242 E081 LDI R24,1
0243 E090 LDI R25,0
0244 8399 STD Y+1,R25
0245 8388 STD Y+0,R24
0246 E629 LDI R18,0x69
0247 E030 LDI R19,0
0248 E100 LDI R16,0x10
0249 E010 LDI R17,0
024A D799 RCALL _EEPROMWriteBytes
(0153) }
(0154)
(0155) if (Key == SHIFT_LEFT)
024B 91800062 LDS R24,0x62
024D 3882 CPI R24,0x82
024E F4B1 BNE 0x0265
(0156) {
(0157) Cont--;
024F 91800069 LDS R24,0x69
0251 5081 SUBI R24,1
0252 93800069 STS 0x69,R24
(0158) if (Cont == 0x00) Cont = 0x7f;
0254 2388 TST R24
0255 F419 BNE 0x0259
0256 E78F LDI R24,0x7F
0257 93800069 STS 0x69,R24
(0159) LcdContrast(Cont);
0259 91000069 LDS R16,0x69
025B D369 RCALL _LcdContrast
(0160) EEPROM_WRITE(0x10, Cont);
025C E081 LDI R24,1
025D E090 LDI R25,0
025E 8399 STD Y+1,R25
025F 8388 STD Y+0,R24
0260 E629 LDI R18,0x69
0261 E030 LDI R19,0
0262 E100 LDI R16,0x10
0263 E010 LDI R17,0
0264 D77F RCALL _EEPROMWriteBytes
(0161) }
(0162)
(0163) Key = NONE;
0265 2422 CLR R2
0266 92200062 STS 0x62,R2
(0164) }
(0165) }
0268 C01D RJMP 0x0286
(0166) else
(0167) {
(0168) // Go in DEEP SLEEP
(0169) LcdClear();
0269 D369 RCALL _LcdClear
(0170) LcdPower(FALSE);
026A 2700 CLR R16
026B D30D RCALL _LcdPower
(0171) PORTD &= ~VRX; // Disable Receiver
026C 9894 CBI 0x12,4
(0172) // Disable Timer0 overflow because the LCD must be init first
(0173) // after wake up
(0174) TIMSK &= ~0x01;
026D B789 IN R24,0x39
026E 7F8E ANDI R24,0xFE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -