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