📄 usb.lst
字号:
C51 COMPILER V6.20c USB 05/19/2003 01:05:06 PAGE 1
C51 COMPILER V6.20c, COMPILATION OF MODULE USB
OBJECT MODULE PLACED IN USB.OBJ
COMPILER INVOKED BY: E:\WIN98\HARDWARE\KEILC\C51\BIN\C51.EXE USB.C DB OE SMALL ROM(LARGE)
stmt level source
1
2 #include "SMPro.H"
3 #include "USB.H"
4 #include "USB200.h"
5 //#include "USBD12.H"
6 #include "CHAP9.H"
7 #include "VDOR.H"
8 #include "HAL.H"
9 #include "Isp1581.h"
10
11 extern ZBOARDFLAGS bZBoardFlags;
12 //extern unsigned char idata GenEpBuf[EP2_RX_FIFO_SIZE ];
13 extern unsigned char idata GenEpBuf[EP1_PACKET_SIZE];
14 extern IO_REQUEST idata ioRequest;
15 unsigned char idata last_key;
16 unsigned char bdata key;
17 sbit bkey0=key^0;
18 sbit bkey1=key^1;
19
20 /*
21 //*************************************************************************
22 // USB protocol function pointer arrays
23 //*************************************************************************
24 */
25 code void (*StandardDeviceRequest[])(void) =
26 {
27 USBClassRequest_GetStatus, // 0
28 USBClassRequest_ClearFeature, // 1
29 reserved, // 2
30 USBClassRequest_SetFeature, // 3
31 reserved, // 4
32 USBClassRequest_SetAddress, // 5
33 USBClassRequest_GetDescriptor, // 6
34 reserved, // 7
35 USBClassRequest_GetConfiguration, // 8
36 USBClassRequest_SetConfiguration, // 9
37 USBClassRequest_GetInterface, // 10
38 USBClassRequest_SetInterface, // 12
39 reserved,
40 reserved,
41 reserved,
42 reserved
43 };
44
45 code void (*VendorDeviceRequest[])(void) =
46 {
47 reserved,//EnableIsoMode,
48 USBVendorCmdSet,
49 USBVendorCmdGet,
50 reserved,//USBVendorRequest_GetFlashPhase,
51 reserved,//USBVendorRequest_GetCodeData,
52 reserved,
53 reserved,//USBVendorRequest_LEDON,
54 reserved,//USBVendorRequest_LEDOFF,
55 reserved,//USBVendorRequest_LEDFlash,
C51 COMPILER V6.20c USB 05/19/2003 01:05:06 PAGE 2
56 reserved,
57 reserved,//USBVendorRequest_WriteCode,
58 USBVendorReadData,
59 read_write_register, // Upper...
60 reserved,
61 reserved,
62 reserved
63 };
64
65 /*
66 //*************************************************************************
67 // Public static data
68 //*************************************************************************
69 */
70 extern unsigned long data lClockTicks;
71
72 CONTROL_XFER data ControlData;
73
74 /* Functions */
75
76 void USB_Stall_EP0(void) //ok
77 {
78 1 ISP1581_StallEP0InControlRead();
79 1 ISP1581_StallEP0InControlWrite();
80 1 bZBoardFlags.bits.DCP_state = USBFSM4DCP_STALL;
81 1
82 1 }
83 void USB_Single_Transmit(unsigned char* pBuf, unsigned char nLen) //ok
84 {
85 1 if(nLen <= EP0_PACKET_SIZE)
86 1 {
87 2 ISP1581_WriteControlEndpoint(pBuf, nLen);
88 2 ControlData.wLength = nLen;
89 2 ControlData.wCount = nLen;
90 2 bZBoardFlags.bits.DCP_state = USBFSM4DCP_CONTROLREADHANDSHAKE;
91 2 }
92 1 }
93
94 void USB_Code_Transmit(unsigned char code* pRomData, unsigned short nLen) //ok
95 {
96 1 ControlData.wCount = 0;
97 1 if(ControlData.wLength > nLen)
98 1 ControlData.wLength = nLen;
99 1
100 1 ControlData.pData = pRomData;
101 1 if(ControlData.wLength >= EP0_PACKET_SIZE)
102 1 {
103 2
104 2 ISP1581_WriteControlEndpoint(ControlData.pData, EP0_PACKET_SIZE);
105 2 ControlData.wCount += EP0_PACKET_SIZE;
106 2
107 2 bZBoardFlags.bits.DCP_state = USBFSM4DCP_DATAIN;
108 2 }
109 1 else
110 1 {
111 2 ISP1581_WriteControlEndpoint(pRomData, ControlData.wLength);
112 2 ControlData.wCount += ControlData.wLength;
113 2 bZBoardFlags.bits.DCP_state = USBFSM4DCP_CONTROLREADHANDSHAKE;
114 2 }
115 1 }
116 void check_key_LED(void)
117 {
C51 COMPILER V6.20c USB 05/19/2003 01:05:06 PAGE 3
118 1
119 1 bkey0=KEYA0;
120 1 bkey1=KEYA1;
121 1
122 1 key &= 0x3;
123 1 if (key != last_key) {
124 2 ISP1581_WriteBulkEndpoint(EPINDEX4EP04IN,&key,1);
125 2 }
126 1
127 1 last_key = key;
128 1
129 1 if(bZBoardFlags.bits.bLED) {
130 2 DISABLE_INTERRUPTS;
131 2 bZBoardFlags.bits.bLED = 0;
132 2 ENABLE_INTERRUPTS;
133 2 MCU_LED0 = !(ioRequest.bCommand & 0x1);
134 2 MCU_LED1 = !(ioRequest.bCommand & 0x2);
135 2 }
136 1
137 1 }
138 ///////////////////////////////
139 void SetupToken_Handler(void)
140 {
141 1 ControlData.wLength = 0;
142 1 ControlData.wCount = 0;
143 1 //if(ISP1581_ReadControlEndpointSetup((UCHAR *)(&(ControlData.DeviceRequest)), sizeof(ControlData.DeviceR
-equest)) == sizeof(DEVICE_REQUEST) )
144 1 if(ISP1581_ReadControlEndpointSetup((UCHAR *)(&(ControlData.DeviceRequest))) == sizeof(DEVICE_REQUEST) )
145 1 {
146 2 ControlData.DeviceRequest.wValue = SWAP(ControlData.DeviceRequest.wValue);
147 2 ControlData.DeviceRequest.wIndex = SWAP(ControlData.DeviceRequest.wIndex);
148 2 ControlData.DeviceRequest.wLength = SWAP(ControlData.DeviceRequest.wLength);
149 2
150 2 ControlData.wLength = ControlData.DeviceRequest.wLength;
151 2 ControlData.wCount = 0;
152 2
153 2 if (ControlData.DeviceRequest.bmRequestType & (UCHAR)USB_ENDPOINT_DIRECTION_MASK)
154 2 {// get command
155 3 ISP1581_ClearBuffer(EPINDEX4CONTROL_SETUP);
156 3 bZBoardFlags.bits.CONTROL_HANDLE_DONE = 1;
157 3 bZBoardFlags.bits.DCP_state = USBFSM4DCP_REQUESTPROC;
158 3 }
159 2 else
160 2 {// set command
161 3 if (ControlData.DeviceRequest.wLength == 0)
162 3 {// Set command without Data stage
163 4 ISP1581_ClearBuffer(EPINDEX4CONTROL_SETUP);
164 4 bZBoardFlags.bits.CONTROL_HANDLE_DONE = 1;
165 4 bZBoardFlags.bits.DCP_state = USBFSM4DCP_REQUESTPROC; // no such command now.
166 4 }
167 3 else
168 3 {// Set command with Data stage
169 4 if(ControlData.DeviceRequest.wLength <= MAX_CONTROLDATA_SIZE)
170 4 {
171 5 bZBoardFlags.bits.DCP_state = USBFSM4DCP_DATAOUT;
172 5 ISP1581_ClearBuffer(EPINDEX4CONTROL_SETUP);
173 5 }
174 4 else
175 4 {
176 5 ISP1581_ClearBuffer(EPINDEX4CONTROL_SETUP);
177 5 ISP1581_StallEP0InControlWrite();
178 5 bZBoardFlags.bits.DCP_state = USBFSM4DCP_STALL;
C51 COMPILER V6.20c USB 05/19/2003 01:05:06 PAGE 4
179 5 }
180 4 }
181 3 }
182 2 }
183 1 else
184 1 {
185 2 USB_Stall_EP0();
186 2 }
187 1 }
188 void DeviceRequest_Handler(void)
189 {
190 1 unsigned char nType, nReq;
191 1
192 1 nType = ControlData.DeviceRequest.bmRequestType & USB_REQUEST_TYPE_MASK; //0x60
193 1 nReq = ControlData.DeviceRequest.bRequest & USB_REQUEST_MASK;
194 1
195 1 if (nType == USB_STANDARD_REQUEST) //0x00
196 1 {
197 2 (*StandardDeviceRequest[nReq])();
198 2 }
199 1 else if (nType == USB_VENDOR_REQUEST) //0x40
200 1 (*VendorDeviceRequest[nReq])();
201 1 else
202 1 USB_Stall_EP0();
203 1
204 1 }
205
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 451 ----
CONSTANT SIZE = 96 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 25 5
IDATA SIZE = 1 ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -