📄 kprotodma.lst
字号:
4 =1 // values for the bits returned by the USB GET_STATUS command
5 =1 #define USB_GETSTATUS_SELF_POWERED 0x01
6 =1 #define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED 0x02
7 =1
8 =1
9 =1 #define USB_DEVICE_DESCRIPTOR_TYPE 0x01
10 =1 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
11 =1 #define USB_STRING_DESCRIPTOR_TYPE 0x03
12 =1 #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
13 =1 #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
14 =1 #define USB_POWER_DESCRIPTOR_TYPE 0x06
15 =1
16 =1 #define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((USHORT)((USHORT)d<<8 | i))
17 =1
18 =1 //
19 =1 // Values for bmAttributes field of an
20 =1 // endpoint descriptor
21 =1 //
22 =1
23 =1 #define USB_ENDPOINT_TYPE_MASK 0x03
24 =1
25 =1 #define USB_ENDPOINT_TYPE_CONTROL 0x00
26 =1 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
27 =1 #define USB_ENDPOINT_TYPE_BULK 0x02
28 =1 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03
29 =1
30 =1
31 =1 //
32 =1 // definitions for bits in the bmAttributes field of a
33 =1 // configuration descriptor.
34 =1 //
35 =1 #define USB_CONFIG_POWERED_MASK 0xc0
C51 COMPILER V7.06 KPROTODMA 11/11/2003 20:11:02 PAGE 10
36 =1
37 =1 #define USB_CONFIG_BUS_POWERED 0x80
38 =1 #define USB_CONFIG_SELF_POWERED 0x40
39 =1 #define USB_CONFIG_REMOTE_WAKEUP 0x20
40 =1
41 =1 //
42 =1 // Endpoint direction bit, stored in address
43 =1 //
44 =1
45 =1 #define USB_ENDPOINT_DIRECTION_MASK 0x80
46 =1
47 =1 // test direction bit in the bEndpointAddress field of
48 =1 // an endpoint descriptor.
49 =1 #define USB_ENDPOINT_DIRECTION_OUT(addr) (!((addr) & USB_ENDPOINT_DIRECTION_MASK))
50 =1 #define USB_ENDPOINT_DIRECTION_IN(addr) ((addr) & USB_ENDPOINT_DIRECTION_MASK)
51 =1
52 =1 //
53 =1 // USB defined request codes
54 =1 // see chapter 9 of the USB 1.0 specifcation for
55 =1 // more information.
56 =1 //
57 =1
58 =1 // These are the correct values based on the USB 1.0
59 =1 // specification
60 =1
61 =1 #define USB_REQUEST_GET_STATUS 0x00
62 =1 #define USB_REQUEST_CLEAR_FEATURE 0x01
63 =1
64 =1 #define USB_REQUEST_SET_FEATURE 0x03
65 =1
66 =1 #define USB_REQUEST_SET_ADDRESS 0x05
67 =1 #define USB_REQUEST_GET_DESCRIPTOR 0x06
68 =1 #define USB_REQUEST_SET_DESCRIPTOR 0x07
69 =1 #define USB_REQUEST_GET_CONFIGURATION 0x08
70 =1 #define USB_REQUEST_SET_CONFIGURATION 0x09
71 =1 #define USB_REQUEST_GET_INTERFACE 0x0A
72 =1 #define USB_REQUEST_SET_INTERFACE 0x0B
73 =1 #define USB_REQUEST_SYNC_FRAME 0x0C
74 =1
75 =1
76 =1 //
77 =1 // defined USB device classes
78 =1 //
79 =1
80 =1
81 =1 #define USB_DEVICE_CLASS_RESERVED 0x00
82 =1 #define USB_DEVICE_CLASS_AUDIO 0x01
83 =1 #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
84 =1 #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
85 =1 #define USB_DEVICE_CLASS_MONITOR 0x04
86 =1 #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
87 =1 #define USB_DEVICE_CLASS_POWER 0x06
88 =1 #define USB_DEVICE_CLASS_PRINTER 0x07
89 =1 #define USB_DEVICE_CLASS_STORAGE 0x08
90 =1 #define USB_DEVICE_CLASS_HUB 0x09
91 =1 #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
92 =1
93 =1 //
94 =1 // USB defined Feature selectors
95 =1 //
96 =1
97 =1 #define USB_FEATURE_ENDPOINT_STALL 0x0000
C51 COMPILER V7.06 KPROTODMA 11/11/2003 20:11:02 PAGE 11
98 =1 #define USB_FEATURE_REMOTE_WAKEUP 0x0001
99 =1 #define USB_FEATURE_POWER_D0 0x0002
100 =1 #define USB_FEATURE_POWER_D1 0x0003
101 =1 #define USB_FEATURE_POWER_D2 0x0004
102 =1 #define USB_FEATURE_POWER_D3 0x0005
103 =1
104 =1 typedef struct _USB_DEVICE_DESCRIPTOR {
105 =1 UCHAR bLength;
106 =1 UCHAR bDescriptorType;
107 =1 USHORT bcdUSB;
108 =1 UCHAR bDeviceClass;
109 =1 UCHAR bDeviceSubClass;
110 =1 UCHAR bDeviceProtocol;
111 =1 UCHAR bMaxPacketSize0;
112 =1 USHORT idVendor;
113 =1 USHORT idProduct;
114 =1 USHORT bcdDevice;
115 =1 UCHAR iManufacturer;
116 =1 UCHAR iProduct;
117 =1 UCHAR iSerialNumber;
118 =1 UCHAR bNumConfigurations;
119 =1 } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
120 =1
121 =1 typedef struct _USB_ENDPOINT_DESCRIPTOR {
122 =1 UCHAR bLength;
123 =1 UCHAR bDescriptorType;
124 =1 UCHAR bEndpointAddress;
125 =1 UCHAR bmAttributes;
126 =1 USHORT wMaxPacketSize;
127 =1 UCHAR bInterval;
128 =1 } USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
129 =1
130 =1 //
131 =1 // values for bmAttributes Field in
132 =1 // USB_CONFIGURATION_DESCRIPTOR
133 =1 //
134 =1
135 =1 #define BUS_POWERED 0x80
136 =1 #define SELF_POWERED 0x40
137 =1 #define REMOTE_WAKEUP 0x20
138 =1
139 =1 typedef struct _USB_CONFIGURATION_DESCRIPTOR {
140 =1 UCHAR bLength;
141 =1 UCHAR bDescriptorType;
142 =1 USHORT wTotalLength;
143 =1 UCHAR bNumInterfaces;
144 =1 UCHAR bConfigurationValue;
145 =1 UCHAR iConfiguration;
146 =1 UCHAR bmAttributes;
147 =1 UCHAR MaxPower;
148 =1 } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
149 =1
150 =1 typedef struct _USB_INTERFACE_DESCRIPTOR {
151 =1 UCHAR bLength;
152 =1 UCHAR bDescriptorType;
153 =1 UCHAR bInterfaceNumber;
154 =1 UCHAR bAlternateSetting;
155 =1 UCHAR bNumEndpoints;
156 =1 UCHAR bInterfaceClass;
157 =1 UCHAR bInterfaceSubClass;
158 =1 UCHAR bInterfaceProtocol;
159 =1 UCHAR iInterface;
C51 COMPILER V7.06 KPROTODMA 11/11/2003 20:11:02 PAGE 12
160 =1 } USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
161 =1
162 =1 typedef struct _USB_STRING_DESCRIPTOR {
163 =1 UCHAR bLength;
164 =1 UCHAR bDescriptorType;
165 =1 UCHAR bString[1];
166 =1 } USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
167 =1
168 =1 //
169 =1 // USB power descriptor added to core specification
170 =1 //
171 =1
172 =1 #define USB_SUPPORT_D0_COMMAND 0x01
173 =1 #define USB_SUPPORT_D1_COMMAND 0x02
174 =1 #define USB_SUPPORT_D2_COMMAND 0x04
175 =1 #define USB_SUPPORT_D3_COMMAND 0x08
176 =1
177 =1 #define USB_SUPPORT_D1_WAKEUP 0x10
178 =1 #define USB_SUPPORT_D2_WAKEUP 0x20
179 =1
180 =1
181 =1 typedef struct _USB_POWER_DESCRIPTOR {
182 =1 UCHAR bLength;
183 =1 UCHAR bDescriptorType;
184 =1 UCHAR bCapabilitiesFlags;
185 =1 USHORT EventNotification;
186 =1 USHORT D1LatencyTime;
187 =1 USHORT D2LatencyTime;
188 =1 USHORT D3LatencyTime;
189 =1 UCHAR PowerUnit;
190 =1 USHORT D0PowerConsumption;
191 =1 USHORT D1PowerConsumption;
192 =1 USHORT D2PowerConsumption;
193 =1 } USB_POWER_DESCRIPTOR, *PUSB_POWER_DESCRIPTOR;
194 =1
195 =1
196 =1 typedef struct _USB_COMMON_DESCRIPTOR {
197 =1 UCHAR bLength;
198 =1 UCHAR bDescriptorType;
199 =1 } USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR;
200 =1
201 =1
202 =1 //
203 =1 // Standard USB HUB definitions
204 =1 //
205 =1 // See Chapter 11
206 =1 //
207 =1
208 =1 typedef struct _USB_HUB_DESCRIPTOR {
209 =1 UCHAR bDescriptorLength; // Length of this descriptor
210 =1 UCHAR bDescriptorType; // Hub configuration type
211 =1 UCHAR bNumberOfPorts; // number of ports on this hub
212 =1 USHORT wHubCharacteristics; // Hub Charateristics
213 =1 UCHAR bPowerOnToPowerGood; // port power on till power good in 2ms
214 =1 UCHAR bHubControlCurrent; // max current in mA
215 =1 //
216 =1 // room for 255 ports power control and removable bitmask
217 =1 UCHAR bRemoveAndPowerMask[64];
218 =1 } USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
219 =1
17 //#include "xxgchap9.h"
18
C51 COMPILER V7.06 KPROTODMA 11/11/2003 20:11:02 PAGE 13
19 extern CONTROL_XFER ControlData;
20 extern IO_REQUEST idata ioRequest;
21 extern EPPFLAGS bEPPflags;
22 extern BOOL bNoRAM;
23
24 extern void single_transmit(unsigned char * buf, unsigned char len);
25 extern void stall_ep0(void);
26
27 void get_firmware_version()
28 {
29 1 unsigned char i;
30 1
31 1 i = 0x30; // firmware version number
32 1 single_transmit((unsigned char *)&i, 1);
33 1
34 1 }
35
36 void get_buffer_size()
37 {
38 1 unsigned char i[4];
39 1
40 1 if(bNoRAM == TRUE) {
41 2 i[0] = EP2_PACKET_SIZE;
42 2 i[1] = 0;
43 2 i[2] = 0;
44 2 i[3] = 0;
45 2 } else {
46 2 i[0] = 0;
47 2 i[1] = 1;
48 2 i[2] = 0;
49 2 i[3] = 0;
50 2 }
51 1 single_transmit(i, 4);
52 1
53 1 }
54
55 void setup_dma_request()
56 {
57 1 memcpy((unsigned char *)&ioRequest + ControlData.DeviceRequest.wValue,
58 1 ControlData.dataBuffer,
59 1 ControlData.DeviceRequest.wLength);
60 1
61 1 ioRequest.uSize = SWAP(ioRequest.uSize);
62 1 ioRequest.uAddressL = SWAP(ioRequest.uAddressL);
63 1
64 1 if(ioRequest.uSize > DMA_BUFFER_SIZE) { // Unaccepted request
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -