?? usbisr.lst
字號(hào):
176 1 #ifndef _INT_MODE_
#ifdef _Debug_
printf("Ep0In last status is 0x%x\n",(unsigned int)(bLastTransactionStatus));
#endif
#endif
181 1
182 1 //for a control-out transfer,a IN token flags this transfer is finished.
183 1 if ((sSysInformation.bUsbStatus == RECEIVE) && \
184 1 (!sSysInformation.sUsbSetUpDealwith.bControOutCommandIsPending))
185 1 {
186 2
187 2 sSysInformation.bUsbStatus = IDLE;
188 2 }
189 1 //else if a previous control-in transfer has not completed yet
190 1 else if (sSysInformation.bUsbStatus == TRANSMIT)
191 1 {
192 2 if (sSysInformation.sUsbSetUpDealwith.wRemaindLength >= D12_EP0_MAX_PACKET_SIZE)
193 2
194 2 bDataLength = D12_EP0_MAX_PACKET_SIZE;
195 2
196 2 else
197 2 {
198 3 bDataLength = sSysInformation.sUsbSetUpDealwith.wRemaindLength;
199 3 }
200 2
201 2 if (bDataLength >0)
202 2 {
203 3 D12_COMMAND_ADDRESS = D12_SELECT_ENDPOINT_CONTROL_IN; //select endpoint,the optional read one byte is
-not read
204 3
205 3 D12_COMMAND_ADDRESS = D12_WRITE_BUFFER_SELECTED_ENDPOINT; //write endpoint buffer
206 3 D12_DATA_ADDRESS = 0; //first byte is reserved,should wirte 0x00
207 3 D12_DATA_ADDRESS = bDataLength; //the second byte is the data length that will be write to buffer
208 3 #ifndef _INT_MODE_
#ifdef _Debug_
printf("Write buffer:");
#endif
#endif
213 3
214 3 for(i=0; i<bDataLength; i++)
215 3 {
216 4 D12_DATA_ADDRESS = *sSysInformation.sUsbSetUpDealwith.pDataSourceAddress;
217 4 #ifndef _INT_MODE_
#ifdef _Debug_
printf("%x,",(unsigned int)(*sSysInformation.sUsbSetUpDealwith.pDataSourceAddress));
#endif
#endif
222 4 sSysInformation.sUsbSetUpDealwith.pDataSourceAddress++;
223 4 }
224 3 #ifndef _INT_MODE_
#ifdef _Debug_
printf("\n");
#endif
#endif
229 3 D12_COMMAND_ADDRESS = D12_VALIDATE_BUFFER_SELECTED_ENDPOINT; //validate buffer
230 3
231 3 sSysInformation.sUsbSetUpDealwith.wRemaindLength -= bDataLength;
232 3 }
233 2 }
234 1 else
235 1 {
236 2 //this is an unexpected IN packet,so we should stall endpoint0
C51 COMPILER V7.01 USBISR 02/17/2006 15:09:24 PAGE 5
237 2 CONTROL_ENDPOINT_STALL //set control endpoint stall
238 2 }
239 1 }
240
241 //
242 //*************************************************************************
243 // Paremeter:
244 // In : None
245 // Out: None
246 // Function:
247 // This firmware use endpoint1-ou as a interrupt endpoint to control
248 // eight LED status.When data received,we save it to mEp1OutBuffer,
249 // and interpret it as LED status.Note we refresh LED status in main
250 // program loop.
251 void Ep1Out(void) //endpoint1 OUT transaction process
252 {
253 1 unsigned char data bLastTransactionStatus;
254 1 unsigned char bDataLength;
255 1
256 1 bLastTransactionStatus = D12ReadLastTransactionStatus(D12_READ_LAST_TRANSACTION_STATUS_ENDPOINT1_OUT);
257 1
258 1 bDataLength = D12ReadBuffer(D12_SELECT_ENDPOINT_ENDPOINT1_OUT, EP1_OUT_BUFFER_SIZE,&mEp1OutBuffer);
259 1 }
260
261 //
262 //*************************************************************************
263 // Paremeter:
264 // In : None
265 // Out: None
266 // Function:
267 // This firmware use endpoint1-in as a interrupt endpoint to transfer
268 // current switch status to host.Switch status is refreshed and saved
269 // at mEp1InBuffer in main program loop.Host software should probe
270 // endpoint-in use polling interval that endpoint descriptor declared.
271 void Ep1In(void) //endpoint1 IN transaction process
272 {
273 1 //In main program loop,mEp1InBuffer is stuffed,when switch status has
274 1 //changed and host receiced it correctly,this interrupt will happened.
275 1 //Here we only need to read last transaction status and has nothing to
276 1 //do.
277 1 unsigned char data bLastTransactionStatus;
278 1 bLastTransactionStatus = D12ReadLastTransactionStatus(D12_READ_LAST_TRANSACTION_STATUS_ENDPOINT1_IN);
279 1
280 1 }
281 //
282 //*************************************************************************
283 // Paremeter:
284 // In : None
285 // Out: None
286 // Function:
287 // This firmware use 512 byte inner ram to demonstrate how to implement bulk transfer.
288 // There are three command operation to ram: loopback, read and write.For loopback,
289 // we just received data and save it to ram,then transfer those data to host without
290 // any change.Host software should first issue a vendor defined control transfer to
291 // tell firmware that the operation command is loopback.For ram read and write,firmware
292 // save data to ram or transfer ram data to host according to host's request.Every time
293 // before ram read or write,host software should first issue a vendor defined control
294 // transfer to tell firmware the operation command is ram read or ram write,the start
295 // address and the r/w length.
296 void Ep2Out(void) //endpoint2 OUT transaction process
297 {
298 1 unsigned char data bLastTransactionStatus;
C51 COMPILER V7.01 USBISR 02/17/2006 15:09:24 PAGE 6
299 1 unsigned char data bDataLength;
300 1 unsigned char xdata * data pBuffer;
301 1 unsigned char data i;
302 1 unsigned char data j;
303 1
304 1
305 1 bLastTransactionStatus = D12ReadLastTransactionStatus(D12_READ_LAST_TRANSACTION_STATUS_ENDPOINT2_OUT);
306 1
307 1 if (sSysInformation.sRamControl.bRamCommand == RAM_COMMAND_LOOPBACK)
308 1 {
309 2 for (j=0;j<2;j++)
310 2 {
311 3 bDataLength = D12ReadBuffer(D12_SELECT_ENDPOINT_ENDPOINT2_OUT, 2*D12_EP2_MAX_PACKET_SIZE,&mRamBuffer);
312 3 if (bDataLength>0)
313 3 {
314 4 D12_COMMAND_ADDRESS = D12_SELECT_ENDPOINT_ENDPOINT2_IN; //select endpoint,the optional read one byte
-is not read
315 4 D12_COMMAND_ADDRESS = D12_WRITE_BUFFER_SELECTED_ENDPOINT; //write endpoint buffer
316 4 D12_DATA_ADDRESS = 0; //first byte is reserved,should wirte 0x00
317 4 D12_DATA_ADDRESS = bDataLength; //the second byte is the data length that will be write to buffer
318 4 #ifndef _INT_MODE_
#ifdef _Debug_
printf("Ep2Out Length is 0x%x\n",(unsigned int)(bDataLength));
#endif
#endif
323 4 pBuffer = &mRamBuffer;
324 4 #ifndef _INT_MODE_
#ifdef _Debug_
printf("Write back to endpoint2_IN; ");
#endif
#endif
329 4 for(i=0; i<bDataLength; i++)
330 4 {
331 5 D12_DATA_ADDRESS = *pBuffer;
332 5 #ifndef _INT_MODE_
#ifdef _Debug_
printf("%x,",(unsigned int)(*pBuffer));
#endif
#endif
337 5 pBuffer++;
338 5 }
339 4 #ifndef _INT_MODE_
#ifdef _Debug_
printf("\n");
#endif
#endif
344 4
345 4 D12_COMMAND_ADDRESS = D12_VALIDATE_BUFFER_SELECTED_ENDPOINT; //validate buffer
346 4
347 4 }
348 3 }
349 2
350 2 /////////////////////////////////////////////////////////////////////////
351 2 }
352 1 else
353 1 { //if Host issued a RAM_COMMAND_WRITE command
354 2 if (sSysInformation.sRamControl.bRamRwStatus == RECEIVE)
355 2 {
356 3 for (j=0;j<2;j++)
357 3 {
358 4 if (sSysInformation.sRamControl.iRamRemaindLength >0)
359 4 {
C51 COMPILER V7.01 USBISR 02/17/2006 15:09:24 PAGE 7
360 5 pBuffer = &mRamBuffer + sSysInformation.sRamControl.iRamStartAddress+\
361 5 (sSysInformation.sRamControl.iRamRwLength-sSysInformation.sRamControl.iRamRemaindLength);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -