
Cypress Semiconductor Corporation
SL811HS and SL811HST: Application Notes
©2001 Cypress Semiconductor Corporation. All rights reserved. The information
and specifications contained in this document are subject to change without
notice.
Date: 07/26/01
Revision: 1.21
Page: 33
printf("Get Device Descriptor: .."); printf("Get Device Descriptor: ..");
uDev.wEPxCRC[0] = crc5((WORD)(DevNum+(0<<7)));// Endpoint 0 uDev.wEPxCRC[0] = crc5((WORD)(DevNum+(0<<7)));// Endpoint 0 |assign new addr|assign new addr
if (!GetDesc(DEVICE<<8,0x09, (BYTE*)SCMD)) return FALSE; if (!GetDesc(DEVICE<<8,0x09, (BYTE*)SCMD)) return FALSE;
printf("Vendor: %04x Product: %04x printf("Vendor: %04x Product: %04x\\n",pDevn",pDev-->idVendor,pDev>idVendor,pDev-->idProduct);>idProduct);
uDev.wVID = pDev uDev.wVID = pDev-->idVendor;>idVendor;
uDev.wPID = pDev uDev.wPID = pDev-->idProduct;>idProduct;
printf("Get Configuration printf("Get Configuration\\n");n");
if if (!GetDesc(CONFIGURATION<<8,0xff, (BYTE*)SCMD)) return FALSE;(!GetDesc(CONFIGURATION<<8,0xff, (BYTE*)SCMD)) return FALSE;
if (!GetDesc(CONFIGURATION<<8,0x12, (BYTE*)SCMD)) return FALSE; if (!GetDesc(CONFIGURATION<<8,0x12, (BYTE*)SCMD)) return FALSE;
if (!GetDesc(CONFIGURATION<<8,0x09, (BYTE*)SCMD)) return FALSE; if (!GetDesc(CONFIGURATION<<8,0x09, (BYTE*)SCMD)) return FALSE;
if (!GetDesc(CONFIGURATION<<8,0x20, (BYTE*)SCMD)) return F if (!GetDesc(CONFIGURATION<<8,0x20, (BYTE*)SCMD)) return FALSE;ALSE;
pConf = (pConfDesc)SCMD; pConf = (pConfDesc)SCMD;
//printf("Len=%d, type: %02x //printf("Len=%d, type: %02x\\n", pConfn", pConf-->wLength, pConf>wLength, pConf-->bType);>bType);
//printf("Set Configuration //printf("Set Configuration\\n");n");
if (!Set_Configuration(DEVICE)) return FALSE; if (!Set_Configuration(DEVICE)) return FALSE;
p = (BYTE*)SCMD; p = (BYTE*)SCMD;
i = *p; i = *p;
pIntf = (pIntfDesc)&p[i]; pIntf = (pIntfDesc)&p[i]; // point to Interface Desc // point to Interface Desc
p = (BYTE*)&p[i+pIntf p = (BYTE*)&p[i+pIntf-->bLength]; // point to EP Desc>bLength]; // point to EP Desc
printf("Number of Endpoint = %d printf("Number of Endpoint = %d\\n",pIntfn",pIntf-->bEndPoints);>bEndPoints);
uDev.bNumOfEPs = pIntf uDev.bNumOfEPs = pIntf-->bEndPoints;>bEndPoints;
if (uDev.bNumOfEPs > cMaxEP) return FALSE; if (uDev.bNumOfEPs > cMaxEP) return FALSE;
ep = (BYTE*)&sE ep = (BYTE*)&sEP;P;
for (i=1; i <= pIntf for (i=1; i <= pIntf-->bEndPoints; i++)>bEndPoints; i++)
{ {
uDev.wEPxCRC[i] = crc5((WORD)(DevNum+(i<<7))); // Endpoint CRC uDev.wEPxCRC[i] = crc5((WORD)(DevNum+(i<<7))); // Endpoint CRC
for (j=0; j<7; j++) ep[j] = *p++; for (j=0; j<7; j++) ep[j] = *p++;
if (sEP.bEPAdd&0x80) Rd_EP = sEP.bEPAdd&0xf; // index of Read EP if (sEP.bEPAdd&0x80) Rd_EP = sEP.bEPAdd&0xf; // index of Read EP
else Wr_EP = sEP else Wr_EP = sEP.bEPAdd;.bEPAdd;
uDev.bEPAddr[i] = sEP.bAttr; uDev.bEPAddr[i] = sEP.bAttr;
uDev.wPayLoad[i] = sEP.wPayLoad; uDev.wPayLoad[i] = sEP.wPayLoad;
printf("Length %x Type %x EndPoint Addr %02x Attr %02x wLength=%04x printf("Length %x Type %x EndPoint Addr %02x Attr %02x wLength=%04x\\n",n",
sEP.bLength, sEP.bType, sEP.bEPAdd, sEP.bAttr, sEP.wPayLoad); sEP.bLength, sEP.bType, sEP.bEPAdd, sEP.bAttr, sEP.wPayLoad);
DToggle DToggle[i] = 0;[i] = 0;
} }
printf("Write Endpoint %d, Read Endpoint %d printf("Write Endpoint %d, Read Endpoint %d\\n", Wr_EP, Rd_EP);n", Wr_EP, Rd_EP);
return TRUE; return TRUE;
}}
5. SL811HS USB TRANSFER
The UsbXfer() subroutine handles USB packet transactions. It supports ping-pong operation
for SETUP, PID_IN and PID_OUT Tokens. This code is currently designed to support Control
pipe, Bulk Data Pipe. This code can be expanded to support ISO and Interrupt endpoints.
The usbXfer() handles USB Transactions. It will report USBStatus register contents:
////----------------------------------------------------------------------------------------------------------------------------------------------------
// usbXfer:// usbXfer:
// NOTE: The CRC contains Device 4// NOTE: The CRC contains Device 4--bit of EndPoint Number | 7bit of EndPoint Number | 7--bit of Device Addrbit of Device Addr
// iso = 1 transfer with ISO mode, else Bulk/Interrupt/Control// iso = 1 transfer with ISO mode, else Bulk/Interrupt/Control
// return 0 on Success// return 0 on Success
////
// USB Status// USB Status
// 0x01 ACK// 0x01 ACK
Kommentare zu diesen Handbüchern