📄 kisr.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
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
C51 COMPILER V6.20c KISR 10/31/2002 21:55:46 PAGE 11
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
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;
C51 COMPILER V6.20c KISR 10/31/2002 21:55:46 PAGE 12
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;
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
C51 COMPILER V6.20c KISR 10/31/2002 21:55:46 PAGE 13
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
9
10 void bus_reset(void);
11
12 void ep0_txdone(void);
13 void ep0_rxdone(void);
14 void ep1_txdone(void);
15 void ep1_rxdone(void);
16 void main_txdone(void);
17 void main_rxdone(void);
18
19 void dma_eot(void);
20
C51 COMPILER V6.20c KISR 10/31/2002 21:55:46 PAGE 14
21 /*
22 //*************************************************************************
23 // Public static data
24 //*************************************************************************
25 */
26 EPPFLAGS bEPPflags;
27
28 /* Control endpoint TX/RX buffers */
29 extern CONTROL_XFER ControlData;
30
31 /* ISR static vars */
32 unsigned char idata GenEpBuf[EP1_PACKET_SIZE];
33 unsigned char idata EpBuf[EP2_PACKET_SIZE];
34 IO_REQUEST idata ioRequest;
35 unsigned char ioSize, ioCount;
36
37 unsigned long ClockTicks = 0;
38 unsigned char xdata MainEpBuf[256];
39
40 extern BOOL bNoRAM;
41
42 timer_isr() interrupt 1
43 {
44 1 DISABLE;
45 1 ClockTicks++;
46 1 bEPPflags.bits.timer = 1;
47 1 ENABLE;
48 1 }
49
50
51 void fn_usb_isr()
52 {
53 1 unsigned int i_st;
54 1
55 1 bEPPflags.bits.in_isr = 1;
56 1
57 1
58 1 i_st = D12_ReadInterruptRegister();
59 1
60 1 if(i_st != 0) {
61 2 if(i_st & D12_INT_BUSRESET) {
62 3 bus_reset();
63 3 bEPPflags.bits.bus_reset = 1;
64 3 }
65 2
66 2 if(i_st & D12_INT_EOT)
67 2 dma_eot();
68 2
69 2 if(i_st & D12_INT_SUSPENDCHANGE)
70 2 bEPPflags.bits.suspend = 1;
71 2
72 2
73 2 if(i_st & D12_INT_ENDP0IN)
74 2 ep0_txdone();
75 2 if(i_st & D12_INT_ENDP0OUT)
76 2 ep0_rxdone();
77 2 if(i_st & D12_INT_ENDP1IN)
78 2 ep1_txdone();
79 2 if(i_st & D12_INT_ENDP1OUT)
80 2 ep1_rxdone();
81 2 if(i_st & D12_INT_ENDP2IN)
82 2 main_txdone();
C51 COMPILER V6.20c KISR 10/31/2002 21:55:46 PAGE 15
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -