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

📄 mp3.s

📁 /*** *** *** *** *** *** *** *** *** *** / /* MP3 Code for M32L */ /* By pasyong
💻 S
📖 第 1 页 / 共 4 页
字号:
	.byte 255,255
	.byte 255,255
	.byte 255,255
	.byte 255,255
	.byte 255,128
	.byte 2,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 255,242
	.byte 130,'T
	.byte 9,232
	.byte 255,22
	.byte 224,1
	.byte 46,0
	.byte 0,0
	.byte 0,0
	.byte 168,2
	.byte 92,172
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.dbsym e vsBeepMP3 _vsBeepMP3 A[4800:4800]kc
	.area text(rom, con, rel)
	.dbfile D:\Temp\AVRTest\SDMP3~1/mp3.h
	.dbfile D:\Temp\AVRTest\SDMP3~1\mp3.c
	.dbfunc e key_port _key_port fV
	.even
_key_port::
	.dbline -1
	.dbline 18
; /************************************************************/
; /*		         MP3 Code for   M32L					    */
; /*				   By   pasyong								*/
; /*				   2006-4									*/
; /*				   Base ICC6.31A					        */
; /************************************************************/
; #include <iom32v.h>
; #include <macros.h>
; #include <stdio.h>
; #include "1011.h"
; #include "mp3.h"
; #include "sd.h"
; #include "fat.h"
; #include "uarst.h"
; #include "3310.h"
; 
; void key_port(void)
; {
	.dbline 19
;  DDRD=0X00;
	clr R2
	out 0x11,R2
	.dbline 20
;  PORTD=0XFF;
	ldi R24,255
	out 0x12,R24
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 23
; }
; void main()
; {
	.dbline 24
;  key_port();
	xcall _key_port
	.dbline 25
;  spi_init();
	xcall _spi_init
	.dbline 27
; 
;  mp3_port_init();vs1011_init();vs1011_init();
	xcall _mp3_port_init
	.dbline 27
	xcall _vs1011_init
	.dbline 27
	xcall _vs1011_init
	.dbline 28
;  sd_port_init();SD_Init();SD_Init();
	xcall _sd_port_init
	.dbline 28
	xcall _SD_Init
	.dbline 28
	xcall _SD_Init
	.dbline 29
;  uart0_init();
	xcall _uart0_init
	.dbline 30
;  SPCR = 0x50;                //提速
	ldi R24,80
	out 0xd,R24
	.dbline 31
;  SPSR = 0x01;                //setup SPI
	ldi R24,1
	out 0xe,R24
	.dbline 33
; 
;  LCD_init(); 
	xcall _LCD_init
	.dbline 35
;  
;  fatInit();                  //查询SDFAT格式
	xcall _fatInit
	.dbline 36
;  if(Fat32Enabled)            //设置FAT格式标志
	lds R2,_Fat32Enabled
	tst R2
	breq L3
	.dbline 37
;  FAT_MASK=FAT32_MASK;
	ldi R20,255
	ldi R21,255
	ldi R22,255
	ldi R23,15
	sts _FAT_MASK+1,R21
	sts _FAT_MASK,R20
	sts _FAT_MASK+2+1,R23
	sts _FAT_MASK+2,R22
	xjmp L6
L3:
	.dbline 39
;  else 
;  FAT_MASK=FAT16_MASK;
	ldi R20,255
	ldi R21,255
	ldi R22,0
	ldi R23,0
	sts _FAT_MASK+1,R21
	sts _FAT_MASK,R20
	sts _FAT_MASK+2+1,R23
	sts _FAT_MASK+2,R22
	xjmp L6
L5:
	.dbline 43
; 
; 
;   while(1)
;   { 
	.dbline 45
;     //播放音乐
;    for(t=3;t<50;t++)
	ldi R24,3
	ldi R25,0
	sts _t+1,R25
	sts _t,R24
	xjmp L11
L8:
	.dbline 46
	.dbline 47
	clr R2
	sts _flag,R2
	.dbline 48
	lds R16,_t
	lds R17,_t+1
	xcall _fatGetDirEntry
	xcall _mp3_play
	.dbline 49
L9:
	.dbline 45
	lds R24,_t
	lds R25,_t+1
	adiw R24,1
	sts _t+1,R25
	sts _t,R24
L11:
	.dbline 45
	lds R24,_t
	lds R25,_t+1
	cpi R24,50
	ldi R30,0
	cpc R25,R30
	brlo L8
	.dbline 50
L6:
	.dbline 42
	xjmp L5
X0:
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e mp3_play _mp3_play fV
;             t1 -> <dead>
;           rate -> <dead>
;    NextCluster -> y+4
;            LBA -> y+0
;              i -> R10,R11
;              n -> R14
;   data_pointer -> R12,R13
;     FirstClust -> y+18
	.even
_mp3_play::
	xcall push_arg4
	xcall push_gset5
	sbiw R28,8
	.dbline -1
	.dbline 55
;    {
; 	  flag=0;
; 	  mp3_play(fatGetDirEntry(t));
; 	 }
;   }
; }
; 
; 
; void mp3_play(unsigned long FirstClust)
; {  
	.dbline 59
;  uint32 LBA,NextCluster;
;  uint16 i,data_pointer,rate;
;  uint8 n,t1;
;  NextCluster = FirstClust;
	movw R30,R28
	ldd R2,z+18
	ldd R3,z+19
	ldd R4,z+20
	ldd R5,z+21
	movw R30,R28
	std z+4,R2
	std z+5,R3
	std z+6,R4
	std z+7,R5
	xjmp L14
L13:
	.dbline 62
; 
;  while (1)
;  {	
	.dbline 63
; 	LBA =fatClustToSect(NextCluster);
	movw R30,R28
	ldd R16,z+4
	ldd R17,z+5
	ldd R18,z+6
	ldd R19,z+7
	xcall _fatClustToSect
	movw R30,R28
	std z+0,R16
	std z+1,R17
	std z+2,R18
	std z+3,R19
	.dbline 64
; 	for (i=0;i<SectorsPerCluster;i++)
	clr R10
	clr R11
	xjmp L19
L16:
	.dbline 65
; 	{
	.dbline 66
; 	 if(flag==0)  ReadBlock(LBA+i);      //读完后文件指针自动后移
	lds R2,_flag
	tst R2
	brne L20
	.dbline 66
	movw R2,R10
	clr R4
	clr R5
	movw R30,R28
	ldd R6,z+0
	ldd R7,z+1
	ldd R8,z+2
	ldd R9,z+3
	add R6,R2
	adc R7,R3
	adc R8,R4
	adc R9,R5
	movw R16,R6
	movw R18,R8
	xcall _ReadBlock
L20:
	.dbline 70
; 		  
; 	 //按键处理程序
; 	 //ST/PS键按下
; 	 if(!(PIND&STOP))
	sbic 0x10,6
	rjmp L22
	.dbline 71
; 	 {
	.dbline 72
; 	  delay_nus(250);
	ldi R16,250
	ldi R17,0
	xcall _delay_nus
	.dbline 73
; 		if(!(PIND&STOP))
	sbic 0x10,6
	rjmp L24
	.dbline 74
; 		{
	.dbline 75
; 		 flag^=0x01;
	ldi R24,1
	lds R2,_flag
	eor R2,R24
	sts _flag,R2
	.dbline 76
; 		}
L24:
	.dbline 77
; 	 }
L22:
	.dbline 79
; 	  //VOLUP键按下
; 	 if(!(PIND&VOLDOWN))  
	sbic 0x10,4
	rjmp L26
	.dbline 80
; 	 {
	.dbline 81
; 	  delay_nus(250);
	ldi R16,250
	ldi R17,0
	xcall _delay_nus
	.dbline 82
; 	  if(!(PIND&VOLDOWN))  
	sbic 0x10,4
	rjmp L28
	.dbline 83
; 		{
	.dbline 84
; 		 vol=vol+((uint)(2<<8)+2);
	lds R24,_vol
	lds R25,_vol+1
	subi R24,254  ; offset = 514
	sbci R25,253
	sts _vol+1,R25
	sts _vol,R24
	.dbline 85
; 		 if(vol>=0xF0F0) vol=0xF0F0; 
	cpi R24,240
	ldi R30,240
	cpc R25,R30
	brlo L30
	.dbline 85
	ldi R24,61680
	ldi R25,240
	sts _vol+1,R25
	sts _vol,R24
	xjmp L31
L30:
	.dbline 86
; 	   else vs1011_cmd_write(0x0b,vol);    //每次左右声道VOL减2
	lds R18,_vol
	lds R19,_vol+1
	ldi R16,11
	xcall _vs1011_cmd_write
L31:
	.dbline 87
; 		}
L28:
	.dbline 88
; 	  }
L26:
	.dbline 90
; 	  //VOLDOWN键按下
; 	 if(!(PIND&VOLUP)) 
	sbic 0x10,5
	rjmp L32
	.dbline 91
; 	 {
	.dbline 92
; 		delay_nus(250);
	ldi R16,250
	ldi R17,0
	xcall _delay_nus
	.dbline 93
; 		if(!(PIND&VOLUP)) 
	sbic 0x10,5
	rjmp L34
	.dbline 94
; 		{
	.dbline 95
; 		 vol=vol-((uint)(2<<8)+2);
	lds R24,_vol
	lds R25,_vol+1
	subi R24,2
	sbci R25,2
	sts _vol+1,R25
	sts _vol,R24
	.dbline 96
; 		 if(vol<=0x0505) vol=0x0505;
	ldi R24,1285
	ldi R25,5
	lds R2,_vol
	lds R3,_vol+1
	cp R24,R2
	cpc R25,R3
	brlo L36
	.dbline 96
	sts _vol+1,R25
	sts _vol,R24
	xjmp L37
L36:
	.dbline 97
; 		 else vs1011_cmd_write(0x0b,vol);   //每次左右声道VOL加2
	lds R18,_vol
	lds R19,_vol+1
	ldi R16,11
	xcall _vs1011_cmd_write
L37:
	.dbline 98
; 	  }
L34:
	.dbline 99
; 	 }
L32:
	.dbline 101
; 	   //NEXT键按下
; 	 if(!(PIND&NEXTSONG)) 
	sbic 0x10,3
	rjmp L38
	.dbline 102
; 	 {
	.dbline 103
; 		delay_nus(250);		
	ldi R16,250
	ldi R17,0
	xcall _delay_nus
	.dbline 104
; 		if(!(PIND&NEXTSONG))  goto NEXT;       //跳到下一首歌曲
	sbic 0x10,3
	rjmp L40
	.dbline 104
	xjmp L42
L40:
	.dbline 105
; 	 }
L38:
	.dbline 107
; 	    //PREV键按下
; 	 if(!(PIND&PREVSONG)) 
	sbic 0x10,2
	rjmp L43
	.dbline 108
; 	 {
	.dbline 109
; 		delay_nus(250);
	ldi R16,250
	ldi R17,0
	xcall _delay_nus
	.dbline 110
; 		if(!(PIND&PREVSONG))
	sbic 0x10,2
	rjmp L45
	.dbline 111
; 		{
	.dbline 112
; 		 t=t-2;goto NEXT;  //返回前一首歌曲
	lds R24,_t
	lds R25,_t+1
	sbiw R24,2
	sts _t+1,R25
	sts _t,R24
	.dbline 112
	xjmp L42
L45:
	.dbline 114
; 	  }
; 	 }
L43:
	.dbline 117
; 		
; 	 	
; 	 data_pointer=0; 
	clr R12
	clr R13
	xjmp L48
L47:
	.dbline 119
;    while(data_pointer<512)
;    {    
	.dbline 120
;     if(PINB&MP3_DATA_REQ)
	sbis 0x16,2
	rjmp L50
	.dbline 121
;     {
	.dbline 122
;      for(n=0;n<32;n++)
	clr R14
	xjmp L55
L52:
	.dbline 123
	.dbline 124
	ldi R24,<_BUFFER
	ldi R25,>_BUFFER
	movw R30,R12
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	xcall _vs1011_data_write
	.dbline 125
	movw R24,R12
	adiw R24,1
	movw R12,R24
	.dbline 126
L53:
	.dbline 122
	inc R14
L55:
	.dbline 122
	mov R24,R14
	cpi R24,32
	brlo L52
	.dbline 127
; 		 {
;       vs1011_data_write(BUFFER[data_pointer]);
;       data_pointer++;   
;    	 }
; 		}
L50:
	.dbline 128
; 	  if (data_pointer==511) break;   //如果现在的数据不够了,则跳出来
	movw R24,R12
	cpi R24,255
	ldi R30,1
	cpc R25,R30
	brne L56
	.dbline 128
	xjmp L49
L56:
	.dbline 129
L48:
	.dbline 118
	movw R24,R12
	cpi R24,0
	ldi R30,2
	cpc R25,R30
	brlo L47
L49:
	.dbline 130
L17:
	.dbline 64
	movw R24,R10
	adiw R24,1
	movw R10,R24
L19:
	.dbline 64
	lds R2,_SectorsPerCluster
	lds R3,_SectorsPerCluster+1
	cp R10,R2
	cpc R11,R3
	brsh X1
	xjmp L16
X1:
	.dbline 131
; 	 }
; 	}
; 	NextCluster = fatNextCluster(NextCluster);
	movw R30,R28
	ldd R16,z+4
	ldd R17,z+5
	ldd R18,z+6
	ldd R19,z+7
	xcall _fatNextCluster
	movw R30,R28
	std z+4,R16
	std z+5,R17
	std z+6,R18
	std z+7,R19
	.dbline 132
; 	if (NextCluster >=(CLUST_RSRVD&FAT_MASK))break;
	ldi R20,246
	ldi R21,255
	ldi R22,255
	ldi R23,255
	lds R4,_FAT_MASK+2
	lds R5,_FAT_MASK+2+1
	lds R2,_FAT_MASK
	lds R3,_FAT_MASK+1
	and R2,R20
	and R3,R21
	and R4,R22
	and R5,R23
	movw R30,R28
	ldd R6,z+4
	ldd R7,z+5
	ldd R8,z+6
	ldd R9,z+7
	cp R6,R2
	cpc R7,R3
	cpc R8,R4
	cpc R9,R5
	brlo L58
	.dbline 132
	xjmp L15
L58:
	.dbline 133
L14:
	.dbline 61
	xjmp L13
L15:
L42:
	.dbline 134
; 	}
;  NEXT: delay_nus(3);  /* 下一首歌曲*/
	ldi R16,3
	ldi R17,0
	xcall _delay_nus
	.dbline -2
L12:
	adiw R28,8
	xcall pop_gset5
	adiw R28,4
	.dbline 0 ; func end
	ret
	.dbsym l t1 1 c
	.dbsym l rate 1 i
	.dbsym l NextCluster 4 l
	.dbsym l LBA 0 l
	.dbsym r i 10 i
	.dbsym r n 14 c
	.dbsym r data_pointer 12 i
	.dbsym l FirstClust 18 l
	.dbend
	.area bss(ram, con, rel)
	.dbfile D:\Temp\AVRTest\SDMP3~1\mp3.c
_t::
	.blkb 2
	.dbfile D:\Temp\AVRTest\SDMP3~1/mp3.h
	.dbsym e t _t i
_true::
	.blkb 1
	.dbsym e true _true c
_FAT_MASK::
	.blkb 4
	.dbsym e FAT_MASK _FAT_MASK l

⌨️ 快捷键说明

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