📄 mp3.lst
字号:
C51 COMPILER V6.23a MP3 12/02/2003 11:07:53 PAGE 1
C51 COMPILER V6.23a, COMPILATION OF MODULE MP3
OBJECT MODULE PLACED IN mp3.OBJ
COMPILER INVOKED BY: d:\SoftDev\Keil\C51\BIN\C51.EXE mp3.c LARGE BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /****************************************************************/
2 /* UP-MP3DIY100 */
3 /* Beijing Universal Pioneering Technology Co., LTD */
4 /* CopyRighted,All right Reserved www.up-tech.com */
5 /* July,2003 */
6 /* 010-62387873 62381842 */
7 /****************************************************************/
8
9 #include "REGSND1.H"
10 #include "atmelusbci.h"
11 #include "uart.h"
12 #include "usbdisk.h"
13 #include "bulk_only.h"
14 #include "fat16.h"
15 #include "flash.h"
16
17 int m=0;
18
19 extern unsigned char bulk_state;//记录USB传输过程中传输状态
20 extern unsigned char Bulk_Out_Buf[];//Bulk-Out端点缓存区
21 extern unsigned char Page_Buf[];//页(扇区)缓存区
22
23 extern unsigned char FirstTransaction;
24 //设备描述符
25 code unsigned char Device_Descriptor[18]={
26 0x12, //0x12
27 0x01, //DEVICE descriptor
28 0x10,0x01, //spec rev level (BCD) 1.0
29 0x0, //device class
30 0x0, //device subclass
31 0x0, //device protocol
32 0x20, //max packet size
33 0x05,0x82, //National's vendor ID
34 0x00,0x11, //National's product ID
35 0x00,0x00, //National's revision ID
36 0, //index of manuf. string
37 0, //index of prod. string
38 0, //index of ser. # string
39 0x01 //number of configs.
40 };
41 //配置描述符
42 code unsigned char Configuration_Descriptor_All[32]={
43
44 9,//Size of Descriptor in Bytes
45 2,//Configuration Descriptor (0x02)
46 0x20,//Total length in bytes of data returned LSB
47 0x00,//MSB
48 1,//Number of Interfaces
49 1,//Value to use as an argument to select this configuration
50 0,//Index of String Descriptor describing this configuration
51 0x80,
52 0xfa,//Maximum Power Consumption in 2mA units
53
54 9,
55 4,
C51 COMPILER V6.23a MP3 12/02/2003 11:07:53 PAGE 2
56 0,//the index of the interface descriptor Number of Interface
57 0,//Value used to select alternative setting
58 2,//EndPoint Number Used in this Descriptor
59 8,//Class Code (Assigned by USB Org)
60 6, //interface subclass1=RBC,2=SFF,3=QIC,4=UFI,5=SFF,6=SCSI
61 0x50,//bulk 0nly Transport
62 0,//Index of String Descriptor Describing this interface
63
64 //Bulk-in Endpoint
65 0x07, //length of this desc.
66 0x05, //ENDPOINT descriptor TYPE
67 0x81, //address (IN) Endpoint 4 84
68 0x02, //attributes (BULK)
69 0x40,0x00, //max packet size (64)
70 0x0, //Does not apply to Bulk endpoints
71
72 //Bulk-out Endpoint
73 0x07, //length of this desc.
74 0x05, //ENDPOINT descriptor TYPE
75 0x02, //address (OUT) Endpoint 5 05
76 0x02, //attributes (BULK)
77 0x40,0x00, //max packet size (64)
78 0x0 //Does not apply to Bulk endpoints
79 };
80
81 //用于存放歌曲列表的数组
82 unsigned char SONG[88] ={'M','O','O','N',' ',' ',' ',' ','T','X','T'};
83
84 //MP3有关的变量*********************
85 #define VOLUME 1
86 #define EFFECTION 2
87 #define SELECTSONG 3
88 #define PLAY 1
89 #define STOP 0
90 unsigned char CurrentFun=SELECTSONG;
91 unsigned char PlayState=PLAY;
92 unsigned char ChangeSong=0;
93
94 unsigned char NowPlaying=0;
95 unsigned char NumofSong=0;
96 extern long int DataRead;
97 //***************************
98
99 //USB DISK
100 //读端点数据
101 unsigned char ReadEp(unsigned char EpNum,unsigned char *Data)
102 {
103 1 unsigned char i=0,nLength;
104 1 UEPNUM=EpNum;//指向相应端点
105 1
106 1 nLength=UBYCTX;//读取端点数据长度
107 1 while(nLength--) {Data[i++]=UEPDATX;/*printuf("%x ",Data[i]);*/}//依次读取端点收到的数据
108 1
109 1 UEPSTAX&=~(RXOUTB0|RXOUTB1|RXSETUP);//清中断标志
110 1
111 1 return(i);//返回读取到的数据的长度
112 1 }
113
114 //向端点0写数据
115 void WriteEp(unsigned char EpNum,unsigned char nLength,unsigned char *Data)
116 {
117 1 unsigned char i=0;
C51 COMPILER V6.23a MP3 12/02/2003 11:07:53 PAGE 3
118 1 UEPNUM=EpNum;//指向相应端点
119 1 UEPSTAX|=DIR;//设置方向为写
120 1 while(nLength--) UEPDATX=Data[i++];//将数据写入端点
121 1 UEPSTAX|=TXRDY;//发送数据Sending the data,this action will switch between bank0 and bank1
122 1 while(!(UEPSTAX&TXCMP)) ;//等待发送完成
123 1 UEPSTAX&=(~(TXCMP));//清中断标志clear TXCMP
124 1 }
125 //写Bulk端点
126 void WriteEpBulk(unsigned char EpNum,unsigned char nLength,unsigned char *Data)
127 {
128 1 unsigned char i;
129 1 UEPNUM=EpNum;//指向相应端点
130 1 UEPSTAX|=DIR;//设置方向为写Set for status of a Control In transaction
131 1 for(i=0;i<nLength;i++) UEPDATX=Data[i];//将数据写入端点
132 1 UEPSTAX|=TXRDY;//发送数据Sending the data,this action will switch between bank0 and bank1
133 1
134 1 }
135 void Get_Status()
136 {
137 1 printu("Get_Status ");
138 1 }
139 void Clear_Feature()
140 {
141 1 printu("Clear_Feature ");
142 1 }
143 void Set_Feature()
144 {
145 1 printu("Set_Feature ");
146 1 }
147 void Set_Address(unsigned char EpNum)
148 {
149 1 // unsigned char Test[]={0};
150 1 WriteEp(0,0,0);//在Status阶段过后才能改变设备地址
151 1
152 1 USBADDR|=EpNum;//设置地址
153 1 USBADDR|=FEN;//地址使能
154 1 USBCON|=FADDEN;
155 1
156 1 // printuf("\nSet_Address:%x\n",USBADDR);
157 1 }
158 void Get_Descriptor(unsigned char DesType,unsigned char nLength)
159 {
160 1 if(DesType==0x01) WriteEp(0,18,Device_Descriptor);//提供设备描述符
161 1 if((DesType==0x02)&&(nLength==0x09)) WriteEp(0,9,Configuration_Descriptor_All);//提供配置描述符
162 1 //提供全部描述符
163 1 if((DesType==0x02)&&(nLength==0xff)) {WriteEp(0,32,Configuration_Descriptor_All);WriteEp(0,2,&Device_Desc
-riptor[4]);}
164 1 //提供全部描述符
165 1 if((DesType==0x02)&&(nLength==0x20)) {WriteEp(0,32,Configuration_Descriptor_All);}
166 1
167 1 // printu("Get_Descriptor\n");
168 1 }
169 void Get_Configuration()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -