📄 mp3.lst
字号:
C51 COMPILER V7.50 MP3 03/16/2006 09:11:14 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE MP3
OBJECT MODULE PLACED IN mp3.OBJ
COMPILER INVOKED BY: C:\Program Files\keil\C51\BIN\C51.EXE mp3.c LARGE BROWSE DEBUG OBJECTEXTEND
line level source
1 /*
2 * Copyright (c) 2004,北京博创兴业科技有限公司
3 * All rights reserved.
4 *
5 * 文件名称:mp3.c
6 * 文件标识:mp3
7 * 摘 要:主函数
8 *
9 * 当前版本:2.0
10 * 作 者:Kent
11 * 完成日期:2004年5月20日
12 *
13 * 取代版本:1.1
14 * 原作者 :Frank
15 * 完成日期:2003年8月10日
16 */
17
18 #include "REGSND1.H"
19 #include "atmelusbci.h"
20 #include "uart.h"
21 #include "usbdisk.h"
22 #include "bulk_only.h"
23 #include "fat16.h"
24 #include "flash.h"
25 //****************************by kent******************************************************************
26 int m = 0;
27 unsigned char MP3InitFlag;
28 //unsigned char PLLRegister;
29 //unsigned char MP3Register;
30 //unsigned char AudioRegister;
31 unsigned char FirstStart = 1;
32 extern unsigned char bulk_state;//记录USB传输过程中传输状态
33 extern unsigned char Bulk_Out_Buf[];//Bulk-Out端点缓存区
34 extern unsigned char Page_Buf[];//页(扇区)缓存区
35 unsigned char MP3_Framehead[4];//解析MP3帧头数组
36 /*
37 bits name comments
38 --------------------------------------------------
39 12 sync 0xFFF
40 1 version 1=mpeg1.0, 0=mpeg2.0
41 2 lay 4-lay = layerI, II or III
42 1 error protection 0=yes, 1=no
43 4 bitrate_index see table below
44 2 sampling_freq see table below
45 1 padding
46 1 extension see table below
47 2 mode see table below
48 2 mode_ext used with "joint stereo" mode
49 1 copyright 0=no 1=yes
50 1 original 0=no 1=yes
51 2 emphasis see table below
52 --------------------------------------------------
53
54 */
55 unsigned char MP3_Trailer[128];//
C51 COMPILER V7.50 MP3 03/16/2006 09:11:14 PAGE 2
56 /*
57 at end of file - 128 bytes
58
59
60
61 offset type len name
62 --------------------------------------------
63 0 char 3 "TAG"
64 3 char 30 title
65 33 char 30 artist
66 63 char 30 album
67 93 char 4 year
68 97 char 30 comments
69 127 byte 1 genre
70 --------------------------------------------
71 */
72 unsigned char BaudRate[2][3][14] = {
73 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,
74 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,
75 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,
76
77 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,
78 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,
79 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160
80 };
81 extern unsigned char FirstTransaction;
82 //设备描述符
83 code unsigned char Device_Descriptor[18] = {
84 0x12, //0x12
85 0x01, //DEVICE descriptor
86 0x10, 0x01, //spec rev level (BCD) 1.0
87 0x0, //device class
88 0x0, //device subclass
89 0x0, //device protocol
90 0x20, //max packet size
91 0x05, 0x82, //National's vendor ID
92 0x00, 0x11, //National's product ID
93 0x00, 0x00, //National's revision ID
94 0, //index of manuf. string
95 0, //index of prod. string
96 0, //index of ser. # string
97 0x01 //number of configs.
98 };
99 //配置描述符
100 code unsigned char Configuration_Descriptor_All[32] = {
101
102 9,//Size of Descriptor in Bytes
103 2,//Configuration Descriptor (0x02)
104 0x20,//Total length in bytes of data returned LSB
105 0x00,//MSB
106 1,//Number of Interfaces
107 1,//Value to use as an argument to select this configuration
108 0,//Index of String Descriptor describing this configuration
109 0x80,
110 0xfa,//Maximum Power Consumption in 2mA units
111
112 9,
113 4,
114 0,//the index of the interface descriptor Number of Interface
115 0,//Value used to select alternative setting
116 2,//EndPoint Number Used in this Descriptor
117 8,//Class Code (Assigned by USB Org)
C51 COMPILER V7.50 MP3 03/16/2006 09:11:14 PAGE 3
118 6, //interface subclass1=RBC,2=SFF,3=QIC,4=UFI,5=SFF,6=SCSI
119 0x50,//bulk 0nly Transport
120 0,//Index of String Descriptor Describing this interface
121
122 //Bulk-in Endpoint
123 0x07, //length of this desc.
124 0x05, //ENDPOINT descriptor TYPE
125 0x81, //address (IN) Endpoint 4 84
126 0x02, //attributes (BULK)
127 0x40, 0x00, //max packet size (64)
128 0x0, //Does not apply to Bulk endpoints
129
130 //Bulk-out Endpoint
131 0x07, //length of this desc.
132 0x05, //ENDPOINT descriptor TYPE
133 0x02, //address (OUT) Endpoint 5 05
134 0x02, //attributes (BULK)
135 0x40, 0x00, //max packet size (64)
136 0x0 //Does not apply to Bulk endpoints
137 };
138
139 //用于存放歌曲列表的数组
140 unsigned char SONG[88] = {'M', 'O', 'O', 'N', ' ', ' ', ' ', ' ', 'T', 'X', 'T'};
141
142 //MP3有关的变量*********************
143 #define VOLUME 1
144 #define EFFECTION 2
145 #define SELECTSONG 3
146 #define PLAY 1
147 #define STOP 0
148 unsigned char CurrentFun = SELECTSONG;
149 unsigned char PlayState = PLAY;
150 unsigned char ChangeSong = 0;
151
152 unsigned char NowPlaying = 0;
153 unsigned char NumofSong = 0;
154 extern long int DataRead;
155 //***************************
156
157 //USB DISK ************************by frank*****************************************************
158 //读端点数据
159 unsigned char ReadEp(unsigned char EpNum, unsigned char *Data)
160 {
161 1 unsigned char i = 0, nLength;
162 1 UEPNUM = EpNum;//指向相应端点
163 1
164 1 nLength = UBYCTX;//读取端点数据长度
165 1 while (nLength--)
166 1 {
167 2 Data[i++] = UEPDATX;/*printuf("%x ",Data[i]);*/
168 2 }//依次读取端点收到的数据
169 1
170 1 UEPSTAX &= ~(RXOUTB0 | RXOUTB1 | RXSETUP);//清中断标志
171 1
172 1 return (i);//返回读取到的数据的长度
173 1 }
174
175 //向端点0写数据
176 void WriteEp(unsigned char EpNum, unsigned char nLength, unsigned char *Data)
177 {
178 1 unsigned char i = 0;
179 1 UEPNUM = EpNum;//指向相应端点
C51 COMPILER V7.50 MP3 03/16/2006 09:11:14 PAGE 4
180 1 UEPSTAX |= DIR;//设置方向为写
181 1
182 1 while (nLength--) UEPDATX = Data[i++];//将数据写入端点
183 1 UEPSTAX |= TXRDY;//发送数据Sending the data,this action will switch between bank0 and bank1
184 1 while (!(UEPSTAX&TXCMP)) ;//等待发送完成
185 1 UEPSTAX &= (~(TXCMP));//清中断标志clear TXCMP
186 1 }
187
188 //写Bulk端点
189 void WriteEpBulk(unsigned char EpNum, unsigned char nLength, unsigned char *Data)
190 {
191 1 unsigned char i;
192 1 UEPNUM = EpNum;//指向相应端点
193 1 UEPSTAX |= DIR;//设置方向为写Set for status of a Control In transaction
194 1
195 1 for (i=0; i<nLength; i++)
196 1 {
197 2 UEPDATX = Data[i];//将数据写入端点
198 2 }
199 1 UEPSTAX |= TXRDY;//发送数据Sending the data,this action will switch between bank0 and bank1
200 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -