📄 vs1001k.s
字号:
.module vs1001K.c
.area text(rom, con, rel)
.dbfile F:\mine\mp3\MP3\vs1001K.c
.dbfunc e delay _delay fV
; m -> R20,R21
; n -> R22,R23
; dat -> R16,R17
.even
_delay::
xcall push_gset2
.dbline -1
.dbline 4
; #include<all.h>
;
; void delay(uint dat)//延迟10us
; { uint m,n;
.dbline 5
; for(m=0;m<dat;m++)
clr R20
clr R21
xjmp L5
L2:
.dbline 6
clr R22
clr R23
xjmp L9
L6:
.dbline 6
L7:
.dbline 6
subi R22,255 ; offset = 1
sbci R23,255
L9:
.dbline 6
cpi R22,2
ldi R30,0
cpc R23,R30
brlo L6
L3:
.dbline 5
subi R20,255 ; offset = 1
sbci R21,255
L5:
.dbline 5
cp R20,R16
cpc R21,R17
brlo L2
.dbline -2
.dbline 7
; for(n=0;n<2;n++);
; }
L1:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r m 20 i
.dbsym r n 22 i
.dbsym r dat 16 i
.dbend
.dbfunc e vs_wait_dreq _vs_wait_dreq fV
.even
_vs_wait_dreq::
.dbline -1
.dbline 10
L11:
.dbline 10
L12:
.dbline 10
; /*等DREQ*/
; void vs_wait_dreq(void)
; { while(!(PIND&0x04)); }
sbis 0x10,2
rjmp L11
.dbline -2
.dbline 10
L10:
.dbline 0 ; func end
ret
.dbend
.dbfunc e write_single _write_single fc
; dat -> R16
.even
_write_single::
.dbline -1
.dbline 14
;
; /*发单个命令*/
; uchar write_single(uchar dat)//发
; {
.dbline 15
; SPDR=dat;
out 0xf,R16
L15:
.dbline 16
L16:
.dbline 16
; while(!(SPSR&0x80));
sbis 0xe,7
rjmp L15
.dbline 17
; return SPDR;
in R16,0xf
.dbline -2
L14:
.dbline 0 ; func end
ret
.dbsym r dat 16 c
.dbend
.dbfunc e read_single _read_single fc
.even
_read_single::
.dbline -1
.dbline 21
; }
;
; uchar read_single(void)//读单个数据
; { return write_single(0xff); }
.dbline 21
ldi R16,255
.dbline -2
L18:
.dbline 0 ; func end
xjmp _write_single
.dbend
.dbfunc e vs_write_sci _vs_write_sci fV
; dat -> R20,R21
; add -> R22
.even
_vs_write_sci::
xcall push_gset2
movw R20,R18
mov R22,R16
.dbline -1
.dbline 25
;
; /*写命令*/
; void vs_write_sci(uchar add,uint dat)//写命令
; { clear_xcs;//XCS有效
.dbline 25
cbi 0x18,4
.dbline 26
; select_vs;
sbi 0x18,3
.dbline 27
; write_single(0x02);//写命令
ldi R16,2
xcall _write_single
.dbline 28
; write_single(add);//写地址
mov R16,R22
xcall _write_single
.dbline 29
; write_single((uchar)(dat>>8));
movw R16,R20
mov R16,R17
clr R17
xcall _write_single
.dbline 30
; write_single((uchar)dat );
mov R16,R20
xcall _write_single
.dbline 31
; set_xcs;
sbi 0x18,4
.dbline -2
.dbline 32
; }
L19:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r dat 20 i
.dbsym r add 22 c
.dbend
.dbfunc e vs_read_sci _vs_read_sci fi
; dat -> R20,R21
; add -> R20
.even
_vs_read_sci::
xcall push_gset1
mov R20,R16
.dbline -1
.dbline 35
;
; uint vs_read_sci(uchar add)//读命令
; { uint dat;
.dbline 36
; clear_xcs;//XCS有效
cbi 0x18,4
.dbline 37
; select_vs;
sbi 0x18,3
.dbline 38
; write_single(0x03);//读命令
ldi R16,3
xcall _write_single
.dbline 39
; write_single(add);//写地址
mov R16,R20
xcall _write_single
.dbline 40
; dat=(uint)read_single()<<8;
xcall _read_single
mov R20,R16
clr R21
mov R21,R20
clr R20
.dbline 41
; dat|=read_single();
xcall _read_single
mov R2,R16
clr R3
or R20,R2
or R21,R3
.dbline 42
; set_xcs;
sbi 0x18,4
.dbline 43
; return dat;
movw R16,R20
.dbline -2
L20:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r dat 20 i
.dbsym r add 20 c
.dbend
.dbfunc e vs_write_sdi_byte _vs_write_sdi_byte fV
; dat -> R16
.even
_vs_write_sdi_byte::
.dbline -1
.dbline 47
; }
; /*发数据*/
; void vs_write_sdi_byte(uchar dat)//发送单个字节
; { set_xcs;
.dbline 47
sbi 0x18,4
.dbline 48
; select_vs;
sbi 0x18,3
.dbline 49
; clear_bysnc;
cbi 0x18,0
.dbline 50
; set_bysnc;
sbi 0x18,0
.dbline 51
; SPDR=dat;
out 0xf,R16
L22:
.dbline 52
L23:
.dbline 52
; while(!(SPSR&0x80));
sbis 0xe,7
rjmp L22
.dbline 53
; clear_bysnc;
cbi 0x18,0
.dbline -2
.dbline 54
; }
L21:
.dbline 0 ; func end
ret
.dbsym r dat 16 c
.dbend
.dbfunc e vs_write_sdi_bytes _vs_write_sdi_bytes fV
; i -> R20,R21
; n -> R18,R19
; add -> R16,R17
.even
_vs_write_sdi_bytes::
xcall push_gset1
.dbline -1
.dbline 56
; void vs_write_sdi_bytes(uchar *add,uint n)//发送多个数据
; { uint i;
.dbline 58
; // vs_wait_dreq();//等DREQ变高
; select_vs;
sbi 0x18,3
.dbline 59
; set_xcs;//选中DCLK
sbi 0x18,4
.dbline 60
; for(i=0;i<n;i++)
clr R20
clr R21
xjmp L29
L26:
.dbline 61
; { clear_bysnc;
.dbline 61
cbi 0x18,0
.dbline 62
; set_bysnc;
sbi 0x18,0
.dbline 63
; SPDR=*add++;
movw R30,R16
ld R2,Z+
movw R16,R30
out 0xf,R2
L30:
.dbline 64
L31:
.dbline 64
sbis 0xe,7
rjmp L30
.dbline 65
L27:
.dbline 60
subi R20,255 ; offset = 1
sbci R21,255
L29:
.dbline 60
cp R20,R18
cpc R21,R19
brlo L26
L33:
.dbline 66
L34:
.dbline 66
; while(!(SPSR&0x80));
; }
; while(!(SPSR&0x80));
sbis 0xe,7
rjmp L33
.dbline 67
; clear_bysnc;
cbi 0x18,0
.dbline -2
.dbline 68
; }
L25:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbsym r n 18 i
.dbsym r add 16 pc
.dbend
.dbfunc e vs1001k_reset _vs1001k_reset fV
.even
_vs1001k_reset::
.dbline -1
.dbline 70
; void vs1001k_reset(void)//VS1001K复位
; { vs_write_sci(MODE,0x0004);
.dbline 70
ldi R18,4
ldi R19,0
clr R16
xcall _vs_write_sci
.dbline 71
; delay(500);
ldi R16,500
ldi R17,1
xcall _delay
.dbline 72
; vs_wait_dreq();
xcall _vs_wait_dreq
.dbline 73
; vs_write_sci(MODE,0x0000);
clr R18
clr R19
clr R16
xcall _vs_write_sci
.dbline 74
; vs_write_sci(VOL,0x0000);
clr R18
clr R19
ldi R16,11
xcall _vs_write_sci
.dbline 75
; vs_write_sdi_byte(0x00);
clr R16
xcall _vs_write_sdi_byte
.dbline 76
; vs_write_sdi_byte(0x00);
clr R16
.dbline -2
.dbline 77
; }
L36:
.dbline 0 ; func end
xjmp _vs_write_sdi_byte
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -