📄 remote.s
字号:
sbci R17,255
xcall _SendRemote
.dbline -2
L5:
adiw R28,63
adiw R28,63
adiw R28,63
adiw R28,63
adiw R28,7 ; offset = 259
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym l text 4 A[255:255]c
.dbsym r LinePtr 20 c
.dbsym r Header 22 c
.dbend
.dbfunc e SendRemote _SendRemote fV
; i -> R20,R21
; buffer -> R22,R23
.even
_SendRemote::
xcall push_gset2
movw R22,R16
.dbline -1
.dbline 97
; }
;
; //******************************************************************
; //* void SendRemote(char *buffer)
; //*
; //*
; //******************************************************************
; void SendRemote(char *buffer)
; {
.dbline 100
; int i;
;
; UCSR1B &= ~0x80; // Rx int disable
lds R24,154
andi R24,127
sts 154,R24
.dbline 101
; i = 0;
clr R20
clr R21
.dbline 102
; TxChar(0x55);
ldi R16,85
xcall _TxChar
.dbline 103
; TxChar(0x55);
ldi R16,85
xcall _TxChar
.dbline 104
; TxChar(0xf0);
ldi R16,240
xcall _TxChar
xjmp L33
L32:
.dbline 106
.dbline 107
movw R2,R20
subi R20,255 ; offset = 1
sbci R21,255
movw R30,R2
add R30,R22
adc R31,R23
ldd R16,z+0
xcall _SendByte
.dbline 108
L33:
.dbline 105
; while (buffer[i] != 0x00)
movw R30,R20
add R30,R22
adc R31,R23
ldd R2,z+0
tst R2
brne L32
.dbline 109
; {
; SendByte(buffer[i++]);
; }
; TxChar(0x0f);
ldi R16,15
xcall _TxChar
L35:
.dbline 111
L36:
.dbline 111
;
; while (!(UCSR1A & 0x40)); // Wait for the char to be cue off
lds R2,155
sbrs R2,6
rjmp L35
.dbline 112
; delay_ms(50);
ldi R16,50
ldi R17,0
xcall _delay_ms
.dbline 114
;
; i = UDR1;
lds R20,156
clr R21
.dbline 115
; UCSR1A |= 0x40;
lds R24,155
ori R24,64
sts 155,R24
.dbline 116
; UCSR1B |= 0x80; // Rx int enable
lds R24,154
ori R24,128
sts 154,R24
.dbline -2
L31:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 I
.dbsym r buffer 22 pc
.dbend
.dbfunc e SendByte _SendByte fV
; i -> R20
; j -> R10
; me -> R12
; TxByte -> R22
.even
_SendByte::
xcall push_gset4
mov R22,R16
.dbline -1
.dbline 125
; }
;
; //******************************************************************
; //* void SendByte(unsigned char TxByte)
; //*
; //* Manchester encode byte and send it
; //******************************************************************
; void SendByte(unsigned char TxByte)
; {
.dbline 128
; unsigned char i,j,me;
;
; for (i=0; i<2; i++)
clr R20
xjmp L42
L39:
.dbline 129
; {
.dbline 130
; WDR();
wdr
.dbline 131
; me = 0; // manchester encoded txbyte
clr R12
.dbline 132
; for (j=0 ; j<4; j++)
clr R10
xjmp L46
L43:
.dbline 133
; {
.dbline 134
; me >>=2;
lsr R12
lsr R12
.dbline 135
; if (TxByte & 0x01)
sbrs R22,0
rjmp L47
.dbline 136
; {
.dbline 137
; me |= 0x80;
mov R24,R12
ori R24,128
mov R12,R24
.dbline 138
; }
xjmp L48
L47:
.dbline 140
; else
; {
.dbline 141
; me |= 0x40;
mov R24,R12
ori R24,64
mov R12,R24
.dbline 142
; }
L48:
.dbline 143
lsr R22
.dbline 144
L44:
.dbline 132
inc R10
L46:
.dbline 132
mov R24,R10
cpi R24,4
brlo L43
.dbline 145
mov R16,R12
xcall _TxChar
.dbline 146
L40:
.dbline 128
inc R20
L42:
.dbline 128
cpi R20,2
brlo L39
.dbline 147
; TxByte >>=1;
; }
; TxChar(me);
; }
; delay_ms(1);
ldi R16,1
ldi R17,0
xcall _delay_ms
.dbline -2
L38:
xcall pop_gset4
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r j 10 c
.dbsym r me 12 c
.dbsym r TxByte 22 c
.dbend
.dbfunc e TxChar _TxChar fV
; ch -> R16
.even
_TxChar::
.dbline -1
.dbline 156
; }
;
; //******************************************************************
; //* TxChar(unsigned char ch)
; //*
; //* Send a byte to the remote
; //******************************************************************
; void TxChar(unsigned char ch)
; {
xjmp L51
L50:
.dbline 157
wdr
L51:
.dbline 157
; while (!(UCSR1A & 0x20)) WDR();
lds R2,155
sbrs R2,5
rjmp L50
.dbline 158
; UDR1 = ch;
sts 156,R16
.dbline -2
L49:
.dbline 0 ; func end
ret
.dbsym r ch 16 c
.dbend
.area vector(rom, abs)
.org 120
jmp _RxChar
.area text(rom, con, rel)
.dbfile G:\IccPro\Mp3Ide\remote.c
.area bss(ram, con, rel)
.dbfile G:\IccPro\Mp3Ide\remote.c
L54:
.blkb 1
L55:
.blkb 1
L56:
.blkb 1
.area data(ram, con, rel)
.dbfile G:\IccPro\Mp3Ide\remote.c
L57:
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile G:\IccPro\Mp3Ide\remote.c
.area text(rom, con, rel)
.dbfile G:\IccPro\Mp3Ide\remote.c
.dbfunc e RxChar _RxChar fV
.dbsym s Qte L57 c
.dbsym s Error L56 c
.dbsym s TempKey L55 c
.dbsym s ch L54 c
.even
_RxChar::
st -y,R2
st -y,R3
st -y,R24
st -y,R25
in R2,0x3f
st -y,R2
.dbline -1
.dbline 168
; }
;
; //******************************************************************
; //* void RxChar(void)
; //*
; //* Send a byte to the remote
; //******************************************************************
; #pragma interrupt_handler RxChar:31
; void RxChar(void)
; {
.dbline 173
; static unsigned char ch,TempKey;
; static unsigned char Error;
; static unsigned char Qte = 0;
;
; ch = UDR1;
lds R2,156
sts L54,R2
.dbline 175
;
; if ((ch == 0xf0) && (Key == 0))
mov R24,R2
cpi R24,240
brne L58
lds R2,_Key
tst R2
brne L58
.dbline 176
; {
.dbline 177
; Qte = 1;
ldi R24,1
sts L57,R24
.dbline 178
; Error = FALSE;
clr R2
sts L56,R2
.dbline 179
; return;
xjmp L53
L58:
.dbline 182
; }
;
; if ((ch == 0x0f) && (Error == FALSE))
lds R24,L54
cpi R24,15
brne L60
lds R2,L56
tst R2
brne L60
.dbline 183
; {
.dbline 184
; Qte = 0;
clr R2
sts L57,R2
.dbline 185
; Key = TempKey;
lds R2,L55
sts _Key,R2
.dbline 186
; return;
xjmp L53
L60:
.dbline 189
; }
;
; if (Qte == 1)
lds R24,L57
cpi R24,1
brne L62
.dbline 190
; {
.dbline 191
; TempKey = ch;
lds R2,L54
sts L55,R2
.dbline 192
; Qte++;
subi R24,255 ; addi 1
sts L57,R24
.dbline 193
; return;
xjmp L53
L62:
.dbline 196
lds R24,L57
cpi R24,2
brne L64
lds R2,L54
com R2
lds R3,L55
cp R3,R2
breq L64
.dbline 197
.dbline 198
ldi R24,1
sts L56,R24
.dbline 199
lds R24,L57
subi R24,255 ; addi 1
sts L57,R24
.dbline 200
L64:
.dbline -2
L53:
ld R2,y+
out 0x3f,R2
ld R25,y+
ld R24,y+
ld R3,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.area data(ram, con, rel)
.dbfile G:\IccPro\Mp3Ide\remote.c
L4:
.blkb 4
.area idata
.byte 37,'c,0,0
.area data(ram, con, rel)
.dbfile G:\IccPro\Mp3Ide\remote.c
L3:
.blkb 6
.area idata
.byte 37,'c,37,'s,0,0
.area data(ram, con, rel)
.dbfile G:\IccPro\Mp3Ide\remote.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -